rpc

package
v0.2.4-0...-f8342f3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPCState

type RPCState struct {
	Goodbye       Responder
	Status        Responder
	Ping          Responder
	Metadata      Responder
	BlocksByRange Responder
	BlocksByRoot  Responder
}

type RequestEntry

type RequestEntry struct {
	From    peer.ID
	Handler reqresp.RequestResponder
	Cancel  func()
}

type RequestKey

type RequestKey uint64

type Responder

type Responder struct {

	// RequestKey -> RequestEntry
	Requests sync.Map
	// contains filtered or unexported fields
}

func (*Responder) AddRequest

func (r *Responder) AddRequest(req *RequestEntry) RequestKey

func (*Responder) CloseRequest

func (r *Responder) CloseRequest(key RequestKey)

func (*Responder) GetRequest

func (r *Responder) GetRequest(key RequestKey) *RequestEntry

type RpcCmd

type RpcCmd struct {
	*base.Base
	*RPCState
}

func (*RpcCmd) Cmd

func (c *RpcCmd) Cmd(route string) (cmd interface{}, err error)

func (*RpcCmd) Help

func (c *RpcCmd) Help() string

func (*RpcCmd) Method

func (c *RpcCmd) Method(name string, resp *Responder, method *reqresp.RPCMethod) *RpcMethodCmd

func (*RpcCmd) Routes

func (c *RpcCmd) Routes() []string

type RpcMethodCloseCmd

type RpcMethodCloseCmd struct {
	*base.Base
	*RpcMethodData
	ReqId string `ask:"<req-id>" help:"the ID of the request to close"`
}

func (*RpcMethodCloseCmd) Help

func (c *RpcMethodCloseCmd) Help() string

func (*RpcMethodCloseCmd) Run

func (c *RpcMethodCloseCmd) Run(ctx context.Context, args ...string) error

type RpcMethodCmd

type RpcMethodCmd struct {
	*base.Base
	*RpcMethodData
}

func (*RpcMethodCmd) Cmd

func (c *RpcMethodCmd) Cmd(route string) (cmd interface{}, err error)

func (*RpcMethodCmd) Help

func (c *RpcMethodCmd) Help() string

func (*RpcMethodCmd) Routes

func (c *RpcMethodCmd) Routes() []string

type RpcMethodData

type RpcMethodData struct {
	Name      string
	Responder *Responder
	Method    *reqresp.RPCMethod
}

type RpcMethodListenCmd

type RpcMethodListenCmd struct {
	*base.Base
	*RpcMethodData
	Timeout     time.Duration         `` /* 127-byte string literal not displayed */
	Compression flags.CompressionFlag `ask:"--compression" help:"Compression. 'none' to disable, 'snappy' for streaming-snappy"`
	Raw         bool                  `ask:"--raw" help:"Do not decode the request, look at raw bytes"`
	Drop        bool                  `ask:"--drop" help:"Drop the requests, do not queue for a response."`
	Read        bool                  `ask:"--read" help:"Read the contents of the request."`
}

func (*RpcMethodListenCmd) Help

func (c *RpcMethodListenCmd) Help() string

func (*RpcMethodListenCmd) Run

func (c *RpcMethodListenCmd) Run(ctx context.Context, args ...string) error

type RpcMethodReqCmd

type RpcMethodReqCmd struct {
	*base.Base
	*RpcMethodData
}

func (*RpcMethodReqCmd) Cmd

func (c *RpcMethodReqCmd) Cmd(route string) (cmd interface{}, err error)

func (*RpcMethodReqCmd) Help

func (c *RpcMethodReqCmd) Help() string

func (*RpcMethodReqCmd) Routes

func (c *RpcMethodReqCmd) Routes() []string

TODO: it may make sense to just collapse this command route, and only support raw requests.

type RpcMethodReqRawCmd

type RpcMethodReqRawCmd struct {
	*base.Base
	*RpcMethodData
	Timeout     time.Duration         `ask:"--timeout" help:"Timeout for full request and response. 0 to disable"`
	Compression flags.CompressionFlag `ask:"--compression" help:"Compression. 'none' to disable, 'snappy' for streaming-snappy"`
	MaxChunks   uint64                `ask:"--max-chunks" help:"Max response chunk count, if 0, do not wait for a response at all."`
	Raw         bool                  `ask:"--raw" help:"If chunks should be logged as raw hex-encoded byte strings"`
	PeerID      flags.PeerIDFlag      `ask:"<peer-id>" help:"libp2p Peer-ID to request"`
	Data        []byte                `ask:"<data>" help:"Raw uncompressed hex-encoded request data"`
}

func (*RpcMethodReqRawCmd) Help

func (c *RpcMethodReqRawCmd) Help() string

func (*RpcMethodReqRawCmd) Run

func (c *RpcMethodReqRawCmd) Run(ctx context.Context, args ...string) error

type RpcMethodRespChunkCmd

type RpcMethodRespChunkCmd struct {
	*base.Base
	*RpcMethodData
}

func (*RpcMethodRespChunkCmd) Cmd

func (c *RpcMethodRespChunkCmd) Cmd(route string) (cmd interface{}, err error)

func (*RpcMethodRespChunkCmd) Help

func (c *RpcMethodRespChunkCmd) Help() string

func (*RpcMethodRespChunkCmd) Routes

func (c *RpcMethodRespChunkCmd) Routes() []string

type RpcMethodRespChunkRawCmd

type RpcMethodRespChunkRawCmd struct {
	*base.Base
	*RpcMethodData
	Done       bool                 `ask:"--done" help:"After writing this chunk, close the response (no more chunks)."`
	ResultCode reqresp.ResponseCode `ask:"--result-code" help:"Customize the chunk result code. (0 = success, 1 = invalid input, 2 = error, 3+ = undefined)"`
	ReqId      string               `ask:"<req-id>" help:"the ID of the request to respond to"`
	Data       []byte               `ask:"<data>" help:"chunk bytes (uncompressed, hex-encoded)"`
}

func (*RpcMethodRespChunkRawCmd) Help

func (c *RpcMethodRespChunkRawCmd) Help() string

func (*RpcMethodRespChunkRawCmd) Run

func (c *RpcMethodRespChunkRawCmd) Run(ctx context.Context, args ...string) error

type RpcMethodRespCmd

type RpcMethodRespCmd struct {
	*base.Base
	*RpcMethodData
}

func (*RpcMethodRespCmd) Cmd

func (c *RpcMethodRespCmd) Cmd(route string) (cmd interface{}, err error)

func (*RpcMethodRespCmd) Help

func (c *RpcMethodRespCmd) Help() string

func (*RpcMethodRespCmd) Routes

func (c *RpcMethodRespCmd) Routes() []string

type RpcMethodRespErrorCmd

type RpcMethodRespErrorCmd struct {
	*base.Base
	*RpcMethodData
	Done       bool                 `ask:"--done" help:"After writing this chunk, close the response (no more chunks)."`
	ResultCode reqresp.ResponseCode `ask:"--result-code" help:"Customize the chunk result code. (0 = success, 1 = invalid input, 2 = error, 3+ = undefined)"`
	ReqId      string               `ask:"<req-id>" help:"the ID of the request to respond to"`
	Text       string               `ask:"<text>" help:"error text data"`
}

func (*RpcMethodRespErrorCmd) Help

func (c *RpcMethodRespErrorCmd) Help() string

func (*RpcMethodRespErrorCmd) Run

func (c *RpcMethodRespErrorCmd) Run(ctx context.Context, args ...string) error

Jump to

Keyboard shortcuts

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