std/amqptest
On this page
Index
- type
QueueOptions - type
FakeMsg - type
FakeSession - type
FakeQueue - type
FakeFail - type
FakePart - type
FakeHub - type
HubOwner - type
BrokerState - type
Broker- method
Broker.serve - method
Broker.queue - method
Broker.event_hub - method
Broker.event_hub_geo_factor - method
Broker.events - method
Broker.topic - method
Broker.subscription - method
Broker.put - method
Broker.ready - method
Broker.locked - method
Broker.dead_letters - method
Broker.scheduled - method
Broker.deferred - method
Broker.tokens - method
Broker.attaches - method
Broker.reject_token - method
Broker.require_token - method
Broker.session_state - method
Broker.fail_next - method
Broker.fail - method
Broker.clear_failures - method
Broker.slow_management - method
Broker.detach_links - method
Broker.disconnect_all
- method
- type
SvLink - type
SvSession - type
SvConn - fn
new
Types
QueueOptions
struct QueueOptions {
sessions: Bool = false
lock_ms: Int = 60000
max_delivery_count: Int = 10
}One entity’s settings.
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.
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.
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.
FakeFail
struct FakeFail {
op: Str
status: Int
condition: Str
description: Str
left: Int
}An injected failure. Internal.
FakePart
struct FakePart {
events: List[amqp.Message] = []
}One partition of an event hub: the events in order, each with its x-opt annotations. Internal.
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.
HubOwner
struct HubOwner {
path: Str
key: Str
epoch: Int
}A receiver link that owns a partition of a consumer group at an epoch. Internal.
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.
Broker
struct Broker {
st: Mutex[BrokerState]
clock: Clock
}A broker. A handle: copies share it.
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.
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).
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.
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).
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.
Broker.topic
fn (b: Broker) topic(name: Str)Declares a topic: a message sent to it is copied to every subscription.
Broker.subscription
fn (b: Broker) subscription(topic: Str, name: Str, opts: QueueOptions = QueueOptions{})Declares the subscription topic/Subscriptions/name, receivable at that address.
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.
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.
Broker.locked
fn (b: Broker) locked(queue: Str) -> IntThe number of messages locked by a receiver.
Broker.dead_letters
fn (b: Broker) dead_letters(queue: Str) -> List[amqp.Message]The messages in the dead letter queue.
Broker.scheduled
fn (b: Broker) scheduled(queue: Str) -> List[amqp.Message]The messages scheduled for later.
Broker.deferred
fn (b: Broker) deferred(queue: Str) -> List[amqp.Message]The deferred messages.
Broker.tokens
fn (b: Broker) tokens() -> List[(Str, Str)]The (audience, token) pairs the broker accepted through $cbs, in order.
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.
Broker.reject_token
fn (b: Broker) reject_token(token: Str)A put-token with this token is answered with 401.
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.
Broker.session_state
fn (b: Broker) session_state(queue: Str, session: Str) -> BytesThe state of a session of a session enabled queue, as set by a client.
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.
Broker.fail
fn (b: Broker) fail(op: Str, status: Int, condition: Str, description: Str)Like fail_next, until clear_failures.
Broker.clear_failures
fn (b: Broker) clear_failures()Broker.slow_management
fn (b: Broker) slow_management(ms: Int)Holds every management reply back by ms milliseconds.
Broker.detach_links
fn (b: Broker) detach_links(queue: Str, error: amqp.WireError)Detaches every link to queue with error (for example amqp:link:detach-forced).
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.
SvLink
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.
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.
SvConn
struct SvConn {
id: Int
max_frame: Int = 65536
sess: List[SvSession] = []
links: List[SvLink] = []
seen_gen: Int = 0
}One connection’s state. Internal.
Functions
new
fn new(clock: Clock) -> BrokerA new broker; clock times message locks, scheduled messages and token expiry.