common

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventScopeDaemon = types.EventScope("daemon")
)
View Source
const (
	SpaceDaemon = "daemon"
)

Variables

This section is empty.

Functions

func AddDaemonFlags added in v0.0.2

func AddDaemonFlags(cmd *cobra.Command)

func LoadConfigFile added in v0.0.2

func LoadConfigFile(filePath string, dmCfg *DaemonConfig) (err error)

func PublishDaemonEvent

func PublishDaemonEvent(event DaemonEvent)

func SubscribeDaemonEvent

func SubscribeDaemonEvent(path types.EventPath, name string, handler types.EventHandler) error

func UnsubscribeDaemonEvent

func UnsubscribeDaemonEvent(path types.EventPath, name string)

func WriteConfigFile added in v0.0.2

func WriteConfigFile(filePath string, dmCfg *DaemonConfig) (err error)

Types

type ClusterState

type ClusterState interface {
	IsLeader() bool
	GetAliveMemberIDs() []string
}

type Context

type Context interface {
	log.Logger
	LastBlockTime() time.Time
	LastBlockIndex() int64
	GetNodeID() string
	GetClient() types.Client
	GetTMConfig() *cfg.Config
	GetConfig() DaemonConfig
	GetClusterState() ClusterState
	SetClusterState(state ClusterState)
}

func NewContext

func NewContext(tmCfg *cfg.Config, logger log.Logger, tmNode *node.Node, config DaemonConfig) Context

type DaemonConfig

type DaemonConfig struct {
	ChainID                  string
	NodeID                   string
	NodeName                 string
	APIAddr                  string `mapstructure:"daemon_api_addr"`
	AliveThresholdBlocks     uint   `mapstructure:"daemon_alive_threshold"`
	DelMemberThresholdBlocks uint   `mapstructure:"daemon_del_member_threshold"`
}

func NewDaemonConfig added in v0.0.2

func NewDaemonConfig() *DaemonConfig

type DaemonEvent

type DaemonEvent types.Event

type DefaultContext

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

func (*DefaultContext) Debug

func (ctx *DefaultContext) Debug(msg string, keyvals ...interface{})

Info log info

func (*DefaultContext) Error

func (ctx *DefaultContext) Error(msg string, keyvals ...interface{})

Info log info

func (*DefaultContext) GetClient

func (ctx *DefaultContext) GetClient() types.Client

func (*DefaultContext) GetClusterState

func (ctx *DefaultContext) GetClusterState() ClusterState

func (*DefaultContext) GetConfig

func (ctx *DefaultContext) GetConfig() DaemonConfig

func (*DefaultContext) GetNodeID

func (ctx *DefaultContext) GetNodeID() string

func (*DefaultContext) GetTMConfig

func (ctx *DefaultContext) GetTMConfig() *cfg.Config

func (*DefaultContext) Info

func (ctx *DefaultContext) Info(msg string, keyvals ...interface{})

Info log info

func (*DefaultContext) LastBlockIndex

func (ctx *DefaultContext) LastBlockIndex() int64

func (*DefaultContext) LastBlockTime

func (ctx *DefaultContext) LastBlockTime() time.Time

func (*DefaultContext) SetClusterState

func (ctx *DefaultContext) SetClusterState(state ClusterState)

func (*DefaultContext) With

func (ctx *DefaultContext) With(keyvals ...interface{}) log.Logger

Info log info

Jump to

Keyboard shortcuts

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