Documentation
¶
Index ¶
- Variables
- type DNSConfig
- type DNSProperties
- type DNSRecord
- type DiscoveredInstance
- type HTTPProperties
- 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 HealthCheckConfig
- type HealthCheckCustomConfig
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) CreateHTTPNamespace(name, description string, tags map[string]string) (string, error)
- func (b *InMemoryBackend) CreatePrivateDNSNamespace(name, description, vpc string, soaTTL int64, tags map[string]string) (string, error)
- func (b *InMemoryBackend) CreatePublicDNSNamespace(name, description string, soaTTL int64, tags map[string]string) (string, error)
- func (b *InMemoryBackend) CreateService(name, namespaceID, description, svcType string, dnsConfig *DNSConfig, ...) (*Service, error)
- func (b *InMemoryBackend) DeleteNamespace(id string) (string, error)
- func (b *InMemoryBackend) DeleteService(id string) error
- func (b *InMemoryBackend) DeleteServiceAttributes(serviceID string) error
- func (b *InMemoryBackend) DeregisterInstance(serviceID, instanceID string) (string, error)
- func (b *InMemoryBackend) DiscoverInstances(namespaceName, serviceName, healthStatus string, queryParams map[string]string) ([]DiscoveredInstance, int64, error)
- func (b *InMemoryBackend) DiscoverInstancesRevision(namespaceName, serviceName string) (int64, error)
- func (b *InMemoryBackend) GetInstance(serviceID, instanceID string) (*Instance, error)
- func (b *InMemoryBackend) GetInstancesHealthStatus(serviceID string, instanceIDs []string) (map[string]string, error)
- func (b *InMemoryBackend) GetNamespace(id string) (*Namespace, error)
- func (b *InMemoryBackend) GetOperation(id string) (*Operation, error)
- func (b *InMemoryBackend) GetService(id string) (*Service, error)
- func (b *InMemoryBackend) GetServiceAttributes(serviceID string) (string, map[string]string, error)
- func (b *InMemoryBackend) ListInstances(serviceID string) ([]Instance, error)
- func (b *InMemoryBackend) ListNamespaces(filter ListNamespacesFilter) []Namespace
- func (b *InMemoryBackend) ListOperations(filter ListOperationsFilter) []Operation
- func (b *InMemoryBackend) ListServices(filter ListServicesFilter) []Service
- func (b *InMemoryBackend) ListTagsForResource(arn string) (map[string]string, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) RegisterInstance(serviceID, instanceID string, attrs map[string]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(arn string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(arn string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateHTTPNamespace(id, description string) (string, error)
- func (b *InMemoryBackend) UpdateInstanceCustomHealthStatus(serviceID, instanceID, status string) error
- func (b *InMemoryBackend) UpdatePrivateDNSNamespace(id, description string) (string, error)
- func (b *InMemoryBackend) UpdatePublicDNSNamespace(id, description string) (string, error)
- func (b *InMemoryBackend) UpdateService(id, description string, dnsConfig *DNSConfig, hcc *HealthCheckConfig) (string, error)
- func (b *InMemoryBackend) UpdateServiceAttributes(serviceARN string, attributes map[string]string) error
- type Instance
- type ListNamespacesFilter
- type ListOperationsFilter
- type ListServicesFilter
- type Namespace
- type NamespaceProperties
- type Operation
- type Provider
- type SOA
- type Service
- type StorageBackend
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNamespaceNotFound is returned when a namespace does not exist. ErrNamespaceNotFound = awserr.New("NamespaceNotFound", awserr.ErrNotFound) // ErrServiceNotFound is returned when a service does not exist. ErrServiceNotFound = awserr.New("ServiceNotFound", awserr.ErrNotFound) // ErrInstanceNotFound is returned when an instance does not exist. ErrInstanceNotFound = awserr.New("InstanceNotFound", awserr.ErrNotFound) // ErrOperationNotFound is returned when an operation does not exist. ErrOperationNotFound = awserr.New("OperationNotFound", awserr.ErrNotFound) // ErrNamespaceAlreadyExists is returned when a namespace with the same name already exists. ErrNamespaceAlreadyExists = awserr.New("NamespaceAlreadyExists", awserr.ErrAlreadyExists) // ErrServiceAttributesNotFound is returned when no attributes exist for a service. ErrServiceAttributesNotFound = awserr.New("ServiceAttributesNotFound", awserr.ErrNotFound) // ErrInvalidInput is returned when an input value is invalid. ErrInvalidInput = awserr.New("InvalidInput", awserr.ErrInvalidParameter) // ErrResourceNotFound is returned when a tagged resource ARN is not found. ErrResourceNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) // ErrResourceInUse is returned when a delete is attempted on a non-empty namespace or service. ErrResourceInUse = awserr.New("ResourceInUse", awserr.ErrConflict) // ErrCustomHealthNotFound is returned when UpdateInstanceCustomHealthStatus is called on a // service that has no HealthCheckCustomConfig. ErrCustomHealthNotFound = awserr.New("CustomHealthNotFound", awserr.ErrNotFound) // ErrTooManyTags is returned when a request would leave a resource with more than // maxTagCount tags. ErrTooManyTags = awserr.New("TooManyTagsException", awserr.ErrInvalidParameter) )
var ErrNilAppContext = errors.New("nil AppContext passed to ServiceDiscovery Provider.Init")
ErrNilAppContext is returned when a nil AppContext is passed to Provider.Init.
Functions ¶
This section is empty.
Types ¶
type DNSConfig ¶
type DNSConfig struct {
NamespaceID string `json:"namespaceID,omitempty"`
RoutingPolicy string `json:"routingPolicy,omitempty"`
DNSRecords []DNSRecord `json:"dnsRecords,omitempty"`
}
DNSConfig holds the DNS configuration for a Cloud Map service.
type DNSProperties ¶
type DNSProperties struct {
SOA *SOA `json:"soa,omitempty"`
HostedZoneID string `json:"hostedZoneId,omitempty"`
}
DNSProperties holds the DNS-specific properties of a namespace.
type DiscoveredInstance ¶
type DiscoveredInstance struct {
Attributes map[string]string
InstanceID string
NamespaceName string
ServiceName string
HealthStatus string
}
DiscoveredInstance is the richer per-instance response for DiscoverInstances.
type HTTPProperties ¶
type HTTPProperties struct {
HTTPName string `json:"httpName,omitempty"`
}
HTTPProperties holds the HTTP-specific properties of a namespace.
type Handler ¶
type Handler struct {
Backend StorageBackend
AccountID string
Region string
}
Handler is the HTTP handler for the AWS Cloud Map service discovery API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new Cloud Map 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 extracts the operation name from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource extracts the primary resource ID from the request body.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported Cloud Map operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for Cloud Map requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Cloud Map API requests. Requests are identified by the X-Amz-Target header prefix "Route53AutoNaming_v20170314.".
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Type string `json:"type"`
ResourcePath string `json:"resourcePath,omitempty"`
FailureThreshold int `json:"failureThreshold,omitempty"`
}
HealthCheckConfig holds the configuration for an AWS-managed HTTP/TCP health check.
type HealthCheckCustomConfig ¶
type HealthCheckCustomConfig struct {
FailureThreshold int `json:"failureThreshold,omitempty"`
}
HealthCheckCustomConfig holds the configuration for a custom health check.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory Cloud Map backend.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new in-memory Cloud Map backend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the AWS account ID this backend is configured for.
func (*InMemoryBackend) CreateHTTPNamespace ¶
func (b *InMemoryBackend) CreateHTTPNamespace(name, description string, tags map[string]string) (string, error)
CreateHTTPNamespace creates an HTTP namespace.
func (*InMemoryBackend) CreatePrivateDNSNamespace ¶
func (b *InMemoryBackend) CreatePrivateDNSNamespace( name, description, vpc string, soaTTL int64, tags map[string]string, ) (string, error)
CreatePrivateDNSNamespace creates a private DNS namespace. soaTTL defaults to 15 when zero.
func (*InMemoryBackend) CreatePublicDNSNamespace ¶
func (b *InMemoryBackend) CreatePublicDNSNamespace( name, description string, soaTTL int64, tags map[string]string, ) (string, error)
CreatePublicDNSNamespace creates a public DNS namespace. soaTTL defaults to 15 when zero.
func (*InMemoryBackend) CreateService ¶
func (b *InMemoryBackend) CreateService( name, namespaceID, description, svcType string, dnsConfig *DNSConfig, hcc *HealthCheckConfig, hccc *HealthCheckCustomConfig, tags map[string]string, ) (*Service, error)
CreateService creates a new Cloud Map service.
func (*InMemoryBackend) DeleteNamespace ¶
func (b *InMemoryBackend) DeleteNamespace(id string) (string, error)
DeleteNamespace deletes a namespace by ID. Returns ResourceInUse if the namespace still has services.
func (*InMemoryBackend) DeleteService ¶
func (b *InMemoryBackend) DeleteService(id string) error
DeleteService deletes a service by ID. Returns ResourceInUse if instances are still registered.
func (*InMemoryBackend) DeleteServiceAttributes ¶
func (b *InMemoryBackend) DeleteServiceAttributes(serviceID string) error
DeleteServiceAttributes removes all custom attributes for a service.
func (*InMemoryBackend) DeregisterInstance ¶
func (b *InMemoryBackend) DeregisterInstance(serviceID, instanceID string) (string, error)
DeregisterInstance deregisters an instance from a service.
func (*InMemoryBackend) DiscoverInstances ¶
func (b *InMemoryBackend) DiscoverInstances( namespaceName, serviceName, healthStatus string, queryParams map[string]string, ) ([]DiscoveredInstance, int64, error)
DiscoverInstances returns discovered instances with full per-instance metadata. Also returns the per-service revision counter.
func (*InMemoryBackend) DiscoverInstancesRevision ¶
func (b *InMemoryBackend) DiscoverInstancesRevision(namespaceName, serviceName string) (int64, error)
DiscoverInstancesRevision returns the current revision for the specified service. Revision is per-service, incremented on each RegisterInstance/DeregisterInstance.
func (*InMemoryBackend) GetInstance ¶
func (b *InMemoryBackend) GetInstance(serviceID, instanceID string) (*Instance, error)
GetInstance returns a registered instance.
func (*InMemoryBackend) GetInstancesHealthStatus ¶
func (b *InMemoryBackend) GetInstancesHealthStatus(serviceID string, instanceIDs []string) (map[string]string, error)
GetInstancesHealthStatus returns the health status for instances in a service. If instanceIDs is non-empty, only those instances are included. Instances without a recorded status default to HEALTHY.
func (*InMemoryBackend) GetNamespace ¶
func (b *InMemoryBackend) GetNamespace(id string) (*Namespace, error)
GetNamespace returns a namespace by ID.
func (*InMemoryBackend) GetOperation ¶
func (b *InMemoryBackend) GetOperation(id string) (*Operation, error)
GetOperation returns an operation by ID.
func (*InMemoryBackend) GetService ¶
func (b *InMemoryBackend) GetService(id string) (*Service, error)
GetService returns a service by ID.
func (*InMemoryBackend) GetServiceAttributes ¶
GetServiceAttributes returns the custom attributes for a service.
func (*InMemoryBackend) ListInstances ¶
func (b *InMemoryBackend) ListInstances(serviceID string) ([]Instance, error)
ListInstances returns all instances registered to a service.
func (*InMemoryBackend) ListNamespaces ¶
func (b *InMemoryBackend) ListNamespaces(filter ListNamespacesFilter) []Namespace
ListNamespaces returns all namespaces sorted by name, optionally filtered.
func (*InMemoryBackend) ListOperations ¶
func (b *InMemoryBackend) ListOperations(filter ListOperationsFilter) []Operation
ListOperations returns all operations sorted by ID, optionally filtered.
func (*InMemoryBackend) ListServices ¶
func (b *InMemoryBackend) ListServices(filter ListServicesFilter) []Service
ListServices returns all services, optionally filtered.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(arn string) (map[string]string, error)
ListTagsForResource returns tags for a resource ARN (namespace or service).
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the AWS region this backend is configured for.
func (*InMemoryBackend) RegisterInstance ¶
func (b *InMemoryBackend) RegisterInstance(serviceID, instanceID string, attrs map[string]string) (string, error)
RegisterInstance registers an instance to a service.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all backend state, resetting to an empty store.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(arn string, tags map[string]string) error
TagResource adds tags to a resource (namespace or service).
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(arn string, tagKeys []string) error
UntagResource removes tags from a resource (namespace or service).
func (*InMemoryBackend) UpdateHTTPNamespace ¶
func (b *InMemoryBackend) UpdateHTTPNamespace(id, description string) (string, error)
UpdateHTTPNamespace updates the description of an HTTP namespace.
func (*InMemoryBackend) UpdateInstanceCustomHealthStatus ¶
func (b *InMemoryBackend) UpdateInstanceCustomHealthStatus(serviceID, instanceID, status string) error
UpdateInstanceCustomHealthStatus sets a custom health status for an instance. Returns CustomHealthNotFound if the service has no HealthCheckCustomConfig.
func (*InMemoryBackend) UpdatePrivateDNSNamespace ¶
func (b *InMemoryBackend) UpdatePrivateDNSNamespace(id, description string) (string, error)
UpdatePrivateDNSNamespace updates the description of a private DNS namespace.
func (*InMemoryBackend) UpdatePublicDNSNamespace ¶
func (b *InMemoryBackend) UpdatePublicDNSNamespace(id, description string) (string, error)
UpdatePublicDNSNamespace updates the description of a public DNS namespace.
func (*InMemoryBackend) UpdateService ¶
func (b *InMemoryBackend) UpdateService( id, description string, dnsConfig *DNSConfig, hcc *HealthCheckConfig, ) (string, error)
UpdateService updates the description and optionally DNSConfig/HealthCheckConfig of a service. Returns the operation ID, matching real AWS UpdateService behavior.
func (*InMemoryBackend) UpdateServiceAttributes ¶
func (b *InMemoryBackend) UpdateServiceAttributes(serviceARN string, attributes map[string]string) error
UpdateServiceAttributes sets or merges custom attributes for a service identified by ARN.
type Instance ¶
type Instance struct {
Attributes map[string]string `json:"attributes,omitempty"`
ID string `json:"id"`
ServiceID string `json:"serviceID"`
}
Instance represents a registered instance in a Cloud Map service.
type ListNamespacesFilter ¶
ListNamespacesFilter contains optional filter parameters for ListNamespaces.
type ListOperationsFilter ¶
ListOperationsFilter contains optional filter parameters for ListOperations.
type ListServicesFilter ¶
type ListServicesFilter struct {
NamespaceID string
}
ListServicesFilter contains optional filter parameters for ListServices.
type Namespace ¶
type Namespace struct {
CreatedAt time.Time `json:"createdAt"`
Tags map[string]string `json:"tags,omitempty"`
Properties *NamespaceProperties `json:"properties,omitempty"`
ID string `json:"id"`
ARN string `json:"arn"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
VPC string `json:"vpc,omitempty"`
ServiceCount int `json:"serviceCount,omitempty"`
}
Namespace represents an AWS Cloud Map namespace.
type NamespaceProperties ¶
type NamespaceProperties struct {
DNSProperties *DNSProperties `json:"dnsProperties,omitempty"`
HTTPProperties *HTTPProperties `json:"httpProperties,omitempty"`
}
NamespaceProperties holds the type-specific properties of a namespace.
type Operation ¶
type Operation struct {
CreateDate time.Time `json:"createDate"`
UpdateDate time.Time `json:"updateDate"`
Targets map[string]string `json:"targets,omitempty"`
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
Operation represents an async Cloud Map operation (e.g., create/delete namespace).
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS Cloud Map (Service Discovery).
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Service Discovery backend and handler.
type SOA ¶
type SOA struct {
TTL int64 `json:"ttl"`
}
SOA holds the Start of Authority TTL for a DNS namespace.
type Service ¶
type Service struct {
CreatedAt time.Time `json:"createdAt"`
Tags map[string]string `json:"tags,omitempty"`
DNSConfig *DNSConfig `json:"dnsConfig,omitempty"`
HealthCheckConfig *HealthCheckConfig `json:"healthCheckConfig,omitempty"`
HealthCheckCustomConfig *HealthCheckCustomConfig `json:"healthCheckCustomConfig,omitempty"`
ID string `json:"id"`
ARN string `json:"arn"`
Name string `json:"name"`
NamespaceID string `json:"namespaceID"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
InstanceCount int `json:"instanceCount,omitempty"`
}
Service represents an AWS Cloud Map service.
type StorageBackend ¶
type StorageBackend interface {
// Namespace operations.
CreateHTTPNamespace(name, description string, tags map[string]string) (string, error)
CreatePrivateDNSNamespace(name, description, vpc string, soaTTL int64, tags map[string]string) (string, error)
CreatePublicDNSNamespace(name, description string, soaTTL int64, tags map[string]string) (string, error)
DeleteNamespace(id string) (string, error)
GetNamespace(id string) (*Namespace, error)
ListNamespaces(filter ListNamespacesFilter) []Namespace
UpdateHTTPNamespace(id, description string) (string, error)
UpdatePrivateDNSNamespace(id, description string) (string, error)
UpdatePublicDNSNamespace(id, description string) (string, error)
// Service operations.
CreateService(
name, namespaceID, description, svcType string,
dnsConfig *DNSConfig,
hcc *HealthCheckConfig,
hccc *HealthCheckCustomConfig,
tags map[string]string,
) (*Service, error)
DeleteService(id string) error
GetService(id string) (*Service, error)
ListServices(filter ListServicesFilter) []Service
UpdateService(id, description string, dnsConfig *DNSConfig, hcc *HealthCheckConfig) (string, error)
GetServiceAttributes(serviceID string) (string, map[string]string, error)
UpdateServiceAttributes(serviceARN string, attributes map[string]string) error
DeleteServiceAttributes(serviceID string) error
// Instance operations.
RegisterInstance(serviceID, instanceID string, attrs map[string]string) (string, error)
DeregisterInstance(serviceID, instanceID string) (string, error)
GetInstance(serviceID, instanceID string) (*Instance, error)
ListInstances(serviceID string) ([]Instance, error)
DiscoverInstances(
namespaceName, serviceName, healthStatus string,
queryParams map[string]string,
) ([]DiscoveredInstance, int64, error)
DiscoverInstancesRevision(namespaceName, serviceName string) (int64, error)
GetInstancesHealthStatus(serviceID string, instanceIDs []string) (map[string]string, error)
UpdateInstanceCustomHealthStatus(serviceID, instanceID, status string) error
// Operation operations.
GetOperation(id string) (*Operation, error)
ListOperations(filter ListOperationsFilter) []Operation
// Tag operations.
ListTagsForResource(arn string) (map[string]string, error)
TagResource(arn string, tags map[string]string) error
UntagResource(arn string, tagKeys []string) error
// Lifecycle methods.
Reset()
Region() string
AccountID() string
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
}
StorageBackend defines the operations required from the Cloud Map storage layer. All methods must be safe for concurrent use.