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:
2026-05-12 17:51:34 +00:00
parent 631c98396e
commit f07782d583
6 changed files with 47 additions and 7 deletions

View File

@@ -180,6 +180,22 @@ func TestWorker_TaskError(t *testing.T) {
c.OnStop() // should not panic
}
func TestWorker_Len(t *testing.T) {
c := New(newLogger(), Config{PoolSize: 1, BufferSize: 10, ShutdownTimeout: time.Second})
if err := c.OnInit(); err != nil {
t.Fatalf("OnInit: %v", err)
}
// Before start, workers are not running — queued tasks stay in the channel.
blocked := make(chan struct{})
c.Dispatch(func(ctx context.Context) error { <-blocked; return nil })
c.Dispatch(func(ctx context.Context) error { <-blocked; return nil })
if got := c.Len(); got != 2 {
t.Errorf("Len() = %d, want 2", got)
}
close(blocked)
_ = c.OnStop()
}
func TestWorker_Lifecycle(t *testing.T) {
c := New(newLogger(), Config{PoolSize: 2, BufferSize: 10, ShutdownTimeout: time.Second})
if err := c.OnInit(); err != nil {