Types
Connection = ref object id*: uint32 reactorId*: uint32 address*: Address stats*: ConnectionStats lastActiveTime*: float64 ## Parts queued to be sent. ## Parts that have been read from the socket. ## Next message sequence num when sending. ## Next message sequence number to receive.
- Source Edit
ConnectionStats = object inFlight*: int ## How many bytes are currently in flight. inQueue*: int ## How many bytes are currently waiting to be sent. saturated*: bool ## If this conn cannot send until it receives acks. latencyTs*: TimeSeries throughputTs*: TimedSamples
- Source Edit
DebugConfig = object tickTime*: float64 ## Override the time processed by calls to tick. dropRate*: float32 ## [0, 1] % simulated drop rate. readLatency*: float32 ## Min simulated read latency in seconds. sendLatency*: float32 ## Min simulated send latency in seconds. maxUdpPacket*: int ## Max size of each outgoing UDP packet in bytes.
- Source Edit
Message = object conn*: Connection sequenceNum*: uint32 data*: string
- Source Edit
Reactor = ref object id*: uint32 address*: Address maxInFlight*: int ## Max bytes in-flight on the socket. debug*: DebugConfig connections*: seq[Connection] newConnections*: seq[Connection] ## New connections since last tick. deadConnections*: seq[Connection] ## Dead connections since last tick. messages*: seq[Message]
- Main networking system that can open or receive connections. Source Edit
Procs
func `$`(address: Address): string {....raises: [], tags: [], forbids: [].}
- Address to string. Source Edit
func `$`(conn: Connection): string {....raises: [], tags: [], forbids: [].}
- Connection to string. Source Edit
func connect(reactor: Reactor; address: Address): Connection {....raises: [], tags: [], forbids: [].}
- Starts a new connection to an address. Source Edit
func connect(reactor: Reactor; host: string; port: int): Connection {. ...raises: [], tags: [], forbids: [].}
- Starts a new connection to host and port. Source Edit
proc disconnect(reactor: Reactor; conn: Connection) {....raises: [OSError], tags: [WriteIOEffect], forbids: [].}
- Disconnects the connection. Source Edit
func initAddress(host: string; port: int): Address {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newReactor(): Reactor {....raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
- Creates a new reactor with system chosen address. Source Edit
proc newReactor(address: Address): Reactor {. ...raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
- Creates a new reactor with address. Source Edit
proc newReactor(host: string; port: int): Reactor {. ...raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
- Creates a new reactor with host and port. Source Edit
proc punchThrough(reactor: Reactor; address: Address) {....raises: [OSError], tags: [WriteIOEffect], forbids: [].}
- Tries to punch through to host/port. Source Edit
proc punchThrough(reactor: Reactor; host: string; port: int) {. ...raises: [OSError], tags: [WriteIOEffect], forbids: [].}
- Tries to punch through to host/port. Source Edit
func send(reactor: Reactor; conn: Connection; data: string) {....raises: [], tags: [], forbids: [].}
- Source Edit
Exports
-
avg, add, avg, max, max, newTimedSamples, TimeSeries, TimedSamples, add, newTimeSeries