Documentation ¶
Index ¶
- Constants
- Variables
- func AddFlags(f *pflag.FlagSet)
- func AttrFrom(ctx context.Context) (map[interface{}]interface{}, bool)
- func AttrMustFrom(ctx context.Context) map[interface{}]interface{}
- func ConfigVar(fs *pflag.FlagSet, path string, sample interface{}, ...) error
- func Configer() configer.ParsedConfiger
- func Context() context.Context
- func Description() string
- func Init(cmd *cobra.Command, opts ...ProcessOption) error
- func Name() string
- func NamedFlagSets() *flag.NamedFlagSets
- func NewContext() context.Context
- func NewRootCmd(opts ...ProcessOption) *cobra.Command
- func Parse(fs *pflag.FlagSet, opts ...configer.ConfigerOption) (configer.ParsedConfiger, error)
- func PrintConfig(w io.Writer)
- func PrintErrln(err error) int
- func PrintFlags(fs *pflag.FlagSet, w io.Writer)
- func RegisterFlags(configPath, groupName string, sample interface{}, ...) error
- func RegisterHooks(in []HookOps) error
- func Shutdown() error
- func Start(fs *pflag.FlagSet) error
- func WgFrom(ctx context.Context) (*sync.WaitGroup, bool)
- func WgMustFrom(ctx context.Context) *sync.WaitGroup
- func WithAttr(ctx context.Context, attributes map[interface{}]interface{}) context.Context
- func WithHookOps(parent context.Context, ops *HookOps) context.Context
- func WithValue(parent context.Context, key interface{}, val interface{}) context.Context
- func WithWg(ctx context.Context, wg *sync.WaitGroup)
- type ConfigOps
- type HookFn
- type HookOps
- type Process
- func (p *Process) AddFlags(fs *pflag.FlagSet)
- func (p *Process) AddGlobalFlags()
- func (p *Process) BindRegisteredFlags(fs *pflag.FlagSet) error
- func (p *Process) ConfigVar(fs *pflag.FlagSet, path string, sample interface{}, ...) error
- func (p *Process) Context() context.Context
- func (p *Process) Description() string
- func (p *Process) Init(cmd *cobra.Command, opts ...ProcessOption) error
- func (p *Process) Name() string
- func (p *Process) NewRootCmd(opts ...ProcessOption) *cobra.Command
- func (p *Process) Parse(fs *pflag.FlagSet, opts ...configer.ConfigerOption) (configer.ParsedConfiger, error)
- func (p *Process) PrintConfig(out io.Writer)
- func (p *Process) PrintFlags(fs *pflag.FlagSet, w io.Writer)
- func (p *Process) RegisterFlags(configPath, groupName string, sample interface{}, ...) error
- func (p *Process) RegisterHooks(in []HookOps) error
- func (p *Process) Start(fs *pflag.FlagSet) error
- type ProcessAction
- type ProcessOption
- func WithConfigOptions(options ...configer.ConfigerOption) ProcessOption
- func WithContext(ctx context.Context) ProcessOption
- func WithDescription(description string) ProcessOption
- func WithName(name string) ProcessOption
- func WithWaitGroup(wg *sync.WaitGroup) ProcessOption
- func WithoutGroup() ProcessOption
- func WithoutLoop() ProcessOption
- type ProcessOptions
- type ProcessPriority
- type ProcessStatus
Constants ¶
View Source
const ( PRI_SYS_INIT uint16 // init & register each system.module PRI_SYS_PRESTART // prepare each system.module's depend PRI_MODULE // init each module PRI_SYS_START // start each system.module PRI_SYS_POSTSTART // no use )
Variables ¶
View Source
var ( DefaultProcess = NewProcess() ErrDryrun = errors.New("dry run") )
Functions ¶
func AttrMustFrom ¶
func Configer ¶ added in v0.0.2
func Configer() configer.ParsedConfiger
func Description ¶
func Description() string
func NamedFlagSets ¶
func NamedFlagSets() *flag.NamedFlagSets
func NewContext ¶
func NewRootCmd ¶
func NewRootCmd(opts ...ProcessOption) *cobra.Command
func Parse ¶ added in v0.0.2
func Parse(fs *pflag.FlagSet, opts ...configer.ConfigerOption) (configer.ParsedConfiger, error)
func PrintConfig ¶
func PrintErrln ¶ added in v0.0.2
func RegisterFlags ¶
func RegisterFlags(configPath, groupName string, sample interface{}, opts ...configer.ConfigFieldsOption) error
func RegisterHooks ¶
Types ¶
type ConfigOps ¶ added in v0.0.2
type ConfigOps struct {
// contains filtered or unexported fields
}
type HookOps ¶
type HookOps struct { Hook HookFn Owner string HookNum ProcessAction Priority uint16 SubPriority uint16 Data interface{} // contains filtered or unexported fields }
func (HookOps) Configer ¶
func (p HookOps) Configer() configer.ParsedConfiger
func (HookOps) ContextAndConfiger ¶
func (p HookOps) ContextAndConfiger() (context.Context, configer.ParsedConfiger)
func (HookOps) SetContext ¶
type Process ¶
type Process struct { *ProcessOptions // contains filtered or unexported fields }
func NewProcess ¶
func NewProcess(opts ...ProcessOption) *Process
func (*Process) AddGlobalFlags ¶ added in v0.0.2
func (p *Process) AddGlobalFlags()
func (*Process) BindRegisteredFlags ¶ added in v0.0.2
func (*Process) Description ¶
func (*Process) Init ¶ added in v0.0.2
func (p *Process) Init(cmd *cobra.Command, opts ...ProcessOption) error
Init set configer options alloc p.ctx validate config each module sort hook options
func (*Process) NewRootCmd ¶
func (p *Process) NewRootCmd(opts ...ProcessOption) *cobra.Command
with proc.Start
func (*Process) Parse ¶ added in v0.0.2
func (p *Process) Parse(fs *pflag.FlagSet, opts ...configer.ConfigerOption) (configer.ParsedConfiger, error)
func (*Process) PrintConfig ¶
func (*Process) RegisterFlags ¶ added in v0.0.2
func (p *Process) RegisterFlags(configPath, groupName string, sample interface{}, opts ...configer.ConfigFieldsOption) error
func (*Process) RegisterHooks ¶ added in v0.0.2
RegisterHooks register hookOps as a module
type ProcessAction ¶
type ProcessAction uint32
const ( ACTION_START ProcessAction = iota ACTION_RELOAD ACTION_STOP ACTION_SIZE )
func (ProcessAction) String ¶
func (p ProcessAction) String() string
type ProcessOption ¶
type ProcessOption func(*ProcessOptions)
func WithConfigOptions ¶
func WithConfigOptions(options ...configer.ConfigerOption) ProcessOption
func WithContext ¶
func WithContext(ctx context.Context) ProcessOption
func WithDescription ¶
func WithDescription(description string) ProcessOption
func WithName ¶
func WithName(name string) ProcessOption
func WithWaitGroup ¶
func WithWaitGroup(wg *sync.WaitGroup) ProcessOption
func WithoutGroup ¶
func WithoutGroup() ProcessOption
func WithoutLoop ¶
func WithoutLoop() ProcessOption
type ProcessOptions ¶
type ProcessOptions struct {
// contains filtered or unexported fields
}
type ProcessPriority ¶
type ProcessPriority uint32
func (ProcessPriority) String ¶
func (p ProcessPriority) String() string
type ProcessStatus ¶
type ProcessStatus uint32
const ( STATUS_INIT ProcessStatus = iota STATUS_PENDING STATUS_RUNNING STATUS_RELOADING STATUS_EXIT )
func (*ProcessStatus) Set ¶
func (p *ProcessStatus) Set(v ProcessStatus)
Click to show internal directories.
Click to hide internal directories.