Documentation
¶
Overview ¶
package noop implements a noop QoS module, enabling a gateway operator to support services which do not yet have a QoS implementation.
Index ¶
- type HTTPResponse
- type NoOpQoS
- func (n *NoOpQoS) ApplyObservations(_ *qosobservations.Observations) error
- func (n *NoOpQoS) CheckWebsocketConnection() bool
- func (n *NoOpQoS) ConsumeExternalBlockHeight(ctx context.Context, heights <-chan int64, gracePeriod time.Duration)
- func (n *NoOpQoS) GetPerceivedBlockNumber() uint64
- func (n *NoOpQoS) GetRequiredQualityChecks(_ protocol.EndpointAddr) []gateway.RequestQoSContext
- func (n *NoOpQoS) HydrateDisqualifiedEndpointsResponse(_ protocol.ServiceID, _ *devtools.DisqualifiedEndpointResponse)
- func (n *NoOpQoS) ParseHTTPRequest(_ context.Context, httpRequest *http.Request, ...) (gateway.RequestQoSContext, bool)
- func (n *NoOpQoS) ParseWebsocketRequest(_ context.Context) (gateway.RequestQoSContext, bool)
- func (n *NoOpQoS) SetReputationService(svc reputation.ReputationService)
- func (n *NoOpQoS) SetSyncAllowance(syncAllowance uint64)
- func (n *NoOpQoS) StartBackgroundSync(ctx context.Context, syncInterval time.Duration)
- func (n *NoOpQoS) UpdateFromExtractedData(endpointAddr protocol.EndpointAddr, data *qostypes.ExtractedData) error
- type RandomEndpointSelector
- func (RandomEndpointSelector) Select(endpoints protocol.EndpointAddrList) (protocol.EndpointAddr, error)
- func (RandomEndpointSelector) SelectMultiple(endpoints protocol.EndpointAddrList, numEndpoints uint) (protocol.EndpointAddrList, error)
- func (RandomEndpointSelector) SelectMultipleWithArchival(endpoints protocol.EndpointAddrList, numEndpoints uint, _ bool) (protocol.EndpointAddrList, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPResponse ¶
type HTTPResponse struct {
// contains filtered or unexported fields
}
HTTPResponse stores the data required for building and returning a user-facing HTTP response based on the response received from an endpoint to a service request.
func (*HTTPResponse) GetHTTPHeaders ¶
func (h *HTTPResponse) GetHTTPHeaders() map[string]string
GetHTTPHeaders always returns nil, as HTTP headers are not used by noop QoS as of PR #106. See: https://github.com/pokt-network/path/pull/106 Implements the pathhttp.HTTPResponse interface.
func (*HTTPResponse) GetHTTPStatusCode ¶
func (h *HTTPResponse) GetHTTPStatusCode() int
GetHTTPStatusCode returns the HTTP status code of the user-facing HTTP response. Implements the pathhttp.HTTPResponse interface.
func (*HTTPResponse) GetPayload ¶
func (h *HTTPResponse) GetPayload() []byte
GetPayload returns the payload of the user-facing HTTP response. Implements the pathhttp.HTTPResponse interface.
type NoOpQoS ¶
type NoOpQoS struct {
// contains filtered or unexported fields
}
NoOpQoS provides a pass-through QoS service with optional block height tracking and endpoint filtering. When syncAllowance is 0 (the default), behavior is identical to a stateless random selector. When syncAllowance > 0 and block height data is available, stale endpoints are filtered out.
func NewNoOpQoSService ¶ added in v1.0.10
NewNoOpQoSService creates a new NoOp QoS service instance.
func (*NoOpQoS) ApplyObservations ¶
func (n *NoOpQoS) ApplyObservations(_ *qosobservations.Observations) error
ApplyObservations on noop QoS only fulfills the interface requirements and does not perform any actions. Implements the gateway.QoSService interface.
func (*NoOpQoS) CheckWebsocketConnection ¶
CheckWebsocketConnection returns true if the endpoint supports Websocket connections. NoOp QoS does not support Websocket connections.
func (*NoOpQoS) ConsumeExternalBlockHeight ¶ added in v1.0.15
func (n *NoOpQoS) ConsumeExternalBlockHeight(ctx context.Context, heights <-chan int64, gracePeriod time.Duration)
ConsumeExternalBlockHeight consumes block heights from an external fetcher channel and uses them as a floor for perceivedBlockHeight. This ensures that if all session endpoints are behind the real chain tip, the perceived block is corrected. The gracePeriod delays applying the external floor after startup, giving suppliers time to report their block heights. Use 0 for the default (60s).
func (*NoOpQoS) GetPerceivedBlockNumber ¶ added in v1.0.12
GetPerceivedBlockNumber returns the perceived current block number. Returns 0 if no block number has been observed yet. Implements gateway.QoSService interface.
func (*NoOpQoS) GetRequiredQualityChecks ¶
func (n *NoOpQoS) GetRequiredQualityChecks(_ protocol.EndpointAddr) []gateway.RequestQoSContext
GetRequiredQualityChecks on noop QoS only fulfills the interface requirements and does not perform any actions. Implements the gateway.QoSService interface.
func (*NoOpQoS) HydrateDisqualifiedEndpointsResponse ¶
func (n *NoOpQoS) HydrateDisqualifiedEndpointsResponse(_ protocol.ServiceID, _ *devtools.DisqualifiedEndpointResponse)
HydrateDisqualifiedEndpointsResponse is a no-op for the noop QoS.
func (*NoOpQoS) ParseHTTPRequest ¶
func (n *NoOpQoS) ParseHTTPRequest(_ context.Context, httpRequest *http.Request, detectedRPCType sharedtypes.RPCType) (gateway.RequestQoSContext, bool)
ParseHTTPRequest reads the supplied HTTP request's body and passes it on to a new requestContext instance. It intentionally avoids performing any validation on the request, as is the designed behavior of the noop QoS. Implements the gateway.QoSService interface. Fallback logic for NoOp: header → jsonrpc (NoOp passes through requests without validation)
func (*NoOpQoS) ParseWebsocketRequest ¶
ParseWebsocketRequest builds a request context from the provided Websocket request. This method implements the gateway.QoSService interface.
func (*NoOpQoS) SetReputationService ¶ added in v1.0.15
func (n *NoOpQoS) SetReputationService(svc reputation.ReputationService)
SetReputationService sets the reputation service for shared state across replicas. The reputation service provides perceived block height via Redis, enabling all replicas to converge on the same chain tip for sync_allowance validation.
func (*NoOpQoS) SetSyncAllowance ¶ added in v1.0.15
SetSyncAllowance dynamically updates the sync allowance for this QoS instance. This is called when external health check rules are loaded/refreshed, since those rules may specify a sync_allowance that wasn't available at QoS creation time.
func (*NoOpQoS) StartBackgroundSync ¶ added in v1.0.15
StartBackgroundSync starts a background goroutine that periodically syncs perceived block height from Redis. This ensures all replicas converge to the same max block height for sync_allowance validation.
The syncInterval determines how often to check Redis (e.g., 5 seconds). Call this after SetReputationService to enable cross-replica sync.
IMPORTANT: This performs an immediate sync on startup to ensure the replica has the latest perceived block height before serving requests.
func (*NoOpQoS) UpdateFromExtractedData ¶ added in v1.0.10
func (n *NoOpQoS) UpdateFromExtractedData(endpointAddr protocol.EndpointAddr, data *qostypes.ExtractedData) error
UpdateFromExtractedData stores the block height reported by an endpoint and updates the perceived block height to the maximum across all endpoints. Implements gateway.QoSService interface.
type RandomEndpointSelector ¶
type RandomEndpointSelector struct{}
RandomEndpointSelector returns a randomly selected endpoint from the set of available ones. It has no fields, since the endpoint selection is random.
func (RandomEndpointSelector) Select ¶
func (RandomEndpointSelector) Select(endpoints protocol.EndpointAddrList) (protocol.EndpointAddr, error)
Select returns a randomly selected endpoint from the set of supplied endpoints.
func (RandomEndpointSelector) SelectMultiple ¶
func (RandomEndpointSelector) SelectMultiple(endpoints protocol.EndpointAddrList, numEndpoints uint) (protocol.EndpointAddrList, error)
SelectMultiple returns multiple randomly selected endpoints from the set of supplied endpoints.
func (RandomEndpointSelector) SelectMultipleWithArchival ¶ added in v1.0.15
func (RandomEndpointSelector) SelectMultipleWithArchival(endpoints protocol.EndpointAddrList, numEndpoints uint, _ bool) (protocol.EndpointAddrList, error)
SelectMultipleWithArchival returns multiple randomly selected endpoints with optional archival filtering. NoOp QoS does not have an archival concept, so requiresArchival is ignored.