ConvergerClient.Protocol.Session (converger_client v0.1.1)

Copy Markdown View Source

Transport-independent Protocol v1 resume state machine.

The rules are in packages/conformance/README.md; the scenarios in packages/conformance/protocol.json check them. on_frame/2 returns the new session and a step: frames to deliver to the application, frames to send now and frames to send after a delay.

Summary

Functions

The first frame of a connection.

A session resuming from watermark (and conversation_id, when known).

Applies one received frame.

The protocol identifier sent in hello.

A sync from the current watermark.

Types

frame()

@type frame() :: map()

step()

@type step() :: %{
  deliver: [frame()],
  send: [frame()],
  schedule: [{non_neg_integer(), frame()}]
}

t()

@type t() :: %ConvergerClient.Protocol.Session{
  conversation_id: String.t() | nil,
  own: MapSet.t(integer()),
  sync_pending: boolean(),
  watermark: non_neg_integer()
}

Functions

hello(s)

@spec hello(t()) :: frame()

The first frame of a connection.

new(watermark \\ 0, conversation_id \\ nil)

@spec new(non_neg_integer(), String.t() | nil) :: t()

A session resuming from watermark (and conversation_id, when known).

on_frame(s, frame)

@spec on_frame(t(), frame()) :: {t(), step()}

Applies one received frame.

protocol()

The protocol identifier sent in hello.

sync_frame(session)

@spec sync_frame(t()) :: frame()

A sync from the current watermark.