Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Flagger ¶
type Flagger interface { // Parse reads flags into the flagger struct. It should be invoked after flag.Parse() which is typically handled by // the derezzolution platform service. Parse() // Run oneshot flags (flags that terminate and don't agument service). Run() }
type Flags ¶
type Flags struct { Flagger BuildInfo bool DoesShowTimestamp bool Property string Version bool // contains filtered or unexported fields }
func (*Flags) HasProperty ¶
HasProperty returns whether we're attempting to read a property from the config.
func (*Flags) Parse ¶
func (f *Flags) Parse()
Parse reads flags into the flagger struct. It should be invoked after flag.Parse() which is typically handled by the derezzolution platform service.
func (*Flags) Run ¶
func (f *Flags) Run()
Run oneshot flags (flags that terminate and don't agument service) that are specific to platform.
func (*Flags) RunWithConfigurer ¶
func (f *Flags) RunWithConfigurer(configurer config.Configurer)
RunWithConfigurer runs oneshot flags (flags that terminate and don't agument service) that are specific to platform and have dependencies on an additional configurer.
func (*Flags) RunWithFlagger ¶
RunWithFlagger runs oneshot flags (flags that terminate and don't augment service) that are specific to platform consumers (typically )
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runners control how workers are executed at a periodicity. For a usage example, check out ExampleRunner.
func NewRunner ¶
func NewRunner(service *Service, config RunnerConfig) *Runner
NewRunner creates a new runner with clean-up behaviors.
func (*Runner) IsStopping ¶
func (*Runner) StartNewWorker ¶
type RunnerConfig ¶
type RunnerConfig struct { // InitDelayDuration is the duration before a worker is started initially. // Total start time of a worker is InitDelayDuration + // rand(InitDelayJitterDuration). InitDelayDuration time.Duration // InitDelayJitterDuration is a random duration added to InitDelayDuration // before a worker is started initially. Total start time of a worker is // InitDelayDuration + rand(InitDelayJitterDuration). InitDelayJitterDuration time.Duration // MaximumCleanUpDuration is the maximum amount of time all workers can // take for clean up. If more workers don't finish within this duration, // they're forcefully stopped. MaximumCleanUpDuration time.Duration // Name of the runner (used in logging). Name string // WorkerSleepDuration is how much time a worker sleeps after a run, before // it starts again. WorkerSleepDuration time.Duration }
type Service ¶
type Service struct { Config *config.Config Flags *Flags Version *Version // contains filtered or unexported fields }
Service holding foundational harness. Each process should only ever have 1 instance of this structure.
func NewService ¶
NewService creates a new service by initializing foundational harness.
func NewServiceWithOptions ¶
func NewServiceWithOptions(packageFS *embed.FS, options *ServiceOptions) *Service
NewService creates a new service by initializing foundational harness using additional config.
func (*Service) AddInterruptListener ¶
func (s *Service) AddInterruptListener(listener func())
Add interrupt listener adds a callback to be invoke immediately after receiving os interrupt signals triggering service termination. Callback does not block.
func (*Service) Run ¶
func (s *Service) Run()
Run the service with a blocking busy-wait watching for OS Signals.
func (*Service) RunWithCleanUp ¶
Run the service with a blocking busy-wait watching for OS Signals.
Upon os signal interrupt, the service winds down in the following order: 1. Notify all interrupt listeners async 2. Stop all runners one-by-one in LIFO fashion 3. Run cleanUpFun blocking 4. OS terminate (returning non-zero if error in 2 or 3)
type ServiceOptions ¶
type ServiceOptions struct { // AdditionalConfigurer can be used for additional configurers (configurations from services that use platform). It // could make sense for this to be an array of configurers. AdditionalConfigurer config.Configurer // AdditionalFlagger can be used for additional flaggers (flag structs from services that use platform). It could // make sense for this to be an array of flaggers. AdditionalFlagger Flagger }
ServiceOptions allow additional service configurability with the NewServiceWithOptions constructor.
type Version ¶
type Version struct { // Build is the primary service build information. Build Build `json:"build"` // BuildTime is the time that the build happened (ideally aligns with the package timestamp), // e.g.: $(date -u +"%Y-%m-%dT%H:%M:%SZ") -> "2023-02-26T07:49:35Z" (UTC) BuildTime time.Time `json:"buildTime"` // Pipeline provides the build method, e.g.: "manual", "github_actions", "bitbucket_pipelines" Pipeline string `json:"pipeline"` // (Optional) If supplied, provides the build information for the resource bundle. Resources Build `json:"resources"` }
func NewVersion ¶
NewVersion creates a new version given a package file system (which must contain version.json).
func (*Version) LogSummary ¶
func (v *Version) LogSummary()