qos

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestErrorForJSONRPCBackendServiceUnmarshalError

func GetRequestErrorForJSONRPCBackendServiceUnmarshalError() *qosobservations.RequestError

GetRequestErrorForJSONRPCBackendServiceUnmarshalError returns a request error for a JSONRPC backend service unmarshaling error. i.e. the payload returned by the endpoint/backend service failed to parse as a valid JSONRPC response.

func GetRequestErrorForProtocolError

func GetRequestErrorForProtocolError() *qosobservations.RequestError

GetRequestErrorForProtocolError returns a request error for a protocol error E.g. the selected endpoint did not return a response.

Types

type HTTPResponse

type HTTPResponse struct {
	// ResponsePayload contains the serialized response body.
	ResponsePayload []byte

	// HTTPStatusCode is the HTTP status code to be returned.
	// If not explicitly set, defaults to http.StatusOK (200).
	HTTPStatusCode int
}

HTTPResponse encapsulates an HTTP response to be returned to the client including payload data and status code.

func BuildHTTPResponseFromBytes

func BuildHTTPResponseFromBytes(
	responsePayload []byte,
	httpStatusCode int,
) HTTPResponse

func BuildHTTPResponseFromJSONRPCResponse

func BuildHTTPResponseFromJSONRPCResponse(
	logger polylog.Logger,
	jsonrpcResp jsonrpc.Response,
) HTTPResponse

func (HTTPResponse) GetHTTPHeaders

func (r HTTPResponse) GetHTTPHeaders() map[string]string

GetHTTPHeaders returns the set of headers for the HTTP response. As of PR #72, the only header returned for JSONRPC is `Content-Type`.

func (HTTPResponse) GetHTTPStatusCode

func (hr HTTPResponse) GetHTTPStatusCode() int

GetHTTPStatusCode returns the HTTP status code for this response. If no status code was explicitly set, returns http.StatusOK (200). StatusOK is returned by default from QoS because it is the responsibility of the QoS service to decide on the HTTP status code returned to the client.

func (HTTPResponse) GetPayload

func (hr HTTPResponse) GetPayload() []byte

GetPayload returns the response payload as a byte slice.

type Observations

type Observations struct{}

Observations is a stub type for QoS observations. It may be extended with actual fields and logic as needed.

type RequestErrorContext

type RequestErrorContext struct {
	Logger polylog.Logger

	// The response to be returned to the user.
	Response jsonrpc.Response

	// The observations to use for the error.
	Observations *qosobservations.Observations
}

RequestErrorContext terminates the processing of a JSONRPC-service request on errors (internal failures or invalid requests). Provides:

  1. Detailed error response to the user.
  2. Log entries to warn on potential incorrect usage.

Implements gateway.RequestQoSContext

func RequestContextFromInternalError

func RequestContextFromInternalError(logger polylog.Logger, jsonrpcRequestID jsonrpc.ID, err error) *RequestErrorContext

RequestContextFromInternalError returns a request context for an internal error. E.g. the selected endpoint did not return a response.

func (*RequestErrorContext) GetEndpointSelector

func (rec *RequestErrorContext) GetEndpointSelector() protocol.EndpointSelector

UpdateWithResponse should never be called. It logs a warning and returns a failing selector that logs a warning on all selection attempts. Implements the gateway.RequestQoSContext interface.

func (*RequestErrorContext) GetHTTPResponse

func (rec *RequestErrorContext) GetHTTPResponse() pathhttp.HTTPResponse

GetHTTPResponse formats the stored JSONRPC error as an HTTP response Implements the gateway.RequestQoSContext interface.

func (*RequestErrorContext) GetObservations

func (rec *RequestErrorContext) GetObservations() qosobservations.Observations

TODO_MVP(@adshmh): Generate observations for the error context. GetObservation returns the QoS observation set for the error context. Implements the gateway.RequestQoSContext interface.

func (*RequestErrorContext) GetServicePayloads

func (rec *RequestErrorContext) GetServicePayloads() []protocol.Payload

GetServicePayload should never be called. It logs a warning and returns nil. Implements the gateway.RequestQoSContext interface.

func (*RequestErrorContext) UpdateWithResponse

func (rec *RequestErrorContext) UpdateWithResponse(endpointAddr protocol.EndpointAddr, endpointSerializedResponse []byte, httpStatusCode int)

UpdateWithResponse should never be called. Only logs a warning. Implements the gateway.RequestQoSContext interface.

Directories

Path Synopsis
package noop implements a noop QoS module, enabling a gateway operator to support services which do not yet have a QoS implementation.
package noop implements a noop QoS module, enabling a gateway operator to support services which do not yet have a QoS implementation.
solana package provides the support required for interacting with the Solana blockchain through the gateway.
solana package provides the support required for interacting with the Solana blockchain through the gateway.

Jump to

Keyboard shortcuts

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