workerproto

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package workerproto defines the bounded wire format shared by the browser broker and isolated runtime workers.

Index

Constants

View Source
const (
	Version         = 1
	MaxMessageBytes = 1 << 20
)

Variables

This section is empty.

Functions

func DecodePayload

func DecodePayload(payload json.RawMessage, target any) error

func MarshalPayload

func MarshalPayload(value any) (json.RawMessage, error)

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec reads and writes big-endian length-prefixed JSON messages.

func NewCodec

func NewCodec(reader io.Reader, writer io.Writer) *Codec

func (*Codec) Read

func (codec *Codec) Read() (Envelope, error)

func (*Codec) Write

func (codec *Codec) Write(message Envelope) error

type Envelope

type Envelope struct {
	Version int             `json:"version"`
	Kind    Kind            `json:"kind"`
	ID      uint64          `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Payload json.RawMessage `json:"payload,omitempty"`
	Error   string          `json:"error,omitempty"`
}

Envelope is one versioned request, response, or one-way event.

type Kind

type Kind string
const (
	KindRequest  Kind = "request"
	KindResponse Kind = "response"
	KindEvent    Kind = "event"
)

Jump to

Keyboard shortcuts

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