callback

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(logger logging.Logger) *Callback

func (*Callback) Cancel

func (c *Callback) Cancel(id int) error

Cancel removes a callback based on an callback ID

func (*Callback) On

func (c *Callback) On(method string, f handlerFunc) int

On adds a new callback based on an ethrpc method and returns the associated callback ID

func (*Callback) Register added in v0.0.3

func (c *Callback) Register(id uint64, method string)

Register keeps track of the ethrpc requests with ethrpc ID to ethrpc method name mapping. It must be called before callback.Run()

func (*Callback) Run

func (c *Callback) Run(resp *Response)

Run, with the ID from the ethrpc response, finds the registered method name, and executes all callbacks associated with the method.

type Response

type Response struct {
	Body *ethrpc.JsonrpcMessage
	IP   string
}

Jump to

Keyboard shortcuts

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