Documentation ¶
Index ¶
- Constants
- func LogDebug(runtime Runtime, operation LogOperation, status LogStatus)
- func LogDebugf(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func LogError(runtime Runtime, operation LogOperation, status LogStatus)
- func LogErrorf(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func LogFatal(runtime Runtime, operation LogOperation, status LogStatus)
- func LogFatalf(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func LogInfo(runtime Runtime, operation LogOperation, status LogStatus)
- func LogInfof(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func LogPanic(runtime Runtime, operation LogOperation, status LogStatus)
- func LogPanicf(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func LogWarn(runtime Runtime, operation LogOperation, status LogStatus)
- func LogWarnf(runtime Runtime, operation LogOperation, status LogStatus, format string, ...)
- func WorkerPoolStrategyRunLoop(p *WorkerPool, i int, wg *sync.WaitGroup, errs SafeArray[Error])
- func WorkerPoolStrategyRunOnce(p *WorkerPool, i int, wg *sync.WaitGroup, errs SafeArray[Error])
- type Builder
- type Error
- type ErrorSeverity
- type ErrorStruct
- type ErrorType
- type Leaser
- type LeaserBuilder
- type LogOperation
- type LogStatus
- type Logger
- type Map
- type Orchestrator
- type Queue
- type Runtime
- type SafeArray
- type Set
- type Strategy
- type Worker
- type WorkerFactory
- type WorkerPool
- type WorkerPoolStrategyFunc
Constants ¶
const ( LogOperationInit LogOperation = "init" LogOperationRun LogOperation = "run" LogOperationStop LogOperation = "stop" LogOperationHandleError LogOperation = "handle-error" LogStatusStart LogStatus = "start" LogStatusProgress LogStatus = "progress" LogStatusSuccess LogStatus = "success" LogStatusFailed LogStatus = "failed" )
Variables ¶
This section is empty.
Functions ¶
func LogDebug ¶ added in v0.1.1
func LogDebug(runtime Runtime, operation LogOperation, status LogStatus)
func LogDebugf ¶ added in v0.1.1
func LogDebugf(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func LogError ¶ added in v0.1.1
func LogError(runtime Runtime, operation LogOperation, status LogStatus)
func LogErrorf ¶ added in v0.1.1
func LogErrorf(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func LogFatal ¶ added in v0.1.1
func LogFatal(runtime Runtime, operation LogOperation, status LogStatus)
func LogFatalf ¶ added in v0.1.1
func LogFatalf(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func LogInfo ¶ added in v0.1.1
func LogInfo(runtime Runtime, operation LogOperation, status LogStatus)
func LogInfof ¶ added in v0.1.1
func LogInfof(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func LogPanic ¶ added in v0.1.1
func LogPanic(runtime Runtime, operation LogOperation, status LogStatus)
func LogPanicf ¶ added in v0.1.1
func LogPanicf(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func LogWarn ¶ added in v0.1.1
func LogWarn(runtime Runtime, operation LogOperation, status LogStatus)
func LogWarnf ¶ added in v0.1.1
func LogWarnf(runtime Runtime, operation LogOperation, status LogStatus, format string, args ...interface{})
func WorkerPoolStrategyRunLoop ¶ added in v0.1.1
func WorkerPoolStrategyRunOnce ¶ added in v0.1.1
Types ¶
type Error ¶
type Error *ErrorStruct
func HandleErrors ¶ added in v0.1.24
func HandleErrors(runtime Runtime, logOperation LogOperation, errs SafeArray[Error]) Error
type ErrorSeverity ¶ added in v0.1.1
type ErrorSeverity int
const ( // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel ErrorSeverity = iota // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel )
type ErrorStruct ¶
type ErrorStruct struct { Type ErrorType Severity ErrorSeverity Message string SubErrors []Error }
type Leaser ¶ added in v0.1.23
type Leaser interface { GetLease(id string) (time.Time, error) ResetLease(id string, allegedLeaseTime time.Time) (time.Time, error) }
Leaser interface provides methods to get and reset lease time for an ID.
type LeaserBuilder ¶ added in v0.1.23
type LeaserBuilder interface {
Build() Leaser
}
LeaserBuilder interface provides a method to build a Leaser instance.
func NewInMemoryLeaserBuilder ¶ added in v0.1.23
func NewInMemoryLeaserBuilder() LeaserBuilder
NewInMemoryLeaserBuilder returns a new instance of inMemoryLeaserBuilder.
type LogOperation ¶ added in v0.1.1
type LogOperation string
type Logger ¶ added in v0.1.14
func DefaultLogger ¶ added in v0.1.1
func DefaultLogger() *Logger
func RuntimeLogger ¶ added in v0.1.11
func RuntimeLogger(runtime Runtime, operation LogOperation) *Logger
type Map ¶
type Map[T comparable, I any] interface { // Get method returns the value and a boolean indicating if the key exists in the map Get(key T) (I, bool) // Set method sets a value for a key and returns the key and value as a tuple Set(key T, value I) (T, I) }
func DefaultMap ¶
func DefaultMap[T comparable, I any]() Map[T, I]
DefaultMap function returns a new inMemoryMap with an initialized map and a mutex
type Orchestrator ¶
type Orchestrator struct { Name string WorkerPools SafeArray[*WorkerPool] Strategy Strategy Logger *Logger Context context.Context }
func (*Orchestrator) GetLogger ¶ added in v0.1.1
func (o *Orchestrator) GetLogger() *Logger
func (*Orchestrator) GetName ¶ added in v0.1.1
func (o *Orchestrator) GetName() string
func (*Orchestrator) GetType ¶ added in v0.1.1
func (o *Orchestrator) GetType() string
func (*Orchestrator) HandleError ¶
func (o *Orchestrator) HandleError(err Error) Error
func (*Orchestrator) Init ¶
func (o *Orchestrator) Init() Error
func (*Orchestrator) Run ¶
func (o *Orchestrator) Run() Error
func (*Orchestrator) Stop ¶
func (o *Orchestrator) Stop() Error
type Queue ¶
type Queue[T any] interface { Runtime Receiver() <-chan T // Sender methods returns a reference to a chan T Sender() chan<- T }
Queue was refactored and now provides 2 functions. - Receiver() - Sender()
Even though DefaultQueue is now a strange wrapper over a channel, It enables us to provide different types of queues. Queue is intended for multiple uses cases, such as abstracting a clustered Queue over the network.
func DefaultQueue ¶
DefaultQueue function returns a new inMemoryQueue with an initialized channel
type SafeArray ¶ added in v0.1.23
type SafeArray[T any] interface { Append(item T) Get(i int) (T, bool) Set(i int, item T) bool Slice(start, end int, stepInterval ...int) SafeArray[T] Length() int }
func DefaultSafeArray ¶ added in v0.1.23
func DefaultSafeArrayWithSize ¶ added in v0.1.24
type Set ¶
type Set[T comparable] interface { // Exist method checks if a key exists in the Set Exist(key T) bool // Set method adds a key to the inMemorySet Set(key T) // TrySet method tries to set a key to the Set. // Returns true, if the key was not already set & sets it. // Else return false. TrySet(key T) bool }
func DefaultSet ¶
func DefaultSet[T comparable]() Set[T]
DefaultSet function returns a new inMemorySet with an initialized map and a mutex
type Strategy ¶
type Strategy interface { Init(Runtime) Error Run(Runtime) Error HandleError(Runtime, Error) Error Stop(Runtime) Error }
func DefaultStrategy ¶
func DefaultStrategy() Strategy
type Worker ¶
type Worker struct { Name string Strategy Strategy Receptor Runtime Logger *Logger Context context.Context }
Worker is a wrapper struct around a concrete implementation of a Runtime. A Worker holds a reference to a Strategy. The Strategy is injected in the worker by the WorkerFactory
func (*Worker) HandleError ¶
type WorkerFactory ¶
type WorkerPool ¶
type WorkerPool struct { Name string Workers SafeArray[*Worker] WorkerFactory WorkerFactory StrategyFunc WorkerPoolStrategyFunc Replicas int Logger *Logger Context context.Context }
func (*WorkerPool) GetLogger ¶ added in v0.1.1
func (p *WorkerPool) GetLogger() *Logger
func (*WorkerPool) GetName ¶ added in v0.1.1
func (p *WorkerPool) GetName() string
func (*WorkerPool) GetType ¶ added in v0.1.1
func (p *WorkerPool) GetType() string
func (*WorkerPool) HandleError ¶
func (p *WorkerPool) HandleError(err Error) Error
func (*WorkerPool) Init ¶
func (p *WorkerPool) Init() Error
func (*WorkerPool) Run ¶
func (p *WorkerPool) Run() Error
func (*WorkerPool) Stop ¶
func (p *WorkerPool) Stop() Error