X3m.System.Dispatcher (X3m System v0.9.0)

Copy Markdown View Source

Summary

Functions

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

Functions

authorized?(message)

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

discover_service(message)

@spec discover_service(X3m.System.Message.t()) ::
  {:unavailable, X3m.System.Message.t()} | {node() | :local, atom()}

dispatch(message)

dispatch(message, opts \\ [])

validate(message)

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.