Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type ConfigProvider
- type Handler
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetClock(now func() time.Time, sleep func(context.Context, time.Duration))
- func (b *InMemoryBackend) SetTiming(t Timing)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type Provider
- type Settings
- type Timing
Constants ¶
const DefaultPort = 8142
DefaultPort is the dedicated Compute Engine REST listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcpcompute: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrSnapshotNull = errors.New("gcpcompute: snapshot contains a null record")
ErrSnapshotNull is returned when a snapshot holds a null record.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPComputeSettings() Settings
}
ConfigProvider extracts Compute Engine configuration from the AppContext Config.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves the Compute Engine v1 REST API on a dedicated listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the project for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported operations as collection@scope.verb.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for all Compute Engine REST requests.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Compute Engine runs on its own listener.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all Compute Engine state under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend on the wall clock.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time, sleep func(context.Context, time.Duration))
SetClock replaces the clock and the sleep used by Operations.Wait; tests inject a fake clock here.
func (*InMemoryBackend) SetTiming ¶
func (b *InMemoryBackend) SetTiming(t Timing)
SetTiming replaces the operation and instance transition delays.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Compute Engine. It serves the compute v1 REST API on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 167-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.GCPCompute.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
type Timing ¶
type Timing struct {
Pending time.Duration
Done time.Duration
Provision time.Duration
Stage time.Duration
Stop time.Duration
}
Timing controls how long operations and instance state transitions take on the backend clock.
func DefaultTiming ¶
func DefaultTiming() Timing
DefaultTiming returns the transition delays used unless a test overrides them.
Source Files
¶
- address.go
- autoscaler.go
- catalog.go
- cidr.go
- consts.go
- disk.go
- errors.go
- filter.go
- firewall.go
- handler.go
- healthcheck.go
- images.go
- instance.go
- instance_group.go
- instance_template.go
- labels.go
- lb.go
- lb_backend.go
- lb_cert.go
- lb_health.go
- lb_neg.go
- lb_proxy.go
- lb_rule.go
- lb_urlmap.go
- list.go
- listops.go
- meta.go
- mig.go
- mig_members.go
- mig_reconcile.go
- network.go
- operations.go
- ops_address.go
- ops_catalog.go
- ops_groups.go
- ops_instance.go
- ops_lb.go
- ops_network.go
- ops_storage.go
- parse.go
- persistence.go
- provider.go
- refs.go
- resources.go
- router.go
- settings.go
- store.go
- subnet.go
- vpcroute.go