Documentation
¶
Index ¶
- Constants
- Variables
- func Execute(app *App, args []string) error
- func ExecuteContext(ctx context.Context, app *App, args []string) error
- func LocalCapabilityAs[T any](registry *LocalCapabilityRegistry, name string) (T, bool)
- func MergeCapabilities(values []string, extra []string) []string
- func MergeCapabilitiesForService(serviceName string, values []string, extra []string) []string
- func NotifySignals() (<-chan os.Signal, func())
- func RegisterServiceProvider[T any](registry *ServiceRegistry[T], provider ServiceProvider[T]) error
- func RunAllProviders(ctx context.Context, app *App) error
- func RunProvider(ctx context.Context, app *App, name string) error
- func ServiceRuntimeCapabilityNames(serviceName string, capabilities []CapabilityContract) []string
- func StopOnSignal(ctx context.Context, app *App, signals <-chan os.Signal) <-chan error
- func ValidateDependencies(capabilities []Capability, providers []Provider) error
- func WrapServiceConfigError(serviceName string, serviceType string, configKey string, err error) error
- type Adapter
- type AdapterMetadata
- type App
- func (a *App) Adapter(name string) (Adapter, bool)
- func (a *App) Adapters() []Adapter
- func (a *App) AdaptersByType(adapterType string) []Adapter
- func (a *App) Capabilities() []Capability
- func (a *App) CapabilitiesByGroup(group string) []Capability
- func (a *App) CapabilitiesByScope(scope string) []Capability
- func (a *App) Capability(name string) (Capability, bool)
- func (a *App) CapabilityStatus(name string) Health
- func (a *App) CapabilityStatuses() []Health
- func (a *App) Command(name string) (Command, bool)
- func (a *App) Commands() []Command
- func (a *App) CommandsByGroup(group string) []Command
- func (a *App) Container() *Container
- func (a *App) Context() context.Context
- func (a *App) Dependencies() []DependencyMetadata
- func (a *App) Plugin(name string) (Plugin, bool)
- func (a *App) Plugins() []Plugin
- func (a *App) PluginsByGroup(group string) []Plugin
- func (a *App) Provider(name string) (Provider, bool)
- func (a *App) ProviderStatus(name string) Health
- func (a *App) ProviderStatuses() []Health
- func (a *App) Providers() []Provider
- func (a *App) ProvidersByGroup(group string) []Provider
- func (a *App) Register(providers ...ProviderContract) error
- func (a *App) RegisterAdapters(adapters ...Adapter) error
- func (a *App) RegisterCapabilities(capabilities ...CapabilityContract) error
- func (a *App) RegisterCommand(commands ...Command) error
- func (a *App) RegisterCommandAdapters(adapters ...CommandAdapter) error
- func (a *App) RegisterPlugins(plugins ...Plugin) error
- func (a *App) RegisterProviderAdapters(adapters ...ProviderAdapter) error
- func (a *App) Run(ctxs ...context.Context) error
- func (a *App) RunAllProviders(ctxs ...context.Context) error
- func (a *App) RunProvider(name string, ctxs ...context.Context) error
- func (a *App) Stop(ctx context.Context) error
- func (a *App) Use(capabilities ...CapabilityContract) error
- func (a *App) UseCapabilityAdapters(adapters ...CapabilityAdapter) error
- func (a *App) ValidateDependencies() error
- type Capability
- func NewCapability(name string, register func(app *App) error) Capability
- func NewCapabilityWithDependencies(name string, dependencies []Dependency, register func(app *App) error, ...) Capability
- func NewCapabilityWithMetadata(metadata CapabilityMetadata, register func(app *App) error, ...) Capability
- func NewCapabilityWithMetadataAndDependencies(metadata CapabilityMetadata, dependencies []Dependency, ...) Capability
- func NewCapabilityWithShutdown(name string, register func(app *App) error, ...) Capability
- func SortCapabilities(capabilities []Capability) ([]Capability, error)
- type CapabilityAdapter
- type CapabilityContract
- type CapabilityFunc
- type CapabilityMetadata
- type Command
- type CommandAdapter
- type CommandMetadata
- type Container
- type Dependency
- type DependencyMetadata
- type HTTPService
- type Health
- type Key
- type LocalCapability
- type LocalCapabilityRegistry
- func (r *LocalCapabilityRegistry) Add(capability LocalCapability)
- func (r *LocalCapabilityRegistry) AddName(name string)
- func (r *LocalCapabilityRegistry) Close() error
- func (r *LocalCapabilityRegistry) Get(name string) (any, bool)
- func (r *LocalCapabilityRegistry) Names() []string
- func (r *LocalCapabilityRegistry) Set(name string, instance any)
- type Plugin
- type PluginMetadata
- type Provider
- type ProviderAdapter
- type ProviderContract
- type ProviderMetadata
- type ProviderMode
- type Registry
- func (r *Registry) Adapter(name string) (Adapter, bool)
- func (r *Registry) Adapters() []Adapter
- func (r *Registry) AdaptersByType(adapterType string) []Adapter
- func (r *Registry) Capabilities() []Capability
- func (r *Registry) CapabilitiesByGroup(group string) []Capability
- func (r *Registry) CapabilitiesByScope(scope string) []Capability
- func (r *Registry) Capability(name string) (Capability, bool)
- func (r *Registry) Command(name string) (Command, bool)
- func (r *Registry) Commands() []Command
- func (r *Registry) CommandsByGroup(group string) []Command
- func (r *Registry) Plugin(name string) (Plugin, bool)
- func (r *Registry) Plugins() []Plugin
- func (r *Registry) PluginsByGroup(group string) []Plugin
- func (r *Registry) Provider(name string) (Provider, bool)
- func (r *Registry) Providers() []Provider
- func (r *Registry) ProvidersByGroup(group string) []Provider
- func (r *Registry) RegisterAdapters(adapters ...Adapter) error
- func (r *Registry) RegisterCapabilities(capabilities ...CapabilityContract) error
- func (r *Registry) RegisterCommands(commands ...Command) error
- func (r *Registry) RegisterPlugins(plugins ...Plugin) error
- func (r *Registry) RegisterProviders(providers ...ProviderContract) error
- type RuntimeCapabilityContext
- func NewRuntimeCapabilityContext[T any](configFile string, name string, serviceType string, configKey string, base T) RuntimeCapabilityContext[T]
- func NewRuntimeCapabilityContextWithBaseLoader[T any](configFile string, name string, serviceType string, configKey string, ...) RuntimeCapabilityContext[T]
- type RuntimeCapabilityInfo
- type RuntimeCapabilityProvider
- type Service
- type ServiceApp
- type ServiceBootstrap
- func (b *ServiceBootstrap[T]) App() *ServiceApp[T]
- func (b *ServiceBootstrap[T]) BuildService(configFile string, name string, serviceType string, base T) (Service, error)
- func (b *ServiceBootstrap[T]) BuildServiceWithCapabilities(configFile string, name string, serviceType string, base T, ...) (Service, error)
- func (b *ServiceBootstrap[T]) BuildServices(configFile string, base T) ([]Service, error)
- func (b *ServiceBootstrap[T]) LoadServiceSpecs(configFile string) (map[string]ServiceSpec, error)
- func (b *ServiceBootstrap[T]) RegisterProvider(provider ServiceProvider[T]) error
- func (b *ServiceBootstrap[T]) RegisterServiceDefinition(def ServiceDefinition[T])
- func (b *ServiceBootstrap[T]) Registry() *ServiceRegistry[T]
- func (b *ServiceBootstrap[T]) ResolveServiceConfigKey(configFile string, name string) (string, error)
- func (b *ServiceBootstrap[T]) ResolveServiceSpec(configFile string, name string) (ServiceSpec, error)
- func (b *ServiceBootstrap[T]) RuntimeCapabilitiesForService(ctx RuntimeCapabilityContext[T]) []CapabilityContract
- func (b *ServiceBootstrap[T]) Service(serviceType string) *ServiceBuilder[T]
- func (b *ServiceBootstrap[T]) ServiceDependenciesForType(serviceType string) []Dependency
- func (b *ServiceBootstrap[T]) ServiceGroupForType(serviceType string) string
- func (b *ServiceBootstrap[T]) ServiceKindForType(serviceType string) (ServiceKind, bool)
- type ServiceBuilder
- func (b *ServiceBuilder[T]) Dependencies(dependencies ...Dependency) *ServiceBuilder[T]
- func (b *ServiceBuilder[T]) Factory(factory ServiceFactory[T])
- func (b *ServiceBuilder[T]) FactoryContext(factory ServiceContextFactory[T])
- func (b *ServiceBuilder[T]) Group(group string) *ServiceBuilder[T]
- func (b *ServiceBuilder[T]) Kind(kind ServiceKind) *ServiceBuilder[T]
- func (b *ServiceBuilder[T]) OptionalCapabilities(names ...string) *ServiceBuilder[T]
- func (b *ServiceBuilder[T]) RequireCapabilities(names ...string) *ServiceBuilder[T]
- func (b *ServiceBuilder[T]) RuntimeCapabilities(factory ServiceRuntimeCapabilityFactory[T]) *ServiceBuilder[T]
- type ServiceCapabilityProvider
- type ServiceConfigError
- type ServiceContext
- type ServiceContextFactory
- type ServiceDefinition
- type ServiceFactory
- type ServiceInfo
- type ServiceInfoProvider
- type ServiceKind
- type ServiceProvider
- type ServiceProviderFunc
- type ServiceRegistered
- type ServiceRegistry
- func (r *ServiceRegistry[T]) BuildService(configFile string, name string, serviceType string, configKey string, base T) (Service, error)
- func (r *ServiceRegistry[T]) BuildServiceWithCapabilities(configFile string, name string, serviceType string, configKey string, base T, ...) (Service, error)
- func (r *ServiceRegistry[T]) BuildServices(configFile string, specs map[string]ServiceSpec, base T) ([]Service, error)
- func (r *ServiceRegistry[T]) RegisterServiceDefinition(def ServiceDefinition[T])
- func (r *ServiceRegistry[T]) RuntimeCapabilitiesForService(ctx RuntimeCapabilityContext[T]) []CapabilityContract
- func (r *ServiceRegistry[T]) ServiceDependencies(serviceType string) []Dependency
- func (r *ServiceRegistry[T]) ServiceGroup(serviceType string) string
- func (r *ServiceRegistry[T]) ServiceKind(serviceType string) (ServiceKind, bool)
- type ServiceRunOptions
- type ServiceRunner
- func (r *ServiceRunner[T]) Bootstrap() *ServiceBootstrap[T]
- func (r *ServiceRunner[T]) NewApp(options ServiceRunOptions) (*App, error)
- func (r *ServiceRunner[T]) RegisterProviders(providers ...ServiceProvider[T]) error
- func (r *ServiceRunner[T]) ResolveServiceType(configFile string, name string) (string, error)
- func (r *ServiceRunner[T]) SelectServices(options ServiceRunOptions) (ServiceSelection, error)
- type ServiceRunnerOptions
- type ServiceRuntimeCapabilityFactory
- type ServiceSelection
- type ServiceSelectionItem
- type ServiceSpec
- type ServiceSpecLoader
- type ServiceSpecResolver
- type Status
Constants ¶
View Source
const ( AdapterTypeCommand = "command" AdapterTypeCapability = "capability" AdapterTypeProvider = "provider" )
View Source
const ( CapabilityBootstrap = "bootstrap" CapabilityBootstrapError = "bootstrap.error" )
View Source
const ( GroupAPI = "api" GroupWorker = "worker" GroupSystem = "system" GroupInternal = "internal" )
View Source
const ( ScopeGlobal = "global" ScopeServiceLocal = "service_local" )
View Source
const DefaultStopTimeout = 10 * time.Second
Variables ¶
View Source
var ( ErrAdapterNil = errors.New("runtime: adapter is nil") ErrAdapterNameRequired = errors.New("runtime: adapter name is required") ErrAdapterTypeRequired = errors.New("runtime: adapter type is required") ErrAdapterTypeUnsupported = errors.New("runtime: adapter type is unsupported") ErrAdapterNameDuplicate = errors.New("runtime: adapter name is duplicate") ErrAdapterNotFound = errors.New("runtime: adapter not found") )
View Source
var ( ErrCapabilityNil = errors.New("runtime: capability is nil") ErrCapabilityNameRequired = errors.New("runtime: capability name is required") ErrCapabilityNameReserved = errors.New("runtime: capability name is reserved") ErrCapabilityNameDuplicate = errors.New("runtime: capability name is duplicate") ErrCapabilityNotFound = errors.New("runtime: capability not found") )
View Source
var ( ErrCommandNil = errors.New("runtime: command is nil") ErrCommandNameRequired = errors.New("runtime: command name is required") ErrCommandNameReserved = errors.New("runtime: command name is reserved") ErrCommandNameDuplicate = errors.New("runtime: command name is duplicate") ErrCommandNotFound = errors.New("runtime: command not found") )
View Source
var ( ErrContainerNil = errors.New("runtime: container is nil") ErrContainerKeyRequired = errors.New("runtime: container key is required") ErrContainerValueNil = errors.New("runtime: container value is nil") )
View Source
var ( ErrDependencyNameRequired = errors.New("runtime: dependency name is required") ErrDependencyMissing = errors.New("runtime: dependency is missing") ErrDependencyDuplicate = errors.New("runtime: dependency is duplicate") ErrDependencyCycle = errors.New("runtime: dependency cycle detected") )
View Source
var ( ErrPluginNil = errors.New("runtime: plugin is nil") ErrPluginNameRequired = errors.New("runtime: plugin name is required") ErrPluginNameReserved = errors.New("runtime: plugin name is reserved") ErrPluginNameDuplicate = errors.New("runtime: plugin name is duplicate") ErrPluginNotFound = errors.New("runtime: plugin not found") )
View Source
var ( ErrProviderNil = errors.New("runtime: provider is nil") ErrProviderNameRequired = errors.New("runtime: provider name is required") ErrProviderNameReserved = errors.New("runtime: provider name is reserved") ErrProviderNameDuplicate = errors.New("runtime: provider name is duplicate") ErrProviderNotFound = errors.New("runtime: provider not found") ErrProviderServiceExited = errors.New("runtime: service provider exited before runtime stopped") )
View Source
var ErrAppNil = errors.New("runtime: app is nil")
View Source
var ErrRegistryNil = errors.New("runtime: registry is nil")
View Source
var ErrServiceSpecLoaderRequired = errors.New("runtime: service specs loader is required")
Functions ¶
func LocalCapabilityAs ¶
func LocalCapabilityAs[T any](registry *LocalCapabilityRegistry, name string) (T, bool)
func MergeCapabilities ¶
func NotifySignals ¶
func RegisterServiceProvider ¶
func RegisterServiceProvider[T any](registry *ServiceRegistry[T], provider ServiceProvider[T]) error
func ServiceRuntimeCapabilityNames ¶ added in v0.1.4
func ServiceRuntimeCapabilityNames(serviceName string, capabilities []CapabilityContract) []string
func StopOnSignal ¶
func ValidateDependencies ¶
func ValidateDependencies(capabilities []Capability, providers []Provider) error
Types ¶
type Adapter ¶
type Adapter interface {
AdapterMetadata() AdapterMetadata
}
type AdapterMetadata ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) AdaptersByType ¶
func (*App) Capabilities ¶
func (a *App) Capabilities() []Capability
func (*App) CapabilitiesByGroup ¶
func (a *App) CapabilitiesByGroup(group string) []Capability
func (*App) CapabilitiesByScope ¶
func (a *App) CapabilitiesByScope(scope string) []Capability
func (*App) Capability ¶
func (a *App) Capability(name string) (Capability, bool)
func (*App) CapabilityStatus ¶
func (*App) CapabilityStatuses ¶
func (*App) CommandsByGroup ¶
func (*App) Dependencies ¶
func (a *App) Dependencies() []DependencyMetadata
func (*App) PluginsByGroup ¶
func (*App) ProviderStatus ¶
func (*App) ProviderStatuses ¶
func (*App) ProvidersByGroup ¶
func (*App) Register ¶
func (a *App) Register(providers ...ProviderContract) error
func (*App) RegisterAdapters ¶
func (*App) RegisterCapabilities ¶
func (a *App) RegisterCapabilities(capabilities ...CapabilityContract) error
func (*App) RegisterCommand ¶
func (*App) RegisterCommandAdapters ¶
func (a *App) RegisterCommandAdapters(adapters ...CommandAdapter) error
func (*App) RegisterPlugins ¶
func (*App) RegisterProviderAdapters ¶
func (a *App) RegisterProviderAdapters(adapters ...ProviderAdapter) error
func (*App) Use ¶
func (a *App) Use(capabilities ...CapabilityContract) error
func (*App) UseCapabilityAdapters ¶
func (a *App) UseCapabilityAdapters(adapters ...CapabilityAdapter) error
func (*App) ValidateDependencies ¶
type Capability ¶
type Capability interface {
CapabilityContract
Status() Status
}
func NewCapability ¶
func NewCapability(name string, register func(app *App) error) Capability
func NewCapabilityWithDependencies ¶
func NewCapabilityWithDependencies(name string, dependencies []Dependency, register func(app *App) error, shutdown func(ctx context.Context) error) Capability
func NewCapabilityWithMetadata ¶
func NewCapabilityWithMetadata(metadata CapabilityMetadata, register func(app *App) error, shutdown func(ctx context.Context) error) Capability
func NewCapabilityWithMetadataAndDependencies ¶
func NewCapabilityWithMetadataAndDependencies(metadata CapabilityMetadata, dependencies []Dependency, register func(app *App) error, shutdown func(ctx context.Context) error) Capability
func SortCapabilities ¶
func SortCapabilities(capabilities []Capability) ([]Capability, error)
type CapabilityAdapter ¶
type CapabilityAdapter interface {
Adapter
Capability() CapabilityContract
}
func NewCapabilityAdapter ¶
func NewCapabilityAdapter(metadata AdapterMetadata, capability CapabilityContract) CapabilityAdapter
type CapabilityContract ¶
type CapabilityContract interface {
Name() string
Metadata() CapabilityMetadata
Dependencies() []Dependency
Register(app *App) error
Shutdown(ctx context.Context) error
}
type CapabilityFunc ¶
func (CapabilityFunc) Dependencies ¶
func (f CapabilityFunc) Dependencies() []Dependency
func (CapabilityFunc) Metadata ¶
func (f CapabilityFunc) Metadata() CapabilityMetadata
func (CapabilityFunc) Name ¶
func (f CapabilityFunc) Name() string
func (CapabilityFunc) Register ¶
func (f CapabilityFunc) Register(app *App) error
func (CapabilityFunc) Status ¶
func (f CapabilityFunc) Status() Status
type CapabilityMetadata ¶
type Command ¶
type Command interface {
Name() string
Metadata() CommandMetadata
Run(ctx context.Context, app *App, args []string) error
}
func NewRunCommand ¶ added in v0.1.4
func NewRunCommand() Command
func NewServeCommand ¶ added in v0.1.4
func NewServeCommand() Command
type CommandAdapter ¶
func NewCommandAdapter ¶
func NewCommandAdapter(metadata AdapterMetadata, command Command) CommandAdapter
type CommandMetadata ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func NewContainer ¶
func NewContainer() *Container
type Dependency ¶
func Optional ¶
func Optional(name string) Dependency
func OptionalBootstrap ¶ added in v0.1.4
func OptionalBootstrap() Dependency
func OptionalCapabilities ¶
func OptionalCapabilities(names ...string) []Dependency
func Require ¶
func Require(name string) Dependency
func RequireBootstrap ¶ added in v0.1.4
func RequireBootstrap() Dependency
func RequireCapabilities ¶
func RequireCapabilities(names ...string) []Dependency
type DependencyMetadata ¶
type HTTPService ¶
type HTTPService struct {
InfoValue ServiceInfo
StartFunc func() error
StopFunc func(context.Context) error
}
func (HTTPService) ServiceInfo ¶
func (s HTTPService) ServiceInfo() ServiceInfo
type LocalCapability ¶
type LocalCapability interface {
Name() string
}
type LocalCapabilityRegistry ¶
type LocalCapabilityRegistry struct {
// contains filtered or unexported fields
}
func NewLocalCapabilityRegistry ¶
func NewLocalCapabilityRegistry() *LocalCapabilityRegistry
func (*LocalCapabilityRegistry) Add ¶
func (r *LocalCapabilityRegistry) Add(capability LocalCapability)
func (*LocalCapabilityRegistry) AddName ¶
func (r *LocalCapabilityRegistry) AddName(name string)
func (*LocalCapabilityRegistry) Close ¶
func (r *LocalCapabilityRegistry) Close() error
func (*LocalCapabilityRegistry) Get ¶
func (r *LocalCapabilityRegistry) Get(name string) (any, bool)
func (*LocalCapabilityRegistry) Names ¶
func (r *LocalCapabilityRegistry) Names() []string
func (*LocalCapabilityRegistry) Set ¶
func (r *LocalCapabilityRegistry) Set(name string, instance any)
type Plugin ¶
type Plugin interface {
Metadata() PluginMetadata
}
func NewPlugin ¶
func NewPlugin(metadata PluginMetadata) Plugin
type PluginMetadata ¶
type Provider ¶
type Provider interface {
ProviderContract
Status() Status
}
func SortProviders ¶
func SortProviders(providers []Provider, capabilities []Capability) ([]Provider, error)
type ProviderAdapter ¶
type ProviderAdapter interface {
Adapter
Provider() ProviderContract
}
func NewProviderAdapter ¶
func NewProviderAdapter(metadata AdapterMetadata, provider ProviderContract) ProviderAdapter
type ProviderContract ¶
type ProviderMetadata ¶
type ProviderMetadata struct {
Name string
Description string
Group string
Internal bool
Mode ProviderMode
}
type ProviderMode ¶
type ProviderMode string
const ( ProviderModeService ProviderMode = "service" ProviderModeJob ProviderMode = "job" )
func ProviderModeOf ¶
func ProviderModeOf(provider ProviderContract) ProviderMode
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) AdaptersByType ¶
func (*Registry) Capabilities ¶
func (r *Registry) Capabilities() []Capability
func (*Registry) CapabilitiesByGroup ¶
func (r *Registry) CapabilitiesByGroup(group string) []Capability
func (*Registry) CapabilitiesByScope ¶
func (r *Registry) CapabilitiesByScope(scope string) []Capability
func (*Registry) Capability ¶
func (r *Registry) Capability(name string) (Capability, bool)
func (*Registry) CommandsByGroup ¶
func (*Registry) PluginsByGroup ¶
func (*Registry) ProvidersByGroup ¶
func (*Registry) RegisterAdapters ¶
func (*Registry) RegisterCapabilities ¶
func (r *Registry) RegisterCapabilities(capabilities ...CapabilityContract) error
func (*Registry) RegisterCommands ¶
func (*Registry) RegisterPlugins ¶
func (*Registry) RegisterProviders ¶
func (r *Registry) RegisterProviders(providers ...ProviderContract) error
type RuntimeCapabilityContext ¶
type RuntimeCapabilityContext[T any] struct { ConfigFile string Name string Type string ConfigKey string Base T // contains filtered or unexported fields }
func (RuntimeCapabilityContext[T]) BaseConfig ¶
func (ctx RuntimeCapabilityContext[T]) BaseConfig() T
func (RuntimeCapabilityContext[T]) LocalName ¶
func (ctx RuntimeCapabilityContext[T]) LocalName(name string) string
type RuntimeCapabilityInfo ¶
func RuntimeCapabilityInfoFor ¶ added in v0.1.4
func RuntimeCapabilityInfoFor(capability CapabilityContract) (RuntimeCapabilityInfo, bool)
func RuntimeCapabilityInfos ¶ added in v0.1.4
func RuntimeCapabilityInfos(app *App) []RuntimeCapabilityInfo
type RuntimeCapabilityProvider ¶
type RuntimeCapabilityProvider interface {
RuntimeCapabilities() []CapabilityContract
}
type ServiceApp ¶
type ServiceApp[T any] struct { // contains filtered or unexported fields }
func NewServiceApp ¶
func NewServiceApp[T any](registry *ServiceRegistry[T]) *ServiceApp[T]
func (*ServiceApp[T]) Service ¶
func (a *ServiceApp[T]) Service(serviceType string) *ServiceBuilder[T]
type ServiceBootstrap ¶ added in v0.1.4
type ServiceBootstrap[T any] struct { // contains filtered or unexported fields }
func NewServiceBootstrap ¶ added in v0.1.4
func NewServiceBootstrap[T any](loadSpecs ServiceSpecLoader) *ServiceBootstrap[T]
func NewServiceBootstrapWithResolver ¶ added in v0.1.4
func NewServiceBootstrapWithResolver[T any](loadSpecs ServiceSpecLoader, resolveSpec ServiceSpecResolver) *ServiceBootstrap[T]
func (*ServiceBootstrap[T]) App ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) App() *ServiceApp[T]
func (*ServiceBootstrap[T]) BuildService ¶ added in v0.1.4
func (*ServiceBootstrap[T]) BuildServiceWithCapabilities ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) BuildServiceWithCapabilities(configFile string, name string, serviceType string, base T, capabilities *LocalCapabilityRegistry) (Service, error)
func (*ServiceBootstrap[T]) BuildServices ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) BuildServices(configFile string, base T) ([]Service, error)
func (*ServiceBootstrap[T]) LoadServiceSpecs ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) LoadServiceSpecs(configFile string) (map[string]ServiceSpec, error)
func (*ServiceBootstrap[T]) RegisterProvider ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) RegisterProvider(provider ServiceProvider[T]) error
func (*ServiceBootstrap[T]) RegisterServiceDefinition ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) RegisterServiceDefinition(def ServiceDefinition[T])
func (*ServiceBootstrap[T]) Registry ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) Registry() *ServiceRegistry[T]
func (*ServiceBootstrap[T]) ResolveServiceConfigKey ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) ResolveServiceConfigKey(configFile string, name string) (string, error)
func (*ServiceBootstrap[T]) ResolveServiceSpec ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) ResolveServiceSpec(configFile string, name string) (ServiceSpec, error)
func (*ServiceBootstrap[T]) RuntimeCapabilitiesForService ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) RuntimeCapabilitiesForService(ctx RuntimeCapabilityContext[T]) []CapabilityContract
func (*ServiceBootstrap[T]) Service ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) Service(serviceType string) *ServiceBuilder[T]
func (*ServiceBootstrap[T]) ServiceDependenciesForType ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) ServiceDependenciesForType(serviceType string) []Dependency
func (*ServiceBootstrap[T]) ServiceGroupForType ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) ServiceGroupForType(serviceType string) string
func (*ServiceBootstrap[T]) ServiceKindForType ¶ added in v0.1.4
func (b *ServiceBootstrap[T]) ServiceKindForType(serviceType string) (ServiceKind, bool)
type ServiceBuilder ¶
type ServiceBuilder[T any] struct { // contains filtered or unexported fields }
func (*ServiceBuilder[T]) Dependencies ¶ added in v0.1.4
func (b *ServiceBuilder[T]) Dependencies(dependencies ...Dependency) *ServiceBuilder[T]
func (*ServiceBuilder[T]) Factory ¶
func (b *ServiceBuilder[T]) Factory(factory ServiceFactory[T])
func (*ServiceBuilder[T]) FactoryContext ¶
func (b *ServiceBuilder[T]) FactoryContext(factory ServiceContextFactory[T])
func (*ServiceBuilder[T]) Group ¶ added in v0.1.4
func (b *ServiceBuilder[T]) Group(group string) *ServiceBuilder[T]
func (*ServiceBuilder[T]) Kind ¶
func (b *ServiceBuilder[T]) Kind(kind ServiceKind) *ServiceBuilder[T]
func (*ServiceBuilder[T]) OptionalCapabilities ¶ added in v0.1.4
func (b *ServiceBuilder[T]) OptionalCapabilities(names ...string) *ServiceBuilder[T]
func (*ServiceBuilder[T]) RequireCapabilities ¶ added in v0.1.4
func (b *ServiceBuilder[T]) RequireCapabilities(names ...string) *ServiceBuilder[T]
func (*ServiceBuilder[T]) RuntimeCapabilities ¶
func (b *ServiceBuilder[T]) RuntimeCapabilities(factory ServiceRuntimeCapabilityFactory[T]) *ServiceBuilder[T]
type ServiceCapabilityProvider ¶
type ServiceCapabilityProvider interface {
Capabilities() []LocalCapability
}
type ServiceConfigError ¶
func (ServiceConfigError) Error ¶
func (e ServiceConfigError) Error() string
func (ServiceConfigError) Unwrap ¶
func (e ServiceConfigError) Unwrap() error
type ServiceContext ¶
type ServiceContext[T any] struct { ConfigFile string Name string Type string ConfigKey string Base T Capabilities *LocalCapabilityRegistry }
func EnsureServiceContext ¶
func EnsureServiceContext[T any](ctx *ServiceContext[T], name string, serviceType string, base T) *ServiceContext[T]
func NewServiceContext ¶
func NewServiceContext[T any](name string, serviceType string, base T) *ServiceContext[T]
func (*ServiceContext[T]) CapabilityLocalFirst ¶
func (ctx *ServiceContext[T]) CapabilityLocalFirst(name string) (any, bool)
func (*ServiceContext[T]) CloseCapabilities ¶
func (ctx *ServiceContext[T]) CloseCapabilities() error
type ServiceContextFactory ¶
type ServiceContextFactory[T any] func(ctx ServiceContext[T]) (Service, error)
type ServiceDefinition ¶
type ServiceDefinition[T any] struct { Type string Kind ServiceKind Group string Dependencies []Dependency Factory ServiceFactory[T] ContextFactory ServiceContextFactory[T] RuntimeCapabilityFactory ServiceRuntimeCapabilityFactory[T] }
type ServiceFactory ¶
type ServiceInfo ¶
type ServiceInfoProvider ¶
type ServiceInfoProvider interface {
ServiceInfo() ServiceInfo
}
type ServiceKind ¶
type ServiceKind string
const ( ServiceKindHTTP ServiceKind = "http" ServiceKindQueue ServiceKind = "queue" ServiceKindCLI ServiceKind = "cli" )
type ServiceProvider ¶
type ServiceProvider[T any] interface { Register(app *ServiceApp[T]) error }
type ServiceProviderFunc ¶
type ServiceProviderFunc[T any] func(app *ServiceApp[T]) error
func (ServiceProviderFunc[T]) Register ¶
func (fn ServiceProviderFunc[T]) Register(app *ServiceApp[T]) error
type ServiceRegistered ¶ added in v0.1.4
type ServiceRegistered[T any] struct { App *App Base T Service Service ServiceInfo ServiceInfo Capabilities []RuntimeCapabilityInfo Selection ServiceSelectionItem }
type ServiceRegistry ¶
type ServiceRegistry[T any] struct { // contains filtered or unexported fields }
func NewServiceRegistry ¶
func NewServiceRegistry[T any]() *ServiceRegistry[T]
func (*ServiceRegistry[T]) BuildService ¶
func (*ServiceRegistry[T]) BuildServiceWithCapabilities ¶
func (r *ServiceRegistry[T]) BuildServiceWithCapabilities(configFile string, name string, serviceType string, configKey string, base T, capabilities *LocalCapabilityRegistry) (Service, error)
func (*ServiceRegistry[T]) BuildServices ¶
func (r *ServiceRegistry[T]) BuildServices(configFile string, specs map[string]ServiceSpec, base T) ([]Service, error)
func (*ServiceRegistry[T]) RegisterServiceDefinition ¶
func (r *ServiceRegistry[T]) RegisterServiceDefinition(def ServiceDefinition[T])
func (*ServiceRegistry[T]) RuntimeCapabilitiesForService ¶
func (r *ServiceRegistry[T]) RuntimeCapabilitiesForService(ctx RuntimeCapabilityContext[T]) []CapabilityContract
func (*ServiceRegistry[T]) ServiceDependencies ¶ added in v0.1.4
func (r *ServiceRegistry[T]) ServiceDependencies(serviceType string) []Dependency
func (*ServiceRegistry[T]) ServiceGroup ¶ added in v0.1.4
func (r *ServiceRegistry[T]) ServiceGroup(serviceType string) string
func (*ServiceRegistry[T]) ServiceKind ¶
func (r *ServiceRegistry[T]) ServiceKind(serviceType string) (ServiceKind, bool)
type ServiceRunOptions ¶ added in v0.1.4
type ServiceRunner ¶ added in v0.1.4
type ServiceRunner[T any] struct { // contains filtered or unexported fields }
func NewServiceRunner ¶ added in v0.1.4
func NewServiceRunner[T any](options ServiceRunnerOptions[T]) *ServiceRunner[T]
func (*ServiceRunner[T]) Bootstrap ¶ added in v0.1.4
func (r *ServiceRunner[T]) Bootstrap() *ServiceBootstrap[T]
func (*ServiceRunner[T]) NewApp ¶ added in v0.1.4
func (r *ServiceRunner[T]) NewApp(options ServiceRunOptions) (*App, error)
func (*ServiceRunner[T]) RegisterProviders ¶ added in v0.1.4
func (r *ServiceRunner[T]) RegisterProviders(providers ...ServiceProvider[T]) error
func (*ServiceRunner[T]) ResolveServiceType ¶ added in v0.1.4
func (r *ServiceRunner[T]) ResolveServiceType(configFile string, name string) (string, error)
func (*ServiceRunner[T]) SelectServices ¶ added in v0.1.4
func (r *ServiceRunner[T]) SelectServices(options ServiceRunOptions) (ServiceSelection, error)
type ServiceRunnerOptions ¶ added in v0.1.4
type ServiceRunnerOptions[T any] struct { Bootstrap *ServiceBootstrap[T] LoadSpecs ServiceSpecLoader ResolveSpec ServiceSpecResolver Providers []ServiceProvider[T] Capabilities func(ServiceSelection) []CapabilityContract BaseConfig func() T Dependencies func(ServiceSelectionItem) []Dependency Group func(ServiceSelectionItem) string CapabilityRegistry func(*App) *LocalCapabilityRegistry CapabilityInfos func(*App) []RuntimeCapabilityInfo NormalizeType func(string) string AllowService func(ServiceSelectionItem) bool OnServiceRegistered func(ServiceRegistered[T]) }
type ServiceRuntimeCapabilityFactory ¶
type ServiceRuntimeCapabilityFactory[T any] func(ctx RuntimeCapabilityContext[T]) []CapabilityContract
type ServiceSelection ¶ added in v0.1.4
type ServiceSelection struct {
ConfigFile string
Services []ServiceSelectionItem
}
type ServiceSelectionItem ¶ added in v0.1.4
type ServiceSelectionItem struct {
ConfigFile string
Name string
Type string
ConfigKey string
Kind ServiceKind
Group string
Dependencies []Dependency
Spec ServiceSpec
Explicit bool
}
type ServiceSpec ¶
type ServiceSpec struct {
Type string `mapstructure:"type" yaml:"type"`
Enabled *bool `mapstructure:"enabled" yaml:"enabled"`
ConfigKey string `mapstructure:"config_key" yaml:"config_key"`
}
func (ServiceSpec) ResolveConfigKey ¶
func (s ServiceSpec) ResolveConfigKey(name string) string
type ServiceSpecLoader ¶ added in v0.1.4
type ServiceSpecLoader func(configFile string) (map[string]ServiceSpec, error)
type ServiceSpecResolver ¶ added in v0.1.4
type ServiceSpecResolver func(configFile string, name string) (ServiceSpec, error)
Source Files
¶
- adapter.go
- app.go
- bootstrap.go
- capability.go
- command.go
- container.go
- default_command.go
- dependency.go
- execute.go
- lifecycle.go
- local_capability.go
- metadata.go
- plugin.go
- provider.go
- provider_capability.go
- registry.go
- service.go
- service_bootstrap.go
- service_context.go
- service_provider.go
- service_runner.go
- service_runtime_capability.go
- signal.go
- status.go
Click to show internal directories.
Click to hide internal directories.