Types
Connection = ref object id*: uint32 reactorId*: uint32 address*: Address stats*: ConnectionStats lastActiveTime*: float64 sendParts: seq[Part] ## Parts queued to be sent. recvParts: seq[Part] ## Parts that have been read from the socket. sendSequenceNum: uint32 ## Next message sequence num when sending. recvSequenceNum: uint32 ## 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 r: Rand id*: uint32 address*: Address socket: Socket time: float64 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: [ValueError], tags: [].}
- Address to string. Source Edit
func `$`(conn: Connection): string {....raises: [ValueError], tags: [].}
- Connection to string. Source Edit
func connect(reactor: Reactor; address: Address): Connection {....raises: [], tags: [].}
- Starts a new connection to an address. Source Edit
func connect(reactor: Reactor; host: string; port: int): Connection {. ...raises: [], tags: [].}
- Starts a new connection to host and port. Source Edit
proc disconnect(reactor: Reactor; conn: Connection) {....raises: [OSError], tags: [WriteIOEffect].}
- Disconnects the connection. Source Edit
func hash(x: Address): Hash {....raises: [], tags: [].}
- Computes a hash for the address. Source Edit
func initAddress(host: string; port: int): Address {....raises: [], tags: [].}
- Source Edit
proc newReactor(): Reactor {....raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect].}
- Creates a new reactor with system chosen address. Source Edit
proc newReactor(address: Address): Reactor {. ...raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect].}
- Creates a new reactor with address. Source Edit
proc newReactor(host: string; port: int): Reactor {. ...raises: [OSError, ValueError, Exception], tags: [TimeEffect, ReadIOEffect, WriteIOEffect].}
- Creates a new reactor with host and port. Source Edit
proc punchThrough(reactor: Reactor; address: Address) {....raises: [OSError], tags: [WriteIOEffect].}
- Tries to punch through to host/port. Source Edit
proc punchThrough(reactor: Reactor; host: string; port: int) {. ...raises: [OSError], tags: [WriteIOEffect].}
- Tries to punch through to host/port. Source Edit
func send(reactor: Reactor; conn: Connection; data: string) {....raises: [], tags: [].}
- Source Edit
Exports
-
avg, add, avg, max, max, newTimedSamples, TimeSeries, TimedSamples, add, newTimeSeries