Documentation ¶
Index ¶
- Constants
- type Builder
- type EventLogger
- func (el EventLogger) CO(event string, o zapcore.ObjectMarshaler, gtags gTags.Tags)
- func (el *EventLogger) Clone() *EventLogger
- func (el EventLogger) F(event string, fields ...zapcore.Field)
- func (el EventLogger) O(event string, o zapcore.ObjectMarshaler)
- func (el *EventLogger) SetTags(tags gTags.Tags) *EventLogger
- func (el EventLogger) Sync() error
- type Host
- type HostModule
- type KVMgr
- type Module
- type ModuleCloser
- type ModuleCustomizedRegister
- type ModuleDriver
- type ModuleMetaDataConfig
- type ModuleOption
- type ModuleProcesses
- type ModuleProvider
- type ModuleServer
- type Option
- type PreServeHook
- type ProcessHTTPHandler
- type ProcessHTTPPather
- type ProcessHandler
- type ProcessHandlerCreator
- type ProcessOption
- type ProcessType
- type Roles
- type Snowflake
- type Snowflake53
Constants ¶
View Source
const ( // snowflake type SnowflakeType_Default = 0 SnowflakeType_53 = 1 )
View Source
const (
InternalServerPathPrefix = "__internal/"
)
etcd prefix used internal by host
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func SetupModule ¶
func SetupModule(provider ModuleProvider, options ...ModuleOption) *Builder
func (*Builder) SetupModule ¶
func (b *Builder) SetupModule(provider ModuleProvider, options ...ModuleOption) *Builder
func (*Builder) WithOptions ¶
type EventLogger ¶
type EventLogger struct {
// contains filtered or unexported fields
}
EventLogger log event object
func (EventLogger) CO ¶
func (el EventLogger) CO(event string, o zapcore.ObjectMarshaler, gtags gTags.Tags)
CO stands for Object. same as O but add new param gTags.
func (*EventLogger) Clone ¶
func (el *EventLogger) Clone() *EventLogger
func (EventLogger) F ¶
func (el EventLogger) F(event string, fields ...zapcore.Field)
F stands for Field, it logs event object by listing event fields one by one
func (EventLogger) O ¶
func (el EventLogger) O(event string, o zapcore.ObjectMarshaler)
O stands for Object, it logs event object that implements zapcore.ObjectMarshaler interface
func (*EventLogger) SetTags ¶
func (el *EventLogger) SetTags(tags gTags.Tags) *EventLogger
func (EventLogger) Sync ¶
func (el EventLogger) Sync() error
type Host ¶
type Host interface { Name() string Logger() *zap.Logger EventLogger() *EventLogger ModuleConfig() env.ModuleConfig Serve() error RegisterModule(moduleName string, addr string, metaData interface{}) error GetConfigPath() string Metrics() prometheus.Registerer EtcdSession() *concurrency.Session KVManager() *KVMgr Snowflake(ctx context.Context, name string, tp uint32) (Snowflake, error) Tags() map[string]string Tracer(moduleName string) opentracing.Tracer // contains filtered or unexported methods }
type HostModule ¶
type HostModule interface { // GetHost return the host belong to GetHost() Host // GetModuleHandler return the module handler created during build GetModuleHandler() interface{} }
type KVMgr ¶
type KVMgr struct {
// contains filtered or unexported fields
}
func (*KVMgr) GetOrGenerate ¶
GetOrGenerate get key or generate key if key does not exist atomic
type ModuleCloser ¶
type ModuleCustomizedRegister ¶
type ModuleCustomizedRegister interface { // ModuleRegisterName return a string could be used to register path like "{hostName}/{ModuleRegisterName}" used in service discovery // if module don't provide this interface, it will use "{hostName}/{moduleName}" instead ModuleRegisterName() string }
type ModuleDriver ¶
type ModuleDriver interface { Host() Host HostName() string ModuleName() string ModuleConfig() env.ModuleConfig Logger() *zap.Logger EventLogger() *EventLogger Metrics() prometheus.Registerer Tracer() opentracing.Tracer }
type ModuleMetaDataConfig ¶
type ModuleMetaDataConfig interface {
// NewModuleMetadata to create a module config's metadata structure, will be used to unmarshal from config.yaml
NewModuleMetadata() interface{}
}
type ModuleOption ¶
type ModuleOption func(*moduleOptions)
func WithModuleName ¶
func WithModuleName(name string) ModuleOption
func WithName ¶
func WithName(name string) ModuleOption
func WithProcess ¶
func WithProcess(processType ProcessType, name string, pcf ProcessHandlerCreator) ModuleOption
WithProcess used to help add extra process to module
func WithRole ¶
func WithRole(role string) ModuleOption
type ModuleProcesses ¶
type ModuleProcesses interface {
SetProcessOptions(options []ProcessOption)
}
type ModuleProvider ¶
type ModuleProvider interface { DefaultName() string Create(ModuleDriver) (Module, error) }
ModuleProvider create Module from Host bot provide ModuleProvider other than Module so Module can be created lazily
func ModuleProviderFromFunc ¶
func ModuleProviderFromFunc(name string, cf func(ModuleDriver) (Module, error)) ModuleProvider
type ModuleServer ¶
type PreServeHook ¶
type ProcessHTTPHandler ¶
ProcessHTTPHandler is used to create http server
type ProcessHTTPPather ¶
type ProcessHTTPPather interface {
GetPaths() []string
}
ProcessHTTPPather is used to limit the metrics path outputs
type ProcessHandler ¶
type ProcessHandler interface { }
type ProcessHandlerCreator ¶
type ProcessHandlerCreator func(module ModuleDriver) (ProcessHandler, error)
type ProcessOption ¶
type ProcessOption struct { ProcessType ProcessType Name string Creator ProcessHandlerCreator }
type Snowflake53 ¶
type Snowflake53 struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.