Documentation
¶
Overview ¶
Package dynamodb implements the AWS DynamoDB API emulator. See docs/services/dynamodb.md for the support matrix.
Index ¶
- type AttributeDef
- type BillingModeSummary
- type GSIUpdate
- type Handler
- func (h *Handler) BatchGetItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) BatchWriteItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateTable(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteTable(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DescribeTable(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DescribeTimeToLive(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListTables(w http.ResponseWriter, r *http.Request)
- func (h *Handler) PutItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Query(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Scan(w http.ResponseWriter, r *http.Request)
- func (h *Handler) TransactGetItems(w http.ResponseWriter, r *http.Request)
- func (h *Handler) TransactWriteItems(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateTable(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateTimeToLive(w http.ResponseWriter, r *http.Request)
- type Item
- type KeySchemaElement
- type Projection
- type ProvisionedThroughput
- type SecondaryIndex
- type Service
- func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
- func (s *Service) DynamoDBInvoker() events.DynamoDBInvoker
- func (s *Service) GetStreamRecordsSince(ctx context.Context, tableName string, afterSeq int64, limit int) ([]*StreamRecord, int64, error)
- func (s *Service) GetStreamTable(ctx context.Context, streamArn string) (*Table, error)
- func (s *Service) ListStreamEnabledTables(ctx context.Context) ([]*Table, error)
- func (s *Service) Name() string
- func (s *Service) Operations() []op.Operation
- func (s *Service) RegisterRoutes(r chi.Router)
- func (s *Service) Stop(_ context.Context)
- func (s *Service) SupportedProtocols() []codec.Codec
- func (s *Service) TargetPrefix() string
- type StreamRecord
- type StreamSpecification
- type Table
- type TimeToLiveDescription
- type TimeToLiveSpecification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeDef ¶
type AttributeDef struct {
AttributeName string `json:"AttributeName"`
AttributeType string `json:"AttributeType"` // "S", "N", "B"
}
AttributeDef defines an attribute type for key schema elements.
type BillingModeSummary ¶
type BillingModeSummary struct {
BillingMode string `json:"BillingMode"`
LastUpdateToPayPerRequest float64 `json:"LastUpdateToPayPerRequestDateTime,omitempty"`
}
BillingModeSummary contains the billing mode and last transition time.
type GSIUpdate ¶
type GSIUpdate struct {
Create *SecondaryIndex `json:"Create,omitempty"`
Delete *struct {
IndexName string `json:"IndexName"`
} `json:"Delete,omitempty"`
Update *struct {
IndexName string `json:"IndexName"`
ProvisionedThroughput *ProvisionedThroughput `json:"ProvisionedThroughput,omitempty"`
} `json:"Update,omitempty"`
}
GSIUpdate describes a single GlobalSecondaryIndex update operation.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds DynamoDB handler dependencies.
func (*Handler) BatchGetItem ¶
func (h *Handler) BatchGetItem(w http.ResponseWriter, r *http.Request)
BatchGetItem handles the DynamoDB BatchGetItem operation.
func (*Handler) BatchWriteItem ¶
func (h *Handler) BatchWriteItem(w http.ResponseWriter, r *http.Request)
BatchWriteItem handles the DynamoDB BatchWriteItem operation.
func (*Handler) CreateTable ¶
func (h *Handler) CreateTable(w http.ResponseWriter, r *http.Request)
CreateTable handles the DynamoDB CreateTable operation.
func (*Handler) DeleteItem ¶
func (h *Handler) DeleteItem(w http.ResponseWriter, r *http.Request)
DeleteItem handles the DynamoDB DeleteItem operation.
func (*Handler) DeleteTable ¶
func (h *Handler) DeleteTable(w http.ResponseWriter, r *http.Request)
DeleteTable handles the DynamoDB DeleteTable operation.
func (*Handler) DescribeTable ¶
func (h *Handler) DescribeTable(w http.ResponseWriter, r *http.Request)
DescribeTable handles the DynamoDB DescribeTable operation.
func (*Handler) DescribeTimeToLive ¶
func (h *Handler) DescribeTimeToLive(w http.ResponseWriter, r *http.Request)
DescribeTimeToLive handles the DynamoDB DescribeTimeToLive operation.
func (*Handler) GetItem ¶
func (h *Handler) GetItem(w http.ResponseWriter, r *http.Request)
GetItem handles the DynamoDB GetItem operation.
func (*Handler) ListTables ¶
func (h *Handler) ListTables(w http.ResponseWriter, r *http.Request)
ListTables handles the DynamoDB ListTables operation.
func (*Handler) PutItem ¶
func (h *Handler) PutItem(w http.ResponseWriter, r *http.Request)
PutItem handles the DynamoDB PutItem operation.
func (*Handler) Query ¶
func (h *Handler) Query(w http.ResponseWriter, r *http.Request)
Query handles the DynamoDB Query operation. Supports hash-key equality, sort-key conditions (=, <, <=, >, >=, BETWEEN, begins_with), FilterExpression, ProjectionExpression, and GSI/LSI via IndexName.
func (*Handler) Scan ¶
func (h *Handler) Scan(w http.ResponseWriter, r *http.Request)
Scan handles the DynamoDB Scan operation.
func (*Handler) TransactGetItems ¶
func (h *Handler) TransactGetItems(w http.ResponseWriter, r *http.Request)
TransactGetItems handles the DynamoDB TransactGetItems operation. AWS docs: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html
func (*Handler) TransactWriteItems ¶
func (h *Handler) TransactWriteItems(w http.ResponseWriter, r *http.Request)
TransactWriteItems handles the DynamoDB TransactWriteItems operation. All-or-nothing: validates all conditions first, then applies all mutations. AWS docs: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html
func (*Handler) UpdateItem ¶
func (h *Handler) UpdateItem(w http.ResponseWriter, r *http.Request)
UpdateItem handles the DynamoDB UpdateItem operation. Supports all UpdateExpression clauses. Upserts the item if it does not exist. AWS docs: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
func (*Handler) UpdateTable ¶
func (h *Handler) UpdateTable(w http.ResponseWriter, r *http.Request)
UpdateTable handles the DynamoDB UpdateTable operation.
func (*Handler) UpdateTimeToLive ¶
func (h *Handler) UpdateTimeToLive(w http.ResponseWriter, r *http.Request)
UpdateTimeToLive handles the DynamoDB UpdateTimeToLive operation.
type Item ¶
type Item = map[string]attrValue
Item is a DynamoDB item represented in DynamoDB JSON format.
type KeySchemaElement ¶
type KeySchemaElement struct {
AttributeName string `json:"AttributeName"`
KeyType string `json:"KeyType"` // "HASH" or "RANGE"
}
KeySchemaElement is a hash or range key definition.
type Projection ¶
type Projection struct {
ProjectionType string `json:"ProjectionType"` // ALL, KEYS_ONLY, INCLUDE
NonKeyAttributes []string `json:"NonKeyAttributes,omitempty"`
}
Projection describes which attributes are projected into a secondary index.
type ProvisionedThroughput ¶
type ProvisionedThroughput struct {
ReadCapacityUnits int64 `json:"ReadCapacityUnits"`
WriteCapacityUnits int64 `json:"WriteCapacityUnits"`
}
ProvisionedThroughput holds the read/write capacity units for a table or GSI.
type SecondaryIndex ¶
type SecondaryIndex struct {
IndexName string `json:"IndexName"`
KeySchema []KeySchemaElement `json:"KeySchema"`
Projection Projection `json:"Projection"`
IndexArn string `json:"IndexArn,omitempty"`
IndexStatus string `json:"IndexStatus,omitempty"`
IndexSizeBytes int64 `json:"IndexSizeBytes"`
ItemCount int64 `json:"ItemCount"`
ProvisionedThroughput *ProvisionedThroughput `json:"ProvisionedThroughput,omitempty"`
}
SecondaryIndex represents a GSI or LSI definition.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements router.Service for DynamoDB.
func New ¶
func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock, bus *events.Bus) *Service
New returns a configured DynamoDB Service.
func (*Service) Dispatch ¶
func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
Dispatch routes to the correct DynamoDB handler based on X-Amz-Target.
func (*Service) DynamoDBInvoker ¶
func (s *Service) DynamoDBInvoker() events.DynamoDBInvoker
DynamoDBInvoker returns an events.DynamoDBInvoker that dispatches operations through the handler's operation map using httptest, so we don't need to export any handler internals.
func (*Service) GetStreamRecordsSince ¶
func (s *Service) GetStreamRecordsSince(ctx context.Context, tableName string, afterSeq int64, limit int) ([]*StreamRecord, int64, error)
GetStreamRecordsSince returns stream records for a table with seq > afterSeq. Returns (records, latestSeqInResult, error).
func (*Service) GetStreamTable ¶
GetStreamTable returns the table descriptor for a given stream ARN.
func (*Service) ListStreamEnabledTables ¶
ListStreamEnabledTables returns all tables that have streaming enabled.
func (*Service) Operations ¶
Operations implements router.ProtocolService.
func (*Service) RegisterRoutes ¶
RegisterRoutes is a no-op — DynamoDB uses POST / which is handled by the router's target dispatcher shared with SQS and SNS.
func (*Service) SupportedProtocols ¶
SupportedProtocols implements router.ProtocolService.
func (*Service) TargetPrefix ¶
TargetPrefix returns the X-Amz-Target prefix for DynamoDB dispatch.
type StreamRecord ¶
type StreamRecord struct {
// SequenceNumber is a monotonic integer used as the primary ordering key.
// Exported as a zero-padded string in API responses.
SequenceNumber int64 `json:"seq"`
EventName string `json:"eventName"` // INSERT, MODIFY, REMOVE
Keys Item `json:"Keys"`
NewImage Item `json:"NewImage,omitempty"`
OldImage Item `json:"OldImage,omitempty"`
CreatedAt int64 `json:"createdAt"` // UnixMilli
}
StreamRecord is a single DynamoDB Streams change record. It is exported so the dynamodbstreams service can use it directly.
type StreamSpecification ¶
type StreamSpecification struct {
StreamEnabled bool `json:"StreamEnabled"`
StreamViewType string `json:"StreamViewType,omitempty"`
}
StreamSpecification describes the DynamoDB Streams configuration for a table.
type Table ¶
type Table struct {
TableName string `json:"TableName"`
KeySchema []KeySchemaElement `json:"KeySchema"`
AttributeDefinitions []AttributeDef `json:"AttributeDefinitions"`
TableStatus string `json:"TableStatus"`
BillingMode string `json:"BillingMode,omitempty"`
BillingModeSummary *BillingModeSummary `json:"BillingModeSummary,omitempty"`
ProvisionedThroughput *ProvisionedThroughput `json:"ProvisionedThroughput,omitempty"`
TableARN string `json:"TableArn"`
CreationDateTime float64 `json:"CreationDateTime"`
ItemCount int64 `json:"ItemCount"`
StreamSpecification *StreamSpecification `json:"StreamSpecification,omitempty"`
LatestStreamArn string `json:"LatestStreamArn,omitempty"`
LatestStreamLabel string `json:"LatestStreamLabel,omitempty"`
TTL *TimeToLiveSpecification `json:"TTL,omitempty"`
GlobalSecondaryIndexes []SecondaryIndex `json:"GlobalSecondaryIndexes,omitempty"`
LocalSecondaryIndexes []SecondaryIndex `json:"LocalSecondaryIndexes,omitempty"`
}
Table represents a DynamoDB table definition.
type TimeToLiveDescription ¶
type TimeToLiveDescription struct {
TimeToLiveStatus string `json:"TimeToLiveStatus"`
AttributeName string `json:"AttributeName,omitempty"`
}
TimeToLiveDescription matches the AWS DescribeTimeToLive response shape.
type TimeToLiveSpecification ¶
type TimeToLiveSpecification struct {
Enabled bool `json:"Enabled"`
AttributeName string `json:"AttributeName"`
}
TimeToLiveSpecification describes the TTL configuration for a table.