elasticache

package
v0.0.1-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package elasticache provides emulation of Amazon ElastiCache.

Implemented: CreateCacheCluster, DescribeCacheClusters, DeleteCacheCluster, CreateServerlessCache, DescribeServerlessCaches, DeleteServerlessCache, ModifyServerlessCache, ModifyCacheCluster, CreateReplicationGroup, DescribeReplicationGroups, DeleteReplicationGroup, ModifyReplicationGroup, CreateCacheSubnetGroup, DescribeCacheSubnetGroups, DeleteCacheSubnetGroup, CreateCacheParameterGroup, DescribeCacheParameterGroups, DeleteCacheParameterGroup, AddTagsToResource, ListTagsForResource, RemoveTagsFromResource.

On CreateCacheCluster, a real Redis container is started (same pattern as RDS). The cluster reaches "available" state once the TCP health check succeeds.

All other operations return HTTP 501 Not Implemented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheCluster

type CacheCluster struct {
	CacheClusterId            string           `json:"CacheClusterId"`
	CacheClusterStatus        string           `json:"CacheClusterStatus"`
	CacheNodeType             string           `json:"CacheNodeType"`
	Engine                    string           `json:"Engine"`
	EngineVersion             string           `json:"EngineVersion"`
	NumCacheNodes             int              `json:"NumCacheNodes"`
	PreferredAvailabilityZone string           `json:"PreferredAvailabilityZone,omitempty"`
	CacheSubnetGroupName      string           `json:"CacheSubnetGroupName,omitempty"`
	ReplicationGroupId        string           `json:"ReplicationGroupId,omitempty"`
	CacheParameterGroupName   string           `json:"CacheParameterGroupName,omitempty"`
	ARN                       string           `json:"ARN"`
	ConfigurationEndpoint     *ClusterEndpoint `json:"ConfigurationEndpoint,omitempty"`
	// Docker fields — internal only, not returned in API responses.
	DockerContainerID string `json:"DockerContainerID,omitempty"`
	HostPort          int    `json:"HostPort,omitempty"`
}

CacheCluster represents a stored ElastiCache cache cluster.

type CacheParameterGroup

type CacheParameterGroup struct {
	CacheParameterGroupName   string `json:"CacheParameterGroupName"`
	CacheParameterGroupFamily string `json:"CacheParameterGroupFamily"`
	Description               string `json:"Description"`
	ARN                       string `json:"ARN"`
}

CacheParameterGroup represents a stored ElastiCache cache parameter group.

type CacheSubnetGroup

type CacheSubnetGroup struct {
	CacheSubnetGroupName        string   `json:"CacheSubnetGroupName"`
	CacheSubnetGroupDescription string   `json:"CacheSubnetGroupDescription"`
	ARN                         string   `json:"ARN"`
	VpcId                       string   `json:"VpcId"`
	SubnetIds                   []string `json:"SubnetIds"`
}

CacheSubnetGroup represents a stored ElastiCache cache subnet group.

type CacheUsageLimits

type CacheUsageLimits struct {
	DataStorage   DataStorageLimit `json:"DataStorage,omitempty"`
	ECPUPerSecond ECPULimit        `json:"ECPUPerSecond,omitempty"`
}

type ClusterEndpoint

type ClusterEndpoint struct {
	Address string `json:"Address"`
	Port    int    `json:"Port"`
}

ClusterEndpoint is the endpoint for a cache cluster or replication group.

type DataStorageLimit

type DataStorageLimit struct {
	Maximum int    `json:"Maximum,omitempty"`
	Unit    string `json:"Unit,omitempty"`
}

type ECPULimit

