Module kflow_multistate

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.

Description

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 as kflow_gen or kflow_gen_aggregate under control. This way different functionality is contained in separate places.

Data Types

wrapped()

abstract datatype: wrapped()

Function Index

handle_flush/2Wrap handle_flush callback.
handle_message/3Wrap handle_message callback.
terminate/2Wrap terminate callback.
wrap/3Wrap intermediate callback module.

Function Details

handle_flush/2

handle_flush(State0::wrapped(), _Config) -> kflow_gen:callback_return(wrapped())

Wrap handle_flush callback

handle_message/3

handle_message(Msg::kflow:message(), State::wrapped(), _Config) -> kflow_gen:callback_return(wrapped())

Wrap handle_message callback

terminate/2

terminate(S::wrapped(), _Config) -> term()

Wrap terminate callback

wrap/3

wrap(NodeId::kflow:node_id(), IntermediateCbModule::module(), Config::term()) -> {ok, wrapped()}

Wrap intermediate callback module


Generated by EDoc