-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protobuf cannot be used with async handlers #228
Comments
hmmm, but we already have Hmmm, actually right now we require class SendOrderEmail < ActiveJob::Base
def perform(event)
event = YAML.load(event)
email = event.data.fetch(:customer_email)
OrderMailer.notify_customer(email).deliver_now!
end
end Perhaps we should require: class SendOrderEmail < ActiveJob::Base
def perform(event)
event = event_store.deserialize(event)
# ... That would probably make much more sense as we would be able to change it in any way in the future. Or maybe: class SendOrderEmail < ActiveJob::Base
def perform(event_id, data, metadata, event_type)
event = event_store.deserialize(data, metadata, event_type)
# ... nah... that does not look really good. |
yeah, |
Workaround: protocolbuffers/protobuf#4391 (comment) |
It seems that I need to:
So that's quite a lot of breaking changes. |
Alternatively we expose Maybe it would event make sense to have |
Note's from today's meetup:
|
hmmm
vs
I just realized they are almost identical... |
Let's say we went with client = Client.new(repository: RailsEventStoreActiveRecord::EventRepository.new(
mapper: RubyEventStore::Mappers::Protobuf.new,
))
client.subscribe(->(ev){@ev = ev}, [ResTesting::OrderCreated])
event = RubyEventStore::Event.new(
event_id: "f90b8848-e478-47fe-9b4a-9f2a1d53622b",
data: ResTesting::OrderCreated.new(
customer_id: 123,
order_id: "K3THNX9",
))
client.publish_event(event, stream_name: 'test') then we would also need to reimplement |
Here: def notify_subscribers(event)
all_subscribers_for(event.class).each do |subscriber|
@dispatcher.call(subscriber, event)
end
end |
https://www.dropbox.com/s/tryu3dyk4jvus32/Screenshot%202018-03-30%2016.21.19.png?dl=0 Interesting to see what bunny (ruby client for rabbitmq does):
|
The interesting part is that |
and protobuf generated class is only passed as Data ! this should make serialization for background jobs and networking easier. Issue: #228
res_testing.OrderCreated instead of ResTesting::OrderCreated, this is less ruby-related and more protobuf oriented. If that descriptor name is used throught many apps, it should be easier to handle it compared to ruby classes. Issue: #228
by handling it on Proto wrapper level. Seriously approaching this would require having a :mapper exposed in :dispatcher which would require having it exposed in :broker but it is already used in :repository. So either we move the dependency higher and pass it down through many layers, or make it a responsibility of :repository which can delegate to :mapper if it wants to but then we would need to pass :repository around to :dispatcher so it could call #event_to_serialized_record when enquing a job and #serialized_record_to_event when dequeing. I am not yet convinced about it. Two additional thoughts: * maybe repository should return RubyEventStore::SerializedRecord and then the migher layer (Client) would use the :mapper to transform it to the right event object. * similarly when saving we could do the same, the other way, Client would already use mapper to serialize the event and repository would receive RubyEventStore::SerializedRecord. * The benefit would be that we could get RAW data from repository, not transform it to domain events and stream over network. Current solution require getting domain events (which are deserialized) and then serializing them again to send over wire. Issue: #228 #255
becuase of eql? behavior/bug from google-protobuf: protocolbuffers/protobuf#4455 and bring back the original implementation to RubyEventStore::Event which uses eql? instead of ==. Issue: #228 #255 #257
because: protocolbuffers/protobuf#4391 we always use
YAML
andgoogle-protobuf
does not work with it right now.add_metadata
)The text was updated successfully, but these errors were encountered: