query

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet            = "get"
	MethodFileList       = "file_list"
	MethodAccountList    = "account_list"
	MethodStatus         = "status"
	MethodResolve        = "resolve"
	MethodClaimSearch    = "claim_search"
	MethodPurchaseCreate = "purchase_create"

	ParamStreamingUrl    = "streaming_url"
	ParamPurchaseReceipt = "purchase_receipt"
)

Variables

This section is empty.

Functions

func MethodAcceptsWallet

func MethodAcceptsWallet(method string) bool

MethodAcceptsWallet returns true for methods that can accept wallet_id

func MethodRequiresWallet

func MethodRequiresWallet(method string) bool

MethodRequiresWallet returns true for methods that require wallet_id

Types

type Caller

type Caller struct {
	// Preprocessor is applied to query before it's sent to the SDK.
	Preprocessor func(q *Query)

	// Cache stores cachable queries to improve performance
	Cache cache.QueryCache
	// contains filtered or unexported fields
}

Caller patches through JSON-RPC requests from clients, doing pre/post-processing, account processing and validation.

func NewCaller

func NewCaller(endpoint string, userID int) *Caller

func (*Caller) AddPreflightHook added in v0.14.1

func (c *Caller) AddPreflightHook(method string, hf Hook)

AddPreflightHook adds query pre-flight hook function, allowing to amend the query before it gets sent to the JSON-RPC server, with an option to return an early response, avoiding sending the query to JSON-RPC server altogether

func (*Caller) Call

func (c *Caller) Call(req *jsonrpc.RPCRequest) (*jsonrpc.RPCResponse, error)

Call method forwards a JSON-RPC request to the lbrynet server. It returns a response that is ready to be sent back to the JSON-RPC client as is.

type Hook added in v0.14.1

type Hook func(c *Caller, q *Query) (*jsonrpc.RPCResponse, error)

type Query

type Query struct {
	Request  *jsonrpc.RPCRequest
	WalletID string
}

Query is a wrapper around client JSON-RPC query for easier (un)marshaling and processing.

func NewQuery

func NewQuery(req *jsonrpc.RPCRequest, walletID string) (*Query, error)

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. If wallet_id is not empty, it will be added as a param to the query when the Caller calls it.

func (*Query) Method

func (q *Query) Method() string

Method is a shortcut for query method.

func (*Query) Params

func (q *Query) Params() interface{}

Params is a shortcut for query params.

func (*Query) ParamsAsMap

func (q *Query) ParamsAsMap() map[string]interface{}

ParamsAsMap returns query params converted to plain map.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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