2026-05-12 23:18:37 +08:00
|
|
|
package starter
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"apigo.cc/go/log"
|
|
|
|
|
"context"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Service defines the lifecycle of a component managed by the starter.
|
|
|
|
|
type Service interface {
|
|
|
|
|
// Start starts the service. It should block until the service is ready.
|
|
|
|
|
Start(ctx context.Context, logger *log.Logger) error
|
|
|
|
|
// Stop stops the service. It should block until the service is cleaned up.
|
|
|
|
|
Stop(ctx context.Context) error
|
2026-05-13 11:11:10 +08:00
|
|
|
// Status returns the current status and health of the service.
|
|
|
|
|
Status() (string, error)
|
2026-05-12 23:18:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reloader defines an optional interface for services that support configuration reloading.
|
|
|
|
|
type Reloader interface {
|
|
|
|
|
Reload() error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UserSignalHandler defines an optional interface for services that handle custom user signals.
|
|
|
|
|
type UserSignalHandler interface {
|
|
|
|
|
// HandleUserSignal handles a custom signal. Return true if the signal was handled.
|
|
|
|
|
HandleUserSignal(sig os.Signal) bool
|
|
|
|
|
}
|