ax(mining): replace prose comments with usage examples in container.go
AX Principle 2 — comments as usage examples, not prose descriptions.
NewContainer, Start, and Shutdown had comments restating the signature
("creates a new container", "begins all background services", etc.).
Replaced with concrete call examples showing how to invoke each function.
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
02e60c2ab5
commit
fdc7064e09
1 changed files with 4 additions and 3 deletions
|
|
@ -63,7 +63,8 @@ type Container struct {
|
|||
shutdownCh chan struct{}
|
||||
}
|
||||
|
||||
// NewContainer creates a new service container with the given configuration.
|
||||
// container := NewContainer(DefaultContainerConfig())
|
||||
// container.Initialize(ctx)
|
||||
func NewContainer(config ContainerConfig) *Container {
|
||||
return &Container{
|
||||
config: config,
|
||||
|
|
@ -127,7 +128,7 @@ func (c *Container) Initialize(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Start begins all background services.
|
||||
// if err := container.Start(ctx); err != nil { return err }
|
||||
func (c *Container) Start(ctx context.Context) error {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
|
@ -152,7 +153,7 @@ func (c *Container) Start(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Shutdown gracefully stops all services in reverse order.
|
||||
// defer container.Shutdown(ctx) // safe to call multiple times
|
||||
func (c *Container) Shutdown(ctx context.Context) error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue