sebak: boscoin.io/sebak/lib/common/observer Index | Files

package observer

import "boscoin.io/sebak/lib/common/observer"

Index

Package Files

observer.go

Constants

const (
    // An event relative to transactions
    Tx  ResourceType = "tx"
    // An event relative to transactions in the transaction pool
    TxPool = "txpool"
    // An event relative to accounts (creation, update)
    Acc = "acc"
)
const (
    // All events related to the `ResourceType`
    All KeyType = "*"
    // "Identifier" of the item
    // Hash for a Transaction, address for an Account.
    Identifier = "identifier"
    // Tx/TxPool only: Transactions with a specified source
    Source = "source"
    // Tx/TxPool only: Transactions with a specified target
    Target = "target"
)

Variables

var ResourceObserver = observable.New()
var SyncBlockWaitObserver = observable.New()

type Condition Uses

type Condition struct {
    // Affected ressource
    Resource ResourceType `json:"resource"`
    // Filter to use (can be `All)
    Key KeyType `json:"key"`
    // If `Key != All`, value of the filter
    Value string `json:"value"`
}

A Condition can be sent as the body when calling subscribe

func NewCondition Uses

func NewCondition(resource ResourceType, key KeyType, v ...string) Condition

Instantiate a new `Condition` object

Params:

ressource = The requested `RessourceType` to stream
key       = The key to stream
v         = An optional value for key. Only the first value will be used.

Returns: A `Condition` object, that can be triggered or passed to `/subscribe`

func (Condition) String Uses

func (c Condition) String() string

Implement `fmt.Stringer`

type Conditions Uses

type Conditions []Condition

An array of Condition

func (Conditions) String Uses

func (cs Conditions) String() string

Implement `fmt.Stringer`

type KeyType Uses

type KeyType = string

The type of key that the event applies to (depends on the ressource)

type ResourceType Uses

type ResourceType = string

The type of ressource that the event concerns

Package observer imports 2 packages (graph) and is imported by 12 packages. Updated 2019-03-27. Refresh now. Tools for package owners.