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) ResponseResult() []byte
- func (h *BaseUpstreamResponse) ResponseResultString() (string, error)
- type Block
- type BlockData
- type BlockInfo
- type BlockType
- type BlockUpstreamStateEvent
- type Cap
- type ClientRetryableError
- type CloseReader
- type FatalErrorUpstreamStateEvent
- type HeadUpstreamStateEvent
- type HttpMethod
- type JsonRpcRequestBody
- type JsonRpcWsUpstreamResponse
- 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 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 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
- type ResponseErrorKind
- type ResponseHolder
- type ResponseHolderWrapper
- type ResultType
- type StateUpstreamEvent
- type StopRetryErr
- 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) ResponseCode() int
- func (s *SubscriptionEventResponse) ResponseResult() []byte
- func (s *SubscriptionEventResponse) ResponseResultString() (string, error)
- type UnbanMethodUpstreamStateEvent
- type UpstreamEvent
- type UpstreamEventType
- type UpstreamJsonRpcRequest
- func NewInternalSubUpstreamJsonRpcRequest(method string, params any) (*UpstreamJsonRpcRequest, error)
- func NewInternalUpstreamJsonRpcRequest(method string, params any) (*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) RequestHash() string
- func (u *UpstreamJsonRpcRequest) RequestType() RequestType
- func (u *UpstreamJsonRpcRequest) SpecMethod() *specs.Method
- type 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(ctx context.Context, newValue any)
- func (u *UpstreamRestRequest) ParseParams(ctx context.Context) specs.MethodParam
- func (u *UpstreamRestRequest) RequestHash() string
- 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
Constants ¶
View Source
const ( BaseError int = iota NoAvailableUpstreams WrongChain CtxErrorCode ClientErrorCode = 400 AuthErrorCode = 403 RequestTimeout = 408 InternalServerErrorCode = 500 RateLimitExceeded = 429 NoSupportedMethod = -32601 IncorrectResponseBody = -32001 )
View Source
const MaxChunkSize = 8192
View Source
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 {
// contains filtered or unexported methods
}
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 UnknownStatus = math.MaxInt )
func (AvailabilityStatus) String ¶
func (a AvailabilityStatus) String() string
type BanMethodUpstreamStateEvent ¶
type BanMethodUpstreamStateEvent struct {
Method string
}
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) ResponseResult ¶
func (h *BaseUpstreamResponse) ResponseResult() []byte
func (*BaseUpstreamResponse) ResponseResultString ¶
func (h *BaseUpstreamResponse) ResponseResultString() (string, error)
type BlockInfo ¶
type BlockInfo struct {
// contains filtered or unexported fields
}
func NewBlockInfo ¶
func NewBlockInfo() *BlockInfo
type BlockUpstreamStateEvent ¶
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{}
type HeadUpstreamStateEvent ¶
type HeadUpstreamStateEvent struct {
HeadData *BlockData
}
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) *JsonRpcWsUpstreamResponse
func (*JsonRpcWsUpstreamResponse) ResponseChan ¶
func (j *JsonRpcWsUpstreamResponse) ResponseChan() chan *WsResponse
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
ModifyParams(ctx context.Context, newValue any)
IsStream() bool
IsSubscribe() bool
RequestType() RequestType
RequestHash() string
SpecMethod() *specs.Method
}
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 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 (*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 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 StopRetryErr ¶
type StopRetryErr struct {
}
func (StopRetryErr) Error ¶
func (s StopRetryErr) Error() string
type SubscriptionEventResponse ¶
type SubscriptionEventResponse struct {
// contains filtered or unexported fields
}
func NewSubscriptionEventResponse ¶
func NewSubscriptionEventResponse(id string, event []byte) *SubscriptionEventResponse
func NewSubscriptionMessageEventResponse ¶
func NewSubscriptionMessageEventResponse(id string, message []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) ResponseCode ¶
func (s *SubscriptionEventResponse) ResponseCode() int
func (*SubscriptionEventResponse) ResponseResult ¶
func (s *SubscriptionEventResponse) ResponseResult() []byte
func (*SubscriptionEventResponse) ResponseResultString ¶
func (s *SubscriptionEventResponse) ResponseResultString() (string, error)
type UnbanMethodUpstreamStateEvent ¶
type UnbanMethodUpstreamStateEvent struct {
Method string
}
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 NewInternalSubUpstreamJsonRpcRequest ¶
func NewInternalSubUpstreamJsonRpcRequest(method string, params any) (*UpstreamJsonRpcRequest, error)
func NewInternalUpstreamJsonRpcRequest ¶
func NewInternalUpstreamJsonRpcRequest(method string, params any) (*UpstreamJsonRpcRequest, error)
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) RequestHash ¶
func (u *UpstreamJsonRpcRequest) RequestHash() string
func (*UpstreamJsonRpcRequest) RequestType ¶
func (u *UpstreamJsonRpcRequest) RequestType() RequestType
func (*UpstreamJsonRpcRequest) SpecMethod ¶
func (u *UpstreamJsonRpcRequest) SpecMethod() *specs.Method
type UpstreamRestRequest ¶
type UpstreamRestRequest struct {
}
func NewUpstreamRestRequest ¶
func NewUpstreamRestRequest() *UpstreamRestRequest
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(ctx context.Context, newValue any)
func (*UpstreamRestRequest) ParseParams ¶
func (u *UpstreamRestRequest) ParseParams(ctx context.Context) specs.MethodParam
func (*UpstreamRestRequest) RequestHash ¶
func (u *UpstreamRestRequest) RequestHash() string
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 *BlockData
UpstreamMethods methods.Methods
BlockInfo *BlockInfo
Caps mapset.Set[Cap]
UpstreamIndex string
RateLimiterBudget *ratelimiter.RateLimitBudget
AutoTuneRateLimiter *ratelimiter.UpstreamAutoTune
}
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
}
type ValidUpstreamEvent ¶
type ValidUpstreamEvent struct{}
type ValidUpstreamStateEvent ¶
type ValidUpstreamStateEvent struct{}
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
Click to show internal directories.
Click to hide internal directories.