Documentation
¶
Overview ¶
Package arczonalshift emulates Application Recovery Controller zonal shift and zonal autoshift.
Index ¶
- Variables
- type Alarm
- type AutoshiftInResource
- type AutoshiftSummary
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() 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) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) CancelPracticeRun(id string) (ShiftView, error)
- func (b *InMemoryBackend) CancelZonalShift(id string) (ShiftView, error)
- func (b *InMemoryBackend) CreatePracticeRunConfiguration(cfg PracticeConfig) (PracticeOut, error)
- func (b *InMemoryBackend) DeletePracticeRunConfiguration(resource string) (PracticeOut, error)
- func (b *InMemoryBackend) GetManagedResource(resource string) (ManagedDetail, error)
- func (b *InMemoryBackend) ListAutoshifts(status, token string, maxResults int) ([]AutoshiftSummary, string, error)
- func (b *InMemoryBackend) ListManagedResources(region, token string, maxResults int) ([]ManagedSummary, string, error)
- func (b *InMemoryBackend) ListZonalShifts(status, resource, token string, maxResults int) ([]ShiftView, string, error)
- func (b *InMemoryBackend) ObserverNotificationStatus() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetAppConfig(cfg any)
- func (b *InMemoryBackend) SetObserverNotificationStatus(status string) (string, error)
- func (b *InMemoryBackend) SetPracticeRunDuration(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartPracticeRun(resource, awayFrom, comment string) (ShiftView, error)
- func (b *InMemoryBackend) StartZonalShift(resource, awayFrom, comment, expiresIn string) (ShiftView, error)
- func (b *InMemoryBackend) UpdatePracticeRunConfiguration(resource string, patch PracticeConfig, set map[string]bool) (PracticeOut, error)
- func (b *InMemoryBackend) UpdateZonalAutoshiftConfiguration(resource, status string) (string, error)
- func (b *InMemoryBackend) UpdateZonalShift(id, comment, expiresIn string) (ShiftView, error)
- type ManagedDetail
- type ManagedSummary
- type PracticeConfig
- type PracticeOut
- type PracticeView
- type Provider
- type ResourceSettings
- type Settings
- type Shift
- type ShiftInResource
- type ShiftView
Constants ¶
This section is empty.
Variables ¶
var ErrNilAppContext = errors.New("arczonalshift: AppContext must not be nil")
ErrNilAppContext is returned by Init when no AppContext is supplied.
Functions ¶
This section is empty.
Types ¶
type AutoshiftInResource ¶
type AutoshiftInResource struct {
AppliedStatus string `json:"appliedStatus"`
AwayFrom string `json:"awayFrom"`
StartTime float64 `json:"startTime"`
}
AutoshiftInResource is an autoshift as shown inside a managed resource.
type AutoshiftSummary ¶
type AutoshiftSummary struct {
EndTime *float64 `json:"endTime,omitempty"`
AwayFrom string `json:"awayFrom"`
Status string `json:"status"`
StartTime float64 `json:"startTime"`
}
AutoshiftSummary is one AWS-initiated autoshift.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
DefaultRegion string
// contains filtered or unexported fields
}
Handler serves the ARC zonal shift API.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates the handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions returns the regions served.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the first path label for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every implemented operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches by SigV4 signing name (or SDK user agent) plus a known path shape.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds zonal shift state; managed resources are read live from ELBv2.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID string) *InMemoryBackend
NewInMemoryBackend creates an empty backend for accountID.
func (*InMemoryBackend) CancelPracticeRun ¶
func (b *InMemoryBackend) CancelPracticeRun(id string) (ShiftView, error)
CancelPracticeRun ends an active practice run immediately.
func (*InMemoryBackend) CancelZonalShift ¶
func (b *InMemoryBackend) CancelZonalShift(id string) (ShiftView, error)
CancelZonalShift ends an active customer zonal shift immediately.
func (*InMemoryBackend) CreatePracticeRunConfiguration ¶
func (b *InMemoryBackend) CreatePracticeRunConfiguration(cfg PracticeConfig) (PracticeOut, error)
CreatePracticeRunConfiguration defines the practice run schedule and alarms for a managed resource.
func (*InMemoryBackend) DeletePracticeRunConfiguration ¶
func (b *InMemoryBackend) DeletePracticeRunConfiguration(resource string) (PracticeOut, error)
DeletePracticeRunConfiguration removes a configuration; zonal autoshift must be disabled first.
func (*InMemoryBackend) GetManagedResource ¶
func (b *InMemoryBackend) GetManagedResource(resource string) (ManagedDetail, error)
GetManagedResource describes one managed resource.
func (*InMemoryBackend) ListAutoshifts ¶
func (b *InMemoryBackend) ListAutoshifts(status, token string, maxResults int) ([]AutoshiftSummary, string, error)
ListAutoshifts lists AWS-initiated autoshifts; this emulator never initiates one, so only the filter is validated.
func (*InMemoryBackend) ListManagedResources ¶
func (b *InMemoryBackend) ListManagedResources(region, token string, maxResults int) ([]ManagedSummary, string, error)
ListManagedResources lists the load balancers of region as zonal-shift managed resources.
func (*InMemoryBackend) ListZonalShifts ¶
func (b *InMemoryBackend) ListZonalShifts(status, resource, token string, maxResults int) ([]ShiftView, string, error)
ListZonalShifts lists shifts, optionally filtered by status and resource.
func (*InMemoryBackend) ObserverNotificationStatus ¶
func (b *InMemoryBackend) ObserverNotificationStatus() string
ObserverNotificationStatus returns the account's autoshift observer notification status.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version starts empty. It implements persistence.Persistable.
func (*InMemoryBackend) SetAppConfig ¶
func (b *InMemoryBackend) SetAppConfig(cfg any)
SetAppConfig records service.AppContext.Config so siblings are resolved at call time.
func (*InMemoryBackend) SetObserverNotificationStatus ¶
func (b *InMemoryBackend) SetObserverNotificationStatus(status string) (string, error)
SetObserverNotificationStatus enables or disables autoshift observer notifications.
func (*InMemoryBackend) SetPracticeRunDuration ¶
func (b *InMemoryBackend) SetPracticeRunDuration(d time.Duration)
SetPracticeRunDuration sets how long a practice run stays ACTIVE (default 30 minutes); d <= 0 restores the default.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state. It implements persistence.Persistable.
func (*InMemoryBackend) StartPracticeRun ¶
func (b *InMemoryBackend) StartPracticeRun(resource, awayFrom, comment string) (ShiftView, error)
StartPracticeRun starts a practice run zonal shift if the practice configuration allows it right now.
func (*InMemoryBackend) StartZonalShift ¶
func (b *InMemoryBackend) StartZonalShift(resource, awayFrom, comment, expiresIn string) (ShiftView, error)
StartZonalShift moves traffic for a managed resource away from one Availability Zone until it expires.
func (*InMemoryBackend) UpdatePracticeRunConfiguration ¶
func (b *InMemoryBackend) UpdatePracticeRunConfiguration( resource string, patch PracticeConfig, set map[string]bool, ) (PracticeOut, error)
UpdatePracticeRunConfiguration replaces the supplied parts of a practice run configuration.
func (*InMemoryBackend) UpdateZonalAutoshiftConfiguration ¶
func (b *InMemoryBackend) UpdateZonalAutoshiftConfiguration(resource, status string) (string, error)
UpdateZonalAutoshiftConfiguration enables or disables zonal autoshift for a managed resource.
func (*InMemoryBackend) UpdateZonalShift ¶
func (b *InMemoryBackend) UpdateZonalShift(id, comment, expiresIn string) (ShiftView, error)
UpdateZonalShift changes the comment and/or resets the expiry of an active zonal shift.
type ManagedDetail ¶
type ManagedDetail struct {
AppliedWeights map[string]float32 `json:"appliedWeights"`
PracticeRunConfiguration *PracticeView `json:"practiceRunConfiguration,omitempty"`
Arn string `json:"arn"`
Name string `json:"name"`
ZonalAutoshiftStatus string `json:"zonalAutoshiftStatus"`
Autoshifts []AutoshiftInResource `json:"autoshifts"`
ZonalShifts []ShiftInResource `json:"zonalShifts"`
}
ManagedDetail is the wire form of GetManagedResource.
type ManagedSummary ¶
type ManagedSummary struct {
AppliedWeights map[string]float32 `json:"appliedWeights"`
Arn string `json:"arn"`
Name string `json:"name"`
PracticeRunStatus string `json:"practiceRunStatus"`
ZonalAutoshiftStatus string `json:"zonalAutoshiftStatus"`
AvailabilityZones []string `json:"availabilityZones"`
Autoshifts []AutoshiftInResource `json:"autoshifts"`
ZonalShifts []ShiftInResource `json:"zonalShifts"`
}
ManagedSummary is the wire form of a managed resource in ListManagedResources.
type PracticeConfig ¶
type PracticeConfig struct {
Resource string `json:"resource"`
OutcomeAlarms []Alarm `json:"outcomeAlarms"`
BlockingAlarms []Alarm `json:"blockingAlarms,omitempty"`
AllowedWindows []string `json:"allowedWindows,omitempty"`
BlockedWindows []string `json:"blockedWindows,omitempty"`
BlockedDates []string `json:"blockedDates,omitempty"`
}
PracticeConfig is a resource's practice run configuration.
type PracticeOut ¶
type PracticeOut struct {
Config *PracticeView `json:"practiceRunConfiguration,omitempty"`
Arn string `json:"arn"`
Name string `json:"name"`
ZonalAutoshiftStatus string `json:"zonalAutoshiftStatus"`
}
PracticeOut is the output of the practice run configuration operations.
type PracticeView ¶
type PracticeView struct {
OutcomeAlarms []Alarm `json:"outcomeAlarms"`
AllowedWindows []string `json:"allowedWindows,omitempty"`
BlockedDates []string `json:"blockedDates,omitempty"`
BlockedWindows []string `json:"blockedWindows,omitempty"`
BlockingAlarms []Alarm `json:"blockingAlarms,omitempty"`
}
PracticeView is the wire form of a practice run configuration.
type Provider ¶
type Provider struct{}
Provider implements service.Provider.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type ResourceSettings ¶
type ResourceSettings struct {
Resource string `json:"resource"`
Autoshift string `json:"autoshift"`
}
ResourceSettings is the per-resource autoshift status; present once any setting is changed.
type Shift ¶
type Shift struct {
StartTime time.Time `json:"startTime"`
ExpiryTime time.Time `json:"expiryTime"`
CanceledAt *time.Time `json:"canceledAt,omitempty"`
ID string `json:"id"`
Resource string `json:"resource"`
AwayFrom string `json:"awayFrom"`
Comment string `json:"comment"`
Type string `json:"type"`
Outcome string `json:"outcome,omitempty"`
}
Shift is a customer-started zonal shift or practice run.
type ShiftInResource ¶
type ShiftInResource struct {
AppliedStatus string `json:"appliedStatus"`
AwayFrom string `json:"awayFrom"`
Comment string `json:"comment"`
ResourceIdentifier string `json:"resourceIdentifier"`
ZonalShiftID string `json:"zonalShiftId"`
PracticeRunOutcome string `json:"practiceRunOutcome,omitempty"`
ShiftType string `json:"shiftType,omitempty"`
ExpiryTime float64 `json:"expiryTime"`
StartTime float64 `json:"startTime"`
}
ShiftInResource is a shift as shown inside a managed resource.
type ShiftView ¶
type ShiftView struct {
AwayFrom string `json:"awayFrom"`
Comment string `json:"comment"`
ResourceIdentifier string `json:"resourceIdentifier"`
Status string `json:"status"`
ZonalShiftID string `json:"zonalShiftId"`
PracticeRunOutcome string `json:"practiceRunOutcome,omitempty"`
ShiftType string `json:"shiftType,omitempty"`
ExpiryTime float64 `json:"expiryTime"`
StartTime float64 `json:"startTime"`
}
ShiftView is the wire form of a zonal shift (summary and Start/Update/Cancel output).