View Source FluentdForwarder.Handler behaviour (FluentdForwarder v0.1.2)

The FluentdForwarder.Handler specification.

A Fluentd forward handler is a module that must export:

  • a c:call/2 function.
  • an init/1 function which takes a set of options and initializes it.

The result returned by init/1 is passed as last argument to c:call/2. Note that init/1 may be called during initialization and as such it must not return pids, ports or values that are specific to the runtime.

The API expected by a module plug is defined as a behaviour by the FluentdForwarder.Handler module (this module).

examples

Examples

defmodule InspectHandler do
  @behaviour FluentdForwarder.Handler

  def init(opts) do
    opts
  end

  def call(tag, time, record, _opts) do
    IO.inspect({tag, time, record})
  end
end

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

@type opts() ::
  binary()
  | tuple()
  | atom()
  | integer()
  | float()
  | [opts()]
  | %{optional(opts()) => opts()}
  | MapSet.t()
@type record() :: map()
@type tag() :: String.t()
@type time() :: float()

Link to this section Callbacks

Link to this callback

call(tag, time, record, opts)

View Source
@callback call(tag(), time(), record(), opts()) :: any()
@callback init(opts()) :: opts()

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.