Documentation
¶
Overview ¶
Package ossvc contains abstractions and utilities for platform-independent service management.
TODO(e.burkov): Add tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
// Name returns the name of the action.
Name() (name ActionName)
// contains filtered or unexported methods
}
Action is the interface for actions that can be performed by Manager.
type ActionInstall ¶
type ActionInstall struct {
// ServiceConf is the configuration for the service to control.
//
// TODO(e.burkov): Get rid of github.com/kardianos/service dependency and
// replace with the actual configuration.
ServiceConf *service.Config
}
ActionInstall is the implementation of the Action interface.
func (*ActionInstall) Name ¶
func (a *ActionInstall) Name() (name ActionName)
Name implements the Action interface for *ActionInstall.
type ActionName ¶
type ActionName string
ActionName is the type for actions' names. It has the following valid values:
const ( ActionNameInstall ActionName = "install" ActionNameReload ActionName = "reload" ActionNameStart ActionName = "start" ActionNameStop ActionName = "stop" ActionNameUninstall ActionName = "uninstall" )
type ActionReload ¶
type ActionReload struct {
// ServiceConf is the configuration for the service to control.
//
// TODO(e.burkov): Get rid of github.com/kardianos/service dependency and
// replace with the actual configuration.
ServiceConf *service.Config
}
ActionReload is the implementation of the Action interface.
func (*ActionReload) Name ¶
func (a *ActionReload) Name() (name ActionName)
Name implements the Action interface for *ActionReload.
type ActionStart ¶
type ActionStart struct {
// ServiceConf is the configuration for the service to control.
//
// TODO(e.burkov): Get rid of github.com/kardianos/service dependency and
// replace with the actual configuration.
ServiceConf *service.Config
}
ActionStart is the implementation of the Action interface.
func (*ActionStart) Name ¶
func (a *ActionStart) Name() (name ActionName)
Name implements the Action interface for *ActionStart.
type ActionStop ¶
type ActionStop struct {
// ServiceConf is the configuration for the service to control.
//
// TODO(e.burkov): Get rid of github.com/kardianos/service dependency and
// replace with the actual configuration.
ServiceConf *service.Config
}
ActionStop is the implementation of the Action interface.
func (*ActionStop) Name ¶
func (a *ActionStop) Name() (name ActionName)
Name implements the Action interface for *ActionStop.
type ActionUninstall ¶
type ActionUninstall struct {
// ServiceConf is the configuration for the service to control.
//
// TODO(e.burkov): Get rid of github.com/kardianos/service dependency and
// replace with the actual configuration.
ServiceConf *service.Config
}
ActionUninstall is the implementation of the Action interface.
func (*ActionUninstall) Name ¶
func (a *ActionUninstall) Name() (name ActionName)
Name implements the Action interface for *ActionUninstall.
type EmptyManager ¶
type EmptyManager struct{}
EmptyManager is an empty implementation of Manager that does nothing.
func (EmptyManager) Perform ¶
func (EmptyManager) Perform(_ context.Context, _ Action) (err error)
Perform implements the Manager interface for EmptyManager.
func (EmptyManager) Status ¶
func (EmptyManager) Status(_ context.Context, _ ServiceName) (status Status, err error)
Status implements the Manager interface for EmptyManager.
type Manager ¶
type Manager interface {
// Perform performs the specified action.
Perform(ctx context.Context, action Action) (err error)
// Status returns the status of the service with the given name.
Status(ctx context.Context, name ServiceName) (status Status, err error)
}
Manager is the interface for communication with the OS service manager.
TODO(e.burkov): Move to golibs.
TODO(e.burkov): Use.
func NewManager ¶
func NewManager(ctx context.Context, conf *ManagerConfig) (mgr Manager, err error)
NewManager returns a new properly initialized Manager, appropriate for the current platform.
type ManagerConfig ¶
type ManagerConfig struct {
// Logger is the logger to use.
Logger *slog.Logger
// CommandConstructor is the constructor to use for creating commands.
CommandConstructor executil.CommandConstructor
}
ManagerConfig contains the configuration for Manager.
type ServiceName ¶
type ServiceName string
ServiceName is the name of a service.
TODO(e.burkov): Validate for each platform.