transport

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 6 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Serve(ctx context.Context, request *jsonrpc.Request, response *jsonrpc.Response)
	OnNotification(ctx context.Context, notification *jsonrpc.Notification)
}

type Interceptor added in v0.3.0

type Interceptor interface {
	// Intercept is called after a response is received for a specific method (even if it's an error)
	// It receives the context, original request, and the response
	// If it returns a non-nil request, that request will be sent as a follow-up
	// If it returns nil, no additional request will be sent
	Intercept(ctx context.Context, request *jsonrpc.Request, response *jsonrpc.Response) (*jsonrpc.Request, error)
}

Interceptor defines an interface for intercepting JSON-RPC requests and responses for specific methods It allows for method-level post-processing of responses and optionally sending additional requests

type NewHandler

type NewHandler func(ctx context.Context, transport Transport) Handler

NewHandler is a function that creates a new Handler

type Notifier

type Notifier interface {
	Notify(ctx context.Context, notification *jsonrpc.Notification) error
}

Notifier represents a notification handler

type RoundTrip

type RoundTrip struct {
	Request  *jsonrpc.Request
	Response *jsonrpc.Response
	// contains filtered or unexported fields
}

RoundTrip represents a trip

func NewRoundTrip

func NewRoundTrip(request *jsonrpc.Request) *RoundTrip

NewRoundTrip creates a new round trip

func (*RoundTrip) SetError

func (t *RoundTrip) SetError(error *jsonrpc.Error)

SetError sets the error

func (*RoundTrip) SetResponse

func (t *RoundTrip) SetResponse(response *jsonrpc.Response)

SetResponse sets the response

func (*RoundTrip) Wait

func (t *RoundTrip) Wait(ctx context.Context, timeout time.Duration) error

Wait waits for the trip to finish

type RoundTrips

type RoundTrips struct {
	Ring []*RoundTrip
	// contains filtered or unexported fields
}

RoundTrips represents a collection of trips

func NewRoundTrips

func NewRoundTrips(capacity int) *RoundTrips

NewRoundTrips creates a new round trips

func (*RoundTrips) Add

func (r *RoundTrips) Add(request *jsonrpc.Request) (*RoundTrip, error)

Add adds a new trip

func (*RoundTrips) CloseWithError

func (r *RoundTrips) CloseWithError(err error)

CloseWithError closes trips with error

func (*RoundTrips) Get

func (r *RoundTrips) Get(index int) *RoundTrip

Get returns the trip at the given index

func (*RoundTrips) Match

func (r *RoundTrips) Match(id any) (*RoundTrip, error)

Match matches a trip by id

func (*RoundTrips) Size

func (r *RoundTrips) Size() int

Size returns the size of the trips

type Sequencer added in v0.7.1

type Sequencer interface {
	NextRequestID() jsonrpc.RequestId

	// LastRequestID returns the most recently generated request id without
	// mutating the underlying sequence counter.
	LastRequestID() jsonrpc.RequestId
}

type Transport

type Transport interface {
	Notifier
	Send(ctx context.Context, request *jsonrpc.Request) (*jsonrpc.Response, error)
}

Directories

Path Synopsis
client
server

Jump to

Keyboard shortcuts

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