-
Notifications
You must be signed in to change notification settings - Fork 124
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
Unify timestamp storage #674
Conversation
537491e
to
c29af6f
Compare
c29af6f
to
dabdbbf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I haven't reviewed protobuf part and ROM part
rails_event_store_active_record/lib/rails_event_store_active_record/event_repository.rb
Outdated
Show resolved
Hide resolved
dabdbbf
to
9863501
Compare
5893ed4
to
533f7ea
Compare
24d3ffc
to
236507a
Compare
@@ -18,7 +18,7 @@ def append_to_stream(events, stream, expected_version) | |||
event_ids << event.event_id | |||
end | |||
add_to_stream(event_ids, stream, expected_version, true) do | |||
Event.import(records) | |||
Event.import(records, timestamps: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does a false do here? we definitely want timestamps from an event, not a database/activerecord generated one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/zdennis/activerecord-import#activerecord-timestamps
Should you wish to specify those columns, you may use the option timestamps: false.
However next paragraph might cause this to be obsolete:
However, it is also possible to set just :created_at in specific records. In this case despite using timestamps: true, :created_at will be updated only in records where that field is nil. Same rule applies for record associations when enabling the option recursive: true
@@ -222,8 +222,16 @@ def with_metadata(metadata, &block) | |||
# {http://railseventstore.org/docs/subscribe/#async-handlers Read more} | |||
# | |||
# @return [Event, Proto] deserialized event | |||
def deserialize(event_type:, event_id:, data:, metadata:) | |||
mapper.serialized_record_to_event(SerializedRecord.new(event_type: event_type, event_id: event_id, data: data, metadata: metadata)) | |||
def deserialize(event_type:, event_id:, data:, metadata:, timestamp:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing test case for timestamp: nil
and timestamp still passed as metadata
"metadata" => "---\n:timestamp: 2019-09-30 00:00:00.000000000 Z\n", | ||
"_aj_symbol_keys" => %w[event_id data metadata event_type], | ||
"metadata" => "--- {}\n", | ||
"timestamp" => {"_aj_serialized"=>"ActiveJob::Serializers::TimeSerializer", "value"=>"2019-09-30T00:00:00Z"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AJ specific, would prefer something more generic even if just for AJ
48c0cfe
to
29c8ed1
Compare
Probably needs database migrations for mysql to upgrade timestamp resolution. |
@@ -8,7 +8,8 @@ def dump(item) | |||
event_id: item.event_id, | |||
metadata: ActiveSupport::HashWithIndifferentAccess.new(item.metadata).deep_symbolize_keys, | |||
data: ActiveSupport::HashWithIndifferentAccess.new(item.data).deep_symbolize_keys, | |||
event_type: item.event_type | |||
event_type: item.event_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should exclude this change in contrib project. It depends on already released RubyEventStore gem version and this will break the tests as timestamp changes has not yet been released. Also IMO we should avoid mixing contrib projects changes into PR with main gems code.
That helps repositories to separate it from metadata enabling better indexing and possibly filtering.
MySQL and Postgres seem to settle on microseconds.
Linux for example has 7 digits in fractional part.
4ad0eec
to
4850f75
Compare
[#627]
Breaking changes so far:
Doubts:
Future extensions on in this PR: