2025-01-17 14:43:11 +05:30
|
|
|
package factory
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
type Service interface {
|
2025-02-19 00:35:53 +05:30
|
|
|
// Starts a service. It should block and should not return until the service is stopped or it fails.
|
2025-01-17 14:43:11 +05:30
|
|
|
Start(context.Context) error
|
|
|
|
|
// Stops a service.
|
|
|
|
|
Stop(context.Context) error
|
|
|
|
|
}
|
2025-02-19 00:35:53 +05:30
|
|
|
|
|
|
|
|
type NamedService interface {
|
|
|
|
|
Named
|
|
|
|
|
Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type namedService struct {
|
|
|
|
|
name Name
|
|
|
|
|
Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *namedService) Name() Name {
|
|
|
|
|
return s.name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewNamedService(name Name, service Service) NamedService {
|
|
|
|
|
return &namedService{
|
|
|
|
|
name: name,
|
|
|
|
|
Service: service,
|
|
|
|
|
}
|
|
|
|
|
}
|