transport

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 13 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) Remove added in v0.25.1

func (r *RoundTrips) Remove(trip *RoundTrip) bool

Remove releases only the supplied trip. A response may already have matched it and its ID or slot may now belong to another request. Cleanup must never remove that replacement. It is safe to call Remove more than once or after CloseWithError; it does not complete the trip or change the response path.

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