jsonrpc

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jsonrpc propagates correlation through an explicit JSON-RPC metadata object. New composes Send/Receive over caller-owned Metadata; it never edits protocol envelopes or JSON-RPC request IDs. Callers decode envelopes, preserve duplicate metadata members, authenticate trust and synchronize maps. No transport, background work, retry or cancellation is introduced.

Deprecated: use github.com/faustbrian/go-correlation/adapters/jsonrpc. This package remains supported through the documented compatibility interval.

Index

Constants

View Source
const (
	// CorrelationField carries the logical workflow identifier.
	CorrelationField = correlation.DefaultCorrelationField
	// RequestField carries the current JSON-RPC hop identifier.
	RequestField = correlation.DefaultRequestField
	// CausationField carries the immediate parent identifier.
	CausationField = correlation.DefaultCausationField
)

Variables

View Source
var (
	// ErrInvalidOptions reports incomplete adapter configuration.
	ErrInvalidOptions = errors.New("jsonrpc correlation: invalid options")
	// ErrMalformedMetadata reports non-string or oversized JSON metadata.
	ErrMalformedMetadata = errors.New("jsonrpc correlation: malformed metadata")
)

Functions

This section is empty.

Types

type Adapter

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

Adapter explicitly sends and receives JSON-RPC metadata. Use New; configuration is immutable but concurrent sharing inherits Factory generator safety and requires independently synchronized metadata maps/bytes.

func New

func New(factory *correlation.Factory, options Options) (*Adapter, error)

New constructs a JSON-RPC metadata adapter, retaining the supplied Factory. Nil factory returns ErrInvalidOptions; invalid codec options preserve Codec's error. No metadata is read and no generator is called at construction.

func (*Adapter) Receive

func (adapter *Adapter) Receive(metadata Metadata, trusted bool) (correlation.Values, error)

Receive validates metadata and creates a fresh receiving request ID. Nil metadata means absent fields. Each selected field allows at most eight raw values, each at most 1026 encoded bytes including quotes/escapes/whitespace; whole maps and unrelated members are not bounded by this check. Invalid JSON or incompatible types return ErrMalformedMetadata; decoded empty text (including null) fails Codec. Trust enables only correlation and request-as-causation after all selected metadata is validated. No mutation or protocol-ID mapping occurs.

func (*Adapter) Send

func (adapter *Adapter) Send(metadata Metadata, parent correlation.Values) (correlation.Values, error)

Send creates and injects a child JSON-RPC metadata hop, replacing only selected absent keys with JSON strings. Nil metadata/adapter returns ErrInvalidOptions; other failures return zero Values and may already consume generator state. Metadata mutation follows Codec preflight, not a transport transaction.

type Metadata

type Metadata map[string][]json.RawMessage

Metadata preserves repeated JSON members supplied by a strict envelope decoder so conflicting duplicates cannot be silently collapsed. Assignment aliases the map and RawMessage byte slices. Keep them stable during receipt; Send replaces only selected keys. Whole-envelope allocation is caller-bounded.

type Options

type Options struct {
	// Codec selects root validation and distinct exact metadata names; empty
	// names select this package's default fields.
	Codec correlation.CodecOptions
}

Options configure JSON-RPC metadata validation and names.

Jump to

Keyboard shortcuts

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