Migrate logging to go-mana-component; delete logging/ package
Replaces the flat key-value logging scheme with component-based structured logging via go-mana-component. Each layer (pool, worker, connection) builds its own component identity and derives a *slog.Logger from a caller-supplied slog.Handler. - Delete logging/ package (logging.go, logging_test.go) - Strip LoggingEnabled and LogLevel from ConnectionConfig, PoolConfig, WorkerConfig; remove associated option funcs - Change NewConnection and NewConnectionFromSocket to accept ctx and slog.Handler instead of *slog.Logger; constructors build component identity via MustNew/MustExtend internally - Change WorkerFactory, NewWorker, connect, and RunDialer to carry slog.Handler; remove PoolPlugin.Handler - Change NewPool to establish pool component identity via MustNew; remove pool_id field, PoolPlugin.ID, and ErrInvalidPoolID - Fix data race in MockSlogHandler: WithAttrs now shares parent mutex pointer rather than allocating a new one per child - Run go fix
This commit is contained in:
@@ -12,13 +12,12 @@ func TestRunKeepalive(t *testing.T) {
|
||||
heartbeat := make(chan struct{})
|
||||
keepalive := make(chan struct{}, 1)
|
||||
timeout := 200 * time.Millisecond
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
go RunKeepalive(ctx, heartbeat, keepalive, timeout, nil)
|
||||
|
||||
// send heartbeats faster than the timeout
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
heartbeat <- struct{}{}
|
||||
}
|
||||
@@ -38,8 +37,7 @@ func TestRunKeepalive(t *testing.T) {
|
||||
heartbeat := make(chan struct{}, 1)
|
||||
keepalive := make(chan struct{}, 1)
|
||||
timeout := 20 * time.Millisecond
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
go RunKeepalive(ctx, heartbeat, keepalive, timeout, nil)
|
||||
|
||||
@@ -80,13 +78,12 @@ func TestRunKeepalive(t *testing.T) {
|
||||
t.Run("disabled keepalive drains heartbeats without blocking", func(t *testing.T) {
|
||||
heartbeat := make(chan struct{})
|
||||
keepalive := make(chan struct{}, 1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
go RunKeepalive(ctx, heartbeat, keepalive, 0, nil)
|
||||
|
||||
// these must not block
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
heartbeat <- struct{}{}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user