goose

Types

pub type AccountData {
  AccountData(active: Bool, did: String, seq: Int, time: String)
}

Constructors

  • AccountData(active: Bool, did: String, seq: Int, time: String)
pub type CommitData {
  CommitData(
    rev: String,
    operation: String,
    collection: String,
    rkey: String,
    record: option.Option(dynamic.Dynamic),
    cid: option.Option(String),
  )
}

Constructors

pub type IdentityData {
  IdentityData(
    did: String,
    handle: String,
    seq: Int,
    time: String,
  )
}

Constructors

  • IdentityData(did: String, handle: String, seq: Int, time: String)

Configuration for Jetstream consumer

pub type JetstreamConfig {
  JetstreamConfig(
    endpoint: String,
    wanted_collections: List(String),
    wanted_dids: List(String),
    cursor: option.Option(Int),
    max_message_size_bytes: option.Option(Int),
    compress: Bool,
    require_hello: Bool,
  )
}

Constructors

  • JetstreamConfig(
      endpoint: String,
      wanted_collections: List(String),
      wanted_dids: List(String),
      cursor: option.Option(Int),
      max_message_size_bytes: option.Option(Int),
      compress: Bool,
      require_hello: Bool,
    )

Jetstream event types

pub type JetstreamEvent {
  CommitEvent(did: String, time_us: Int, commit: CommitData)
  IdentityEvent(
    did: String,
    time_us: Int,
    identity: IdentityData,
  )
  AccountEvent(did: String, time_us: Int, account: AccountData)
  UnknownEvent(raw: String)
}

Constructors

  • CommitEvent(did: String, time_us: Int, commit: CommitData)
  • IdentityEvent(did: String, time_us: Int, identity: IdentityData)
  • AccountEvent(did: String, time_us: Int, account: AccountData)
  • UnknownEvent(raw: String)

Values

pub fn build_url(config: JetstreamConfig) -> String

Build the WebSocket URL with query parameters

pub fn connect(
  url: String,
  handler_pid: process.Pid,
  compress: Bool,
) -> Result(process.Pid, dynamic.Dynamic)

Connect to Jetstream WebSocket using Erlang gun library

pub fn default_config() -> JetstreamConfig

Create a default configuration for US East endpoint

pub fn parse_event(json_string: String) -> JetstreamEvent

Parse a JSON event string into a JetstreamEvent

pub fn start_consumer(
  config: JetstreamConfig,
  on_event: fn(String) -> Nil,
) -> Nil

Start consuming the Jetstream feed

Search Document