Documentation ¶
Index ¶
- func CreateLogger(c *cli.Context, opts *CLIOpts, conf config.Type, streamsMode bool) (logger log.Modular, err error)
- func DelayShutdown(ctx context.Context, duration time.Duration) error
- func ReadConfig(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) (mainPath string, inferred bool, conf *config.Reader)
- func RunManagerUntilStopped(c *cli.Context, conf config.Type, stopMgr *StoppableManager, ...) int
- func RunService(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) int
- type CLIOpts
- type CLIStreamBootstrapFunc
- type Stoppable
- type StoppableManager
- type SwappableStopper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateLogger ¶
func CreateLogger(c *cli.Context, opts *CLIOpts, conf config.Type, streamsMode bool) (logger log.Modular, err error)
CreateLogger from a CLI context and a stream config.
func DelayShutdown ¶
DelayShutdown attempts to block until either: - The delay period ends - The provided context is cancelled - The process receives an interrupt or sigterm
func ReadConfig ¶
func ReadConfig(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) (mainPath string, inferred bool, conf *config.Reader)
ReadConfig attempts to read a general service wide config via a returned config.Reader based on input CLI flags. This includes applying any config overrides expressed by the --set flag.
func RunManagerUntilStopped ¶
func RunManagerUntilStopped( c *cli.Context, conf config.Type, stopMgr *StoppableManager, stopStrm Stoppable, dataStreamClosedChan chan struct{}, ) int
RunManagerUntilStopped will run the provided HTTP server and block until either a provided stream stoppable is gracefully terminated (via the dataStreamClosedChan) or a signal is given to the process to terminate, at which point the provided HTTP server, the manager, and the stoppable is stopped according to the configured shutdown timeout.
func RunService ¶
RunService runs a service command (either the default or the streams subcommand).
Types ¶
type CLIOpts ¶
type CLIOpts struct { Version string DateBuilt string MainConfigSpecCtor func() docs.FieldSpecs // TODO: This becomes a service.Environment OnManagerInitialised func(mgr bundle.NewManagement, pConf *docs.ParsedConfig) error OnLoggerInit func(l log.Modular) (log.Modular, error) }
func NewCLIOpts ¶
type CLIStreamBootstrapFunc ¶
type CLIStreamBootstrapFunc func()
type Stoppable ¶
Stoppable represents a resource (a Bento stream) that can be stopped.
func CombineStoppables ¶
CombineStoppables returns a single Stoppable that will call each provided Stoppable in the order they are specified on a Stop. If any stoppable returns an error all subsequent stoppables will still be called before an error is returned.
type StoppableManager ¶
type StoppableManager struct {
// contains filtered or unexported fields
}
StoppableManager wraps a manager and API type that potentially outlives one or more dependent streams and encapsulates the logic for shutting them down within the deadline of a given context.
func CreateManager ¶
func CreateManager( c *cli.Context, cliOpts *CLIOpts, logger log.Modular, streamsMode bool, conf config.Type, mgrOpts ...manager.OptFunc, ) (stoppableMgr *StoppableManager, err error)
CreateManager from a CLI context and a stream config.
func (*StoppableManager) API ¶
func (s *StoppableManager) API() *api.Type
API returns the underlying api type.
func (*StoppableManager) Manager ¶
func (s *StoppableManager) Manager() *manager.Type
Manager returns the underlying manager type.
type SwappableStopper ¶
type SwappableStopper struct {
// contains filtered or unexported fields
}
SwappableStopper wraps an active Stoppable resource in a mechanism that allows changing the resource for something else after stopping it.
func NewSwappableStopper ¶
func NewSwappableStopper(s Stoppable) *SwappableStopper
NewSwappableStopper creates a new swappable stopper resource around an initial stoppable.