Documentation
¶
Index ¶
- Constants
- func IsRetryable(response ResponseHolder) bool
- func IsStream(method string) bool
- func ResponseCanBeStreamed(reader *bufio.Reader, chunkSize int) bool
- func ResultAsNumber(result []byte) uint64
- func ResultAsString(result []byte) string
- func ToHttpCode(response ResponseHolder) int
- type AbstractUpstreamStateEvent
- type ApiConnectorType
- type AvailabilityStatus
- type BanMethodUpstreamStateEvent
- type BaseUpstreamResponse
- func NewHttpUpstreamResponse(id string, body []byte, responseCode int, requestType RequestType) *BaseUpstreamResponse
- func NewHttpUpstreamResponseStream(id string, reader io.Reader, requestType RequestType) *BaseUpstreamResponse
- func NewHttpUpstreamResponseWithError(error *ResponseError) *BaseUpstreamResponse
- func NewSimpleHttpUpstreamResponse(id string, body []byte, requestType RequestType) *BaseUpstreamResponse
- func (h *BaseUpstreamResponse) EncodeResponse(realId []byte) io.Reader
- func (h *BaseUpstreamResponse) GetError() *ResponseError
- func (h *BaseUpstreamResponse) HasError() bool
- func (h *BaseUpstreamResponse) HasStream() bool
- func (h *BaseUpstreamResponse) Id() string
- func (h *BaseUpstreamResponse) ResponseCode() int
- func (h *BaseUpstreamResponse) ResponseHeaders() http.Header
- func (h *BaseUpstreamResponse) ResponseResult() []byte
- func (h *BaseUpstreamResponse) ResponseResultString() (string, error)
- func (h *BaseUpstreamResponse) WithResponseHeaders(headers http.Header) *BaseUpstreamResponse
- type Block
- type BlockInfo
- type BlockType
- type BlockUpstreamStateEvent
- type Cap
- type ClientRetryableError
- type CloseReader
- type FatalErrorUpstreamStateEvent
- type HasResponseHeaders
- type HeadUpstreamEvent
- type HeadUpstreamStateEvent
- type HttpMethod
- type JsonRpcRequestBody
- type JsonRpcWsUpstreamResponse
- type Labels
- type LabelsUpstreamStateEvent
- type LowerBoundData
- type LowerBoundInfo
- type LowerBoundType
- type LowerBoundUpstreamStateEvent
- type RemoveUpstreamEvent
- type ReplyError
- func NewPartialFailure(request RequestHolder, responseError *ResponseError) *ReplyError
- func NewReplyError(id string, responseError *ResponseError, responseType RequestType, ...) *ReplyError
- func NewTotalFailure(request RequestHolder, responseError *ResponseError) *ReplyError
- func NewTotalFailureFromErr(id string, err error, responseType RequestType) *ReplyError
- func (r *ReplyError) EncodeResponse(realId []byte) io.Reader
- func (r *ReplyError) GetError() *ResponseError
- func (r *ReplyError) HasError() bool
- func (r *ReplyError) HasStream() bool
- func (r *ReplyError) Id() string
- func (r *ReplyError) ResponseCode() int
- func (r *ReplyError) ResponseResult() []byte
- func (r *ReplyError) ResponseResultString() (string, error)
- type RequestHolder
- type RequestKind
- type RequestObserver
- func (b *RequestObserver) AddResult(result RequestResult, final bool)
- func (b *RequestObserver) GetChain() chains.Chain
- func (b *RequestObserver) GetRequestKind() RequestKind
- func (b *RequestObserver) GetResults() []RequestResult
- func (b *RequestObserver) TrackUpstreamCall() func()
- func (b *RequestObserver) WithApiKey(apiKey string) *RequestObserver
- func (b *RequestObserver) WithChain(chain chains.Chain) *RequestObserver
- func (b *RequestObserver) WithMethod(method string) *RequestObserver
- func (b *RequestObserver) WithRequestKind(kind RequestKind) *RequestObserver
- type RequestResult
- type RequestType
- type ResponseError
- func AuthError(cause error) *ResponseError
- func ClientError(cause error) *ResponseError
- func CtxError(cause error) *ResponseError
- func IncorrectResponseBodyError(cause error) *ResponseError
- func NoAvailableUpstreamsError() *ResponseError
- func NotSupportedMethodError(method string) *ResponseError
- func ParseError() *ResponseError
- func QuorumInsufficientSignaturesError(got, required int) *ResponseError
- func QuorumInvalidSignatureError(providerID string) *ResponseError
- func QuorumMalformedHeaderError(cause error) *ResponseError
- func QuorumMissingSignaturesError() *ResponseError
- func QuorumNotSupportedError(reason string) *ResponseError
- func QuorumUnexpectedRequestIDError(expected, got string) *ResponseError
- func QuorumUnknownProviderError(providerID string) *ResponseError
- func QuorumVerificationError(cause error) *ResponseError
- func RateLimitError() *ResponseError
- func RequestTimeoutError() *ResponseError
- func ResponseErrorWithData(code int, message string, data interface{}) *ResponseError
- func ResponseErrorWithMessage(message string) *ResponseError
- func ServerError() *ResponseError
- func ServerErrorWithCause(cause error) *ResponseError
- func WrongChainError(chain string) *ResponseError
- func WsTotalFailureError() *ResponseError
- type ResponseErrorKind
- type ResponseHolder
- type ResponseHolderWrapper
- type ResponseKind
- type ResponseReceivedHook
- type ResultType
- type StateUpstreamEvent
- type StatusUpstreamStateEvent
- type StopRetryErr
- type SubscribeConnectorState
- type SubscribeUpstreamStateEvent
- type SubscriptionEventResponse
- func (s *SubscriptionEventResponse) EncodeResponse(realId []byte) io.Reader
- func (s *SubscriptionEventResponse) GetError() *ResponseError
- func (s *SubscriptionEventResponse) HasError() bool
- func (s *SubscriptionEventResponse) HasStream() bool
- func (s *SubscriptionEventResponse) Id() string
- func (s *SubscriptionEventResponse) IsEventFrame() bool
- func (s *SubscriptionEventResponse) ResponseCode() int
- func (s *SubscriptionEventResponse) ResponseResult() []byte
- func (s *SubscriptionEventResponse) ResponseResultString() (string, error)
- type SubscriptionMessageResponse
- func (s *SubscriptionMessageResponse) EncodeResponse(realId []byte) io.Reader
- func (s *SubscriptionMessageResponse) GetError() *ResponseError
- func (s *SubscriptionMessageResponse) HasError() bool
- func (s *SubscriptionMessageResponse) HasStream() bool
- func (s *SubscriptionMessageResponse) Id() string
- func (s *SubscriptionMessageResponse) IsEventFrame() bool
- func (s *SubscriptionMessageResponse) ResponseCode() int
- func (s *SubscriptionMessageResponse) ResponseResult() []byte
- func (s *SubscriptionMessageResponse) ResponseResultString() (string, error)
- type SubscriptionMethodResultResponse
- func (s *SubscriptionMethodResultResponse) EncodeResponse(_ []byte) io.Reader
- func (s *SubscriptionMethodResultResponse) GetError() *ResponseError
- func (s *SubscriptionMethodResultResponse) HasError() bool
- func (s *SubscriptionMethodResultResponse) HasStream() bool
- func (s *SubscriptionMethodResultResponse) Id() string
- func (s *SubscriptionMethodResultResponse) IsEventFrame() bool
- func (s *SubscriptionMethodResultResponse) ResponseCode() int
- func (s *SubscriptionMethodResultResponse) ResponseResult() []byte
- func (s *SubscriptionMethodResultResponse) ResponseResultString() (string, error)
- type SubscriptionResponseHolder
- type SubscriptionResultResponse
- func (s *SubscriptionResultResponse) EncodeResponse(realId []byte) io.Reader
- func (s *SubscriptionResultResponse) GetError() *ResponseError
- func (s *SubscriptionResultResponse) HasError() bool
- func (s *SubscriptionResultResponse) HasStream() bool
- func (s *SubscriptionResultResponse) Id() string
- func (s *SubscriptionResultResponse) IsEventFrame() bool
- func (s *SubscriptionResultResponse) ResponseCode() int
- func (s *SubscriptionResultResponse) ResponseResult() []byte
- func (s *SubscriptionResultResponse) ResponseResultString() (string, error)
- type UnaryRequestResult
- func (u *UnaryRequestResult) GetApiKey() string
- func (u *UnaryRequestResult) GetChain() chains.Chain
- func (u *UnaryRequestResult) GetDuration() float64
- func (u *UnaryRequestResult) GetMethod() string
- func (u *UnaryRequestResult) GetReqKind() RequestKind
- func (u *UnaryRequestResult) GetRespKind() ResponseKind
- func (u *UnaryRequestResult) GetTimestamp() time.Time
- func (u *UnaryRequestResult) GetUpstreamId() string
- func (u *UnaryRequestResult) IsSuccessfulRetry() bool
- func (u *UnaryRequestResult) WithDuration(duration float64) *UnaryRequestResult
- func (u *UnaryRequestResult) WithRespKindFromResponse(response ResponseHolder) *UnaryRequestResult
- func (u *UnaryRequestResult) WithSuccessfulRetry() *UnaryRequestResult
- func (u *UnaryRequestResult) WithUpstreamId(upstreamId string) *UnaryRequestResult
- type UnbanMethodUpstreamStateEvent
- type UpstreamEvent
- type UpstreamEventType
- type UpstreamJsonRpcRequest
- func NewInternalSubUpstreamJsonRpcRequest(method string, params any, chain chains.Chain) (*UpstreamJsonRpcRequest, error)
- func NewInternalUpstreamJsonRpcRequest(method string, params any, chain chains.Chain) (*UpstreamJsonRpcRequest, error)
- func NewStreamUpstreamJsonRpcRequest(id string, realId json.RawMessage, method string, params json.RawMessage, ...) *UpstreamJsonRpcRequest
- func NewUpstreamJsonRpcRequest(id string, realId json.RawMessage, method string, params json.RawMessage, ...) *UpstreamJsonRpcRequest
- func NewUpstreamJsonRpcRequestWithSpecMethod(method string, params any, specMethod *specs.Method) (*UpstreamJsonRpcRequest, error)
- func (u *UpstreamJsonRpcRequest) Body() ([]byte, error)
- func (u *UpstreamJsonRpcRequest) Headers() map[string]string
- func (u *UpstreamJsonRpcRequest) Id() string
- func (u *UpstreamJsonRpcRequest) IsStream() bool
- func (u *UpstreamJsonRpcRequest) IsSubscribe() bool
- func (u *UpstreamJsonRpcRequest) Method() string
- func (u *UpstreamJsonRpcRequest) ModifyParams(ctx context.Context, newValue any)
- func (u *UpstreamJsonRpcRequest) ParseParams(ctx context.Context) specs.MethodParam
- func (u *UpstreamJsonRpcRequest) RealId() string
- func (u *UpstreamJsonRpcRequest) RequestHash() string
- func (u *UpstreamJsonRpcRequest) RequestObserver() *RequestObserver
- func (u *UpstreamJsonRpcRequest) RequestType() RequestType
- func (u *UpstreamJsonRpcRequest) SpecMethod() *specs.Method
- type UpstreamRestRequest
- func NewInternalUpstreamRestRequest(httpMethod, path string, chain chains.Chain) *UpstreamRestRequest
- func NewInternalUpstreamRestRequestWithQuery(httpMethod, path string, query map[string]string, chain chains.Chain) *UpstreamRestRequest
- func NewUpstreamRestRequest(httpMethod, path string, body []byte) *UpstreamRestRequest
- func (u *UpstreamRestRequest) Body() ([]byte, error)
- func (u *UpstreamRestRequest) Headers() map[string]string
- func (u *UpstreamRestRequest) Id() string
- func (u *UpstreamRestRequest) IsStream() bool
- func (u *UpstreamRestRequest) IsSubscribe() bool
- func (u *UpstreamRestRequest) Method() string
- func (u *UpstreamRestRequest) ModifyParams(_ context.Context, _ any)
- func (u *UpstreamRestRequest) ParseParams(_ context.Context) specs.MethodParam
- func (u *UpstreamRestRequest) RequestHash() string
- func (u *UpstreamRestRequest) RequestObserver() *RequestObserver
- func (u *UpstreamRestRequest) RequestType() RequestType
- func (u *UpstreamRestRequest) SpecMethod() *specs.Method
- type UpstreamState
- type UpstreamSubscriptionResponse
- type ValidUpstreamEvent
- type ValidUpstreamStateEvent
- type WsJsonRpcResponse
- func (w *WsJsonRpcResponse) EncodeResponse(realId []byte) io.Reader
- func (w *WsJsonRpcResponse) GetError() *ResponseError
- func (w *WsJsonRpcResponse) HasError() bool
- func (w *WsJsonRpcResponse) HasStream() bool
- func (w *WsJsonRpcResponse) Id() string
- func (w *WsJsonRpcResponse) ResponseCode() int
- func (w *WsJsonRpcResponse) ResponseResult() []byte
- func (w *WsJsonRpcResponse) ResponseResultString() (string, error)
- type WsResponse
- type ZeroBlock
Constants ¶
const ( BaseError int = iota NoAvailableUpstreams WrongChain CtxErrorCode WsTotalFailure ClientErrorCode = 400 AuthErrorCode = 403 RequestTimeout = 408 InternalServerErrorCode = 500 RateLimitExceeded = 429 NoSupportedMethod = -32601 IncorrectResponseBody = -32001 QuorumSignatureErrCode = -32010 )
const MaxChunkSize = 8192
const MethodSeparator = "#"
Variables ¶
This section is empty.
Functions ¶
func IsRetryable ¶
func IsRetryable(response ResponseHolder) bool
func ResultAsNumber ¶
func ResultAsString ¶
func ToHttpCode ¶
func ToHttpCode(response ResponseHolder) int
Types ¶
type AbstractUpstreamStateEvent ¶
type AbstractUpstreamStateEvent interface {
ProcessEvent(state UpstreamState) UpstreamState
Same(state UpstreamState) bool
}
type ApiConnectorType ¶
type ApiConnectorType int
const ( JsonRpcConnector ApiConnectorType = iota RestConnector GrpcConnector WsConnector )
func (ApiConnectorType) String ¶
func (a ApiConnectorType) String() string
type AvailabilityStatus ¶
type AvailabilityStatus int
const ( Available AvailabilityStatus = iota + 1 Immature Syncing UnknownStatus = math.MaxInt )
func (AvailabilityStatus) String ¶
func (a AvailabilityStatus) String() string
type BanMethodUpstreamStateEvent ¶
type BanMethodUpstreamStateEvent struct {
Method string
}
func (*BanMethodUpstreamStateEvent) ProcessEvent ¶
func (b *BanMethodUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*BanMethodUpstreamStateEvent) Same ¶
func (b *BanMethodUpstreamStateEvent) Same(_ UpstreamState) bool
type BaseUpstreamResponse ¶
type BaseUpstreamResponse struct {
// contains filtered or unexported fields
}
func NewHttpUpstreamResponse ¶
func NewHttpUpstreamResponse(id string, body []byte, responseCode int, requestType RequestType) *BaseUpstreamResponse
func NewHttpUpstreamResponseStream ¶
func NewHttpUpstreamResponseStream(id string, reader io.Reader, requestType RequestType) *BaseUpstreamResponse
func NewHttpUpstreamResponseWithError ¶
func NewHttpUpstreamResponseWithError(error *ResponseError) *BaseUpstreamResponse
func NewSimpleHttpUpstreamResponse ¶
func NewSimpleHttpUpstreamResponse(id string, body []byte, requestType RequestType) *BaseUpstreamResponse
func (*BaseUpstreamResponse) EncodeResponse ¶
func (h *BaseUpstreamResponse) EncodeResponse(realId []byte) io.Reader
func (*BaseUpstreamResponse) GetError ¶
func (h *BaseUpstreamResponse) GetError() *ResponseError
func (*BaseUpstreamResponse) HasError ¶
func (h *BaseUpstreamResponse) HasError() bool
func (*BaseUpstreamResponse) HasStream ¶
func (h *BaseUpstreamResponse) HasStream() bool
func (*BaseUpstreamResponse) Id ¶
func (h *BaseUpstreamResponse) Id() string
func (*BaseUpstreamResponse) ResponseCode ¶
func (h *BaseUpstreamResponse) ResponseCode() int
func (*BaseUpstreamResponse) ResponseHeaders ¶
func (h *BaseUpstreamResponse) ResponseHeaders() http.Header
func (*BaseUpstreamResponse) ResponseResult ¶
func (h *BaseUpstreamResponse) ResponseResult() []byte
func (*BaseUpstreamResponse) ResponseResultString ¶
func (h *BaseUpstreamResponse) ResponseResultString() (string, error)
func (*BaseUpstreamResponse) WithResponseHeaders ¶
func (h *BaseUpstreamResponse) WithResponseHeaders(headers http.Header) *BaseUpstreamResponse
type Block ¶
type Block struct {
Height uint64
Slot uint64
Hash blockchain.HashId
ParentHash blockchain.HashId
}
func NewBlockWithHeight ¶
func NewBlockWithHeights ¶
func (Block) CompareWithHeight ¶
func (Block) IsEmptyByHeight ¶
func (Block) IsFullEmpty ¶
type BlockInfo ¶
type BlockInfo struct {
// contains filtered or unexported fields
}
func NewBlockInfo ¶
func NewBlockInfo() *BlockInfo
type BlockUpstreamStateEvent ¶
func (*BlockUpstreamStateEvent) ProcessEvent ¶
func (b *BlockUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*BlockUpstreamStateEvent) Same ¶
func (b *BlockUpstreamStateEvent) Same(state UpstreamState) bool
type ClientRetryableError ¶
type ClientRetryableError struct {
// contains filtered or unexported fields
}
func NewClientRetryableError ¶
func NewClientRetryableError(err error) *ClientRetryableError
func (ClientRetryableError) Error ¶
func (e ClientRetryableError) Error() string
type CloseReader ¶
type CloseReader struct {
// contains filtered or unexported fields
}
func NewCloseReader ¶
func NewCloseReader(ctx context.Context, mainReader io.Reader, readerToClose io.ReadCloser) *CloseReader
type FatalErrorUpstreamStateEvent ¶
type FatalErrorUpstreamStateEvent struct{}
func (*FatalErrorUpstreamStateEvent) ProcessEvent ¶
func (f *FatalErrorUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*FatalErrorUpstreamStateEvent) Same ¶
func (f *FatalErrorUpstreamStateEvent) Same(_ UpstreamState) bool
type HasResponseHeaders ¶
HasResponseHeaders is an optional capability for response holders that carry upstream HTTP response headers (e.g. QR<N>-id-* quorum signatures). Kept separate from ResponseHolder to avoid forcing every implementation.
type HeadUpstreamEvent ¶
type HeadUpstreamEvent struct {
Status AvailabilityStatus
Head Block
}
type HeadUpstreamStateEvent ¶
type HeadUpstreamStateEvent struct {
HeadData Block
}
func (*HeadUpstreamStateEvent) ProcessEvent ¶
func (h *HeadUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*HeadUpstreamStateEvent) Same ¶
func (h *HeadUpstreamStateEvent) Same(_ UpstreamState) bool
type HttpMethod ¶
type HttpMethod int
const ( Get HttpMethod = iota Post )
func (HttpMethod) String ¶
func (h HttpMethod) String() string
type JsonRpcRequestBody ¶
type JsonRpcRequestBody struct {
Id json.RawMessage `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}
type JsonRpcWsUpstreamResponse ¶
type JsonRpcWsUpstreamResponse struct {
// contains filtered or unexported fields
}
func NewJsonRpcWsUpstreamResponse ¶
func NewJsonRpcWsUpstreamResponse(messages chan *WsResponse, subOpId string) *JsonRpcWsUpstreamResponse
func (*JsonRpcWsUpstreamResponse) OpId ¶
func (j *JsonRpcWsUpstreamResponse) OpId() string
func (*JsonRpcWsUpstreamResponse) ResponseChan ¶
func (j *JsonRpcWsUpstreamResponse) ResponseChan() chan *WsResponse
type Labels ¶
type Labels struct {
// contains filtered or unexported fields
}
func (*Labels) GetAllLabels ¶
type LabelsUpstreamStateEvent ¶
func (*LabelsUpstreamStateEvent) ProcessEvent ¶
func (l *LabelsUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*LabelsUpstreamStateEvent) Same ¶
func (l *LabelsUpstreamStateEvent) Same(state UpstreamState) bool
type LowerBoundData ¶
type LowerBoundData struct {
Bound int64
Timestamp int64
Type LowerBoundType
}
func NewLowerBoundData ¶
func NewLowerBoundData(bound, timestamp int64, boundType LowerBoundType) LowerBoundData
func NewLowerBoundDataNow ¶
func NewLowerBoundDataNow(bound int64, boundType LowerBoundType) LowerBoundData
type LowerBoundInfo ¶
type LowerBoundInfo struct {
// contains filtered or unexported fields
}
func NewLowerBoundInfo ¶
func NewLowerBoundInfo() *LowerBoundInfo
func (*LowerBoundInfo) AddLowerBound ¶
func (l *LowerBoundInfo) AddLowerBound(data LowerBoundData)
func (*LowerBoundInfo) Copy ¶
func (l *LowerBoundInfo) Copy() *LowerBoundInfo
func (*LowerBoundInfo) GetAllBounds ¶
func (l *LowerBoundInfo) GetAllBounds() []LowerBoundData
func (*LowerBoundInfo) GetLowerBound ¶
func (l *LowerBoundInfo) GetLowerBound(boundType LowerBoundType) (LowerBoundData, bool)
type LowerBoundType ¶
type LowerBoundType int
const ( UnknownBound LowerBoundType = iota + 1 SlotBound StateBound ReceiptsBound TxBound BlockBound )
func (LowerBoundType) String ¶
func (t LowerBoundType) String() string
type LowerBoundUpstreamStateEvent ¶
type LowerBoundUpstreamStateEvent struct {
Data LowerBoundData
}
func (*LowerBoundUpstreamStateEvent) ProcessEvent ¶
func (l *LowerBoundUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*LowerBoundUpstreamStateEvent) Same ¶
func (l *LowerBoundUpstreamStateEvent) Same(state UpstreamState) bool
type RemoveUpstreamEvent ¶
type RemoveUpstreamEvent struct{}
type ReplyError ¶
type ReplyError struct {
ErrorKind ResponseErrorKind
// contains filtered or unexported fields
}
func NewPartialFailure ¶
func NewPartialFailure(request RequestHolder, responseError *ResponseError) *ReplyError
func NewReplyError ¶
func NewReplyError(id string, responseError *ResponseError, responseType RequestType, errorKind ResponseErrorKind) *ReplyError
func NewTotalFailure ¶
func NewTotalFailure(request RequestHolder, responseError *ResponseError) *ReplyError
func NewTotalFailureFromErr ¶
func NewTotalFailureFromErr(id string, err error, responseType RequestType) *ReplyError
func (*ReplyError) EncodeResponse ¶
func (r *ReplyError) EncodeResponse(realId []byte) io.Reader
func (*ReplyError) GetError ¶
func (r *ReplyError) GetError() *ResponseError
func (*ReplyError) HasError ¶
func (r *ReplyError) HasError() bool
func (*ReplyError) HasStream ¶
func (r *ReplyError) HasStream() bool
func (*ReplyError) Id ¶
func (r *ReplyError) Id() string
func (*ReplyError) ResponseCode ¶
func (r *ReplyError) ResponseCode() int
func (*ReplyError) ResponseResult ¶
func (r *ReplyError) ResponseResult() []byte
func (*ReplyError) ResponseResultString ¶
func (r *ReplyError) ResponseResultString() (string, error)
type RequestHolder ¶
type RequestHolder interface {
Id() string
Method() string
Headers() map[string]string
Body() ([]byte, error)
ParseParams(ctx context.Context) specs.MethodParam
RequestType() RequestType
RequestHash() string
SpecMethod() *specs.Method
RequestObserver() *RequestObserver
ModifyParams(ctx context.Context, newValue any)
IsStream() bool
IsSubscribe() bool
}
type RequestKind ¶
type RequestKind int
const ( UnknownReqKind RequestKind = iota InternalUnary InternalSubscription Local Cached Unary Subscription )
func (RequestKind) String ¶
func (r RequestKind) String() string
type RequestObserver ¶
type RequestObserver struct {
// contains filtered or unexported fields
}
func NewRequestObserver ¶
func NewRequestObserver(isSub bool) *RequestObserver
func (*RequestObserver) AddResult ¶
func (b *RequestObserver) AddResult(result RequestResult, final bool)
func (*RequestObserver) GetChain ¶
func (b *RequestObserver) GetChain() chains.Chain
func (*RequestObserver) GetRequestKind ¶
func (b *RequestObserver) GetRequestKind() RequestKind
func (*RequestObserver) GetResults ¶
func (b *RequestObserver) GetResults() []RequestResult
func (*RequestObserver) TrackUpstreamCall ¶
func (b *RequestObserver) TrackUpstreamCall() func()
func (*RequestObserver) WithApiKey ¶
func (b *RequestObserver) WithApiKey(apiKey string) *RequestObserver
func (*RequestObserver) WithChain ¶
func (b *RequestObserver) WithChain(chain chains.Chain) *RequestObserver
func (*RequestObserver) WithMethod ¶
func (b *RequestObserver) WithMethod(method string) *RequestObserver
func (*RequestObserver) WithRequestKind ¶
func (b *RequestObserver) WithRequestKind(kind RequestKind) *RequestObserver
type RequestResult ¶
type RequestResult interface {
// contains filtered or unexported methods
}
type RequestType ¶
type RequestType int
const ( Rest RequestType = iota JsonRpc Ws Grpc Unknown )
func (RequestType) String ¶
func (r RequestType) String() string
type ResponseError ¶
func AuthError ¶
func AuthError(cause error) *ResponseError
func ClientError ¶
func ClientError(cause error) *ResponseError
func CtxError ¶
func CtxError(cause error) *ResponseError
func IncorrectResponseBodyError ¶
func IncorrectResponseBodyError(cause error) *ResponseError
func NoAvailableUpstreamsError ¶
func NoAvailableUpstreamsError() *ResponseError
func NotSupportedMethodError ¶
func NotSupportedMethodError(method string) *ResponseError
func ParseError ¶
func ParseError() *ResponseError
func QuorumInsufficientSignaturesError ¶
func QuorumInsufficientSignaturesError(got, required int) *ResponseError
func QuorumInvalidSignatureError ¶
func QuorumInvalidSignatureError(providerID string) *ResponseError
func QuorumMalformedHeaderError ¶
func QuorumMalformedHeaderError(cause error) *ResponseError
func QuorumMissingSignaturesError ¶
func QuorumMissingSignaturesError() *ResponseError
func QuorumNotSupportedError ¶
func QuorumNotSupportedError(reason string) *ResponseError
func QuorumUnexpectedRequestIDError ¶
func QuorumUnexpectedRequestIDError(expected, got string) *ResponseError
func QuorumUnknownProviderError ¶
func QuorumUnknownProviderError(providerID string) *ResponseError
func QuorumVerificationError ¶
func QuorumVerificationError(cause error) *ResponseError
func RateLimitError ¶
func RateLimitError() *ResponseError
func RequestTimeoutError ¶
func RequestTimeoutError() *ResponseError
func ResponseErrorWithData ¶
func ResponseErrorWithData(code int, message string, data interface{}) *ResponseError
func ResponseErrorWithMessage ¶
func ResponseErrorWithMessage(message string) *ResponseError
func ServerError ¶
func ServerError() *ResponseError
func ServerErrorWithCause ¶
func ServerErrorWithCause(cause error) *ResponseError
func WrongChainError ¶
func WrongChainError(chain string) *ResponseError
func WsTotalFailureError ¶
func WsTotalFailureError() *ResponseError
func (*ResponseError) Error ¶
func (b *ResponseError) Error() string
type ResponseErrorKind ¶
type ResponseErrorKind int
const ( PartialFailure ResponseErrorKind = iota TotalFailure )
type ResponseHolder ¶
type ResponseHolderWrapper ¶
type ResponseHolderWrapper struct {
UpstreamId string
RequestId string
Response ResponseHolder
}
type ResponseKind ¶
type ResponseKind int
const ( UnknownRespKind ResponseKind = iota Ok Cancelled Error RetryableError RoutingError )
func GetRespKindFromResponse ¶
func GetRespKindFromResponse(response ResponseHolder) ResponseKind
func (ResponseKind) String ¶
func (r ResponseKind) String() string
type ResponseReceivedHook ¶
type ResponseReceivedHook interface {
OnResponseReceived(ctx context.Context, request RequestHolder, respWrapper *ResponseHolderWrapper)
}
type ResultType ¶
type ResultType int
const ( ResultOk ResultType = iota ResultOkWithError ResultPartialFailure ResultTotalFailure ResultStop )
func GetResponseType ¶
func GetResponseType(wrapper *ResponseHolderWrapper, err error) ResultType
type StateUpstreamEvent ¶
type StateUpstreamEvent struct {
State *UpstreamState
}
type StatusUpstreamStateEvent ¶
type StatusUpstreamStateEvent struct {
Status AvailabilityStatus
}
func (*StatusUpstreamStateEvent) ProcessEvent ¶
func (s *StatusUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*StatusUpstreamStateEvent) Same ¶
func (s *StatusUpstreamStateEvent) Same(state UpstreamState) bool
type StopRetryErr ¶
type StopRetryErr struct {
}
func (StopRetryErr) Error ¶
func (s StopRetryErr) Error() string
type SubscribeConnectorState ¶
type SubscribeConnectorState int
const ( WsDisconnected SubscribeConnectorState = iota WsConnected )
type SubscribeUpstreamStateEvent ¶
type SubscribeUpstreamStateEvent struct {
State SubscribeConnectorState
}
func (*SubscribeUpstreamStateEvent) ProcessEvent ¶
func (s *SubscribeUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*SubscribeUpstreamStateEvent) Same ¶
func (s *SubscribeUpstreamStateEvent) Same(state UpstreamState) bool
type SubscriptionEventResponse ¶
type SubscriptionEventResponse struct {
// contains filtered or unexported fields
}
func NewSubscriptionEventResponse ¶
func NewSubscriptionEventResponse(id string, event []byte) *SubscriptionEventResponse
func (*SubscriptionEventResponse) EncodeResponse ¶
func (s *SubscriptionEventResponse) EncodeResponse(realId []byte) io.Reader
func (*SubscriptionEventResponse) GetError ¶
func (s *SubscriptionEventResponse) GetError() *ResponseError
func (*SubscriptionEventResponse) HasError ¶
func (s *SubscriptionEventResponse) HasError() bool
func (*SubscriptionEventResponse) HasStream ¶
func (s *SubscriptionEventResponse) HasStream() bool
func (*SubscriptionEventResponse) Id ¶
func (s *SubscriptionEventResponse) Id() string
func (*SubscriptionEventResponse) IsEventFrame ¶
func (s *SubscriptionEventResponse) IsEventFrame() bool
func (*SubscriptionEventResponse) ResponseCode ¶
func (s *SubscriptionEventResponse) ResponseCode() int
func (*SubscriptionEventResponse) ResponseResult ¶
func (s *SubscriptionEventResponse) ResponseResult() []byte
func (*SubscriptionEventResponse) ResponseResultString ¶
func (s *SubscriptionEventResponse) ResponseResultString() (string, error)
type SubscriptionMessageResponse ¶
type SubscriptionMessageResponse struct {
// contains filtered or unexported fields
}
func NewSubscriptionMessageEventResponse ¶
func NewSubscriptionMessageEventResponse(id string, message []byte) *SubscriptionMessageResponse
func (*SubscriptionMessageResponse) EncodeResponse ¶
func (s *SubscriptionMessageResponse) EncodeResponse(realId []byte) io.Reader
func (*SubscriptionMessageResponse) GetError ¶
func (s *SubscriptionMessageResponse) GetError() *ResponseError
func (*SubscriptionMessageResponse) HasError ¶
func (s *SubscriptionMessageResponse) HasError() bool
func (*SubscriptionMessageResponse) HasStream ¶
func (s *SubscriptionMessageResponse) HasStream() bool
func (*SubscriptionMessageResponse) Id ¶
func (s *SubscriptionMessageResponse) Id() string
func (*SubscriptionMessageResponse) IsEventFrame ¶
func (s *SubscriptionMessageResponse) IsEventFrame() bool
func (*SubscriptionMessageResponse) ResponseCode ¶
func (s *SubscriptionMessageResponse) ResponseCode() int
func (*SubscriptionMessageResponse) ResponseResult ¶
func (s *SubscriptionMessageResponse) ResponseResult() []byte
func (*SubscriptionMessageResponse) ResponseResultString ¶
func (s *SubscriptionMessageResponse) ResponseResultString() (string, error)
type SubscriptionMethodResultResponse ¶
type SubscriptionMethodResultResponse struct {
// contains filtered or unexported fields
}
func NewSubscriptionMethodResultResponse ¶
func NewSubscriptionMethodResultResponse(id, method string, result []byte, subId json.RawMessage) *SubscriptionMethodResultResponse
func (*SubscriptionMethodResultResponse) EncodeResponse ¶
func (s *SubscriptionMethodResultResponse) EncodeResponse(_ []byte) io.Reader
func (*SubscriptionMethodResultResponse) GetError ¶
func (s *SubscriptionMethodResultResponse) GetError() *ResponseError
func (*SubscriptionMethodResultResponse) HasError ¶
func (s *SubscriptionMethodResultResponse) HasError() bool
func (*SubscriptionMethodResultResponse) HasStream ¶
func (s *SubscriptionMethodResultResponse) HasStream() bool
func (*SubscriptionMethodResultResponse) Id ¶
func (s *SubscriptionMethodResultResponse) Id() string
func (*SubscriptionMethodResultResponse) IsEventFrame ¶
func (s *SubscriptionMethodResultResponse) IsEventFrame() bool
func (*SubscriptionMethodResultResponse) ResponseCode ¶
func (s *SubscriptionMethodResultResponse) ResponseCode() int
func (*SubscriptionMethodResultResponse) ResponseResult ¶
func (s *SubscriptionMethodResultResponse) ResponseResult() []byte
func (*SubscriptionMethodResultResponse) ResponseResultString ¶
func (s *SubscriptionMethodResultResponse) ResponseResultString() (string, error)
type SubscriptionResponseHolder ¶
type SubscriptionResponseHolder interface {
ResponseHolder
IsEventFrame() bool
}
type SubscriptionResultResponse ¶
type SubscriptionResultResponse struct {
// contains filtered or unexported fields
}
func NewSubscriptionResultEventResponse ¶
func NewSubscriptionResultEventResponse(id string, result []byte) *SubscriptionResultResponse
func (*SubscriptionResultResponse) EncodeResponse ¶
func (s *SubscriptionResultResponse) EncodeResponse(realId []byte) io.Reader
func (*SubscriptionResultResponse) GetError ¶
func (s *SubscriptionResultResponse) GetError() *ResponseError
func (*SubscriptionResultResponse) HasError ¶
func (s *SubscriptionResultResponse) HasError() bool
func (*SubscriptionResultResponse) HasStream ¶
func (s *SubscriptionResultResponse) HasStream() bool
func (*SubscriptionResultResponse) Id ¶
func (s *SubscriptionResultResponse) Id() string
func (*SubscriptionResultResponse) IsEventFrame ¶
func (s *SubscriptionResultResponse) IsEventFrame() bool
func (*SubscriptionResultResponse) ResponseCode ¶
func (s *SubscriptionResultResponse) ResponseCode() int
func (*SubscriptionResultResponse) ResponseResult ¶
func (s *SubscriptionResultResponse) ResponseResult() []byte
func (*SubscriptionResultResponse) ResponseResultString ¶
func (s *SubscriptionResultResponse) ResponseResultString() (string, error)
type UnaryRequestResult ¶
type UnaryRequestResult struct {
// contains filtered or unexported fields
}
func NewUnaryRequestResult ¶
func NewUnaryRequestResult() *UnaryRequestResult
func (*UnaryRequestResult) GetApiKey ¶
func (u *UnaryRequestResult) GetApiKey() string
func (*UnaryRequestResult) GetChain ¶
func (u *UnaryRequestResult) GetChain() chains.Chain
func (*UnaryRequestResult) GetDuration ¶
func (u *UnaryRequestResult) GetDuration() float64
func (*UnaryRequestResult) GetMethod ¶
func (u *UnaryRequestResult) GetMethod() string
func (*UnaryRequestResult) GetReqKind ¶
func (u *UnaryRequestResult) GetReqKind() RequestKind
func (*UnaryRequestResult) GetRespKind ¶
func (u *UnaryRequestResult) GetRespKind() ResponseKind
func (*UnaryRequestResult) GetTimestamp ¶
func (u *UnaryRequestResult) GetTimestamp() time.Time
func (*UnaryRequestResult) GetUpstreamId ¶
func (u *UnaryRequestResult) GetUpstreamId() string
func (*UnaryRequestResult) IsSuccessfulRetry ¶
func (u *UnaryRequestResult) IsSuccessfulRetry() bool
func (*UnaryRequestResult) WithDuration ¶
func (u *UnaryRequestResult) WithDuration(duration float64) *UnaryRequestResult
func (*UnaryRequestResult) WithRespKindFromResponse ¶
func (u *UnaryRequestResult) WithRespKindFromResponse(response ResponseHolder) *UnaryRequestResult
func (*UnaryRequestResult) WithSuccessfulRetry ¶
func (u *UnaryRequestResult) WithSuccessfulRetry() *UnaryRequestResult
func (*UnaryRequestResult) WithUpstreamId ¶
func (u *UnaryRequestResult) WithUpstreamId(upstreamId string) *UnaryRequestResult
type UnbanMethodUpstreamStateEvent ¶
type UnbanMethodUpstreamStateEvent struct {
Method string
}
func (*UnbanMethodUpstreamStateEvent) ProcessEvent ¶
func (u *UnbanMethodUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*UnbanMethodUpstreamStateEvent) Same ¶
func (u *UnbanMethodUpstreamStateEvent) Same(_ UpstreamState) bool
type UpstreamEvent ¶
type UpstreamEvent struct {
Id string
Chain chains.Chain
EventType UpstreamEventType
}
type UpstreamEventType ¶
type UpstreamEventType interface {
// contains filtered or unexported methods
}
type UpstreamJsonRpcRequest ¶
type UpstreamJsonRpcRequest struct {
// contains filtered or unexported fields
}
func NewStreamUpstreamJsonRpcRequest ¶
func NewStreamUpstreamJsonRpcRequest(id string, realId json.RawMessage, method string, params json.RawMessage, specMethod *specs.Method) *UpstreamJsonRpcRequest
func NewUpstreamJsonRpcRequest ¶
func NewUpstreamJsonRpcRequest( id string, realId json.RawMessage, method string, params json.RawMessage, isSub bool, specMethod *specs.Method, ) *UpstreamJsonRpcRequest
func (*UpstreamJsonRpcRequest) Body ¶
func (u *UpstreamJsonRpcRequest) Body() ([]byte, error)
func (*UpstreamJsonRpcRequest) Headers ¶
func (u *UpstreamJsonRpcRequest) Headers() map[string]string
func (*UpstreamJsonRpcRequest) Id ¶
func (u *UpstreamJsonRpcRequest) Id() string
func (*UpstreamJsonRpcRequest) IsStream ¶
func (u *UpstreamJsonRpcRequest) IsStream() bool
func (*UpstreamJsonRpcRequest) IsSubscribe ¶
func (u *UpstreamJsonRpcRequest) IsSubscribe() bool
func (*UpstreamJsonRpcRequest) Method ¶
func (u *UpstreamJsonRpcRequest) Method() string
func (*UpstreamJsonRpcRequest) ModifyParams ¶
func (u *UpstreamJsonRpcRequest) ModifyParams(ctx context.Context, newValue any)
func (*UpstreamJsonRpcRequest) ParseParams ¶
func (u *UpstreamJsonRpcRequest) ParseParams(ctx context.Context) specs.MethodParam
func (*UpstreamJsonRpcRequest) RealId ¶
func (u *UpstreamJsonRpcRequest) RealId() string
RealId returns the textual form of the JSON-RPC id actually placed on the wire (u.realId), unwrapped from the outer JSON quotes for string ids. This is what upstreams echo back in correlation headers (e.g. the QR quorum signature headers), and it differs from Id() which is nodecore's internal UUID tag used to route responses.
func (*UpstreamJsonRpcRequest) RequestHash ¶
func (u *UpstreamJsonRpcRequest) RequestHash() string
func (*UpstreamJsonRpcRequest) RequestObserver ¶
func (u *UpstreamJsonRpcRequest) RequestObserver() *RequestObserver
func (*UpstreamJsonRpcRequest) RequestType ¶
func (u *UpstreamJsonRpcRequest) RequestType() RequestType
func (*UpstreamJsonRpcRequest) SpecMethod ¶
func (u *UpstreamJsonRpcRequest) SpecMethod() *specs.Method
type UpstreamRestRequest ¶
type UpstreamRestRequest struct {
// contains filtered or unexported fields
}
func NewInternalUpstreamRestRequest ¶
func NewInternalUpstreamRestRequest(httpMethod, path string, chain chains.Chain) *UpstreamRestRequest
func NewUpstreamRestRequest ¶
func NewUpstreamRestRequest(httpMethod, path string, body []byte) *UpstreamRestRequest
NewUpstreamRestRequest builds an external-facing REST request from an incoming HTTP call. Encodes method as "<VERB>#<path>" so the shared HttpConnector can split on MethodSeparator and forward the call to the upstream. Always initialises the observer to avoid a nil deref in ObserverConnector.
func (*UpstreamRestRequest) Body ¶
func (u *UpstreamRestRequest) Body() ([]byte, error)
func (*UpstreamRestRequest) Headers ¶
func (u *UpstreamRestRequest) Headers() map[string]string
func (*UpstreamRestRequest) Id ¶
func (u *UpstreamRestRequest) Id() string
func (*UpstreamRestRequest) IsStream ¶
func (u *UpstreamRestRequest) IsStream() bool
func (*UpstreamRestRequest) IsSubscribe ¶
func (u *UpstreamRestRequest) IsSubscribe() bool
func (*UpstreamRestRequest) Method ¶
func (u *UpstreamRestRequest) Method() string
func (*UpstreamRestRequest) ModifyParams ¶
func (u *UpstreamRestRequest) ModifyParams(_ context.Context, _ any)
func (*UpstreamRestRequest) ParseParams ¶
func (u *UpstreamRestRequest) ParseParams(_ context.Context) specs.MethodParam
func (*UpstreamRestRequest) RequestHash ¶
func (u *UpstreamRestRequest) RequestHash() string
func (*UpstreamRestRequest) RequestObserver ¶
func (u *UpstreamRestRequest) RequestObserver() *RequestObserver
func (*UpstreamRestRequest) RequestType ¶
func (u *UpstreamRestRequest) RequestType() RequestType
func (*UpstreamRestRequest) SpecMethod ¶
func (u *UpstreamRestRequest) SpecMethod() *specs.Method
type UpstreamState ¶
type UpstreamState struct {
Status AvailabilityStatus
HeadData Block
UpstreamMethods methods.Methods
Caps mapset.Set[Cap]
UpstreamIndex string
RateLimiterBudget *ratelimiter.RateLimitBudget
AutoTuneRateLimiter *ratelimiter.UpstreamAutoTune
BlockInfo *BlockInfo
LowerBoundsInfo *LowerBoundInfo
Labels *Labels
}
func DefaultUpstreamState ¶
func DefaultUpstreamState(upstreamMethods methods.Methods, caps mapset.Set[Cap], upstreamIndex string, rt *ratelimiter.RateLimitBudget, autoTuneRateLimiter *ratelimiter.UpstreamAutoTune) UpstreamState
type UpstreamSubscriptionResponse ¶
type UpstreamSubscriptionResponse interface {
ResponseChan() chan *WsResponse
OpId() string
}
type ValidUpstreamEvent ¶
type ValidUpstreamEvent struct{}
type ValidUpstreamStateEvent ¶
type ValidUpstreamStateEvent struct{}
func (*ValidUpstreamStateEvent) ProcessEvent ¶
func (v *ValidUpstreamStateEvent) ProcessEvent(state UpstreamState) UpstreamState
func (*ValidUpstreamStateEvent) Same ¶
func (v *ValidUpstreamStateEvent) Same(_ UpstreamState) bool
type WsJsonRpcResponse ¶
type WsJsonRpcResponse struct {
// contains filtered or unexported fields
}
func NewWsJsonRpcResponse ¶
func NewWsJsonRpcResponse(id string, result []byte, error *ResponseError) *WsJsonRpcResponse
func (*WsJsonRpcResponse) EncodeResponse ¶
func (w *WsJsonRpcResponse) EncodeResponse(realId []byte) io.Reader
func (*WsJsonRpcResponse) GetError ¶
func (w *WsJsonRpcResponse) GetError() *ResponseError
func (*WsJsonRpcResponse) HasError ¶
func (w *WsJsonRpcResponse) HasError() bool
func (*WsJsonRpcResponse) HasStream ¶
func (w *WsJsonRpcResponse) HasStream() bool
func (*WsJsonRpcResponse) Id ¶
func (w *WsJsonRpcResponse) Id() string
func (*WsJsonRpcResponse) ResponseCode ¶
func (w *WsJsonRpcResponse) ResponseCode() int
func (*WsJsonRpcResponse) ResponseResult ¶
func (w *WsJsonRpcResponse) ResponseResult() []byte
func (*WsJsonRpcResponse) ResponseResultString ¶
func (w *WsJsonRpcResponse) ResponseResultString() (string, error)
type WsResponse ¶
type WsResponse struct {
Id string
SubId string
Message []byte
Type RequestType
Error *ResponseError
Event []byte
}
func ParseJsonRpcWsMessage ¶
func ParseJsonRpcWsMessage(body []byte) *WsResponse