Documentation
¶
Index ¶
- type FileStore
- type Info
- type Manager
- func (m *Manager) Get(name string) (*Service, error)
- func (m *Manager) List() ([]*Service, error)
- func (m *Manager) Remove(ctx context.Context, name string) error
- func (m *Manager) Replicas(name string) []*vm.VM
- func (m *Manager) Run(ctx context.Context, name, image string, replicas int, opts Options) (*Service, error)
- func (m *Manager) Scale(ctx context.Context, name string, desiredReplicas int) (*Service, error)
- func (m *Manager) ServiceInfo(svc *Service) Info
- func (m *Manager) Update(ctx context.Context, name, newImage string, healthTimeout time.Duration) (*Service, error)
- type Options
- type ReplicaInfo
- type Service
- type StoreInterface
- type Strategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore persists services to disk as JSON files under a root directory.
func NewFileStore ¶
NewFileStore creates a new FileStore rooted at dir.
type Info ¶
type Info struct {
Name string `json:"name"`
Image string `json:"image"`
DesiredReplicas int `json:"desired_replicas"`
ReadyReplicas int `json:"ready_replicas"`
Strategy string `json:"strategy"`
Health string `json:"health"`
Env []string `json:"env,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ReplicaIDs []string `json:"replica_ids"`
}
Info is the serialisable representation of a service for API responses.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages service lifecycle: creation, scaling, updates, and removal.
func NewManager ¶
func NewManager(mgr vm.Manager, store StoreInterface) *Manager
NewManager creates a new service Manager backed by the given VM manager and store.
func (*Manager) Run ¶
func (m *Manager) Run(ctx context.Context, name, image string, replicas int, opts Options) (*Service, error)
Run creates a service with the desired number of replicas and starts them.
func (*Manager) ServiceInfo ¶
ServiceInfo builds an Info from a Service and its live replicas.
type Options ¶
type Options struct {
Memory string
CPUs int
Env []string
PortMaps []vm.PortMap
NetworkName string
HealthCheck *vm.HealthCheckConfig
Restart vm.RestartConfig
Strategy Strategy
HealthTimeout time.Duration
}
Options contains optional parameters for creating a service.
type ReplicaInfo ¶
type ReplicaInfo struct {
ID string `json:"id"`
Name string `json:"name"`
State vm.State `json:"state"`
Health vm.HealthStatus `json:"health"`
IP string `json:"ip,omitempty"`
}
ReplicaInfo describes a single replica within a service.
type Service ¶
type Service struct {
// Name is the unique service identifier.
Name string
// Image is the unikernel image reference (e.g. "myapp:latest").
Image string
// DesiredReplicas is the target number of running replicas.
DesiredReplicas int
// Strategy controls how updates are applied.
Strategy Strategy
// HealthTimeout is the maximum duration to wait for new replicas to
// become healthy during rolling updates. Zero means no waiting.
HealthTimeout time.Duration
// Config holds the VM configuration template used for each replica.
Config vm.Config
// CreatedAt is the timestamp when the service was created.
CreatedAt time.Time
// UpdatedAt is the timestamp when the service was last updated.
UpdatedAt time.Time
}
Service represents a group of VM replicas managed as a single unit.
type StoreInterface ¶
type StoreInterface interface {
Save(svc *Service) error
Get(name string) (*Service, error)
List() ([]*Service, error)
Delete(name string) error
}
StoreInterface is the interface for persisting and retrieving services.