Documentation ¶
Index ¶
- Variables
- func GetServiceTag(field reflect.StructField) string
- type API
- type CommonConfig
- type DrepApp
- type ExecuteContext
- func (econtext *ExecuteContext) AggerateFlags() ([]cli.Command, []cli.Flag)
- func (econtext *ExecuteContext) FlatConfig(phaseName string) error
- func (econtext *ExecuteContext) GetApis() []API
- func (econtext *ExecuteContext) GetConfig(phaseName string) json.RawMessage
- func (econtext *ExecuteContext) GetService(name string) Service
- func (econtext *ExecuteContext) RequireService(name string) Service
- func (econtext *ExecuteContext) UnmashalConfig(serviceName string, config interface{}) error
- type Option
- type OrService
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ConfigFileFlag general config file flag ConfigFileFlag = cli.StringFlag{ Name: "config", Usage: "add config description", } // HomeDirFlag general home directory flag HomeDirFlag = common.DirectoryFlag{ Name: "homedir", Usage: "Home directory for the datadir logdir and keystore", } // PprofFlag general pprof flag PprofFlag = cli.BoolFlag{ Name: "pprof", Usage: "ppfof for debug performance, --pprof = true", } TestNetFlag = cli.BoolFlag{ Name: "testnet", Usage: "start test net,default is mainnet, --testnet = true", } SoloNetFlag = cli.BoolFlag{ Name: "solonet", Usage: "start test net,default is mainnet, --testnet = true", } )
var ( // ErrNotMatchedService print error msg ErrNotMatchedService = errors.New("the service added not match service interface") // ErrConfigiNotFound print error msg ErrConfigiNotFound = errors.New("specify config file not exist") // ErrServiceNotFound print error msg ErrServiceNotFound = errors.New("Service not found") )
var ( TServiceService = reflect.TypeOf((*Service)(nil)).Elem() TOrService = reflect.TypeOf((*OrService)(nil)).Elem() )
var ( // CommandHelpTemplate general template of command 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"` ConfigFile string `json:"configFile,omitempty"` }
CommonConfig read before app run,this fuction shared by other moudles
type DrepApp ¶
type DrepApp struct { Context *ExecuteContext *cli.App // contains filtered or unexported fields }
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 (DrepApp) IncludeServices ¶
IncludeServices add many services
type ExecuteContext ¶
type ExecuteContext struct { NetConfigType params.NetType //mainnet testnet solonet ConfigPath string CommonConfig *CommonConfig PhaseConfig map[string]json.RawMessage Cli *cli.Context LifeBus EventBus.Bus Services []Service GitCommit string Usage string Quit chan struct{} }
ExecuteContext centralizes all the data and global parameters of application execution, and each service can read the part it needs.
func (*ExecuteContext) AggerateFlags ¶
func (econtext *ExecuteContext) AggerateFlags() ([]cli.Command, []cli.Flag)
AggerateFlags aggregate command configuration items required for each service
func (*ExecuteContext) FlatConfig ¶
func (econtext *ExecuteContext) FlatConfig(phaseName string) error
FlatConfig marshal json config to map
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) 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.
func (*ExecuteContext) UnmashalConfig ¶
func (econtext *ExecuteContext) UnmashalConfig(serviceName string, config interface{}) error
UnmashalConfig unmashal json config
type Service ¶
type Service interface { Name() string // service name must be unique Api() []API // Interfaces required for services CommandFlags() ([]cli.Command, []cli.Flag) // flags required for services //P2pMessages() map[int]interface{} //Receive(context actor.Context) Init(executeContext *ExecuteContext) error Start(executeContext *ExecuteContext) error Stop(executeContext *ExecuteContext) error }
Service can customize their own configuration, command parameters, interfaces, services