Help us shape the future of Go! Take the 2026 Go Developer Survey

jsonrpc

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jsonrpc defines the A2A v1.0 JSON-RPC wire constants and validation shared by the gateway-owned HTTP guards.

Index

Constants

View Source
const (
	Version       = "2.0"
	A2AVersion    = "1.0"
	HeaderVersion = "A2A-Version"
	// Method constants are local because the SDK's constants are internal. Keep
	// these literals identical to the A2A v1.0 SDK wire method strings.
	MethodSendMessage          = "SendMessage"
	MethodSendStreamingMessage = "SendStreamingMessage"
	MethodGetTask              = "GetTask"
	MethodListTasks            = "ListTasks"
	MethodCancelTask           = "CancelTask"
	MethodSubscribeToTask      = "SubscribeToTask"
)

Variables

This section is empty.

Functions

func AllowedMethod

func AllowedMethod(method string) bool

func CopyValidatedSSE

func CopyValidatedSSE(dst io.Writer, src io.Reader, maxEventBytes, maxStreamBytes int64, onEvent func([]byte) error) error

CopyValidatedSSE copies complete SSE records without changing their bytes, while bounding each event and the aggregate stream. onEvent validates every non-heartbeat data payload before that record is written.

func IsInvalidParams

func IsInvalidParams(err error) bool

func IsInvalidSSE

func IsInvalidSSE(err error) bool

IsInvalidSSE reports whether err represents invalid upstream SSE content.

func RemoveVersionQuery

func RemoveVersionQuery(rawQuery string) string

RemoveVersionQuery removes every case variant of A2A-Version while retaining the ordering of all other raw query fields.

func ValidateResponse

func ValidateResponse(body []byte, requestID json.RawMessage) error

func ValidateServiceVersion

func ValidateServiceVersion(header http.Header, query url.Values) error

ValidateServiceVersion accepts A2A 1.0 from the header or any case-insensitive query-key spelling, rejecting duplicates and conflicts.

func ValidateTenant

func ValidateTenant(req InspectedRequest, selected string) error

ValidateTenant requires the request tenant to exactly match the selected interface tenant, including presence versus omission.

Types

type InspectedRequest

type InspectedRequest struct {
	RequestMeta
	Notification       bool
	Tenant             string
	TenantPresent      bool
	EmbeddedPushConfig bool
}

InspectedRequest is the bounded, read-only view Path A needs before it forwards the original request bytes unchanged.

func InspectRequest

func InspectRequest(body []byte) (InspectedRequest, error)

InspectRequest validates one non-batch JSON-RPC request and extracts only the policy fields needed by the governed proxy. It deliberately does not return a typed A2A request: accepted bytes must not be re-marshaled.

type InvalidParamsError

type InvalidParamsError struct{ Err error }

InvalidParamsError identifies a request whose JSON-RPC envelope is usable but whose A2A params cannot be inspected safely. Callers can still use the returned request metadata to preserve the id, method-specific response channel, notification semantics, and validation order.

func (*InvalidParamsError) Error

func (e *InvalidParamsError) Error() string

func (*InvalidParamsError) Unwrap

func (e *InvalidParamsError) Unwrap() error

type InvalidSSEError

type InvalidSSEError struct{ Err error }

InvalidSSEError identifies an SSE framing, size, or payload validation failure separately from source reads and destination writes.

func (*InvalidSSEError) Error

func (e *InvalidSSEError) Error() string

func (*InvalidSSEError) Unwrap

func (e *InvalidSSEError) Unwrap() error

type RequestMeta

type RequestMeta struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	ID      json.RawMessage `json:"id"`
}

func ParseRequestMeta

func ParseRequestMeta(body []byte) (RequestMeta, error)

Jump to

Keyboard shortcuts

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