每个已发布的 Rails 事件存储事件是否都有时间戳?

Does every published Rails Event Store event have a timestamp?

是否每个Rails Event Store event that's been published automatically get assigned a timestamp? I'm trying to build functionality that relies upon a timestamp automatically being present for events deserialized from the event_store within a job, but I don't know that I can rely on that. I'm hoping that one does not need to manually add a timestamp to the event's metadata in order for a timestamp to be present, since it doesn't appear that that's been done anywhere in the code base I'm working on. I'm aware that the docs表示RubyEventStore::Event#timestamp方法的return值可以是nil,但我希望不会是nil 对于已发布的事件。

除非您提供自己的时间戳(元数据中的 :timestamp 键),否则每个存储的事件都将包含用当前时间丰富的元数据 - 请参阅 https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/client.rb#L311

可以nil。但只有当您的 clock 提供给 RailsEventStore 客户端时才会 return nil。

在即将发布的 Rails Event Store 2.0 版本中,我们还将添加有效时间(valid_at 元数据中的属性),这将允许实施 BI 时间事件源。敬请期待。