Help us shape the future of Go! Take the 2026 Go Developer Survey

networkmonitor

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 23 Imported by: 0

README

CloudWatch Network Monitor

Parity grade: A · SDK aws-sdk-go-v2/service/networkmonitor@v1.16.4 · last audited 2026-10-07 (9bcb4b792)

Coverage

Metric Value
PARITY entries audited 12 (12 ok)
Feature families 1 (1 ok)
Known gaps none
Deferred items 1
Resource leaks clean
Deferred
  • AccessDeniedException (403) / ThrottlingException (429) are not wired: verified this pass that there is no shared auth/rate-limit middleware anywhere in gopherstack that would inject these for networkmonitor (checked pkgs/chaos, which is fault-injection only, not standard error mapping) -- corrects last pass's unverified guess that such middleware existed. This backend has no auth model and no request-rate accounting, so there is no real condition under which these codes would ever be produced; every other audited service in this repo (ce, pipes, ssoadmin, fis, apprunner, polly) follows the same pattern of only wiring exception branches that have a genuine backend trigger. Re-open if gopherstack ever grows a cross-service auth/throttle layer.

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation determines the operation name from the HTTP request.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts the monitor name from the request path.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

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

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears handler state (delegates to backend if supported).

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches Network Monitor requests by service + path.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

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

func (b *InMemoryBackend) GetMonitor(ctx context.Context, name string) (*Monitor, error)

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) Reset

func (b *InMemoryBackend) Reset()

Reset clears all backend state.

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) SetActivationDelay

func (b *InMemoryBackend) SetActivationDelay(d time.Duration)

SetActivationDelay keeps new monitors and probes in PENDING for d before they report ACTIVE (default 0: ACTIVE immediately).

func (*InMemoryBackend) SetAppConfig

func (b *InMemoryBackend) SetAppConfig(cfg any)

SetAppConfig records service.AppContext.Config so sibling backends can be resolved lazily, after every provider has been constructed.

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

Init initializes the Network Monitor service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL