{"modulePath":"github.com/Stackdome/stackdome","version":"v0.0.7-alpha","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package worker\n\n## Functions\n\n```go\nfunc NewWorkerError(workerName string) *workerError\n```\n\n## Types\n\n```go\ntype BaseWorker struct {\n\tQueue       workqueue.TypedRateLimitingInterface[Operand]\n\tWorkerName  string\n\tWorkerError WorkerError\n\n\tEnv string\n\t// contains filtered or unexported fields\n}\n```\nBaseWorker implements generic functionalities for a worker. Actual workers types are supposed to embed this type in them.\n\n```go\nfunc NewBaseWorker(workerName string, env string) BaseWorker\n```\n\n```go\nfunc (w *BaseWorker) EnqueueAfter(operand Operand, after time.Duration)\n```\nClients call this method to enqueue a worker after the passed duration.\n\n```go\nfunc (w *BaseWorker) EnqueueNow(operand Operand)\n```\nClients call this method to enqueue work to a worker immeadiately.\n\n```go\nfunc (w *BaseWorker) Logger() logger.Logger\n```\n\n```go\nfunc (w *BaseWorker) Name() string\n```\n\n```go\nfunc (w *BaseWorker) WorkQueue() workqueue.TypedRateLimitingInterface[Operand]\n```\n\n```go\ntype Operand interface{}\n```\n\n```go\nfunc ToOperandList[T any](in ...T) []Operand\n```\n\n```go\ntype PeriodicReconcilable interface {\n\tInterval() time.Duration\n}\n```\nIf a worker implements PeriodicReconcilable, the worker manager would run enqueue GetInput()'s result to the worker's work queue every Interval().\n\n```go\ntype Result struct {\n\tRequeue bool\n\n\t// RequeueAfter if greater than 0, tells the worker manager to requeue the operand after the Duration.\n\t// Implies that Requeue is true, there is no need to set Requeue to true at the same time as RequeueAfter.\n\tRequeueAfter time.Duration\n}\n```\nResult contains the result of a worker's Execute invocation.\n\n```go\nfunc (r *Result) IsZero() bool\n```\nIsZero returns true if this result is empty.\n\n```go\ntype Worker interface {\n\tExecute(ctx context.Context, operand Operand) (Result, *errors.ServiceError)\n\tEnqueueNow(operand Operand)\n\tEnqueueAfter(Operand Operand, after time.Duration)\n\tWorkQueue() workqueue.TypedRateLimitingInterface[Operand]\n\t// Function that returns the list of operands to be passed to the workers execute method.\n\tGetInput(context.Context) ([]Operand, *errors.ServiceError)\n\tLogger() logger.Logger\n\tName() string\n}\n```\nWorkers both run periodically at \\`Interval()\\` and when clients call \\`EnqueueNow()\\`.\n\n```go\ntype WorkerError interface {\n\tNewError(format string, args ...any) *errors.ServiceError\n}\n```\n\n","path":"github.com/Stackdome/stackdome/pkg/worker","name":"worker","synopsis":"","isRedistributable":true}
