Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrCounfigNotFound(s any) error
- func NewErrDefaultServiceNotFound(t ServiceType) error
- func NewErrDisabled(target string) error
- func NewErrDisabledService(s Service) error
- func NewErrInvalid(target string) error
- func NewErrInvalidService(s Service) error
- func NewErrNotFound(target string) error
- func NewErrServiceNotFound(t ServiceType) error
- type Config
- type ConfigBase
- type Manager
- func (mgr *Manager) DefaultService(t ServiceType) (Service, error)
- func (mgr *Manager) EnabledServicesByType(t ServiceType) []Service
- func (mgr *Manager) RegisterService(service Service)
- func (mgr *Manager) ReloadServices(services []Service)
- func (mgr *Manager) Services() []Service
- func (mgr *Manager) ServicesByType(t ServiceType) []Service
- func (mgr *Manager) Start() error
- func (mgr Manager) Stop() error
- func (mgr *Manager) String() string
- type RootConfig
- type Service
- type ServiceConfig
- type ServiceExtConfig
- type ServiceType
- type ServiceTypeConfig
- type ServiceTypeExtConfig
Constants ¶
const ( ConfigTLS = "tls" ConfigPlugins = "plugins" ConfigDefault = "default" ConfigEnabled = "enabled" ConfigPort = "port" )
const (
// ExclusiveServiceType represents an exclusive service type.
ExclusiveServiceType = 0x80
)
Variables ¶
var ErrDisabled = errors.New("disabled")
var ErrInvalid = errors.New("invalid")
var ErrNotFound = errors.New("not found")
Functions ¶
func NewErrCounfigNotFound ¶ added in v1.0.0
func NewErrDefaultServiceNotFound ¶ added in v0.9.0
func NewErrDefaultServiceNotFound(t ServiceType) error
func NewErrDisabled ¶ added in v0.9.0
func NewErrDisabledService ¶ added in v0.9.0
func NewErrInvalid ¶ added in v0.9.0
func NewErrInvalidService ¶ added in v0.9.0
func NewErrNotFound ¶ added in v0.9.0
func NewErrServiceNotFound ¶ added in v0.9.0
func NewErrServiceNotFound(t ServiceType) error
Types ¶
type Config ¶ added in v0.9.0
type Config interface { ConfigBase RootConfig ServiceTypeConfig ServiceTypeExtConfig ServiceConfig ServiceExtConfig }
Config represents a plug-in configuration interface.
func NewConfigWith ¶ added in v1.0.0
type ConfigBase ¶ added in v1.0.0
type ConfigBase interface { config.Config // String returns a string representation of the configuration. SetConfig(c config.Config) // Object returns a raw configuration object. Object() config.Config }
ConfigBase represents a basic configuration interface.
type Manager ¶
type Manager struct { Config // contains filtered or unexported fields }
Manager represents a plug-in manager.
func (*Manager) DefaultService ¶ added in v0.9.0
func (mgr *Manager) DefaultService(t ServiceType) (Service, error)
DefaultService returns the default plug-in service with the specified type.
func (*Manager) EnabledServicesByType ¶ added in v0.9.0
func (mgr *Manager) EnabledServicesByType(t ServiceType) []Service
EnabledServicesByType returns all enabled plug-in services with the specified type.
func (*Manager) RegisterService ¶
RegisterService adds a plug-in service.
func (*Manager) ReloadServices ¶
ReloadServices reloads all plug-in services.
func (*Manager) ServicesByType ¶ added in v0.9.0
func (mgr *Manager) ServicesByType(t ServiceType) []Service
ServicesByType returns all registered plug-in services with the specified type.
type RootConfig ¶ added in v1.3.2
type RootConfig interface { // GetTLSConfig returns a TLS configuration. GetTLSConfig() (tls.Config, error) }
RootConfig represents a root configuration interface.
type Service ¶
type Service interface { // SetConfig sets the specified config. SetConfig(config config.Config) // ServiceType returns the service type. ServiceType() ServiceType // ServiceName returns the service name. ServiceName() string // Start starts the service Start() error // Stop stops the service Stop() error }
Service represents a plugin service.
type ServiceConfig ¶ added in v1.0.0
type ServiceConfig interface { // GetServiceConfig returns a value for the specified name in the service. GetServiceConfig(service Service, paths ...string) (any, error) // GetServiceConfigString returns a string value for the specified name in the service. GetServiceConfigString(service Service, paths ...string) (string, error) // GetServiceConfigInt returns an integer value for the specified name in the service. GetServiceConfigInt(service Service, paths ...string) (int, error) // GetServiceConfigBool returns a boolean value for the specified name in the service. GetServiceConfigBool(service Service, paths ...string) (bool, error) }
ServiceConfig represents a configuration interface for service.
type ServiceExtConfig ¶ added in v1.0.0
type ServiceExtConfig interface { // IsServiceConfigEnabled returns true if the service is enabled. IsServiceConfigEnabled(service Service) bool // GetServiceConfigPort returns a port number for the service. GetServiceConfigPort(service Service) (int, error) }
ServiceExtConfig represents an extension configuration interface for service.
type ServiceType ¶
type ServiceType uint8
ServiceType represents a service type.
const ( // SystemService represents a system service. SystemService ServiceType = 0x01 // CoderKeyService represents a serializer service for key. CoderKeyService ServiceType = 0x02 | ExclusiveServiceType // CoderDocumentService represents a serializer service for document. CoderDocumentService ServiceType = 0x03 | ExclusiveServiceType // QueryService represents a query service. QueryService ServiceType = 0x04 // StoreDocumentService represents a document store service. StoreDocumentService ServiceType = 0x05 | ExclusiveServiceType // StoreKvService represents a key-value store service. StoreKvService ServiceType = 0x06 | ExclusiveServiceType // StoreKvCacheService represents a key-value cache store service. StoreKvCacheService ServiceType = 0x07 | ExclusiveServiceType // CoordinatorService represents a coordinator service. CoordinatorService ServiceType = 0x08 | ExclusiveServiceType // TracingService represents a distributed tracing service. TracingService ServiceType = 0x09 | ExclusiveServiceType // MetricsService represents a metrics service. MetricsService ServiceType = 0x0A // AuthenticatorService represents an authenticator service. AuthenticatorService ServiceType = 0x0B // ExtendService represents an uncategorized service. ExtendService ServiceType = 0x0F )
func (ServiceType) IsExclusive ¶ added in v0.9.0
func (t ServiceType) IsExclusive() bool
IsExclusive returns true if the service type is exclusive.
func (ServiceType) String ¶
func (t ServiceType) String() string
String returns a string representation of the service type.
type ServiceTypeConfig ¶ added in v1.2.0
type ServiceTypeConfig interface { // GetServiceTypeConfig returns a value for the specified name in the service type. GetServiceTypeConfig(serviceType ServiceType, item string) (any, error) // GetServiceTypeConfigString returns a string value for the specified name in the service type. GetServiceTypeConfigString(serviceType ServiceType, item string) (string, error) // GetServiceTypeConfigInt returns an integer value for the specified name in the service type. GetServiceTypeConfigInt(serviceType ServiceType, item string) (int, error) // GetServiceTypeConfigBool returns a boolean value for the specified name in the service type. GetServiceTypeConfigBool(serviceType ServiceType, item string) (bool, error) }
ServiceTypeConfig represents a configuration interface for service type.
type ServiceTypeExtConfig ¶ added in v1.2.0
type ServiceTypeExtConfig interface { // IsServiceTypeConfigEnabled returns true if the service type is enabled. IsServiceTypeConfigEnabled(serviceType ServiceType) bool // GetServiceTypeConfigPort returns a port number for the service type. GetServiceTypeDefault(serviceType ServiceType) (string, error) }
ServiceTypeExtConfig represents an extension configuration interface for service type.