service.go RawHistoryFolder
1// Package services defines the service interface and common service patterns
2package services
3
4// Service is the base interface that all application services must implement
5// This allows for consistent service management, lifecycle control, and dependency injection
6type Service interface {
7 // ServiceName returns the unique identifier for this service
8 // Used for logging, debugging, and service registration
9 ServiceName() string
10}
11
12// Initializable services can be initialized after construction
13type Initializable interface {
14 Service
15 // Initialize performs any setup required after construction
16 // Returns an error if initialization fails
17 Initialize() error
18}
19
20// Cleanable services can cleanup resources on shutdown
21type Cleanable interface {
22 Service
23 // Cleanup releases any resources held by the service
24 // Should be idempotent and safe to call multiple times
25 Cleanup() error
26}
27
28// LifecycleService implements both Initializable and Cleanable
29// Use this for services that need both initialization and cleanup
30type LifecycleService interface {
31 Initializable
32 Cleanable
33}