MessageStore.Message.copy
You're seeing just the function
copy
, go back to MessageStore.Message module for more information.
Specs
copy(message_type(), recorded_message(), [path() | key()]) :: event_message()
The copy function constructs a message from another message's data.
Examples
iex> recorded_message = %EventStore.RecordedEvent{
...> causation_id: nil,
...> correlation_id: "abcd1234",
...> created_at: ~U[2021-07-15 12:15:07.379908Z],
...> data: %{foo: "bazinga"},
...> event_id: "b9fcdccd-a495-4df3-889a-4b38f35a2618",
...> event_number: 935,
...> event_type: "Test",
...> metadata: %{bar: "baz", moo: 1},
...> stream_uuid: "test-123",
...> stream_version: 935
...> }
iex> Message.copy("Foo", recorded_message, [:data, [:metadata, :bar]])
%EventStore.EventData{
event_id: nil,
event_type: "Foo",
data: %{foo: "bazinga"},
metadata: %{bar: "baz"},
causation_id: nil,
correlation_id: nil
}
Warning
Copying the metadata should be used with extreme caution, and has no practical use in everyday applicative logic. Except for certain testing and infrastructural scenarios, copying the identifying metadata from one message to another can result in significant malfunctions if the copied message is then written to a stream and processed.