callback

package
v0.0.4 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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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