Documentation ¶
Overview ¶
Package captain is used to run your job, and monitor during runtime
Index ¶
- type CommChan
- type Config
- func (config *Config) Run()
- func (config *Config) SetWorker(worker Worker)
- func (config *Config) WithLockProvider(lockProvider LockProvider)
- func (config *Config) WithResultProcessor(processor ResultProcessor)
- func (config *Config) WithRuntimeProcessingFrequency(frequency time.Duration)
- func (config *Config) WithRuntimeProcessor(processor RuntimeProcessor)
- type LockProvider
- type ResultProcessor
- type RuntimeProcessor
- type Worker
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommChan ¶
CommChan is a basic struct containing channels used for communication between your worker, runtime and result processor
type Config ¶
type Config struct { ResultProcessor ResultProcessor RuntimeProcessor RuntimeProcessor RuntimeProcessingFrequency time.Duration LockProvider LockProvider Worker Worker SummaryBuffer int }
Config represents a configuration of a job. You can either create your own, or use CreateJob function which will initialize basic configuration.
func CreateJob ¶
func CreateJob() Config
CreateJob creates a basic empty configuration with some defaults.
func (*Config) WithLockProvider ¶
func (config *Config) WithLockProvider(lockProvider LockProvider)
WithLockProvider is used to set LockProvider.
func (*Config) WithResultProcessor ¶
func (config *Config) WithResultProcessor(processor ResultProcessor)
WithResultProcessor is used to set ResultProcessor.
Example ¶
package main import ( "fmt" "github.com/fossapps/captain" "strconv" ) func main() { job := captain.CreateJob() job.SetWorker(func(channels captain.CommChan) { channels.Result <- "Total Items: " + strconv.Itoa(80) }) job.WithResultProcessor(func(results []string) { fmt.Printf("%+v\n", results[0]) }) job.Run() }
Output: Total Items: 80
func (*Config) WithRuntimeProcessingFrequency ¶
WithRuntimeProcessingFrequency is used to set how frequently RuntimeProcessor is called.
func (*Config) WithRuntimeProcessor ¶
func (config *Config) WithRuntimeProcessor(processor RuntimeProcessor)
WithRuntimeProcessor is used to set the RuntimeProcessor.
type LockProvider ¶
LockProvider is used if we need to make sure that two jobs aren't running at the same time.
type ResultProcessor ¶
type ResultProcessor func(results []string)
ResultProcessor is called after execution of worker.
type RuntimeProcessor ¶
RuntimeProcessor gets called every `RuntimeProcessingFrequency` duration.