Dista · API

dista.conn

A non-blocking framed connection, for the head's event loop.

The head talks to every driver and worker at once, so it must never block on one of them. A Conn reads and writes with MSG_DONTWAIT, so no call blocks. It reads whatever has arrived into an input buffer and hands out complete frames, and queues outgoing frames in an output buffer that flush drains as the socket accepts it. The event loop polls for writability only while something is queued.

Structs

Conn

struct Conn

Implements Movable

Fields
stream: Stream
closed: Bool: The peer hung up, or the connection failed.

__init__

def __init__(out self, var stream: Stream)

fd

def fd(self) -> c_int

read_available

def read_available(mut self, limit: Int = Int(0))

Reads what's waiting on the socket into the input buffer: all of it, or with limit, about that many bytes, leaving the rest in the socket, where poll still reports it.

next_frame

def next_frame(mut self) -> Optional[Frame]

The next complete frame in the input buffer, if there is one.

send

def send(mut self, kind: UInt8, object_id: UInt64, task_id: UInt64, payload: Span[UInt8])

Queues a frame and sends as much as the socket takes now.

flush

def flush(mut self)

Sends queued output until the socket would block.

wants_write

def wants_write(self) -> Bool

unsent

def unsent(self) -> Int

Bytes queued to send that the peer hasn't taken yet.