lightspeed/agent/typestate

Typestate lifecycle for Lightspeed session agents.

Types

Agent

opaque

A session agent parameterized by lifecycle state.

pub opaque type Agent(state)

Marker type for a disconnected agent.

pub type Disconnected {
  Disconnected
}

Constructors

  • Disconnected

Marker type for an agent draining before shutdown.

pub type Draining {
  Draining
}

Constructors

  • Draining

Marker type for an agent performing protocol handshake.

pub type Handshaking {
  Handshaking
}

Constructors

  • Handshaking

Lifecycle labels useful for logs and protocol diagnostics.

pub type Lifecycle {
  DisconnectedLabel
  HandshakingLabel
  MountedLabel
  LiveLabel
  DrainingLabel
  TerminatedLabel
}

Constructors

  • DisconnectedLabel
  • HandshakingLabel
  • MountedLabel
  • LiveLabel
  • DrainingLabel
  • TerminatedLabel

Marker type for an active live agent.

pub type Live {
  Live
}

Constructors

  • Live

Marker type for an agent whose component has mounted.

pub type Mounted {
  Mounted
}

Constructors

  • Mounted

Marker type for a terminated agent.

pub type Terminated {
  Terminated
}

Constructors

  • Terminated

Values

pub fn drain(agent: Agent(Live)) -> Agent(Draining)

Transition from live to draining.

pub fn go_live(agent: Agent(Mounted)) -> Agent(Live)

Transition from mounted to live.

pub fn handshake(
  agent: Agent(Disconnected),
) -> Agent(Handshaking)

Transition from disconnected to handshaking.

pub fn id(agent: Agent(state)) -> String

Return the agent id.

pub fn lifecycle(agent: Agent(state)) -> Lifecycle

Return the lifecycle label.

pub fn lifecycle_to_string(lifecycle: Lifecycle) -> String

Convert a lifecycle label to a stable string.

pub fn mount(agent: Agent(Handshaking)) -> Agent(Mounted)

Transition from handshaking to mounted.

pub fn new(id: String) -> Agent(Disconnected)

Create a disconnected agent.

pub fn terminate(agent: Agent(Draining)) -> Agent(Terminated)

Transition from draining to terminated.

Search Document