View Source X3m.System.Dispatcher (X3m System v0.8.3)

Summary

Functions

Sets message.dry_run to true if it was (by default) false and dispatches service call.

Functions

@spec authorized?(X3m.System.Message.t()) ::
  boolean() | {:service_unavailable, atom()}
Link to this function

discover_service(message)

View Source
@spec discover_service(X3m.System.Message.t()) ::
  {:unavailable, X3m.System.Message.t()} | {node() | :local, atom()}
Link to this function

dispatch(message, opts \\ [])

View Source

Sets message.dry_run to true if it was (by default) false and dispatches service call.

Pay attention if you have some side effects (like persistence of unique values in DB) in your command handling. Such validations should be either avoided or Aggregate needs to implement rollback/2 and commit/2 callbacks.

If service call is valid, message.response will be in {:ok, aggregate_version} format, otherwise response will have error message as it would have if dispatch was called.