cloudmap

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AwsFacade added in v0.1.1

type AwsFacade interface {
	// ListNamespaces provides ServiceDiscovery ListNamespaces wrapper interface for paginator.
	ListNamespaces(context.Context, *sd.ListNamespacesInput, ...func(*sd.Options)) (*sd.ListNamespacesOutput, error)

	// ListServices provides ServiceDiscovery ListServices wrapper interface for paginator.
	ListServices(context.Context, *sd.ListServicesInput, ...func(options *sd.Options)) (*sd.ListServicesOutput, error)

	// ListOperations provides ServiceDiscovery ListOperations wrapper interface for paginator.
	ListOperations(context.Context, *sd.ListOperationsInput, ...func(*sd.Options)) (*sd.ListOperationsOutput, error)

	// GetOperation provides ServiceDiscovery GetOperation wrapper interface.
	GetOperation(context.Context, *sd.GetOperationInput, ...func(*sd.Options)) (*sd.GetOperationOutput, error)

	// CreateHttpNamespace provides ServiceDiscovery CreateHttpNamespace wrapper interface.
	CreateHttpNamespace(context.Context, *sd.CreateHttpNamespaceInput, ...func(*sd.Options)) (*sd.CreateHttpNamespaceOutput, error)

	// CreateService provides ServiceDiscovery CreateService wrapper interface.
	CreateService(context.Context, *sd.CreateServiceInput, ...func(*sd.Options)) (*sd.CreateServiceOutput, error)

	// RegisterInstance provides ServiceDiscovery RegisterInstance wrapper interface.
	RegisterInstance(context.Context, *sd.RegisterInstanceInput, ...func(*sd.Options)) (*sd.RegisterInstanceOutput, error)

	// DeregisterInstance provides ServiceDiscovery DeregisterInstance wrapper interface.
	DeregisterInstance(context.Context, *sd.DeregisterInstanceInput, ...func(*sd.Options)) (*sd.DeregisterInstanceOutput, error)

	// DiscoverInstances provides ServiceDiscovery DiscoverInstances wrapper interface.
	DiscoverInstances(context.Context, *sd.DiscoverInstancesInput, ...func(*sd.Options)) (*sd.DiscoverInstancesOutput, error)
}

AwsFacade wraps the minimal surface area of ServiceDiscovery API calls for the AWS SDK required by the AWS Cloud Map client. This enables mock generation for unit testing.

func NewAwsFacadeFromConfig added in v0.1.1

func NewAwsFacadeFromConfig(cfg *aws.Config) AwsFacade

NewAwsFacadeFromConfig creates a new AWS facade from an AWS client config.

type OperationPoller added in v0.1.1

type OperationPoller interface {
	// Submit operations to async poll
	Submit(ctx context.Context, opProvider func() (opId string, err error))

	// Poll operations for a terminal state
	Poll(ctx context.Context, opId string) (*types.Operation, error)

	// Await waits for all operation results from async poll
	Await() (err error)
}

OperationPoller polls a list operations for a terminal status

func NewOperationPoller added in v0.3.1

func NewOperationPoller(sdApi ServiceDiscoveryApi) OperationPoller

NewOperationPoller creates a new operation poller

func NewOperationPollerWithConfig added in v0.3.1

func NewOperationPollerWithConfig(pollInterval, pollTimeout time.Duration, sdApi ServiceDiscoveryApi) OperationPoller

NewOperationPollerWithConfig creates a new operation poller

type SdCacheConfig added in v0.2.0

type SdCacheConfig struct {
	NsTTL    time.Duration
	SvcTTL   time.Duration
	EndptTTL time.Duration
}

type ServiceDiscoveryApi added in v0.1.1

