update ChangeLog
[lwes-erlang/github-mirror.git] / src / lwes_emitter.erl
blob25fdeac71d622a28cf7b29ac4bf7da39073da208
1 -module(lwes_emitter).
3 % create any resources and return a fixed structure which will be sent in
4 % subsequent calls, configuration is expected to be a list of some sort,
5 % most of the time this will be something like [{key, value}].
6 -callback new(Config :: list()) -> State :: term().
8 % return an id to be used for stats gathering. In most cases this should
9 % be an atom so that it will show up under the label column for lwes:stats()
10 % calls
11 -callback id(State :: term()) ->
12 {Ip :: tuple(), Port :: integer() }
13 | {Label :: atom(), {Ip :: tuple(), Port :: integer() }}
14 | atom().
16 % prepare the event, in most cases this will use one of the to_* methods
17 % in lwes_event (like to_binary, to_iolist, to_json, etc), but also allows
18 % one to implement any serialization format as a plugin
19 -callback prep(Event :: term()) -> term().
21 % emit the event, this will get the State from new/1 as well as the event
22 % from prep/1
23 -callback emit(State :: term(), Event :: term()) -> ok | {error, atom()}.
25 % close the emitter, called on shutdown or if configuration is updated
26 % this could be called, then immediately new/1 called again.
27 -callback close(State :: term()) -> ok.