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:
+4
-9
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func setupPool(t *testing.T) (*Pool, *honeybeetest.MockDialer) {
|
||||
t.Helper()
|
||||
pool, err := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool, err := NewPool(context.Background(), nil, nil)
|
||||
assert.NoError(t, err)
|
||||
dialer := &honeybeetest.MockDialer{
|
||||
DialContextFunc: func(context.Context, string, http.Header) (types.Socket, *http.Response, error) {
|
||||
@@ -45,11 +45,6 @@ func expectEvent(
|
||||
|
||||
// Tests
|
||||
|
||||
func TestPoolID(t *testing.T) {
|
||||
_, err := NewPool(context.Background(), "", nil, nil)
|
||||
assert.ErrorIs(t, err, ErrInvalidPoolID)
|
||||
}
|
||||
|
||||
func TestPoolConnect(t *testing.T) {
|
||||
t.Run("successfully adds connection", func(t *testing.T) {
|
||||
pool, _ := setupPool(t)
|
||||
@@ -90,7 +85,7 @@ func TestPoolConnect(t *testing.T) {
|
||||
|
||||
func TestPoolClose(t *testing.T) {
|
||||
t.Run("channels close after pool close", func(t *testing.T) {
|
||||
pool, _ := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool, _ := NewPool(context.Background(), nil, nil)
|
||||
pool.Close()
|
||||
_, ok := <-pool.Inbox()
|
||||
assert.False(t, ok)
|
||||
@@ -99,7 +94,7 @@ func TestPoolClose(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("connect after close returns error", func(t *testing.T) {
|
||||
pool, _ := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool, _ := NewPool(context.Background(), nil, nil)
|
||||
pool.Close()
|
||||
err := pool.Connect("wss://test")
|
||||
assert.ErrorIs(t, err, ErrPoolClosed)
|
||||
@@ -157,7 +152,7 @@ func TestPoolSend(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
pool, err := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool, err := NewPool(context.Background(), nil, nil)
|
||||
assert.NoError(t, err)
|
||||
pool.dialer = mockDialer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user