herald v0.1.0-beta.4 Herald.Router

Provides the routes DSL.

Routes is a way trought Herald know:

  • Which Message Schema uses to encode a message before send it;

  • Which function must be used to process a message when receives

An router must be implemented as a module of your application, as bellow:

defmodule MyApp.Router do
  use Herald.Router

  route "my_queue1",
    schema: MyApp.Message1,
    processor: &MyApp.Message1.my_processor/1

  route "my_queue2",
    schema: MyApp.Message2,
    processor: &MyApp.Message2.my_processor/1
end

Each application using Herald must have only one router.

You need configure what your Router in application configurations, as bellow:

config :herald,
  router: MyApp.Router

For more details, see route/2

Link to this section Summary

Functions

Defines a config for a given queue.

Link to this section Functions

Link to this macro

route(queue, config)

(macro)

Defines a config for a given queue.

Config fields

  • schema - Represents a struct using Herald.Message which will be used to represent any message received in queue;

  • processor - Represents a function which will process messages received in queue.

For more details, see the module doc.