Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · amqptest

Docs

std/amqptest

On this page

Index

Types

QueueOptions

struct QueueOptions {
  sessions: Bool = false
  lock_ms: Int = 60000
  max_delivery_count: Int = 10
}

One entity’s settings.

Source: std/amqptest.xo:8

FakeMsg

struct FakeMsg {
  seq: Int
  m: amqp.Message
  delivery_count: Int = 0
  lock_token: Bytes = b""
  locked_until: Int = 0
  lock_conn: Int = 0
  scheduled_ms: Int = 0
  enqueued_ms: Int = 0
  session: Str = ""
  deferred: Bool = false
  dead_reason: Str = ""
  dead_description: Str = ""
}

A message held by a queue. Internal: use the Broker’s methods.

Source: std/amqptest.xo:18

FakeSession

struct FakeSession {
  id: Str
  state: Bytes = b""
  locked_until: Int = 0
  owner: Int = 0
  updated_ms: Int = 0
}

A session of a session enabled queue. Internal.

Source: std/amqptest.xo:36

FakeQueue

struct FakeQueue {
  name: Str
  opts: QueueOptions
  is_topic: Bool = false
  msgs: List[FakeMsg] = []
  dead: List[FakeMsg] = []
  next_seq: Int = 1
  sessions: List[FakeSession] = []
}

A queue, or a topic’s subscription (named topic/Subscriptions/name), or a topic (no messages). Internal.

Source: std/amqptest.xo:47

FakeFail

struct FakeFail {
  op: Str
  status: Int
  condition: Str
  description: Str
  left: Int
}

An injected failure. Internal.

Source: std/amqptest.xo:58

FakePart

struct FakePart {
  events: List[amqp.Message] = []
}

One partition of an event hub: the events in order, each with its x-opt annotations. Internal.

Source: std/amqptest.xo:70

FakeHub

struct FakeHub {
  name: Str
  groups: List[Str]
  parts: List[FakePart]
  created_ms: Int
  rr: Int = 0
  geo_factor: Int = 1
}

An event hub (decision 0521). Internal.

Source: std/amqptest.xo:75

HubOwner

struct HubOwner {
  path: Str
  key: Str
  epoch: Int
}

A receiver link that owns a partition of a consumer group at an epoch. Internal.

Source: std/amqptest.xo:87

BrokerState

struct BrokerState {
  queues: List[FakeQueue] = []
  hubs: List[FakeHub] = []
  owners: List[HubOwner] = []
  tokens: List[(Str, Str)] = []
  attaches: List[(Str, Str, List[Str])] = []
  expiries: List[(Str, Int)] = []
  rejected: List[Str] = []
  require_token: Bool = false
  fails: List[FakeFail] = []
  wakes: List[(Int, Chan[Bool])] = []
  conns: List[(Int, ServerConn)] = []
  next_conn: Int = 1
  next_lock: Int = 1
  slow_mgmt_ms: Int = 0
  gen: Int = 0
  detaches: List[(Int, Str, amqp.WireError)] = []
  closes: List[(Int, amqp.WireError?)] = []
}

The broker’s state. Internal.

Source: std/amqptest.xo:96

Broker

struct Broker {
  st: Mutex[BrokerState]
  clock: Clock
}

A broker. A handle: copies share it.

Source: std/amqptest.xo:122

Broker.serve

fn (b: Broker) serve(g: task.Group, l: Listener) uses (net.listen, clock)

Serves the connections l accepts, each in a task of g; returns at once. The tasks end when g is cancelled or l is closed.

Source: std/amqptest.xo:189

Broker.queue

fn (b: Broker) queue(name: Str, opts: QueueOptions = QueueOptions{})

Declares a queue (a queue is also created, with the defaults, by the first link to it).

Source: std/amqptest.xo:192

Broker.event_hub

fn (b: Broker) event_hub(name: Str, partitions: Int, consumer_groups: List[Str] = ["$Default"])

Declares an event hub with partitions partitions (ids “0”, “1”, …), receivable by each consumer group at hub/ConsumerGroups/cg/Partitions/id and sendable at hub or hub/Partitions/id.

Source: std/amqptest.xo:195

Broker.event_hub_geo_factor

fn (b: Broker) event_hub_geo_factor(hub: Str, factor: Int)

Sets the georeplication_factor an event hub’s READ reports (1 when declared; above 1 means geo-replication is enabled, as Event Hubs v2 reads it).

Source: std/amqptest.xo:198

Broker.events

fn (b: Broker) events(hub: Str, partition: Int) -> List[amqp.Message]

The events a partition holds, with their x-opt-sequence-number, x-opt-offset and x-opt-enqueued-time message annotations.

Source: std/amqptest.xo:201

Broker.topic

fn (b: Broker) topic(name: Str)

Declares a topic: a message sent to it is copied to every subscription.

Source: std/amqptest.xo:203

Broker.subscription

fn (b: Broker) subscription(topic: Str, name: Str, opts: QueueOptions = QueueOptions{})

