Module kflow_demux_bridge

kflow_demux_bridge 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_demux_bridge behaviour.
Required callback functions: fully_processed_offset/1.

Description

kflow_demux_bridge 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.

Intermediate CBMs using demux bridge must implement both kflow_gen and kflow_demux_bridge behaviors.

NOTE: fully_processed_offset/1 callback should 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 different 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/2Wrap intermediate callback module:.

Function Details

handle_flush/2

handle_flush(State0, Config) -> any()

Wrap handle_flush callback

handle_message/3

handle_message(Msg, State0, Config) -> any()

Wrap handle_message callback

terminate/2

terminate(S, Config) -> any()

Wrap terminate callback

wrap/2

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

Wrap intermediate callback module:


Generated by EDoc