type ServiceDiscoveryApi interface {
	// GetNamespaceMap returns a map of all namespaces in the Cloud Map account indexed by namespace name.
	GetNamespaceMap(ctx context.Context) (namespaces map[string]*model.Namespace, err error)

	// GetServiceIdMap returns a map of all service IDs for a given namespace indexed by service name.
	GetServiceIdMap(ctx context.Context, namespaceId string) (serviceIdMap map[string]string, err error)

	// DiscoverInstances returns a list of service instances registered to a given service.
	DiscoverInstances(ctx context.Context, nsName string, svcName string, queryParameters map[string]string) (insts []types.HttpInstanceSummary, err error)

	// GetOperation returns an operation.
	GetOperation(ctx context.Context, operationId string) (operation *types.Operation, err error)

	// CreateHttpNamespace creates a HTTP namespace in AWS Cloud Map for a given name.
	CreateHttpNamespace(ctx context.Context, namespaceName string) (operationId string, err error)

	// CreateService creates a named service in AWS Cloud Map under the given namespace.
	CreateService(ctx context.Context, namespace model.Namespace, serviceName string) (serviceId string, err error)

	// RegisterInstance registers a service instance in AWS Cloud Map.
	RegisterInstance(ctx context.Context, serviceId string, instanceId string, instanceAttrs map[string]string) (operationId string, err error)

	// DeregisterInstance de-registers a service instance in Cloud Map.
	DeregisterInstance(ctx context.Context, serviceId string, instanceId string) (operationId string, err error)
}

ServiceDiscoveryApi handles the AWS Cloud Map API request and response processing logic, and converts results to internal data structures. It manages all interactions with the AWS SDK.

func NewServiceDiscoveryApiFromConfig added in v0.1.1

func NewServiceDiscoveryApiFromConfig(cfg *aws.Config) ServiceDiscoveryApi

NewServiceDiscoveryApiFromConfig creates a new AWS Cloud Map API connection manager from an AWS client config.

type ServiceDiscoveryClient

type ServiceDiscoveryClient interface {
	// ListServices returns all services and their endpoints for a given namespace.
	ListServices(ctx context.Context, namespaceName string) ([]*model.Service, error)

	// CreateService creates a Cloud Map service resource, and namespace if necessary.
	CreateService(ctx context.Context, namespaceName string, serviceName string) error

	// GetService returns a service resource fetched from AWS Cloud Map or nil if not found.
	GetService(ctx context.Context, namespaceName string, serviceName string) (*model.Service, error)

	// RegisterEndpoints registers all endpoints for given service.
	RegisterEndpoints(ctx context.Context, namespaceName string, serviceName string, endpoints []*model.Endpoint) error

	// DeleteEndpoints de-registers all endpoints for given service.
	DeleteEndpoints(ctx context.Context, namespaceName string, serviceName string, endpoints []*model.Endpoint) error
}

ServiceDiscoveryClient provides the service endpoint management functionality required by the AWS Cloud Map multi-cluster service discovery for Kubernetes controller. It maintains local caches for all AWS Cloud Map resources.

func NewDefaultServiceDiscoveryClient added in v0.2.0

func NewDefaultServiceDiscoveryClient(cfg *aws.Config, clusterUtils model.ClusterUtils) ServiceDiscoveryClient

NewDefaultServiceDiscoveryClient creates a new service discovery client for AWS Cloud Map with default resource cache from a given AWS client config.

func NewServiceDiscoveryClientWithCustomCache added in v0.2.0

func NewServiceDiscoveryClientWithCustomCache(cfg *aws.Config, cacheConfig *SdCacheConfig, clusterUtils model.ClusterUtils) ServiceDiscoveryClient

type ServiceDiscoveryClientCache added in v0.2.0

type ServiceDiscoveryClientCache interface {
	GetNamespaceMap() (namespaces map[string]*model.Namespace, found bool)
	CacheNamespaceMap(namespaces map[string]*model.Namespace)
	EvictNamespaceMap()
	GetServiceIdMap(namespaceName string) (serviceIdMap map[string]string, found bool)
	CacheServiceIdMap(namespaceName string, serviceIdMap map[string]string)
	EvictServiceIdMap(namespaceName string)
	GetEndpoints(namespaceName string, serviceName string) (endpoints []*model.Endpoint, found bool)
	CacheEndpoints(namespaceName string, serviceName string, endpoints []*model.Endpoint)
	EvictEndpoints(namespaceName string, serviceName string)
}

func NewDefaultServiceDiscoveryClientCache added in v0.2.0

func NewDefaultServiceDiscoveryClientCache() ServiceDiscoveryClientCache

func NewServiceDiscoveryClientCache added in v0.2.0

func NewServiceDiscoveryClientCache(cacheConfig *SdCacheConfig) ServiceDiscoveryClientCache

Jump to

Keyboard shortcuts

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