Documentation
¶
Overview ¶
Package timestreaminfluxdb emulates Amazon Timestream for InfluxDB: DB instances, clusters, parameter groups and backups, with an opt-in docker engine that runs a real InfluxDB 2 server per instance.
Index ¶
- Constants
- Variables
- type BackupConfig
- type BackupInput
- type ClusterConfig
- type ClusterInput
- type ClusterUpdate
- type ContainerRuntime
- type DBBackup
- type DBCluster
- type DBInstance
- type DBParameterGroup
- type DockerEngine
- type Engine
- type EngineHandle
- type EngineSpec
- type GroupInput
- type HTTPDoer
- 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) Shutdown(_ context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) CreateDBBackup(ctx context.Context, in BackupInput) (wBackup, error)
- func (b *InMemoryBackend) CreateDBCluster(ctx context.Context, in ClusterInput) (string, string, error)
- func (b *InMemoryBackend) CreateDBInstance(ctx context.Context, in InstanceInput) (wInstance, error)
- func (b *InMemoryBackend) CreateDBParameterGroup(ctx context.Context, in GroupInput) (wParameterGroup, error)
- func (b *InMemoryBackend) DeleteDBBackup(ctx context.Context, id string) (wBackup, error)
- func (b *InMemoryBackend) DeleteDBCluster(ctx context.Context, id string) (string, error)
- func (b *InMemoryBackend) DeleteDBInstance(ctx context.Context, id string) (wInstance, error)
- func (b *InMemoryBackend) GetDBBackup(ctx context.Context, id string) (wBackup, error)
- func (b *InMemoryBackend) GetDBCluster(ctx context.Context, id string) (wCluster, error)
- func (b *InMemoryBackend) GetDBInstance(ctx context.Context, id string) (wInstance, error)
- func (b *InMemoryBackend) GetDBParameterGroup(ctx context.Context, id string) (wParameterGroup, error)
- func (b *InMemoryBackend) ListDBBackups(ctx context.Context, resourceID, token string, maxResults int32) (page.Page[wBackupSummary], error)
- func (b *InMemoryBackend) ListDBClusters(ctx context.Context, token string, maxResults int32) (page.Page[wClusterSummary], error)
- func (b *InMemoryBackend) ListDBInstances(ctx context.Context, token string, maxResults int32) (page.Page[wInstanceSummary], error)
- func (b *InMemoryBackend) ListDBInstancesForCluster(ctx context.Context, clusterID, token string, maxResults int32) (page.Page[wInstanceSummary], error)
- func (b *InMemoryBackend) ListDBParameterGroups(ctx context.Context, token string, maxResults int32) (page.Page[wParameterGroupSummary], error)
- func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) RebootDBCluster(ctx context.Context, id string, instanceIDs []string) (string, error)
- func (b *InMemoryBackend) RebootDBInstance(ctx context.Context, id string) (wInstance, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RestoreFromDBBackup(ctx context.Context, in RestoreInput) (RestoreResult, error)
- func (b *InMemoryBackend) SetEngine(e Engine)
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) SetSubnetResolver(r SubnetResolver)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, add map[string]string) error
- func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, keys []string) error
- func (b *InMemoryBackend) UpdateDBCluster(ctx context.Context, id string, u ClusterUpdate) (string, error)
- func (b *InMemoryBackend) UpdateDBInstance(ctx context.Context, id string, u InstanceUpdate) (wInstance, error)
- type InstanceInput
- type InstanceUpdate
- type LogDelivery
- type Maintenance
- type Pending
- type Placement
- type Provider
- type RestoreInput
- type RestoreResult
- type SubnetResolver
Constants ¶
const ( // EngineEnv selects the engine mode: "stub" (metadata only, default) or "docker". EngineEnv = "TIMESTREAM_INFLUXDB_ENGINE" // HostEnv is the address engine-backed instances are reached on; default 127.0.0.1. HostEnv = "TIMESTREAM_INFLUXDB_HOST" // EngineDockerMode runs a real influxdb:2 container per instance. EngineDockerMode = "docker" )
const (
// Image is the InfluxDB 2 image each engine-backed instance runs.
Image = "influxdb:2"
)
Variables ¶
var ( ErrAccessDenied = errors.New("access denied") ErrConflict = errors.New("conflict") ErrInternalServer = errors.New("internal server error") ErrResourceNotFound = errors.New("resource not found") ErrQuotaExceeded = errors.New("service quota exceeded") ErrThrottling = errors.New("throttling") ErrValidation = errors.New("validation") )
Sentinels, one per exception in the pinned SDK's error set.
Functions ¶
This section is empty.
Types ¶
type BackupConfig ¶
type BackupConfig struct {
CustomSchedule string `json:"customSchedule,omitempty"`
Type string `json:"type"`
RetentionDays int32 `json:"retentionDays"`
Enabled bool `json:"enabled"`
}
BackupConfig is an automated backup schedule.
type BackupInput ¶
type BackupInput struct {
RetentionDays *int32
Tags map[string]string
ResourceID string
Name string
}
BackupInput holds CreateDbBackup parameters.
type ClusterConfig ¶
type ClusterConfig struct {
DedicatedCompactor *bool `json:"dedicatedCompactor,omitempty"`
IngestQueryInstances *int32 `json:"ingestQueryInstances,omitempty"`
QueryOnlyInstances *int32 `json:"queryOnlyInstances,omitempty"`
}
ClusterConfig describes a cluster's node roles.
type ClusterInput ¶
type ClusterInput struct {
Tags map[string]string
LogDelivery *LogDelivery
Maintenance *Maintenance
AllocatedStorage *int32
Port *int32
Name string
Username string
Password string
Organization string
Bucket string
DBInstanceType string
DBStorageType string
DeploymentType string
NetworkType string
FailoverMode string
KMSKeyID string
ParameterGroupID string
SubnetIDs []string
SecurityGroupIDs []string
BackupConfigs []BackupConfig
Publicly bool
}
ClusterInput holds CreateDbCluster parameters.
type ClusterUpdate ¶
type ClusterUpdate struct {
LogDelivery *LogDelivery
Maintenance *Maintenance
Port *int32
DBInstanceType string
ParameterGroupID string
FailoverMode string
BackupConfigs []BackupConfig
HasBackupConfigs bool
}
ClusterUpdate holds UpdateDbCluster parameters.
type ContainerRuntime ¶
type ContainerRuntime interface {
HasImage(ctx context.Context, imageRef string) (bool, error)
PullImage(ctx context.Context, imageRef string) error
CreateAndStart(ctx context.Context, spec container.Spec) (string, error)
StopAndRemove(ctx context.Context, containerID string) error
}
ContainerRuntime is the slice of container.Runtime the docker engine needs.
type DBBackup ¶
type DBBackup struct {
CreatedAt time.Time `json:"createdAt"`
Tags map[string]string `json:"tags,omitempty"`
ClusterConfig *ClusterConfig `json:"clusterConfig,omitempty"`
Pending Pending `json:"pending"`
ID string `json:"id"`
Name string `json:"name"`
ARN string `json:"arn"`
AccountID string `json:"accountId"`
Region string `json:"region"`
ResourceID string `json:"resourceId"`
ResourceType string `json:"resourceType"`
EngineType string `json:"engineType"`
FailoverMode string `json:"failoverMode,omitempty"`
Type string `json:"type"`
Username string `json:"username"`
Organization string `json:"organization"`
Bucket string `json:"bucket"`
Placement Placement `json:"placement"`
RetentionDays int32 `json:"retentionDays"`
}
DBBackup is a backup of an instance or cluster.
type DBCluster ¶
type DBCluster struct {
CreatedAt time.Time `json:"createdAt"`
Tags map[string]string `json:"tags,omitempty"`
Config *ClusterConfig `json:"config,omitempty"`
Password string `json:"-"`
Pending Pending `json:"pending"`
ID string `json:"id"`
Name string `json:"name"`
ARN string `json:"arn"`
AccountID string `json:"accountId"`
Region string `json:"region"`
Username string `json:"username"`
Organization string `json:"organization"`
Bucket string `json:"bucket"`
EngineType string `json:"engineType"`
FailoverMode string `json:"failoverMode"`
Placement Placement `json:"placement"`
}
DBCluster is a Timestream for InfluxDB cluster.
type DBInstance ¶
type DBInstance struct {
CreatedAt time.Time `json:"createdAt"`
Tags map[string]string `json:"tags,omitempty"`
Mode string `json:"mode,omitempty"`
Username string `json:"username"`
ID string `json:"id"`
Name string `json:"name"`
ARN string `json:"arn"`
AccountID string `json:"accountId"`
Region string `json:"region"`
ClusterID string `json:"clusterId,omitempty"`
Password string `json:"-"`
Failed string `json:"failed,omitempty"`
Organization string `json:"organization"`
Bucket string `json:"bucket"`
AZ string `json:"az"`
StandbyAZ string `json:"standbyAz,omitempty"`
EngineType string `json:"engineType"`
EngineHost string `json:"engineHost,omitempty"`
Pending Pending `json:"pending"`
Placement Placement `json:"placement"`
EnginePort int32 `json:"enginePort,omitempty"`
}
DBInstance is a Timestream for InfluxDB instance.
type DBParameterGroup ¶
type DBParameterGroup struct {
Tags map[string]string `json:"tags,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
ARN string `json:"arn"`
Description string `json:"description,omitempty"`
AccountID string `json:"accountId"`
Region string `json:"region"`
Parameters json.RawMessage `json:"parameters,omitempty"`
}
DBParameterGroup is a named set of InfluxDB parameters.
type DockerEngine ¶
type DockerEngine struct {
Runtime ContainerRuntime
Ports *portalloc.Allocator
HTTP HTTPDoer
Host string
Image string
// PollInterval and StartTimeout bound the readiness wait; zero uses the defaults.
PollInterval time.Duration
StartTimeout time.Duration
}
DockerEngine runs one influxdb:2 container per instance.
func (*DockerEngine) Start ¶
func (d *DockerEngine) Start(ctx context.Context, spec EngineSpec) (EngineHandle, error)
Start pulls the image if needed, runs the container initialised from spec and waits for /health.
func (*DockerEngine) Stop ¶
func (d *DockerEngine) Stop(ctx context.Context, h EngineHandle) error
Stop removes the container and frees its host port.
type Engine ¶
type Engine interface {
// Start launches a server initialised from spec and returns once it accepts connections.
Start(ctx context.Context, spec EngineSpec) (EngineHandle, error)
// Stop removes the server.
Stop(ctx context.Context, h EngineHandle) error
}
Engine runs real InfluxDB servers for instances; nil keeps instances metadata-only.
type EngineHandle ¶
EngineHandle identifies a running InfluxDB container and where it is reachable.
type EngineSpec ¶
type EngineSpec struct {
Name string
Username string
Password string
Organization string
Bucket string
}
EngineSpec describes the InfluxDB container to run for one instance.
type GroupInput ¶
type GroupInput struct {
Tags map[string]string
Name string
Description string
Parameters json.RawMessage
}
GroupInput holds CreateDbParameterGroup parameters.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
DefaultRegion string
}
Handler serves the Timestream for InfluxDB awsjson1.0 API.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions this handler serves.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name from X-Amz-Target.
func (*Handler) ExtractResource ¶
ExtractResource returns the operation name; the API has no single resource key.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every routed operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches the AmazonTimestreamInfluxDB X-Amz-Target prefix.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the Timestream for InfluxDB state; one coarse lock guards every table.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) Close ¶
func (b *InMemoryBackend) Close()
Close stops every engine container and waits for in-flight starts.
func (*InMemoryBackend) CreateDBBackup ¶
func (b *InMemoryBackend) CreateDBBackup(ctx context.Context, in BackupInput) (wBackup, error)
CreateDBBackup takes an on-demand backup of an instance or cluster.
func (*InMemoryBackend) CreateDBCluster ¶
func (b *InMemoryBackend) CreateDBCluster(ctx context.Context, in ClusterInput) (string, string, error)
CreateDBCluster creates a cluster and its member instances in CREATING state.
func (*InMemoryBackend) CreateDBInstance ¶
func (b *InMemoryBackend) CreateDBInstance(ctx context.Context, in InstanceInput) (wInstance, error)
CreateDBInstance creates an instance in CREATING state.
func (*InMemoryBackend) CreateDBParameterGroup ¶
func (b *InMemoryBackend) CreateDBParameterGroup(ctx context.Context, in GroupInput) (wParameterGroup, error)
CreateDBParameterGroup creates a parameter group.
func (*InMemoryBackend) DeleteDBBackup ¶
func (b *InMemoryBackend) DeleteDBBackup(ctx context.Context, id string) (wBackup, error)
DeleteDBBackup starts backup deletion.
func (*InMemoryBackend) DeleteDBCluster ¶
DeleteDBCluster starts cluster deletion with its member instances.
func (*InMemoryBackend) DeleteDBInstance ¶
func (b *InMemoryBackend) DeleteDBInstance(ctx context.Context, id string) (wInstance, error)
DeleteDBInstance starts instance deletion.
func (*InMemoryBackend) GetDBBackup ¶
func (b *InMemoryBackend) GetDBBackup(ctx context.Context, id string) (wBackup, error)
GetDBBackup returns a backup.
func (*InMemoryBackend) GetDBCluster ¶
func (b *InMemoryBackend) GetDBCluster(ctx context.Context, id string) (wCluster, error)
GetDBCluster returns a cluster.
func (*InMemoryBackend) GetDBInstance ¶
func (b *InMemoryBackend) GetDBInstance(ctx context.Context, id string) (wInstance, error)
GetDBInstance returns an instance.
func (*InMemoryBackend) GetDBParameterGroup ¶
func (b *InMemoryBackend) GetDBParameterGroup(ctx context.Context, id string) (wParameterGroup, error)
GetDBParameterGroup returns a parameter group.
func (*InMemoryBackend) ListDBBackups ¶
func (b *InMemoryBackend) ListDBBackups( ctx context.Context, resourceID, token string, maxResults int32, ) (page.Page[wBackupSummary], error)
ListDBBackups lists backups, optionally for one resource, newest first.
func (*InMemoryBackend) ListDBClusters ¶
func (b *InMemoryBackend) ListDBClusters( ctx context.Context, token string, maxResults int32, ) (page.Page[wClusterSummary], error)
ListDBClusters lists clusters ordered by name.
func (*InMemoryBackend) ListDBInstances ¶
func (b *InMemoryBackend) ListDBInstances( ctx context.Context, token string, maxResults int32, ) (page.Page[wInstanceSummary], error)
ListDBInstances lists instances ordered by name.
func (*InMemoryBackend) ListDBInstancesForCluster ¶
func (b *InMemoryBackend) ListDBInstancesForCluster( ctx context.Context, clusterID, token string, maxResults int32, ) (page.Page[wInstanceSummary], error)
ListDBInstancesForCluster lists a cluster's member instances.
func (*InMemoryBackend) ListDBParameterGroups ¶
func (b *InMemoryBackend) ListDBParameterGroups( ctx context.Context, token string, maxResults int32, ) (page.Page[wParameterGroupSummary], error)
ListDBParameterGroups lists parameter groups ordered by name.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
ListTagsForResource returns a resource's tags.
func (*InMemoryBackend) RebootDBCluster ¶
func (b *InMemoryBackend) RebootDBCluster(ctx context.Context, id string, instanceIDs []string) (string, error)
RebootDBCluster reboots a cluster, or only the listed member instances.
func (*InMemoryBackend) RebootDBInstance ¶
func (b *InMemoryBackend) RebootDBInstance(ctx context.Context, id string) (wInstance, error)
RebootDBInstance moves an instance through REBOOTING back to AVAILABLE.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the default region.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears every table and stops engine containers.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version is discarded.
func (*InMemoryBackend) RestoreFromDBBackup ¶
func (b *InMemoryBackend) RestoreFromDBBackup(ctx context.Context, in RestoreInput) (RestoreResult, error)
RestoreFromDBBackup creates a resource from a backup, or resets the original one.
func (*InMemoryBackend) SetEngine ¶
func (b *InMemoryBackend) SetEngine(e Engine)
SetEngine switches the backend to engine mode: new instances run a real InfluxDB server.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay overrides the transitional status window.
func (*InMemoryBackend) SetSubnetResolver ¶
func (b *InMemoryBackend) SetSubnetResolver(r SubnetResolver)
SetSubnetResolver wires the EC2 lookup used to validate subnets.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, add map[string]string) error
TagResource adds or replaces tags.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, keys []string) error
UntagResource removes tags by key.
func (*InMemoryBackend) UpdateDBCluster ¶
func (b *InMemoryBackend) UpdateDBCluster(ctx context.Context, id string, u ClusterUpdate) (string, error)
UpdateDBCluster changes a cluster and moves it to an updating status.
func (*InMemoryBackend) UpdateDBInstance ¶
func (b *InMemoryBackend) UpdateDBInstance(ctx context.Context, id string, u InstanceUpdate) (wInstance, error)
UpdateDBInstance changes an instance and moves it to an updating status.
type InstanceInput ¶
type InstanceInput struct {
Tags map[string]string
LogDelivery *LogDelivery
Maintenance *Maintenance
Name string
Username string
Password string
Organization string
Bucket string
DBInstanceType string
DBStorageType string
DeploymentType string
NetworkType string
KMSKeyID string
ParameterGroupID string
SubnetIDs []string
SecurityGroupIDs []string
BackupConfigs []BackupConfig
AllocatedStorage int32
Port int32
PubliclyAccessible bool
}
InstanceInput holds CreateDbInstance parameters.
type InstanceUpdate ¶
type InstanceUpdate struct {
LogDelivery *LogDelivery
Maintenance *Maintenance
AllocatedStorage *int32
Port *int32
DBInstanceType string
DBStorageType string
DeploymentType string
ParameterGroupID string
BackupConfigs []BackupConfig
HasBackupConfigs bool
}
InstanceUpdate holds UpdateDbInstance parameters; nil or empty fields are unchanged.
type LogDelivery ¶
LogDelivery is the S3 log delivery configuration.
type Maintenance ¶
Maintenance is the maintenance window.
type Pending ¶
type Pending struct {
Until time.Time `json:"until"`
Kind string `json:"kind"`
Engine bool `json:"engine,omitempty"`
}
Pending is a transitional status that lasts until Until, or until the engine reports when Engine is set.
type Placement ¶
type Placement struct {
LogDelivery *LogDelivery `json:"logDelivery,omitempty"`
Maintenance *Maintenance `json:"maintenance,omitempty"`
DBInstanceType string `json:"dbInstanceType"`
DBStorageType string `json:"dbStorageType"`
DeploymentType string `json:"deploymentType"`
NetworkType string `json:"networkType"`
KMSKeyID string `json:"kmsKeyId,omitempty"`
ParameterGroupID string `json:"parameterGroupId,omitempty"`
SubnetIDs []string `json:"subnetIds"`
SecurityGroupIDs []string `json:"securityGroupIds"`
BackupConfigs []BackupConfig `json:"backupConfigs,omitempty"`
AllocatedStorage int32 `json:"allocatedStorage"`
Port int32 `json:"port"`
PubliclyAccessible bool `json:"publiclyAccessible"`
}
Placement holds the settings shared by instances, clusters and the backups of both.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Amazon Timestream for InfluxDB.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type RestoreInput ¶
type RestoreInput struct {
RestoreToTime *time.Time
Port *int32
Publicly *bool
LogDelivery *LogDelivery
Maintenance *Maintenance
Tags map[string]string
BackupID string
Name string
DeploymentType string
KMSKeyID string
NetworkType string
RestoreMode string
SubnetIDs []string
SecurityGroupIDs []string
BackupConfigs []BackupConfig
HasBackupConfigs bool
}
RestoreInput holds RestoreFromDbBackup parameters.
type RestoreResult ¶
type RestoreResult struct {
DeploymentType string
EngineType string
ResourceType string
ResourceID string
}
RestoreResult describes the resource a restore produced.
type SubnetResolver ¶
SubnetResolver looks up the IPv4 CIDR of a VPC subnet.