BotEx.Routing.MessageHandler (bot_ex v1.0.2)

Summary

Functions

Returns a specification to start this module under a supervisor.

Return current module config [middleware: middleware, default_buffering_time: time, buffering_strategy: buffering_strategy]

Apply middleware modules to messages

Apply middleware to incoming messages and buffering them

Fluhs messages to handlers

Callback implementation for GenServer.init/1.

Reload config from storage

Update config.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_config()

@spec get_config() :: [
  middleware: list(),
  default_buffering_time: integer(),
  buffering_strategy: module()
]

Return current module config [middleware: middleware, default_buffering_time: time, buffering_strategy: buffering_strategy]

handle(msg_list, bot_key)

@spec handle(any(), any()) :: :ok

Apply middleware modules to messages

handle_cast(msg, state)

Apply middleware to incoming messages and buffering them

Parameters

  • {bot_key, msg_list}: bot_key - atom with bot key, list - list incoming BotEx.Models.Message messages
  • state: current state

handle_info(msg, state)

@spec handle_info(
  {:flush_buffer, any()},
  BotEx.Routing.MessageHandler.State.t()
) :: {:noreply, BotEx.Routing.MessageHandler.State.t()}

Fluhs messages to handlers

init(args)

@spec init(any()) :: {:ok, BotEx.Routing.MessageHandler.State.t()}

Callback implementation for GenServer.init/1.

reload_config()

@spec reload_config() :: :ok

Reload config from storage

start_link(_)

@spec start_link(any()) :: :ignore | {:error, any()} | {:ok, pid()}

update_config(config)

@spec update_config(keyword()) :: :ok

Update config.

Parameters

  • config: list of new middleware, default_buffering_time, buffering_strategy. [middleware: [Middleware, ...], default_buffering_time: 2000, buffering_strategy: BufferingStrategy]