Ming.Pipeline (Ming v0.1.1)

View Source

Pipeline is a struct used as an argument in the callback functions of modules implementing the Ming.Middleware behaviour.

This struct must be returned by each function to be used in the next middleware based on the configured middleware chain.

Pipeline fields

  • application - the Ming application.

  • assigns - shared user data as a map.

  • correlation_id - an optional UUID used to correlate related commands/events together.

  • request - command struct being dispatched.

  • request_uuid - UUID assigned to the command being dispatched.

  • consistency - requested dispatch consistency, either: :eventual (default) or :strong.

  • halted - flag indicating whether the pipeline was halted.

  • metadata - the metadata map to be persisted along with the events.

  • response - sets the response to send back to the caller.

Summary

Functions

Puts the key with value equal to value into assigns map.

Puts the key with value equal to value into metadata map.

Executes the middleware chain.

Halts the pipeline by preventing further middleware downstream from being invoked.

Has the pipeline been halted?

Sets the response to be returned to the dispatch caller, unless already set.

Extract the response from the pipeline

Types

t()

@type t() :: %{
  application: term() | nil,
  correlation_id: Ming.UUID.hex() | Ming.UUID.raw(),
  request: any(),
  request_uuid: Ming.UUID.hex() | Ming.UUID.raw() | nil,
  respose: any() | nil,
  metadata: map(),
  halted: boolean(),
  assigned: map()
}

Functions

assign(pipeline, key, value)

Puts the key with value equal to value into assigns map.

assign_metadata(pipeline, key, value)

Puts the key with value equal to value into metadata map.

Note: Use of atom keys in metadata is deprecated in favour of binary strings.

chain(pipeline, stage, middleware)

Executes the middleware chain.

halt(pipeline)

Halts the pipeline by preventing further middleware downstream from being invoked.

Prevents dispatch of the command if halt occurs in a before_dispatch callback.

halted?(pipeline)

Has the pipeline been halted?

respond(pipeline, response)

Sets the response to be returned to the dispatch caller, unless already set.

response(pipeline)

Extract the response from the pipeline