abi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventHTTPRequest = "http.request"
	EventWSOpen      = "ws.open"
	EventWSFrame     = "ws.frame"
	EventWSClose     = "ws.close"
)

Event kinds delivered to the cell as the step envelope payload.

View Source
const (
	WSOpCodeText   uint8 = 1
	WSOpCodeBinary uint8 = 2
)

WebSocket frame opcodes delivered to and accepted from cells.

View Source
const HeaderSize = 8 + 8 + 4

Variables

This section is empty.

Functions

func EncodeHTTPFetchChunk

func EncodeHTTPFetchChunk(c HTTPFetchChunk) ([]byte, error)

EncodeHTTPFetchChunk marshals c for delivery to the cell.

func EncodeHTTPFetchStreamHeader

func EncodeHTTPFetchStreamHeader(h HTTPFetchStreamHeader) ([]byte, error)

EncodeHTTPFetchStreamHeader marshals h for delivery to the cell.

func EncodeHTTPRequest

func EncodeHTTPRequest(req HTTPRequest) ([]byte, error)

EncodeHTTPRequest marshals req to MessagePack for delivery to the cell.

func EncodeHTTPResponse

func EncodeHTTPResponse(resp HTTPResponse) ([]byte, error)

EncodeHTTPResponse marshals resp to MessagePack for delivery to the cell as an outbound fetch result.

func EncodeStepEvent

func EncodeStepEvent(kind string, payload []byte) ([]byte, error)

EncodeStepEvent wraps a pre-encoded payload with the kind discriminator and marshals the result for delivery via the step envelope.

func EncodeWSClose

func EncodeWSClose(e WSClose) ([]byte, error)

EncodeWSClose marshals a WSClose event for delivery via StepEvent.

func EncodeWSFrame

func EncodeWSFrame(e WSFrame) ([]byte, error)

EncodeWSFrame marshals a WSFrame event for delivery via StepEvent.

func EncodeWSOpen

func EncodeWSOpen(e WSOpen) ([]byte, error)

EncodeWSOpen marshals a WSOpen event for delivery via StepEvent.

Types

type HTTPFetchChunk

type HTTPFetchChunk struct {
	Bytes []byte `msgpack:"bytes"`
	EOF   bool   `msgpack:"eof"`
	Err   string `msgpack:"err,omitempty"`
}

HTTPFetchChunk is the response of http_fetch_read. Bytes is the data (possibly empty if the underlying reader returned 0 bytes without error — cell should retry). EOF is true after the final chunk; the cell should call http_fetch_close to release the stream afterward. Err is a human-readable string set only when a non-EOF read error occurred; cells should treat it as terminal.

func DecodeHTTPFetchChunk

func DecodeHTTPFetchChunk(data []byte) (HTTPFetchChunk, error)

DecodeHTTPFetchChunk parses MessagePack bytes from the host.

type HTTPFetchRequest

type HTTPFetchRequest struct {
	Method  string            `msgpack:"method"`
	URL     string            `msgpack:"url"`
	Headers map[string]string `msgpack:"headers"`
	Body    []byte            `msgpack:"body"`
	Timeout int64             `msgpack:"timeout,omitempty"`
}

HTTPFetchRequest is sent by the cell to http_fetch to perform an outbound HTTP call. URL must be absolute; Method defaults to GET when blank. Headers and Body are optional.

Timeout is the per-request deadline in nanoseconds. Zero means "use the default fetch timeout." Non-zero values override the default — applied by the fetcher via context.WithTimeout on http.Client.Do. Matches the Go time.Duration wire shape on the cell side (int64 nanoseconds).

func DecodeHTTPFetchRequest

func DecodeHTTPFetchRequest(data []byte) (HTTPFetchRequest, error)

DecodeHTTPFetchRequest parses MessagePack bytes produced by the cell.

type HTTPFetchStreamHeader

type HTTPFetchStreamHeader struct {
	ID      uint64            `msgpack:"id"`
	Status  uint32            `msgpack:"status"`
	Headers map[string]string `msgpack:"headers"`
}

HTTPFetchStreamHeader is the response of http_fetch_begin. ID is the opaque stream handle the cell passes to http_fetch_read / http_fetch_close. Status + Headers come from the live response; the body is NOT included — the cell pulls it via repeated reads.

func DecodeHTTPFetchStreamHeader

func DecodeHTTPFetchStreamHeader(data []byte) (HTTPFetchStreamHeader, error)

DecodeHTTPFetchStreamHeader parses MessagePack bytes from the host.

type HTTPRequest

type HTTPRequest struct {
	ID      uint64            `msgpack:"id"`
	Method  string            `msgpack:"method"`
	Path    string            `msgpack:"path"`
	Params  map[string]string `msgpack:"params"`
	Query   map[string]string `msgpack:"query"`
	Headers map[string]string `msgpack:"headers"`
	Body    []byte            `msgpack:"body"`
	// RemoteAddr is the peer address as observed by the host (typically
	// the TCP source — "host:port" on IPv4, "[host]:port" on IPv6). The
	// host populates this from the incoming net.Conn so cells can do
	// rate-limiting keyed on the real peer when no proxy headers are
	// present. Empty when the host couldn't determine one.
	RemoteAddr string `msgpack:"remote_addr,omitempty"`
}

