feat(worker)!: promote to v1.0.0 — add Len() to Provider, bump deps to v1
Add Len() int to Provider interface; returns current queue depth for observability and test assertions. Bump launcher and logz to v1.0.1. Go directive bumped to 1.26. API committed as stable.
This commit is contained in:
@@ -16,6 +16,8 @@ type Task func(ctx context.Context) error
|
||||
type Provider interface {
|
||||
// Dispatch queues a task. Returns false if the queue is full (backpressure).
|
||||
Dispatch(task Task) bool
|
||||
// Len returns the current number of tasks waiting in the queue.
|
||||
Len() int
|
||||
}
|
||||
|
||||
// Component adds lifecycle management to Provider.
|
||||
@@ -103,6 +105,8 @@ func (w *workerComponent) OnStop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *workerComponent) Len() int { return len(w.taskQueue) }
|
||||
|
||||
func (w *workerComponent) Dispatch(task Task) bool {
|
||||
select {
|
||||
case w.taskQueue <- task:
|
||||
|
||||
Reference in New Issue
Block a user