notifier

package
v0.0.0-...-782215f Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const EventBufSize = 2 << 4

event generation buffer

View Source
const (
	EventNameERC20 = "erc20_log_event"
)
View Source
const (
	EventNameEthBalanceChange = "eth_balance_change_event"
)
View Source
const HTTP_USER_AGENT = "858Chain/Token-Shout-Agent"

Variables

View Source
var ErrShouldRetry = errors.New("should retry")
View Source
var EventTypeRegistry = []string{}

Functions

func EncodeEvent

func EncodeEvent(event Event) ([]byte, error)

func ShouldRetry

func ShouldRetry(err error) bool

Types

type ERC20LogEvent

type ERC20LogEvent struct {
	// contains filtered or unexported fields
}

func NewERC20LogEvent

func NewERC20LogEvent(meta map[string]interface{}) *ERC20LogEvent

func (*ERC20LogEvent) From

func (ethEvent *ERC20LogEvent) From() string

func (*ERC20LogEvent) GetEvent

func (ethEvent *ERC20LogEvent) GetEvent() map[string]interface{}

func (*ERC20LogEvent) To

func (ethEvent *ERC20LogEvent) To() string

func (*ERC20LogEvent) Type

func (ethEvent *ERC20LogEvent) Type() string

type EthBalanceChangeEvent

type EthBalanceChangeEvent struct {
	// contains filtered or unexported fields
}

func NewEthBalanceChangeEvent

func NewEthBalanceChangeEvent(meta map[string]interface{}) *EthBalanceChangeEvent

func (*EthBalanceChangeEvent) From

func (ethEvent *EthBalanceChangeEvent) From() string

func (*EthBalanceChangeEvent) GetEvent

func (ethEvent *EthBalanceChangeEvent) GetEvent() map[string]interface{}

func (*EthBalanceChangeEvent) To

func (ethEvent *EthBalanceChangeEvent) To() string

func (*EthBalanceChangeEvent) Type

func (ethEvent *EthBalanceChangeEvent) Type() string

type Event

type Event interface {
	GetEvent() map[string]interface{}

	// eth_balance_change_event / erc20_token_transfer
	Type() string
	From() string
	To() string
}

type Msg

type Msg struct {
	EventType string                 `json:"type"`
	Event     map[string]interface{} `json:"event"`
}

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Engine of notification

func New

func New() *Notifier

func (*Notifier) EventChan

func (notifier *Notifier) EventChan() chan<- Event

func (*Notifier) InstallReceiver

func (notifier *Notifier) InstallReceiver(name string, receiver *Receiver)

func (*Notifier) ListReceivers

func (notifier *Notifier) ListReceivers() map[string]*Receiver

func (*Notifier) Start

func (notifier *Notifier) Start(ctx context.Context)

func (*Notifier) Stop

func (notifier *Notifier) Stop()

func (*Notifier) UninstallReceiver

func (notifier *Notifier) UninstallReceiver(name string)

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver receive event notfication

func NewReceiver

func NewReceiver(cfg ReceiverConfig) *Receiver

func (*Receiver) Accept

func (r *Receiver) Accept(event Event)

Accept event and spawn new goroutine to post event back to the endpoint.

func (*Receiver) Match

func (r *Receiver) Match(event Event) bool

Check if event type in receivier's eventTypes

type ReceiverConfig

type ReceiverConfig struct {
	RetryCount          uint     `json:"retrycount"`
	Endpoint            string   `json:"endpoint"`
	NewBalanceRemaining float64  `json:"newBalanceRemaining"`
	EventTypes          []string `json:"eventTypes"`

	// address support the following format
	//
	// * - all valid address
	// all-in-wallet - all address in local wallet
	// 0x9d8ec6a2cfe2a6abdf5a6041e752ba851abb4dbb,0x9d8ec6a2cfe2a6abdf5a6041e752ba851abb4dbb
	FromAddresses []string `json:"from"`
	ToAddresses   []string `json:"to"`
}

Config of receivers

func (ReceiverConfig) ValidCheck

func (rc ReceiverConfig) ValidCheck() error

Jump to

Keyboard shortcuts

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