retrace/wire

Versioned, application-neutral delivery envelopes. Payloads are application-encoded strings. This module checks transport and sequence invariants; it does not interpret the application’s model.

Types

pub type Batch {
  Batch(
    session: Session,
    checkpoint: retrace.Checkpoint(String),
    entries: List(retrace.Entry(Event)),
  )
}

Constructors

pub type Error {
  MalformedEnvelope
  InvalidSession
  EmptyBatch
  TooManyEntries
  TooLarge
  InvalidHistory(retrace.Error(Nil))
}

Constructors

  • MalformedEnvelope
  • InvalidSession
  • EmptyBatch
  • TooManyEntries
  • TooLarge
  • InvalidHistory(retrace.Error(Nil))
pub type Event {
  Event(kind: String, payload: String)
}

Constructors

  • Event(kind: String, payload: String)

A session the server opened, with the capability to append to it. Only the writer that opened the session holds the token; a batch must present it.

pub type Grant {
  Grant(session: Session, token: String)
}

Constructors

  • Grant(session: Session, token: String)

What a writer states about a session before the server issues its id.

pub type Metadata {
  Metadata(
    user_ref: String,
    build: String,
    contract: String,
    platform: String,
  )
}

Constructors

  • Metadata(
      user_ref: String,
      build: String,
      contract: String,
      platform: String,
    )
pub type Session {
  Session(
    id: String,
    user_ref: String,
    build: String,
    contract: String,
    platform: String,
  )
}

Constructors

  • Session(
      id: String,
      user_ref: String,
      build: String,
      contract: String,
      platform: String,
    )

One batch presented with its session’s write token. The token is never part of the batch, so stored and read batches cannot reveal it.

pub type Upload {
  Upload(token: String, batch: Batch)
}

Constructors

  • Upload(token: String, batch: Batch)

Values

pub fn decode_batch(input: String) -> Result(Batch, Error)
pub fn decode_grant(input: String) -> Result(Grant, Error)

Decode a grant and check that its id and token are well formed.

pub fn decode_metadata(input: String) -> Result(Metadata, Error)
pub fn decode_upload(input: String) -> Result(Upload, Error)

Decode an upload. The batch is validated as decode_batch does, and a token that is not a well-formed capability is malformed.

pub fn encode(batch: Batch) -> String
pub fn encode_grant(grant: Grant) -> String
pub fn encode_metadata(metadata: Metadata) -> String
pub fn encode_upload(upload: Upload) -> String
pub fn end_sequence(batch: Batch) -> Int
pub fn end_time(batch: Batch) -> Int
pub const max_bytes: Int
pub const max_entries: Int
pub const max_upload_bytes: Int

The largest encoded upload: a full batch plus its write token.

pub fn metadata(session: Session) -> Metadata
pub fn origin(session: Session) -> retrace.Origin
pub fn session(id: String, metadata: Metadata) -> Session
pub fn session_decoder() -> decode.Decoder(Session)
pub fn session_json(session: Session) -> json.Json
pub fn valid_id(id: String) -> Bool
pub fn validate(batch: Batch) -> Result(Nil, Error)
pub fn validate_metadata(
  metadata: Metadata,
) -> Result(Nil, Error)
✨ Search Document