ax(mining): replace prose field comments with usage examples in ContainerConfig
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

ContainerConfig had five "X is the Y" prose field comments that restated
the type signature (AX §2 violation). Container had three section-divider
labels ("Core services", "Database store", "Initialization state") that
describe what is self-evident from the field names. Both patterns are
explicitly banned — delete prose, show usage.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 16:47:16 +01:00
parent 07ba7b7e62
commit d8dffa398b
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -8,29 +8,22 @@ import (
"forge.lthn.ai/Snider/Mining/pkg/logging"
)
// cfg := mining.DefaultContainerConfig()
// cfg.ListenAddr = ":8080"
// cfg.SimulationMode = true
// containerConfig := mining.DefaultContainerConfig()
// containerConfig.ListenAddr = ":8080"
// containerConfig.SimulationMode = true
// ContainerConfig{ListenAddr: ":9090", DisplayAddr: "localhost:9090", SwaggerNamespace: "/api/v1/mining"}
// ContainerConfig{SimulationMode: true, Database: database.Config{Enabled: false}}
type ContainerConfig struct {
// Database configuration
Database database.Config
// ListenAddr is the address to listen on (e.g., ":9090")
ListenAddr string
// DisplayAddr is the address shown in Swagger docs
DisplayAddr string
// SwaggerNamespace is the API path prefix
Database database.Config
ListenAddr string
DisplayAddr string
SwaggerNamespace string
// SimulationMode enables simulation mode for testing
SimulationMode bool
SimulationMode bool
}
// cfg := mining.DefaultContainerConfig()
// cfg.ListenAddr = ":8080"
// c := NewContainer(cfg)
// containerConfig := mining.DefaultContainerConfig()
// containerConfig.ListenAddr = ":8080"
// container := NewContainer(containerConfig)
func DefaultContainerConfig() ContainerConfig {
return ContainerConfig{
Database: database.Config{
@ -44,26 +37,20 @@ func DefaultContainerConfig() ContainerConfig {
}
}
// c := NewContainer(DefaultContainerConfig())
// c.Initialize(ctx); c.Start(ctx); defer c.Shutdown(ctx)
// container := NewContainer(DefaultContainerConfig())
// container.Initialize(ctx); container.Start(ctx); defer container.Shutdown(ctx)
type Container struct {
config ContainerConfig
mutex sync.RWMutex
// Core services
config ContainerConfig
mutex sync.RWMutex
manager ManagerInterface
profileManager *ProfileManager
nodeService *NodeService
eventHub *EventHub
service *Service
// Database store (interface for testing)
hashrateStore database.HashrateStore
// Initialization state
initialized bool
hashrateStore database.HashrateStore
initialized bool
transportStarted bool
shutdownCh chan struct{}
shutdownCh chan struct{}
}
// container := NewContainer(DefaultContainerConfig())
@ -216,24 +203,24 @@ func (c *Container) Manager() ManagerInterface {
return c.manager
}
// pm := container.ProfileManager()
// pm.SaveProfile("eth-main", config)
// profileManager := container.ProfileManager()
// profileManager.SaveProfile("eth-main", config)
func (c *Container) ProfileManager() *ProfileManager {
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.profileManager
}
// ns := container.NodeService() // nil if P2P is unavailable
// ns.GetPeers()
// nodeService := container.NodeService() // nil if P2P is unavailable
// nodeService.GetPeers()
func (c *Container) NodeService() *NodeService {
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.nodeService
}
// hub := container.EventHub()
// hub.Broadcast(event)
// eventHub := container.EventHub()
// eventHub.Broadcast(event)
func (c *Container) EventHub() *EventHub {
c.mutex.RLock()
defer c.mutex.RUnlock()