Declares the subscription topic/Subscriptions/name, receivable at that address.

Source: std/amqptest.xo:205

Broker.put

fn (b: Broker) put(queue: Str, m: amqp.Message)

Puts a message on a queue (or a topic) as if a client had sent it.

Source: std/amqptest.xo:208

Broker.ready

fn (b: Broker) ready(queue: Str) -> List[amqp.Message]

The messages that can be delivered now, in order, as a client would receive them.

Source: std/amqptest.xo:210

Broker.locked

fn (b: Broker) locked(queue: Str) -> Int

The number of messages locked by a receiver.

Source: std/amqptest.xo:212

Broker.dead_letters

fn (b: Broker) dead_letters(queue: Str) -> List[amqp.Message]

The messages in the dead letter queue.

Source: std/amqptest.xo:214

Broker.scheduled

fn (b: Broker) scheduled(queue: Str) -> List[amqp.Message]

The messages scheduled for later.

Source: std/amqptest.xo:216

Broker.deferred

fn (b: Broker) deferred(queue: Str) -> List[amqp.Message]

The deferred messages.

Source: std/amqptest.xo:218

Broker.tokens

fn (b: Broker) tokens() -> List[(Str, Str)]

The (audience, token) pairs the broker accepted through $cbs, in order.

Source: std/amqptest.xo:220

Broker.attaches

fn (b: Broker) attaches() -> List[(Str, Str, List[Str])]

Every link a client attached, in order: its address (a sender’s target, a receiver’s source), the client’s role (“sender” or “receiver”) and the Attach’s desired capabilities.

Source: std/amqptest.xo:223

Broker.reject_token

fn (b: Broker) reject_token(token: Str)

A put-token with this token is answered with 401.

Source: std/amqptest.xo:225

Broker.require_token

fn (b: Broker) require_token(on: Bool)

Links to entities are refused (amqp:unauthorized-access) until a put-token whose audience ends with the entity’s name was accepted and has not expired.

Source: std/amqptest.xo:228

Broker.session_state

fn (b: Broker) session_state(queue: Str, session: Str) -> Bytes

The state of a session of a session enabled queue, as set by a client.

Source: std/amqptest.xo:230

Broker.fail_next

fn (b: Broker) fail_next(op: Str, status: Int, condition: Str, description: Str)

The next use of operation op fails with an error: an attach, a transfer, a disposition or a put-token is refused with condition; a management operation (renew-lock, peek-message, schedule-message, cancel-scheduled-message, receive-by-sequence-number, update-disposition, renew-session-lock, get-session-state, set-session-state) answers status with condition and description.

Source: std/amqptest.xo:237

Broker.fail

fn (b: Broker) fail(op: Str, status: Int, condition: Str, description: Str)

Like fail_next, until clear_failures.

Source: std/amqptest.xo:239

Broker.clear_failures

fn (b: Broker) clear_failures()

Source: std/amqptest.xo:240

Broker.slow_management

fn (b: Broker) slow_management(ms: Int)

Holds every management reply back by ms milliseconds.

Source: std/amqptest.xo:242

fn (b: Broker) detach_links(queue: Str, error: amqp.WireError)

Detaches every link to queue with error (for example amqp:link:detach-forced).

Source: std/amqptest.xo:244

Broker.disconnect_all

fn (b: Broker) disconnect_all(error: amqp.WireError? = None)

Closes every connection, with error in the Close frame when given, otherwise by dropping the transport.

Source: std/amqptest.xo:247

struct SvLink {
  handle: Int
  remote: Int
  channel: Int
  name: Str
  sends: Bool
  kind: Int
  queue: Str
  credit: Int = 0
  delivery_count: Int = 0
  presettled: Bool = false
  session_id: Str = ""
  partial: Bytes = b""
  partial_id: Int = 0
  partial_settled: Bool = false
  partial_active: Bool = false
  partial_format: Int = 0
  replies: List[amqp.Message] = []
  unsettled: List[(Int, Int)] = []
  detached: Bool = false
  hub: Str = ""
  cg: Str = ""
  part: Int = -1
  pos: Int = 0
  epoch: Int = 0
  hkey: Str = ""
}

A link of one connection. Internal.

Source: std/amqptest.xo:128

SvSession

struct SvSession {
  channel: Int
  next_in: Int = 0
  next_out: Int = 0
  remote_window: Int = 0
  ended: Bool = false
  in_used: Int = 0
}

A session of one connection. Internal.

Source: std/amqptest.xo:165

SvConn

struct SvConn {
  id: Int
  max_frame: Int = 65536
  sess: List[SvSession] = []
  links: List[SvLink] = []
  seen_gen: Int = 0
}

One connection’s state. Internal.

Source: std/amqptest.xo:176

Functions

new

fn new(clock: Clock) -> Broker

A new broker; clock times message locks, scheduled messages and token expiry.

Source: std/amqptest.xo:185

↑ index