types

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 8 Imported by: 1

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 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

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)
}

type Codec

type Codec = amino.Codec

func NewCodec

func NewCodec() *Codec

NewCodec

type Command

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

type CommandProcessor

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

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 EventHandler

type EventHandler func(event Event)

type EventPath

type EventPath string

func (EventPath) HasPrefix

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

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 NoDataError

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

func NewNoDataError

func NewNoDataError() NoDataError

func (NoDataError) Error

func (err NoDataError) Error() string

type Queue

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

Queue ...

func (*Queue) Pop

func (queue *Queue) Pop() (value *Command)

Pop ..

func (*Queue) Push

func (queue *Queue) Push(value *Command)

Push ..

func (*Queue) Size

func (queue *Queue) Size() int

Size ..

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