types

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Has     = ViewType(0)
	GetOne  = ViewType(1)
	GetMany = ViewType(2)
	GetKeys = ViewType(3)
)
View Source
const (
	TxSet        = TxType(11)
	TxSetSync    = TxType(12)
	TxDelete     = TxType(21)
	TxDeleteSync = TxType(22)
	TxCommit     = TxType(90)
)
View Source
const GlobalEventScope = EventScope("")

Variables

View Source
var (
	LastKeySuffix      = "~~~"
	LastKeySuffixBytes = []byte(LastKeySuffix)
)
View Source
var BasicCdc = NewCodec()

BasicCdc is the basic codec

Functions

func EncodeTxMsg

func EncodeTxMsg(msg *TxMsg) ([]byte, error)

func EncodeViewMsg

func EncodeViewMsg(msg *ViewMsg) ([]byte, error)

func IsNoDataError

func IsNoDataError(err error) bool

func LoadModuleConfigFile added in v0.0.2

func LoadModuleConfigFile(filePath string, modCfg interface{}) (err error)

func Publish

func Publish(scope EventScope, event Event) error

func RegisterCodec

func RegisterCodec(cdc *Codec)

RegisterCodec registers concrete types on the Amino codec

func Subscribe

func Subscribe(scope EventScope, path EventPath, name string, handler EventHandler) error

func TxTypeString

func TxTypeString(typ TxType) string

func Unsubscribe added in v0.0.2

func Unsubscribe(scope EventScope, path EventPath, name string)

func WriteModuleConfigFile added in v0.0.2

func WriteModuleConfigFile(filePath string, modCfg ModuleConfig) (err error)

Types

type Client

type Client interface {
	BroadcastTxSync(msg *TxMsg) error
	BroadcastTxAsync(msg *TxMsg) error
	BroadcastTxCommit(msg *TxMsg) error
	Commit() error
	Has(msg *ViewMsg) (bool, error)
	Query(msg *ViewMsg) ([]byte, error)
	GetObject(msg *ViewMsg, obj interface{}) (err error)
	GetMany(msg *ViewMsg, handler KVHandler) (err error)
	GetKeys(msg *ViewMsg) ([]string, error)
	UnmarshalObject(bz []byte, ptr interface{}) error
	MarshalObject(ptr interface{}) ([]byte, error)
	UnmarshalJson(bz []byte, ptr interface{}) error
	MarshalJson(ptr interface{}) ([]byte, error)
	CurrentBlockNumber() (block int64)
}

type Codec

type Codec = amino.Codec

func NewCodec

func NewCodec() *Codec

NewCodec

type EmptyModuleConfig added in v0.0.2

type EmptyModuleConfig struct {
}

func (EmptyModuleConfig) GetTemplate added in v0.0.2

func (e EmptyModuleConfig) GetTemplate() string

type Event

type Event interface {
	Path() EventPath
}

type EventBus

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

func RegisterEventBus

func RegisterEventBus(scope EventScope) *EventBus

func (*EventBus) Publish

func (bus *EventBus) Publish(event Event)

func (*EventBus) Subscribe

func (bus *EventBus) Subscribe(path EventPath, name string, handler EventHandler) error

func (*EventBus) Unsubscribe

func (bus *EventBus) Unsubscribe(path EventPath, name string)

type EventBusRegistry added in v0.0.2

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

func (*EventBusRegistry) Publish added in v0.0.2

func (registry *EventBusRegistry) Publish(scope EventScope, event Event) error

func (*EventBusRegistry) RegisterEventBus added in v0.0.2

func (registry *EventBusRegistry) RegisterEventBus(scope EventScope) *EventBus

func (*EventBusRegistry) Subscribe added in v0.0.2

func (registry *EventBusRegistry) Subscribe(scope EventScope, path EventPath, name string, handler EventHandler) error

func (*EventBusRegistry) Unsubscribe added in v0.0.2

func (registry *EventBusRegistry) Unsubscribe(scope EventScope, path EventPath, name string)

type EventHandler

type EventHandler func(event Event)

type EventPath

type EventPath string

func (EventPath) HasPrefix

func (path EventPath) HasPrefix(prefix EventPath) (ok bool)

type EventRouter added in v0.0.2

type EventRouter struct {
	sync.Mutex
	Path EventPath
	// contains filtered or unexported fields
}

func NewEventRouter added in v0.0.2

func NewEventRouter(path EventPath) *EventRouter

func (*EventRouter) Add added in v0.0.2

func (router *EventRouter) Add(name string, handler EventHandler) error

func (*EventRouter) PushEvent added in v0.0.2

func (router *EventRouter) PushEvent(event Event)

func (*EventRouter) Remove added in v0.0.2

func (router *EventRouter) Remove(name string)

type EventScope

type EventScope string

type KVHandler

type KVHandler func(key []byte, value []byte) bool

DataHandler data handler for GetMany

type KeyValue

type KeyValue struct {
	Key   []byte
	Value []byte
}

type ModuleConfig added in v0.0.2

type ModuleConfig interface {
	GetTemplate() string
}

type NoDataError

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

func NewNoDataError

func NewNoDataError() NoDataError

func (NoDataError) Error

func (err NoDataError) Error() string

type SpaceRegistry

type SpaceRegistry interface {
	RegisterSpace(name string)
	RegisterSpaceIfNotExist(name string)
}

type Store

type Store interface {
	GetPath() string
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	Set(key []byte, value []byte) error
	SetSync(key []byte, value []byte) error
	Delete(key []byte) error
	DeleteSync(key []byte) error
	Iterator(start, end []byte) (dbm.Iterator, error)
	GetMany(start, end []byte) (kvArrayBytes []byte, err error)
}

type TxMsg

type TxMsg struct {
	Type   TxType
	Space  string
	Path   string
	Key    []byte
	Data   []byte
	TxHash int64
}

func DecodeTxMsg

func DecodeTxMsg(msgBytes []byte) (*TxMsg, error)

func NewTxMsg

func NewTxMsg(typ TxType, space string, path string, key string, data []byte) *TxMsg

func (*TxMsg) GetEventKey

func (msg *TxMsg) GetEventKey() string

func (*TxMsg) GetTypeString

func (msg *TxMsg) GetTypeString() string

func (*TxMsg) SetTxHash

func (msg *TxMsg) SetTxHash()

to avoid 'tx already exists in cache' problem

type TxType

type TxType uint8

type ViewMsg

type ViewMsg struct {
	Type  ViewType
	Space string
	Path  string
	Start []byte
	End   []byte
}

func DecodeViewMsg

func DecodeViewMsg(msgBytes []byte) (*ViewMsg, error)

func NewViewMsgHas

func NewViewMsgHas(space string, path string, key string) *ViewMsg

func NewViewMsgKeys

func NewViewMsgKeys(space string, path string, start string, end string) *ViewMsg

func NewViewMsgMany

func NewViewMsgMany(space string, path string, start string, end string) *ViewMsg

func NewViewMsgOne

func NewViewMsgOne(space string, path string, key string) *ViewMsg

type ViewType

type ViewType uint8

Jump to

Keyboard shortcuts

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