plugins

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigTLS     = "tls"
	ConfigPlugins = "plugins"
	ConfigDefault = "default"
	ConfigEnabled = "enabled"
	ConfigPort    = "port"
)
View Source
const (
	// ExclusiveServiceType represents an exclusive service type.
	ExclusiveServiceType = 0x80
)

Variables

View Source
var ErrDisabled = errors.New("disabled")
View Source
var ErrInvalid = errors.New("invalid")
View Source
var ErrNotFound = errors.New("not found")

Functions

func NewErrCounfigNotFound added in v1.0.0

func NewErrCounfigNotFound(s any) error

func NewErrDefaultServiceNotFound added in v0.9.0

func NewErrDefaultServiceNotFound(t ServiceType) error

func NewErrDisabled added in v0.9.0

func NewErrDisabled(target string) error

func NewErrDisabledService added in v0.9.0

func NewErrDisabledService(s Service) error

func NewErrInvalid added in v0.9.0

func NewErrInvalid(target string) error

func NewErrInvalidService added in v0.9.0

func NewErrInvalidService(s Service) error

func NewErrNotFound added in v0.9.0

func NewErrNotFound(target string) error

func NewErrServiceNotFound added in v0.9.0

func NewErrServiceNotFound(t ServiceType) error

Types

type Config added in v0.9.0

Config represents a plug-in configuration interface.

func NewConfig added in v1.0.0

func NewConfig() Config

func NewConfigWith added in v1.0.0

func NewConfigWith(conf config.Config) Config

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 NewManager

func NewManager() *Manager

NewManager returns a plug-in manager instance.

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

func (mgr *Manager) RegisterService(service Service)

RegisterService adds a plug-in service.

func (*Manager) ReloadServices

func (mgr *Manager) ReloadServices(services []Service)

ReloadServices reloads all plug-in services.

func (*Manager) Services added in v0.9.0

func (mgr *Manager) Services() []Service

Services returns all registered 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.

func (*Manager) Start

func (mgr *Manager) Start() error

Start starts all plug-in services.

func (Manager) Stop

func (mgr Manager) Stop() error

Stop stops all plug-in services.

func (*Manager) String

func (mgr *Manager) String() string

String returns a string representation of the plug-in manager.

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 ServiceTypes

func ServiceTypes() []ServiceType

ServiceTypes returns all service types.

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.

Directories

Path Synopsis
coder
key
mysql
nolint:gocognit
nolint:gocognit
sql
nolint:gocognit
nolint:gocognit
kv
system
ot

Jump to

Keyboard shortcuts

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