slashdotdash / conduit

RealWorld example backend implementing the CQRS/ES pattern in Elixir and Phoenix
MIT License
353 stars 67 forks source link

Question: How to write into metadata field? #14

Open bumbus opened 5 years ago

bumbus commented 5 years ago

Hi, this might be a noobish question, but I could not figure out how to write into events.metadata. As I see it, maybe correct me if I am wrong, this would be the right place to save for example (phoenix) connection information like user IP etc.

Thanks fro advance.

slashdotdash commented 5 years ago

You can include any metadata during command dispatch. It will be copied onto any events created by the command.

ExampleRouter.dispatch(command,
  metadata: %{"issuer_id" => issuer_id, "user_id" => "user@example.com"}
)

Metadata is a useful place to record detais about the originating request (IP address, authenticated user id, etc.).

bumbus commented 5 years ago

thank you very much for helping out