Documentation ¶
Index ¶
- Constants
- func HTTPClient() *http.Client
- type Config
- type ContainerRegistry
- type GPU
- type IP
- type IPStore
- type IPType
- type LogConfig
- type LogFormat
- type LogLevel
- type MockIPStore
- type MockVMStore
- type ProviderRegistry
- type Server
- type ServerOpts
- type ServiceOpts
- type ServiceOptsByName
- type ServiceStore
- type StaticIPs
- type StaticVMIPs
- type VM
- type VMStore
Constants ¶
const ( ServerConfigName = "yeoman.json" AppConfigName = "app.json" )
const Missing _error = "missing"
Variables ¶
This section is empty.
Functions ¶
func HTTPClient ¶
HTTPClient returns an HTTP client that doesn't share a global transport. The implementation is taken from github.com/hashicorp/go-cleanhttp.
Types ¶
type Config ¶
type Config struct { Log LogConfig `json:"log,omitempty"` ProviderRegistries []ProviderRegistry `json:"providerRegistries"` Store string `json:"store"` }
func ParseConfig ¶
func ParseConfigForService ¶
type ContainerRegistry ¶
type MockIPStore ¶
type MockIPStore struct {
// contains filtered or unexported fields
}
MockIPStore implements the CloudProvider interface for simplified testing.
func (*MockIPStore) CreateStaticIP ¶
func (*MockIPStore) GetStaticIPs ¶
func (m *MockIPStore) GetStaticIPs( context.Context, ) (StaticIPs, error)
type MockVMStore ¶
type MockVMStore struct {
// contains filtered or unexported fields
}
type ProviderRegistry ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server tracks the state of services, manages autoscaling, and handles starting up and shutting down.
func (*Server) Serve ¶
Targeted process structure: Server > ProviderRegion > Zone > Service * Server is the root responsible for everything else. * ProviderRegion monitors a single region, e.g. gcp:us-central1. * Zone monitors a single zone, e.g. us-central1-b. * Service represents one or more VMs, e.g. "dashboard".
type ServerOpts ¶
type ServerOpts struct { Log *slog.Logger ServiceStore ServiceStore ProviderStores map[string]IPStore ZoneStores map[string]VMStore ProviderRegistries map[string]ContainerRegistry }
type ServiceOpts ¶
type ServiceOpts struct { Name string `json:"name"` MachineType string `json:"machineType"` DiskSizeGB int `json:"diskSizeGB"` AllowHTTP bool `json:"allowHTTP"` StaticIP bool `json:"staticIP"` Seccomp string `json:"seccomp"` Count int `json:"count"` UpdatedAt time.Time `json:"updatedAt"` }
ServiceOpts contains the persistant state of a Service, as configured via `yeoman -count $count service create $name`.
type ServiceOptsByName ¶
type ServiceOptsByName []ServiceOpts
func (ServiceOptsByName) Len ¶
func (a ServiceOptsByName) Len() int
func (ServiceOptsByName) Less ¶
func (a ServiceOptsByName) Less(i, j int) bool
func (ServiceOptsByName) Swap ¶
func (a ServiceOptsByName) Swap(i, j int)
type ServiceStore ¶
type ServiceStore interface { GetService(ctx context.Context, name string) (ServiceOpts, error) GetServices(ctx context.Context) (map[string]ServiceOpts, error) SetService(ctx context.Context, opts ServiceOpts) error SetServices(ctx context.Context, opts map[string]ServiceOpts) error DeleteService(ctx context.Context, name string) error }
type StaticVMIPs ¶
type VM ¶
type VM struct { // Name of the VM. Name string `json:"name"` // MachineType in the cloud provider. MachineType string `json:"machineType"` // Disk size in GB. Disk int `json:"disk"` // GPU to attach to the machine. GPU *GPU `json:"gpu,omitempty"` // Image installed on the disk. Image string `json:"image,omitempty"` // ContainerImage to be used if configured. ContainerImage string `json:"containerImage,omitempty"` // Tags on the box applied during creation to indicate the services to // be deployed. Tags []string `json:"-"` // IPs assigned to the box. IPs StaticVMIPs `json:"ips,omitempty"` // AllowHTTP will disable any cloud-based firewall on ports 80 and 443. // This is useful for reverse-proxy boxes that need to be exposed to // the public internet. AllowHTTP bool `json:"allowHTTP"` // Seccomp allows overwriting the default seccomp profile in Docker. // This is useful for running headless chromium, among other things. Seccomp string `json:"seccomp"` // Running is true when the VM is live and false in all other // circumstances. Running bool `json:"running"` }
type VMStore ¶
type VMStore interface { // GetAllVMs on the cloud provider. GetAllVMs(context.Context, *slog.Logger) ([]VM, error) // GetVM by name on the cloud provider. GetVM(context.Context, *slog.Logger, string) (VM, error) // DeleteVM. The implementation should shutdown the VM properly prior // to delete and hang until the box is completely deleted. DeleteVM(ctx context.Context, log *slog.Logger, name string) error // CreateVM. This must hang until boot completes. CreateVM(context.Context, *slog.Logger, VM) error // RestartVM. Hang until boot completes. RestartVM(context.Context, *slog.Logger, VM) error }