Documentation
¶
Index ¶
- Variables
- type ArrayValue
- type ColumnMetadata
- type ExecutedStatement
- type Field
- 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(_ *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 InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) AddTransactionInternal(txID string)
- func (b *InMemoryBackend) BatchExecuteStatement(ctx context.Context, resourceARN, sql, transactionID string, ...) ([]UpdateResult, error)
- func (b *InMemoryBackend) BeginTransaction(ctx context.Context, resourceARN string) (string, error)
- func (b *InMemoryBackend) CommitTransaction(ctx context.Context, transactionID string) (string, error)
- func (b *InMemoryBackend) ExecuteSQL(ctx context.Context, resourceARN, sqlStatements string) ([]SQLStatementResult, error)
- func (b *InMemoryBackend) ExecuteStatement(ctx context.Context, resourceARN, sql, transactionID string, ...) ([][]Field, []ColumnMetadata, int64, []Field, error)
- func (b *InMemoryBackend) ListExecutedStatements(ctx context.Context) []ExecutedStatement
- func (b *InMemoryBackend) ListTransactions(ctx context.Context) map[string]Transaction
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RollbackTransaction(ctx context.Context, transactionID string) (string, error)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type Provider
- type SQLParameter
- type SQLStatementResult
- type StorageBackend
- type Transaction
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTransactionNotFound is returned when a transaction does not exist. ErrTransactionNotFound = awserr.New("TransactionNotFoundException", awserr.ErrNotFound) // ErrValidation is returned when input validation fails. ErrValidation = awserr.New("BadRequestException", awserr.ErrInvalidParameter) )
var ErrNilAppContext = errors.New("nil AppContext passed to RDSData Provider.Init")
ErrNilAppContext is returned by Init when a nil AppContext is passed.
Functions ¶
This section is empty.
Types ¶
type ArrayValue ¶ added in v1.2.0
type ArrayValue struct {
ArrayValues []ArrayValue `json:"arrayValues,omitempty"`
BooleanValues []bool `json:"booleanValues,omitempty"`
DoubleValues []float64 `json:"doubleValues,omitempty"`
LongValues []int64 `json:"longValues,omitempty"`
StringValues []string `json:"stringValues,omitempty"`
}
ArrayValue represents an array of values, mirroring the real API's ArrayValue union (types.ArrayValue in aws-sdk-go-v2/service/rdsdata). Exactly one member is meaningfully populated at a time, matching the real union's shape.
type ColumnMetadata ¶
type ColumnMetadata struct {
Name string `json:"name"`
Label string `json:"label"`
TypeName string `json:"typeName"`
SchemaName string `json:"schemaName"`
TableName string `json:"tableName"`
Type int32 `json:"type"`
ArrayBaseColumnType int32 `json:"arrayBaseColumnType"`
Nullable int32 `json:"nullable"`
Precision int32 `json:"precision"`
Scale int32 `json:"scale"`
IsAutoIncrement bool `json:"isAutoIncrement"`
IsCaseSensitive bool `json:"isCaseSensitive"`
IsCurrency bool `json:"isCurrency"`
IsSigned bool `json:"isSigned"`
}
ColumnMetadata describes a single column returned by a SQL statement. Field set mirrors the real RDS Data API shape (types.ColumnMetadata in aws-sdk-go-v2/service/rdsdata); see engine.go's columnMetadataFor for how each field is derived from the pure-Go SQLite driver's limited column introspection.
type ExecutedStatement ¶
type ExecutedStatement struct {
SQL string `json:"sql"`
ResourceARN string `json:"resourceArn"`
TransactionID string `json:"transactionId,omitempty"`
}
ExecutedStatement represents a record of an executed SQL statement.
type Field ¶
type Field struct {
IsNull *bool `json:"isNull,omitempty"`
BooleanValue *bool `json:"booleanValue,omitempty"`
LongValue *int64 `json:"longValue,omitempty"`
DoubleValue *float64 `json:"doubleValue,omitempty"`
StringValue *string `json:"stringValue,omitempty"`
ArrayValue *ArrayValue `json:"arrayValue,omitempty"`
BlobValue []byte `json:"blobValue,omitempty"`
}
Field represents a single field value in an RDS Data API record.
ArrayValue is modeled for wire completeness (it is a real member of the SDK's Field union -- types.FieldMemberArrayValue) even though this mock can never populate it in a result: real AWS documents "Array parameters are not supported" for ExecuteStatementInput.Parameters (see validateNoArrayParameters in handler.go, which rejects it on the way in), and the pure-Go SQLite driver backing the mock engine never produces an array-typed result column. See PARITY.md.
type Handler ¶
type Handler struct {
Backend StorageBackend
AccountID string
Region string
}
Handler is the HTTP handler for the RDS Data REST API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new RDS Data 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 request path.
func (*Handler) ExtractResource ¶
ExtractResource always returns an empty string for the RDS Data API. The resource is identified by a resourceArn in the request body, but parsing the body here would require double-buffering; metrics and logging can rely on ExtractOperation instead.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported RDS Data operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for RDS Data requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears all handler and backend state. Useful for test isolation.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches RDS Data API requests. All path-based matches are gated on the SigV4 service name to prevent routing conflicts with other services that share similar REST paths.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
Dead-wiring fix (Phase 3.3): InMemoryBackend already implemented Snapshot/Restore, but Handler never delegated to them, so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked RDSData up -- the backend's persistence logic existed but was never invoked. This delegation (matching the mediastore/codecommit/cleanrooms pattern) wires RDSData into persistence for the first time.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is an in-memory RDS Data backend.
All resource maps are nested by region (outer key = region) so that same-named resources are isolated across regions. The per-region inner maps / tables are created lazily via the *Store helpers. Callers must hold b.mu while accessing them. See store_setup.go for why transactions is a map[string]*store.Table[Transaction] while executedStatements and txCounter remain plain maps.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new in-memory RDS Data backend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the AWS account ID this backend is configured for.
func (*InMemoryBackend) AddTransactionInternal ¶
func (b *InMemoryBackend) AddTransactionInternal(txID string)
AddTransactionInternal directly inserts a transaction into the backend's default region. This is intended only for seeding test data.
func (*InMemoryBackend) BatchExecuteStatement ¶
func (b *InMemoryBackend) BatchExecuteStatement( ctx context.Context, resourceARN, sql, transactionID string, parameterSets [][]SQLParameter, ) ([]UpdateResult, error)
BatchExecuteStatement executes a batch of SQL statements and returns results for each.
func (*InMemoryBackend) BeginTransaction ¶
BeginTransaction starts a new transaction and returns its ID.
func (*InMemoryBackend) CommitTransaction ¶
func (b *InMemoryBackend) CommitTransaction( ctx context.Context, transactionID string, ) (string, error)
CommitTransaction commits a transaction by ID.
func (*InMemoryBackend) ExecuteSQL ¶
func (b *InMemoryBackend) ExecuteSQL( ctx context.Context, resourceARN, sqlStatements string, ) ([]SQLStatementResult, error)
ExecuteSQL executes one or more SQL statements against the cluster. This is a deprecated operation; use ExecuteStatement or BatchExecuteStatement instead.
func (*InMemoryBackend) ExecuteStatement ¶
func (b *InMemoryBackend) ExecuteStatement( ctx context.Context, resourceARN, sql, transactionID string, parameters ...SQLParameter, ) ([][]Field, []ColumnMetadata, int64, []Field, error)
ExecuteStatement executes a SQL statement and returns its result set. Named parameters (e.g. ":id") are bound when supplied. The returned generated fields are non-empty only for an INSERT into a table with a single INTEGER PRIMARY KEY column -- see generatedFieldsFor in engine.go.
func (*InMemoryBackend) ListExecutedStatements ¶
func (b *InMemoryBackend) ListExecutedStatements(ctx context.Context) []ExecutedStatement
ListExecutedStatements returns a copy of all executed statements for the request's region.
func (*InMemoryBackend) ListTransactions ¶
func (b *InMemoryBackend) ListTransactions(ctx context.Context) map[string]Transaction
ListTransactions returns a deep copy of all active transactions for the request's region.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the AWS region this backend is configured for.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all backend state. Useful for test isolation.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot.
func (*InMemoryBackend) RollbackTransaction ¶
func (b *InMemoryBackend) RollbackTransaction( ctx context.Context, transactionID string, ) (string, error)
RollbackTransaction rolls back a transaction by ID.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for RDS Data.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the RDS Data service backend and handler.
type SQLParameter ¶
type SQLParameter struct {
Name string `json:"name"`
TypeHint string `json:"typeHint,omitempty"`
Value Field `json:"value"`
}
SQLParameter represents a named parameter for a SQL statement. TypeHint mirrors the real API's DATE/DECIMAL/JSON/TIME/TIMESTAMP/UUID hint values; it is accepted on the wire but does not change bind behavior since the mock SQLite engine has no distinct DATE/TIMESTAMP/UUID column types to convert to (see PARITY.md).
type SQLStatementResult ¶
type SQLStatementResult struct {
NumberOfRecordsUpdated int64 `json:"numberOfRecordsUpdated"`
}
SQLStatementResult represents the result of a single SQL statement in an ExecuteSql call.
type StorageBackend ¶
type StorageBackend interface {
// Statement execution
ExecuteStatement(
ctx context.Context,
resourceARN, sql, transactionID string,
parameters ...SQLParameter,
) ([][]Field, []ColumnMetadata, int64, []Field, error)
BatchExecuteStatement(
ctx context.Context,
resourceARN, sql, transactionID string,
parameterSets [][]SQLParameter,
) ([]UpdateResult, error)
ExecuteSQL(ctx context.Context, resourceARN, sqlStatements string) ([]SQLStatementResult, error)
// Transaction management
BeginTransaction(ctx context.Context, resourceARN string) (string, error)
CommitTransaction(ctx context.Context, transactionID string) (string, error)
RollbackTransaction(ctx context.Context, transactionID string) (string, error)
// Introspection helpers (used by tests and dashboard)
ListExecutedStatements(ctx context.Context) []ExecutedStatement
ListTransactions(ctx context.Context) map[string]Transaction
// Lifecycle
Reset()
Region() string
AccountID() string
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
}
StorageBackend defines the interface for RDS Data backend implementations. All methods must be safe for concurrent use.
type Transaction ¶
type Transaction struct {
TransactionID string `json:"transactionId"`
Status string `json:"status"`
}
Transaction represents an in-progress database transaction.
type UpdateResult ¶
type UpdateResult struct {
GeneratedFields []Field `json:"generatedFields"`
}
UpdateResult represents the result of a single update in a batch.
GeneratedFields is populated with the rowid-alias INTEGER PRIMARY KEY value assigned by an INSERT, when the target table declares exactly one such column (see generatedFieldsFor in engine.go). It is left empty for every other statement shape, matching real AWS ("generatedFields ... isn't supported by Aurora PostgreSQL").