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:
+9
-12
@@ -19,8 +19,7 @@ func TestRunDialer(t *testing.T) {
|
||||
url := "wss://test"
|
||||
dial := make(chan struct{}, 1)
|
||||
newConn := make(chan *transport.Connection, 1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
mockSocket := honeybeetest.NewMockSocket()
|
||||
pool := PoolPlugin{
|
||||
@@ -31,7 +30,7 @@ func TestRunDialer(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil)
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil, nil)
|
||||
dial <- struct{}{}
|
||||
|
||||
honeybeetest.Eventually(t, func() bool {
|
||||
@@ -49,8 +48,7 @@ func TestRunDialer(t *testing.T) {
|
||||
url := "wss://test"
|
||||
dial := make(chan struct{}, 1)
|
||||
newConn := make(chan *transport.Connection, 1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
gate := make(chan struct{})
|
||||
dialCount := atomic.Int32{}
|
||||
@@ -71,14 +69,14 @@ func TestRunDialer(t *testing.T) {
|
||||
ConnectionConfig: connConfig,
|
||||
}
|
||||
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil)
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil, nil)
|
||||
dial <- struct{}{}
|
||||
|
||||
// wait for dial to start blocking on gate
|
||||
<-started
|
||||
|
||||
// flood dial while dialer is blocked
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
select {
|
||||
case dial <- struct{}{}:
|
||||
default:
|
||||
@@ -114,8 +112,7 @@ func TestRunDialer(t *testing.T) {
|
||||
url := "wss://test"
|
||||
dial := make(chan struct{}, 1)
|
||||
newConn := make(chan *transport.Connection, 1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
|
||||
// use atomic counter to fail first dial and pass second
|
||||
dialCount := atomic.Int32{}
|
||||
@@ -137,7 +134,7 @@ func TestRunDialer(t *testing.T) {
|
||||
ConnectionConfig: connConfig,
|
||||
}
|
||||
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil)
|
||||
go RunDialer(url, ctx, pool, dial, newConn, nil, nil)
|
||||
dial <- struct{}{}
|
||||
dial <- struct{}{}
|
||||
|
||||
@@ -161,7 +158,7 @@ func TestRunDialer(t *testing.T) {
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
RunDialer(url, ctx, pool, dial, newConn, nil)
|
||||
RunDialer(url, ctx, pool, dial, newConn, nil, nil)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
@@ -198,7 +195,7 @@ func TestRunDialer(t *testing.T) {
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
RunDialer(url, ctx, pool, dial, newConn, nil)
|
||||
RunDialer(url, ctx, pool, dial, newConn, nil, nil)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user