Documentation
¶
Overview ¶
Package service defines a unified lifecycle interface for application services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthChecker ¶
type HealthChecker interface {
// Health returns nil when the service is healthy.
Health(ctx context.Context) error
}
HealthChecker is an optional interface that services can implement to participate in health checks.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages service registration, startup, and shutdown.
func NewRegistry ¶
NewRegistry creates a new service registry.
func (*Registry) HealthChecks ¶
func (r *Registry) HealthChecks() []HealthChecker
HealthChecks returns all registered services that implement HealthChecker.
func (*Registry) Register ¶
func (r *Registry) Register(svc Service, info ServiceInfo)
Register adds a service to the registry.
type Service ¶
type Service interface {
// Name returns the service name (used for logging and dependency resolution).
Name() string
// Start initializes and starts the service.
Start(ctx context.Context) error
// Stop gracefully shuts down the service.
Stop(ctx context.Context) error
}
Service defines the unified service lifecycle interface.
type ServiceInfo ¶
type ServiceInfo struct {
// Name identifies the service (must match Service.Name()).
Name string
// Priority controls startup order (lower numbers start first).
Priority int
// DependsOn lists service names that must be started before this one.
DependsOn []string
}
ServiceInfo holds metadata for service registration.
Click to show internal directories.
Click to hide internal directories.