HTTPRequest is delivered to the cell via the step envelope payload when an HTTP request arrives on a route it registered with http_register. ID is allocated by the host and must be echoed back in HTTPResponse.

type HTTPResponse

type HTTPResponse struct {
	ID      uint64            `msgpack:"id"`
	Status  uint32            `msgpack:"status"`
	Headers map[string]string `msgpack:"headers"`
	Cookies []string          `msgpack:"cookies,omitempty"`
	Body    []byte            `msgpack:"body"`
}

HTTPResponse is produced by the cell and passed to http_respond, or returned to the cell by the host as the result of http_fetch. ID is meaningful for inbound responses (matches HTTPRequest.ID); for outbound fetch results it is zero.

Cookies carries fully-formatted Set-Cookie header values — one per entry — so handlers can emit multiple cookies in a single response. Headers is a single-valued map and would overwrite duplicates, so any Set-Cookie emitted there is merged into Cookies by the host.

func DecodeHTTPResponse

func DecodeHTTPResponse(data []byte) (HTTPResponse, error)

DecodeHTTPResponse parses MessagePack bytes produced by the cell.

type SSEEmitRequest

type SSEEmitRequest struct {
	Path  string `msgpack:"path"`
	ID    string `msgpack:"id,omitempty"`
	Event string `msgpack:"event,omitempty"`
	Data  string `msgpack:"data"`
}

SSEEmitRequest is what the cell passes to sse_emit. Path selects the SSE route to broadcast on; Data is the event payload. ID and Event are optional SSE fields — ID sets "id:", Event sets "event:" before data.

func DecodeSSEEmitRequest

func DecodeSSEEmitRequest(data []byte) (SSEEmitRequest, error)

DecodeSSEEmitRequest parses sse_emit input.

type StepEnvelope

type StepEnvelope struct {
	CallNumber uint64
	WallTime   uint64
	Payload    []byte
}

StepEnvelope is the universal header passed to every pulp_step call.

Layout (little-endian, fixed):

call_number  uint64  — how many times step has been called
wall_time    uint64  — unix nanoseconds when Go called step
payload_len  uint32  — length of the following payload bytes
payload      []byte  — trigger data, cell-defined

func (StepEnvelope) Encode

func (e StepEnvelope) Encode() []byte

type StepEvent

type StepEvent struct {
	Kind    string             `msgpack:"kind"`
	Payload msgpack.RawMessage `msgpack:"payload"`
}

StepEvent is the outer MessagePack envelope wrapping any event the host delivers to pulp_step. Kind selects which concrete struct Payload decodes to. An empty envelope payload (envelope.Payload == nil) means "no event this step" — the cell should treat it as a tick and return.

func DecodeStepEvent

func DecodeStepEvent(data []byte) (StepEvent, error)

DecodeStepEvent unmarshals the step envelope payload into a StepEvent. Callers inspect Kind to decide how to decode Payload.

type WSClose

type WSClose struct {
	ConnID uint64 `msgpack:"conn_id"`
	Code   uint16 `msgpack:"code"`
	Reason string `msgpack:"reason"`
}

WSClose is the ws.close event — one per disconnect, whether initiated by the client, the cell, or the host.

type WSCloseRequest

type WSCloseRequest struct {
	ConnID uint64 `msgpack:"conn_id"`
	Code   uint16 `msgpack:"code"`
	Reason string `msgpack:"reason"`
}

WSCloseRequest is what the cell passes to ws_close.

func DecodeWSCloseRequest

func DecodeWSCloseRequest(data []byte) (WSCloseRequest, error)

DecodeWSCloseRequest parses ws_close input.

type WSFrame

type WSFrame struct {
	ConnID  uint64 `msgpack:"conn_id"`
	OpCode  uint8  `msgpack:"opcode"`
	Payload []byte `msgpack:"payload"`
}

WSFrame is the ws.frame event — one per inbound frame.

type WSOpen

type WSOpen struct {
	ConnID  uint64            `msgpack:"conn_id"`
	Path    string            `msgpack:"path"`
	Query   map[string]string `msgpack:"query"`
	Headers map[string]string `msgpack:"headers"`
}

WSOpen is the ws.open event — one per accepted connection. ConnID is the host-assigned connection identifier cells pass back to ws_send and ws_close.

type WSSendRequest

type WSSendRequest struct {
	ConnID  uint64 `msgpack:"conn_id"`
	OpCode  uint8  `msgpack:"opcode"`
	Payload []byte `msgpack:"payload"`
}

WSSendRequest is what the cell passes to ws_send: which connection, what opcode, the payload bytes.

func DecodeWSSendRequest

func DecodeWSSendRequest(data []byte) (WSSendRequest, error)

DecodeWSSendRequest parses ws_send input.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL