Documentation
¶
Index ¶
- Constants
- func EncodeHTTPRequest(req HTTPRequest) ([]byte, error)
- func EncodeHTTPResponse(resp HTTPResponse) ([]byte, error)
- func EncodeStepEvent(kind string, payload []byte) ([]byte, error)
- func EncodeWSClose(e WSClose) ([]byte, error)
- func EncodeWSFrame(e WSFrame) ([]byte, error)
- func EncodeWSOpen(e WSOpen) ([]byte, error)
- type HTTPFetchRequest
- type HTTPRequest
- type HTTPResponse
- type SSEEmitRequest
- type StepEnvelope
- type StepEvent
- type WSClose
- type WSCloseRequest
- type WSFrame
- type WSOpen
- type WSSendRequest
Constants ¶
const ( EventHTTPRequest = "http.request" EventWSOpen = "ws.open" EventWSFrame = "ws.frame" EventWSClose = "ws.close" )
Event kinds delivered to the plugin as the step envelope payload.
const ( WSOpCodeText uint8 = 1 WSOpCodeBinary uint8 = 2 )
WebSocket frame opcodes delivered to and accepted from plugins.
const HeaderSize = 8 + 8 + 4
Variables ¶
This section is empty.
Functions ¶
func EncodeHTTPRequest ¶
func EncodeHTTPRequest(req HTTPRequest) ([]byte, error)
EncodeHTTPRequest marshals req to MessagePack for delivery to the plugin.
func EncodeHTTPResponse ¶
func EncodeHTTPResponse(resp HTTPResponse) ([]byte, error)
EncodeHTTPResponse marshals resp to MessagePack for delivery to the plugin as an outbound fetch result.
func EncodeStepEvent ¶
EncodeStepEvent wraps a pre-encoded payload with the kind discriminator and marshals the result for delivery via the step envelope.
func EncodeWSClose ¶
EncodeWSClose marshals a WSClose event for delivery via StepEvent.
func EncodeWSFrame ¶
EncodeWSFrame marshals a WSFrame event for delivery via StepEvent.
func EncodeWSOpen ¶
EncodeWSOpen marshals a WSOpen event for delivery via StepEvent.
Types ¶
type HTTPFetchRequest ¶
type HTTPFetchRequest struct {
Method string `msgpack:"method"`
URL string `msgpack:"url"`
Headers map[string]string `msgpack:"headers"`
Body []byte `msgpack:"body"`
}
HTTPFetchRequest is sent by the plugin to http_fetch to perform an outbound HTTP call. URL must be absolute; Method defaults to GET when blank. Headers and Body are optional.
func DecodeHTTPFetchRequest ¶
func DecodeHTTPFetchRequest(data []byte) (HTTPFetchRequest, error)
DecodeHTTPFetchRequest parses MessagePack bytes produced by the plugin.
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"`
}
HTTPRequest is delivered to the plugin 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"`
Body []byte `msgpack:"body"`
}
HTTPResponse is produced by the plugin and passed to http_respond, or returned to the plugin 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.
func DecodeHTTPResponse ¶
func DecodeHTTPResponse(data []byte) (HTTPResponse, error)
DecodeHTTPResponse parses MessagePack bytes produced by the plugin.
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 plugin 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 ¶
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, plugin-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 plugin should treat it as a tick and return.
func DecodeStepEvent ¶
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 plugin, 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 plugin 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 plugins 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 plugin passes to ws_send: which connection, what opcode, the payload bytes.
func DecodeWSSendRequest ¶
func DecodeWSSendRequest(data []byte) (WSSendRequest, error)
DecodeWSSendRequest parses ws_send input.