Documentation
¶
Index ¶
- Variables
- type ExportedMonitor
- 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) CreateMonitor(ctx context.Context, name string, aggregationPeriod *int64, ...) (*Monitor, error)
- func (b *InMemoryBackend) CreateProbe(ctx context.Context, monitorName string, pi *probeInput, ...) (*Probe, error)
- func (b *InMemoryBackend) DeleteMonitor(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteProbe(ctx context.Context, monitorName, probeID string) error
- func (b *InMemoryBackend) GetMonitor(ctx context.Context, name string) (*Monitor, error)
- func (b *InMemoryBackend) GetProbe(ctx context.Context, monitorName, probeID string) (*Probe, error)
- func (b *InMemoryBackend) ListMonitors(ctx context.Context, state, nextToken string, maxResults int) ([]monitorSummary, string, error)
- func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateMonitor(ctx context.Context, name string, aggregationPeriod int64) (*Monitor, error)
- func (b *InMemoryBackend) UpdateProbe(ctx context.Context, monitorName, probeID string, req *updateProbeRequest) (*Probe, error)
- type Monitor
- type Probe
- type Provider
- type StorageBackend
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a monitor or probe does not exist. ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) // ErrAlreadyExists is returned when a monitor already exists. ErrAlreadyExists = awserr.New("ConflictException", awserr.ErrAlreadyExists) // ErrValidation is returned for invalid input parameters. ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter) // ErrServiceQuotaExceeded is returned when a create operation would exceed // one of the documented Network Synthetic Monitor service quotas (see the // max*PerAccount/max*PerMonitor constants below). ErrServiceQuotaExceeded = errors.New("networkmonitor: service quota exceeded") )
var ErrNilAppContext = errors.New("networkmonitor: AppContext must not be nil")
ErrNilAppContext is returned by Provider.Init when a nil AppContext is supplied.
Functions ¶
This section is empty.
Types ¶
type ExportedMonitor ¶
type ExportedMonitor = Monitor
ExportedMonitor is a compatibility alias used by the dashboard package.
type Handler ¶
type Handler struct {
Backend StorageBackend
AccountID string
DefaultRegion string
}
Handler is the HTTP handler for the CloudWatch Network Monitor REST API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new Network Monitor handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation determines the operation name from the HTTP request.
func (*Handler) ExtractResource ¶
ExtractResource extracts the monitor name from the request path.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported Network Monitor operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears handler state (delegates to backend if supported).
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Network Monitor requests by service + path.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory implementation of StorageBackend. Resources are isolated by region via the "region|name" composite key [regionKey] builds (see store_setup.go for the Phase 3.3 datalayer conversion this struct went through).
func NewInMemoryBackend ¶
func NewInMemoryBackend(region, accountID string) *InMemoryBackend
NewInMemoryBackend creates a new InMemoryBackend.
func (*InMemoryBackend) CreateMonitor ¶
func (b *InMemoryBackend) CreateMonitor( ctx context.Context, name string, aggregationPeriod *int64, probeInputs []createMonitorProbeInput, tags map[string]string, ) (*Monitor, error)
CreateMonitor creates a new monitor.
func (*InMemoryBackend) CreateProbe ¶
func (b *InMemoryBackend) CreateProbe( ctx context.Context, monitorName string, pi *probeInput, tags map[string]string, ) (*Probe, error)
CreateProbe adds a probe to an existing monitor.
func (*InMemoryBackend) DeleteMonitor ¶
func (b *InMemoryBackend) DeleteMonitor(ctx context.Context, name string) error
DeleteMonitor deletes a monitor and its probes.
func (*InMemoryBackend) DeleteProbe ¶
func (b *InMemoryBackend) DeleteProbe(ctx context.Context, monitorName, probeID string) error
DeleteProbe removes a probe from a monitor.
func (*InMemoryBackend) GetMonitor ¶
GetMonitor returns a monitor by name.
func (*InMemoryBackend) GetProbe ¶
func (b *InMemoryBackend) GetProbe( ctx context.Context, monitorName, probeID string, ) (*Probe, error)
GetProbe returns a probe from a monitor.
func (*InMemoryBackend) ListMonitors ¶
func (b *InMemoryBackend) ListMonitors( ctx context.Context, state, nextToken string, maxResults int, ) ([]monitorSummary, string, error)
ListMonitors returns a filtered, paginated list of monitor summaries.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource( ctx context.Context, resourceARN string, ) (map[string]string, error)
ListTagsForResource returns tags for a monitor or probe by ARN.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource( ctx context.Context, resourceARN string, tags map[string]string, ) error
TagResource adds or updates tags on a monitor or probe.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource( ctx context.Context, resourceARN string, tagKeys []string, ) error
UntagResource removes tags from a monitor or probe.
func (*InMemoryBackend) UpdateMonitor ¶
func (b *InMemoryBackend) UpdateMonitor( ctx context.Context, name string, aggregationPeriod int64, ) (*Monitor, error)
UpdateMonitor updates a monitor's aggregation period.
func (*InMemoryBackend) UpdateProbe ¶
func (b *InMemoryBackend) UpdateProbe( ctx context.Context, monitorName, probeID string, req *updateProbeRequest, ) (*Probe, error)
UpdateProbe updates a probe's attributes.
type Monitor ¶
type Monitor struct {
CreatedAt *time.Time `json:"createdAt,omitempty"`
ModifiedAt *time.Time `json:"modifiedAt,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
MonitorArn string `json:"monitorArn"`
MonitorName string `json:"monitorName"`
Region string `json:"region"`
State string `json:"state"`
Probes []*Probe `json:"probes,omitempty"`
AggregationPeriod int64 `json:"aggregationPeriod"`
}
Monitor represents an AWS CloudWatch Network Monitor monitor.
Region is not part of the AWS wire shape (handler.go always builds a dedicated response DTO rather than marshaling Monitor directly); it exists purely to carry the store.Table composite-key component ("region|name", see regionKey in backend.go) through JSON round-tripping, since monitors were previously nested by region (map[string]map[string]*Monitor) instead of carrying their region on the value itself. See store_setup.go.
type Probe ¶
type Probe struct {
CreatedAt *time.Time `json:"createdAt,omitempty"`
ModifiedAt *time.Time `json:"modifiedAt,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
PacketSize *int32 `json:"packetSize,omitempty"`
DestinationPort *int32 `json:"destinationPort,omitempty"`
Destination string `json:"destination"`
SourceArn string `json:"sourceArn"`
Protocol string `json:"protocol"`
State string `json:"state"`
AddressFamily string `json:"addressFamily,omitempty"`
VpcID string `json:"vpcId,omitempty"`
ProbeID string `json:"probeId,omitempty"`
ProbeArn string `json:"probeArn,omitempty"`
}
Probe represents a network monitor probe.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Network Monitor service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Network Monitor service backend and handler.
type StorageBackend ¶
type StorageBackend interface {
CreateMonitor(
ctx context.Context,
name string,
aggregationPeriod *int64,
probes []createMonitorProbeInput,
tags map[string]string,
) (*Monitor, error)
DeleteMonitor(ctx context.Context, name string) error
GetMonitor(ctx context.Context, name string) (*Monitor, error)
UpdateMonitor(ctx context.Context, name string, aggregationPeriod int64) (*Monitor, error)
ListMonitors(
ctx context.Context,
state, nextToken string,
maxResults int,
) ([]monitorSummary, string, error)
CreateProbe(
ctx context.Context,
monitorName string,
probe *probeInput,
tags map[string]string,
) (*Probe, error)
DeleteProbe(ctx context.Context, monitorName, probeID string) error
GetProbe(ctx context.Context, monitorName, probeID string) (*Probe, error)
UpdateProbe(
ctx context.Context,
monitorName, probeID string,
req *updateProbeRequest,
) (*Probe, error)
ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
}
StorageBackend is the interface for the Network Monitor in-memory backend.