type ECPULimit struct {
	Maximum int `json:"Maximum,omitempty"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles ElastiCache Query-protocol requests.

func (*Handler) AddTagsToResource

func (h *Handler) AddTagsToResource(w http.ResponseWriter, r *http.Request)

func (*Handler) CreateCacheCluster

func (h *Handler) CreateCacheCluster(w http.ResponseWriter, r *http.Request)

CreateCacheCluster creates a new cache cluster and (when Docker is available) starts a real Redis container. The cluster transitions to "available" once the TCP health check succeeds, matching AWS semantics.

func (*Handler) CreateCacheParameterGroup

func (h *Handler) CreateCacheParameterGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) CreateCacheSubnetGroup

func (h *Handler) CreateCacheSubnetGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) CreateReplicationGroup

func (h *Handler) CreateReplicationGroup(w http.ResponseWriter, r *http.Request)

CreateReplicationGroup creates a replication group and (when Docker is available) starts a single primary container. The group transitions to "available" once the TCP health check succeeds, matching AWS semantics.

func (*Handler) CreateServerlessCache

func (h *Handler) CreateServerlessCache(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteCacheCluster

func (h *Handler) DeleteCacheCluster(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteCacheParameterGroup

func (h *Handler) DeleteCacheParameterGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteCacheSubnetGroup

func (h *Handler) DeleteCacheSubnetGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteReplicationGroup

func (h *Handler) DeleteReplicationGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteServerlessCache

func (h *Handler) DeleteServerlessCache(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeCacheClusters

func (h *Handler) DescribeCacheClusters(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeCacheEngineVersions

func (h *Handler) DescribeCacheEngineVersions(w http.ResponseWriter, r *http.Request)

TODO(priority:P3): Implement DescribeCacheEngineVersions — can return a static list of supported redis/valkey versions.

func (*Handler) DescribeCacheParameterGroups

func (h *Handler) DescribeCacheParameterGroups(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeCacheParameters

func (h *Handler) DescribeCacheParameters(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeCacheSubnetGroups

func (h *Handler) DescribeCacheSubnetGroups(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeReplicationGroups

func (h *Handler) DescribeReplicationGroups(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeServerlessCaches

func (h *Handler) DescribeServerlessCaches(w http.ResponseWriter, r *http.Request)

func (*Handler) ListTagsForResource

func (h *Handler) ListTagsForResource(w http.ResponseWriter, r *http.Request)

func (*Handler) ModifyCacheCluster

func (h *Handler) ModifyCacheCluster(w http.ResponseWriter, r *http.Request)

func (*Handler) ModifyReplicationGroup

func (h *Handler) ModifyReplicationGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) ModifyServerlessCache

func (h *Handler) ModifyServerlessCache(w http.ResponseWriter, r *http.Request)

func (*Handler) RebootCacheCluster

func (h *Handler) RebootCacheCluster(w http.ResponseWriter, r *http.Request)

TODO(priority:P3): Implement RebootCacheCluster.

func (*Handler) RemoveTagsFromResource

func (h *Handler) RemoveTagsFromResource(w http.ResponseWriter, r *http.Request)

type ReplicationGroup

type ReplicationGroup struct {
	ReplicationGroupId     string           `json:"ReplicationGroupId"`
	Description            string           `json:"Description"`
	Status                 string           `json:"Status"`
	ARN                    string           `json:"ARN"`
	AutomaticFailover      string           `json:"AutomaticFailover"`
	MultiAZ                string           `json:"MultiAZ"`
	CacheNodeType          string           `json:"CacheNodeType"`
	Engine                 string           `json:"Engine"`
	EngineVersion          string           `json:"EngineVersion"`
	SnapshotRetentionLimit int              `json:"SnapshotRetentionLimit"`
	MemberClusters         []string         `json:"MemberClusters,omitempty"`
	ConfigurationEndpoint  *ClusterEndpoint `json:"ConfigurationEndpoint,omitempty"`
	// Docker fields — internal only, not returned in API responses.
	DockerContainerID string `json:"DockerContainerID,omitempty"`
	HostPort          int    `json:"HostPort,omitempty"`
}

ReplicationGroup represents a stored ElastiCache replication group.

type ServerlessCache

type ServerlessCache struct {
	ServerlessCacheName   string           `json:"ServerlessCacheName"`
	Description           string           `json:"Description"`
	Status                string           `json:"Status"`
	Engine                string           `json:"Engine"`
	MajorEngineVersion    string           `json:"MajorEngineVersion"`
	FullEngineVersion     string           `json:"FullEngineVersion"`
	CacheUsageLimits      CacheUsageLimits `json:"CacheUsageLimits,omitempty"`
	ARN                   string           `json:"ARN"`
	CreateTime            string           `json:"CreateTime"`
	Endpoint              *ClusterEndpoint `json:"Endpoint,omitempty"`
	ReaderEndpoint        *ClusterEndpoint `json:"ReaderEndpoint,omitempty"`
	SubnetIds             []string         `json:"SubnetIds,omitempty"`
	SecurityGroupIds      []string         `json:"SecurityGroupIds,omitempty"`
	SnapshotArnsToRestore []string         `json:"SnapshotArnsToRestore,omitempty"`
	SnapshotRetention     int              `json:"SnapshotRetentionLimit"`
	DailySnapshotTime     string           `json:"DailySnapshotTime,omitempty"`
	NetworkType           string           `json:"NetworkType,omitempty"`
	UserGroupId           string           `json:"UserGroupId,omitempty"`
	KmsKeyId              string           `json:"KmsKeyId,omitempty"`
	DockerContainerID     string           `json:"DockerContainerID,omitempty"`
	HostPort              int              `json:"HostPort,omitempty"`
}

ServerlessCache represents a stored ElastiCache serverless cache.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements router.Service and router.QueryDispatcher for ElastiCache. Uses the AWS Query protocol (form-encoded POST, XML responses) and identifies itself by the API version "2015-02-02".

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock) *Service

New returns a configured ElastiCache Service.

func (*Service) DispatchQuery

func (s *Service) DispatchQuery(w http.ResponseWriter, r *http.Request)

DispatchQuery satisfies router.QueryDispatcher; routes to the correct handler.

func (*Service) InitBus

func (s *Service) InitBus(bus *events.Bus)

InitBus wires the event bus for ElastiCache lifecycle events and subscribes to Docker container events so cluster status stays in sync with container state.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) Operations

func (s *Service) Operations() []op.Operation

func (*Service) OwnsVersion

func (s *Service) OwnsVersion(version string) bool

OwnsVersion satisfies router.QueryVersionOwner.

func (*Service) ReconcileContainers

func (s *Service) ReconcileContainers(ctx context.Context, containers []docker.ContainerSummary)

ReconcileContainers satisfies router.ContainerReconciler. It is called once after Docker becomes available at startup and syncs stored cluster statuses against the actual container state.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(_ chi.Router)

RegisterRoutes satisfies router.Service. ElastiCache has no emulator-only REST endpoints; all operations go through DispatchQuery.

func (*Service) SetDocker

func (s *Service) SetDocker(dc *docker.Client)

SetDocker wires the Docker client for ElastiCache container management and starts the DockerGC background remove loop.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context)

Stop cancels pending lifecycle transitions, waits for in-flight Docker goroutines, then cleans up all containers via the GC.

func (*Service) SupportedProtocols

func (s *Service) SupportedProtocols() []codec.Codec

Jump to

Keyboard shortcuts

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