Documentation ¶
Index ¶
Constants ¶
const ErrAuthFailed int = -32085
ErrAuthFailed is when supplied auth_token / account_id is not present in the database.
const ErrInternal int = -32603
ErrInternal is a general server error code
const ErrInvalidParams int = -32602
ErrInvalidParams signifies a client-supplied params error
const ErrInvalidRequest int = -32600
ErrInvalidRequest signifies a general client error
const ErrJSONParse int = -32700
ErrJSONParse means invalid JSON was received by the server.
ErrMethodUnavailable means the client-requested method cannot be found
const ErrProxy int = -32080
ErrProxy is for general errors that originate inside the proxy module
const MethodAccountBalance = "account_balance"
const MethodAccountList = "account_list"
const MethodClaimSearch = "claim_search"
const MethodCommentList = "comment_list"
const MethodFileList = "file_list"
const MethodGet = "get"
const MethodResolve = "resolve"
const MethodStatus = "status"
Variables ¶
var CacheLogger = monitor.NewModuleLogger("proxy_cache")
CacheLogger is for logging query cache-related messages
Functions ¶
func InitResponseCache ¶
func InitResponseCache(c ResponseCache)
InitResponseCache initializes module-level responseCache variable
Types ¶
type AuthFailed ¶ added in v0.7.0
type AuthFailed struct {
CallError
}
AuthFailed is for authentication failures when jsonrpc client has provided a token
func (AuthFailed) Code ¶ added in v0.7.0
func (e AuthFailed) Code() int
Code returns JSRON-RPC error code
func (AuthFailed) Error ¶ added in v0.7.0
func (e AuthFailed) Error() string
type CallError ¶ added in v0.7.0
type CallError interface { AsRPCResponse() *jsonrpc.RPCResponse Code() int Error() string }
CallError is for whatever errors might occur when processing or forwarding client JSON-RPC request
type Caller ¶ added in v0.7.0
type Caller struct {
// contains filtered or unexported fields
}
Caller patches through JSON-RPC requests from clients, doing pre/post-processing, account processing and validation.
func (*Caller) Call ¶ added in v0.7.0
Call method processes a raw query received from JSON-RPC client and forwards it to LbrynetServer. It returns a response that is ready to be sent back to the JSON-RPC client as is.
func (*Caller) SetPreprocessor ¶ added in v0.8.0
func (c *Caller) SetPreprocessor(p Preprocessor)
SetPreprocessor applies provided function to query before it's sent to the LbrynetServer.
type GenericError ¶ added in v0.7.0
type GenericError struct {
// contains filtered or unexported fields
}
func NewError ¶ added in v0.7.0
func NewError(e error) GenericError
NewError is for general internal errors
func NewInternalError ¶ added in v0.7.0
func NewInternalError(e error) GenericError
NewInternalError is for SDK-related errors (connection problems etc)
func NewMethodError ¶ added in v0.7.0
func NewMethodError(e error) GenericError
NewMethodError creates a call method error
func NewParamsError ¶ added in v0.7.0
func NewParamsError(e error) GenericError
NewParamsError signifies an error in method parameters
func NewParseError ¶ added in v0.7.0
func NewParseError(e error) GenericError
NewParseError is for json parsing errors
func (GenericError) AsRPCResponse ¶ added in v0.7.0
func (e GenericError) AsRPCResponse() *jsonrpc.RPCResponse
AsRPCResponse returns error as jsonrpc.RPCResponse
func (GenericError) Code ¶ added in v0.7.0
func (e GenericError) Code() int
Code returns JSRON-RPC error code
func (GenericError) Error ¶ added in v0.7.0
func (e GenericError) Error() string
func (GenericError) Unwrap ¶ added in v0.9.0
func (e GenericError) Unwrap() error
type Preprocessor ¶ added in v0.8.0
type Preprocessor func(q *Query)
type ProxyService ¶ added in v0.10.4
ProxyService generates Caller objects and keeps execution time metrics for all calls proxied through those objects.
func NewService ¶ added in v0.7.0
func NewService(opts Opts) *ProxyService
NewService is the entry point to proxy module. Normally only one instance of ProxyService should be created per running server.
func (*ProxyService) NewCaller ¶ added in v0.10.4
func (ps *ProxyService) NewCaller(walletID string) *Caller
NewCaller returns an instance of Caller ready to proxy requests. Note that `SetWalletID` needs to be called if an authenticated user is making this call.
type Query ¶ added in v0.7.0
type Query struct { Request *jsonrpc.RPCRequest // contains filtered or unexported fields }
Query is a wrapper around client JSON-RPC query for easier (un)marshaling and processing.
func NewQuery ¶ added in v0.7.0
NewQuery initializes Query object with JSON-RPC request supplied as bytes. The object is immediately usable and returns an error in case request parsing fails.
func (*Query) Params ¶ added in v0.7.0
func (q *Query) Params() interface{}
Params is a shortcut for query params.
func (*Query) ParamsAsMap ¶ added in v0.7.0
ParamsAsMap returns query params converted to plain map.
func (*Query) ParamsToStruct ¶ added in v0.8.0
ParamsToStruct returns query params parsed into a supplied structure.
func (*Query) SetWalletID ¶ added in v0.9.0
type RequestHandler ¶ added in v0.7.0
type RequestHandler struct {
*ProxyService
}
RequestHandler is a wrapper for passing proxy.ProxyService instance to proxy HTTP handler.
func NewRequestHandler ¶ added in v0.8.2
func NewRequestHandler(svc *ProxyService) *RequestHandler
NewRequestHandler initializes request handler with a provided Proxy ProxyService instance
func (*RequestHandler) Handle ¶ added in v0.7.0
func (rh *RequestHandler) Handle(w http.ResponseWriter, r *http.Request)
Handle forwards client JSON-RPC request to proxy.
func (*RequestHandler) HandleOptions ¶ added in v0.8.2
func (rh *RequestHandler) HandleOptions(w http.ResponseWriter, r *http.Request)
HandleOptions returns necessary CORS headers for pre-flight requests to proxy API
type ResponseCache ¶
type ResponseCache interface { Save(method string, params interface{}, r interface{}) Retrieve(method string, params interface{}) interface{} Count() int // contains filtered or unexported methods }
ResponseCache interface describes methods for SDK response cache saving and retrieval