app

package
v0.0.0-...-7505a0c Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigFileFlag = cli.StringFlag{
		Name:  "config",
		Usage: "TODO add config description",
	}
	// General settings
	HomeDirFlag = common.DirectoryFlag{
		Name:  "homedir",
		Usage: "Home directory for the datadir logdir and keystore",
	}
)
View Source
var (
	CommandHelpTemplate = `` /* 471-byte string literal not displayed */

)

Functions

func GetServiceTag

func GetServiceTag(field reflect.StructField) string

GetServiceTag read service tag name to match service that has added in

Types

type API

type API struct {
	Namespace string      // namespace under which the rpc methods of Service are exposed
	Version   string      // api version for DApp's
	Service   interface{} // receiver instance which holds the methods
	Public    bool        // indication if the methods must be considered safe for public use
}

API describes the set of methods offered over the RPC interface

type CommonConfig

type CommonConfig struct {
	HomeDir string `json:"homeDir,omitempty"`
}

CommonConfig read before app run,this fuction shared by other moudles

type DrepApp

type DrepApp struct {
	Context *ExecuteContext
	*cli.App
}

DrepApp based on the cli.App, the module service operation is encapsulated. The purpose is to achieve the independence of each module and reduce dependencies as far as possible.

func NewApp

func NewApp() *DrepApp

NewApp create a new app

func (DrepApp) AddServiceType

func (mApp DrepApp) AddServiceType(serviceTypes ...reflect.Type) error

AddServiceType add many services

func (DrepApp) Run

func (mApp DrepApp) Run() error

Run read the global configuration, parse the global command parameters, initialize the main process one by one, and execute the service before the main process starts.

type ExecuteContext

type ExecuteContext struct {
	ConfigPath   string
	CommonConfig *CommonConfig //
	PhaseConfig  map[string]json.RawMessage
	CliContext   *cli.Context

	Services []Service

	GitCommit string
	Usage     string
}

ExecuteContext centralizes all the data and global parameters of application execution, and each service can read the part it needs.

func (*ExecuteContext) AddService

func (econtext *ExecuteContext) AddService(service Service)

AddService add a service to context, The application then initializes and starts the service.

func (*ExecuteContext) GetApis

func (econtext *ExecuteContext) GetApis() []API

GetApis aggregate interface functions for each service to provide for use by RPC services

func (*ExecuteContext) GetConfig

func (econtext *ExecuteContext) GetConfig(phaseName string) json.RawMessage

GetConfig Configuration is divided into several segments, each service only needs to obtain its own configuration data, and the parsing process is also controlled by each service itself.

func (*ExecuteContext) GetFlags

func (econtext *ExecuteContext) GetFlags() []cli.Flag

GetFlags aggregate command configuration items required for each service

func (*ExecuteContext) GetService

func (econtext *ExecuteContext) GetService(name string) Service

GetService In addition, there is a dependency relationship between services. This method is used to find the dependency services you need in the context.

func (*ExecuteContext) RequireService

func (econtext *ExecuteContext) RequireService(name string) Service

RequireService When a service depends on another service, RequireService is used to obtain the dependent service.

type Service

type Service interface {
	Name() string      // service  name must be unique
	Api() []API        // Interfaces required for services
	Flags() []cli.Flag // flags required for services

	Init(executeContext *ExecuteContext) error
	Start(executeContext *ExecuteContext) error
	Stop(executeContext *ExecuteContext) error
}

Services can customize their own configuration, command parameters, interfaces, services

Jump to

Keyboard shortcuts

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