event

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Ctx     context.Context
	Payload *Payload
	ResCh   chan Payload
	Rid     string
	Src     string
}

func PackageJSON

func PackageJSON(ctx context.Context, raw string, res chan Payload, src string) *Envelope

type OpsHandler

type OpsHandler interface {
	Route(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)
}

type OpsHandlerFunc

type OpsHandlerFunc func(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)

OpsHandlerFunc adapts a plain function to the OpsHandler interface, in the same shape as http.HandlerFunc. Built-in core ops (e.g. txco://noop) are registered as OpsHandlerFunc values.

func (OpsHandlerFunc) Route

func (f OpsHandlerFunc) Route(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)

Route satisfies OpsHandler.

type Payload

type Payload struct {
	Raw  string `json:"raw,omitempty"`
	Type Type   `json:"type,omitempty"`
	Meta string `json:"meta,omitempty"`
}

func CreateJSONPayload

func CreateJSONPayload(raw string) Payload

func ErrResponse

func ErrResponse(errMsg string, raw string, err error) (Payload, error)

func (Payload) String

func (payload Payload) String() string

type RawJSON

type RawJSON string

func NewJSON

func NewJSON(raw string) RawJSON

func (RawJSON) CreateJSONPayload

func (raw RawJSON) CreateJSONPayload() (Payload, error)

func (RawJSON) Set

func (raw RawJSON) Set(insertPoint string, val interface{}) RawJSON

func (RawJSON) String

func (raw RawJSON) String() string

type Type

type Type int

Event payloads may have different types

const (
	// Null is an empty message, an ACK
	Null Type = iota

	// JSON is a raw block of JSON
	JSON

	// Error
	ErrorStr

	// StreamHead carries the response status + headers snapshot for a
	// streamed HTTP response. Sent once, before any StreamChunk; the
	// outlet writes the head and switches into incremental-flush mode.
	StreamHead

	// StreamChunk carries a block of raw (already-decoded) response body
	// bytes in Raw, to be written and flushed immediately.
	StreamChunk

	// StreamEnd terminates a streamed response. No body; the outlet
	// returns once it receives this.
	StreamEnd
)

func (Type) String

func (t Type) String() string

String returns a string representation of the type.

Jump to

Keyboard shortcuts

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