node

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatadirUsed    = errors.New("datadir already used by another process")
	ErrNodeStopped    = errors.New("node not started")
	ErrNodeRunning    = errors.New("node already running")
	ErrServiceUnknown = errors.New("unknown service")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name refers the name of node's instance
	Name string

	// Version should be set to the version number of the program.
	Version string `toml:"-"`

	// DataDir is the root folder that store data and service-configs
	DataDir string `toml:",omitempty"`

	// HTTPHost is the host interface on which to start the HTTP RPC server.
	HTTPHost string `toml:",omitempty"`

	// HTTPPort is the TCP port number on which to start the HTTP RPC server.
	HTTPPort int `toml:",omitempty"`

	P2PPort          int      `toml:",omitempty"`
	P2PPortConsensus int      `toml:",omitempty"`
	P2PSeeds         []string `toml:",omitempty"`

	LogLevel string `toml:",omitempty"`

	// Logger is a custom logger
	Logger log.Logger `toml:"-"`

	Timer service_configs.TimerConfig

	GRPC service_configs.GRPCConfig

	Consensus service_configs.ConsensusConfig
}

func (*Config) NodeDB

func (c *Config) NodeDB() string

DB returns the path to the discovery database.

func (*Config) NodeName

func (c *Config) NodeName() string

GetName returns the node's complete name

func (*Config) ResolvePath

func (c *Config) ResolvePath(path string) string

ResolvePath resolves path in the instance directory.

type DuplicateServiceError

type DuplicateServiceError struct {
	//Kind reflect.Type
	Kind string
}

func (*DuplicateServiceError) Error

func (e *DuplicateServiceError) Error() string

type NamedServiceConstructor

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

type Node

type Node struct {
	MainLoop *eventloop.EventLoop
	EvBus    EventBus.Bus
	// contains filtered or unexported fields
}

Node is a container and manager of services

func New

func New(conf *Config) (*Node, error)

func (*Node) Register

func (n *Node) Register(name string, constructor ServiceConstructor) error

func (*Node) Restart

func (n *Node) Restart() error

func (*Node) Service

func (n *Node) Service(serviceName string) (interface{}, error)

func (*Node) Start

func (n *Node) Start() error

func (*Node) Stop

func (n *Node) Stop() error

func (*Node) Wait

func (n *Node) Wait()

type Service

type Service interface {
	Start(node *Node) error

	// stop all goroutines belonging to the service,
	// blocking until all of them are terminated.
	Stop() error
}

type ServiceConstructor

type ServiceConstructor func(ctx *ServiceContext) (Service, error)

type ServiceContext

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

func (*ServiceContext) Config

func (ctx *ServiceContext) Config() Config

func (*ServiceContext) ResolvePath

func (ctx *ServiceContext) ResolvePath(path string) string

func (*ServiceContext) Service

func (ctx *ServiceContext) Service(name string) (interface{}, error)

type StopError

type StopError struct {
	Server   error
	Services map[string]error
}

StopError is returned if a Node fails to stop either any of its registered services or itself.

type StopError struct {
	Server   error
	Services map[reflect.Type]error
}

func (*StopError) Error

func (e *StopError) Error() string

Error generates a textual representation of the stop error.

Jump to

Keyboard shortcuts

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