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:
Jay
2026-05-20 11:44:54 -04:00
parent 5b31db304a
commit b44a46ed2f
28 changed files with 179 additions and 464 deletions
+1 -39
View File
@@ -12,7 +12,7 @@ import (
type WorkerFactory func(
ctx context.Context,
id string,
logger *slog.Logger,
handler slog.Handler,
) (Worker, error)
// Pool Config
@@ -20,8 +20,6 @@ type WorkerFactory func(
type PoolConfig struct {
InboxBufferSize int
EventsBufferSize int
LoggingEnabled bool
LogLevel *slog.Level
ConnectionConfig *transport.ConnectionConfig
WorkerFactory WorkerFactory
WorkerConfig *WorkerConfig
@@ -44,8 +42,6 @@ func GetDefaultPoolConfig() *PoolConfig {
return &PoolConfig{
InboxBufferSize: 256,
EventsBufferSize: 10,
LoggingEnabled: true,
LogLevel: nil,
ConnectionConfig: nil,
WorkerFactory: nil,
WorkerConfig: nil,
@@ -108,21 +104,6 @@ func WithEventsBufferSize(value int) PoolOption {
}
}
func WithPoolLoggingEnabled(value bool) PoolOption {
return func(c *PoolConfig) error {
c.LoggingEnabled = value
return nil
}
}
func WithPoolLogLevel(level slog.Level) PoolOption {
return func(c *PoolConfig) error {
l := level
c.LogLevel = &l
return nil
}
}
func WithConnectionConfig(cc *transport.ConnectionConfig) PoolOption {
return func(c *PoolConfig) error {
err := transport.ValidateConnectionConfig(cc)
@@ -157,8 +138,6 @@ func WithWorkerFactory(wf WorkerFactory) PoolOption {
type WorkerConfig struct {
KeepaliveTimeout time.Duration
ReconnectDelay time.Duration
LoggingEnabled bool
LogLevel *slog.Level
}
type WorkerOption func(*WorkerConfig) error
@@ -178,8 +157,6 @@ func GetDefaultWorkerConfig() *WorkerConfig {
return &WorkerConfig{
KeepaliveTimeout: 60 * time.Second,
ReconnectDelay: 2 * time.Second,
LoggingEnabled: true,
LogLevel: nil,
}
}
@@ -237,18 +214,3 @@ func WithReconnectDelay(value time.Duration) WorkerOption {
return nil
}
}
func WithWorkerLoggingEnabled(value bool) WorkerOption {
return func(c *WorkerConfig) error {
c.LoggingEnabled = value
return nil
}
}
func WithWorkerLogLevel(level slog.Level) WorkerOption {
return func(c *WorkerConfig) error {
l := level
c.LogLevel = &l
return nil
}
}