Skip to content

Flow Controlling Content Producer

Mikko Karjalainen edited this page Apr 2, 2020 · 1 revision

Finite State Machine (FSM) Design

The FSM regulates the packet flow as per reactive back pressure protocol. It receives content data packets from Netty channel pipeline, and emits them to the subscriber as requested. The specifics depend on the producer state.

All data packets go through a FIFO queue, from which they are dequeued as per reactive back pressure requests.

The FSM has four basic states:

BUFFERING

  • An initial state
  • Waiting for subscribtion.
  • The subscriber has not yet subscribed.
  • The FSM queues all received data because it doesn’t have a subscriber to send to.

BUFFERING_COMPLETED

  • Still waiting for subscription.
  • The message body is fully received. Therefore no more content chunk events are expected.
  • The full message body sits in the queue until a subscriber subscribes.

STREAMING

  • Has an active subscription.
  • The message body is still ongoing. It has not yet been fully received.
  • The FSM keeps emitting content chunks from the FIFO, subject to reactive back pressure protocol.

EMITTING_BUFFERED_CONTENT

  • Has an active subscription.
  • The message body is fully received. Therefore no more content chunk events are expected.
  • There is still data in FIFO that has not yet been emitted due to back pressure constraints.