service

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveDependencies

func ResolveDependencies(services map[string]config.Service, requestedServices []string) ([]string, error)

ResolveDependencies resolves service dependencies and returns them in start order Returns a list of service names in the order they should be started Detects circular dependencies and returns an error if found

Types

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph represents the service dependency relationships

type HealthStatus

type HealthStatus string

HealthStatus represents the health status of a service

const (
	HealthUnknown   HealthStatus = "unknown"   // Health status not yet determined
	HealthHealthy   HealthStatus = "healthy"   // Service is healthy
	HealthUnhealthy HealthStatus = "unhealthy" // Service is unhealthy
	HealthStarting  HealthStatus = "starting"  // Service is starting (health check has not run yet)
)

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator manages the lifecycle of multiple services with parallel execution

func NewOrchestrator

func NewOrchestrator(projectName string, dockerClient *docker.Client, networkID string) *Orchestrator

NewOrchestrator creates a new service orchestrator

func (*Orchestrator) AddService

func (o *Orchestrator) AddService(name string, cfg config.Service)

AddService adds a service to the orchestrator

func (*Orchestrator) GetService

func (o *Orchestrator) GetService(name string) (*Service, bool)

GetService returns a service by name

func (*Orchestrator) StartServicesInOrder

func (o *Orchestrator) StartServicesInOrder(ctx context.Context, orderedServiceNames []string, cfg *config.Config) error

StartServicesInOrder starts services in dependency order with parallel execution Services at the same dependency level are started in parallel Returns an error if any service fails, rolling back successfully started services

func (*Orchestrator) StopAll

func (o *Orchestrator) StopAll(ctx context.Context) error

StopAll stops all services managed by the orchestrator

type Service

type Service struct {
	// Service identification
	Name        string         // Service name (e.g., "frontend", "api")
	ProjectName string         // Project this service belongs to
	Config      config.Service // Service configuration from ork.yml
	// contains filtered or unexported fields
}

Service represents a runtime service instance with state tracking

func New

func New(name string, projectName string, cfg config.Service) *Service

New creates a new Service instance

func (*Service) CheckHealth

func (s *Service) CheckHealth(ctx context.Context) error

CheckHealth performs a health check on the service

func (*Service) GetContainerID

func (s *Service) GetContainerID() string

GetContainerID returns the container ID

func (*Service) GetHealthStatus

func (s *Service) GetHealthStatus() HealthStatus

GetHealthStatus returns the current health status

func (*Service) GetLastError

func (s *Service) GetLastError() error

GetLastError returns the last error encountered

func (*Service) GetStartedAt

func (s *Service) GetStartedAt() time.Time

GetStartedAt returns when the service was started

func (*Service) GetState

func (s *Service) GetState() State

GetState returns the current service state

func (*Service) GetUptime

func (s *Service) GetUptime() time.Duration

GetUptime returns how long the service has been running

func (*Service) IsHealthy

func (s *Service) IsHealthy() bool

IsHealthy returns true if the service is healthy

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns true if the service is currently running

func (*Service) Restart

func (s *Service) Restart(ctx context.Context, client *docker.Client, networkID string) error

Restart restarts the service by stopping and then starting it

func (*Service) Start

func (s *Service) Start(ctx context.Context, client *docker.Client, networkID string) error

Start starts the service container

func (*Service) Stop

func (s *Service) Stop(ctx context.Context, client *docker.Client) error

Stop stops the service container

func (*Service) String

func (s *Service) String() string

String returns a string representation of the service

func (*Service) WasAlreadyRunning added in v0.2.0

func (s *Service) WasAlreadyRunning() bool

WasAlreadyRunning returns true if the service was found already running (not newly started)

type State

type State string

State represents the current state of a service

const (
	StatePending  State = "pending"  // Service not yet started
	StateStarting State = "starting" // Service is being started
	StateRunning  State = "running"  // Service is running
	StateStopping State = "stopping" // Service is being stopped
	StateStopped  State = "stopped"  // Service has been stopped
	StateFailed   State = "failed"   // Service failed to start or crashed
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL