kflow_multistate
is a module that helps keeping track of
multiple states of an intermediate callback module.
Copyright © 2019 Klarna Bank AB (publ)
This module defines the kflow_multistate behaviour.
Required callback functions: init/3, handle_message/3, handle_flush/2, terminate/2, fully_processed_offset/1.
kflow_multistate
is a module that helps keeping track of
multiple states of an intermediate callback module. It wraps
around a stateful intermediate CBM and multiplexes its state
according to the value of route
field of upstream messages. It
also rewrites fully_processed_offset
field of the downstream
messages to make sure all unacked messages of all routes get
replayed on pipe restart.
Stateful intermediate CBMs using must implement kflow_multistate
behavior.
NOTE: fully_processed_offset/1
callback must be a pure function.
NOTE: It doesn't make much sense to use this wrapper for stateless modules.
NOTE: Callback module that wraps around a callback module may sound like a terrible idea. But in reality it's the only sane way to keep complexity of already difficult-to-understand modules such askflow_gen
or kflow_gen_aggregate
under control. This way
different functionality is contained in separate places.
abstract datatype: wrapped()
handle_flush/2 | Wrap handle_flush callback. |
handle_message/3 | Wrap handle_message callback. |
terminate/2 | Wrap terminate callback. |
wrap/3 | Wrap intermediate callback module. |
handle_flush(State0::wrapped(), _Config) -> kflow_gen:callback_return(wrapped())
Wrap handle_flush
callback
handle_message(Msg::kflow:message(), State::wrapped(), _Config) -> kflow_gen:callback_return(wrapped())
Wrap handle_message
callback
terminate(S::wrapped(), _Config) -> term()
Wrap terminate
callback
wrap(NodeId::kflow:node_id(), IntermediateCbModule::module(), Config::term()) -> {ok, wrapped()}
Wrap intermediate callback module
Generated by EDoc