Documentation
¶
Overview ¶
Package sdk provides an in-process AWS mock that routes AWS SDK v2 calls directly to CloudMock's gateway handler without any HTTP/TCP overhead.
Usage:
cm := sdk.New()
defer cm.Close()
cfg := cm.Config()
s3Client := s3.NewFromConfig(cfg, func(o *s3.Options) { o.UsePathStyle = true })
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChaosOption ¶
type ChaosOption func(*chaosOpts)
ChaosOption configures a fault injection rule.
func WithLatency ¶
func WithLatency(ms int) ChaosOption
WithLatency sets the added latency in milliseconds for "latency" faults.
func WithMessage ¶
func WithMessage(msg string) ChaosOption
WithMessage sets the error message returned with the fault.
func WithPercentage ¶
func WithPercentage(pct int) ChaosOption
WithPercentage sets the probability (0-100) that the fault fires on any given request.
func WithStatusCode ¶
func WithStatusCode(code int) ChaosOption
WithStatusCode sets the HTTP status code returned for "error" faults.
type CloudMock ¶
type CloudMock struct {
// contains filtered or unexported fields
}
CloudMock is an in-process AWS mock. All AWS SDK calls routed through its Config() go directly to the gateway handler with zero network overhead.
func New ¶
New creates a new in-process CloudMock instance. By default it uses a minimal profile (S3, STS, DynamoDB, SQS) with IAM disabled for speed.
func (*CloudMock) ClearFaults ¶
ClearFaults disables all chaos rules on the in-process engine.
func (*CloudMock) Close ¶
func (cm *CloudMock) Close()
Close releases resources held by this CloudMock instance, including stopping background goroutines such as the DynamoDB TTL reaper. Safe to call multiple times; the underlying service closers are idempotent.
func (*CloudMock) Config ¶
Config returns an aws.Config that routes all SDK calls through CloudMock in-process.
func (*CloudMock) InjectFault ¶
func (cm *CloudMock) InjectFault(service, action, faultType string, opts ...ChaosOption) error
InjectFault adds a fault injection rule to the in-process chaos engine. faultType is one of "error", "latency", "timeout", "blackhole", or "throttle".
func (*CloudMock) TraceStore ¶
func (cm *CloudMock) TraceStore() *gateway.TraceStore
TraceStore returns the trace store if tracing is enabled, or nil otherwise.
type Option ¶
type Option func(*options)
Option configures a CloudMock instance.
func WithAccountID ¶
WithAccountID sets the AWS account ID for the mock.
func WithIAMMode ¶
WithIAMMode sets the IAM enforcement mode ("none", "log", "enforce").
func WithProfile ¶
WithProfile sets the service profile ("minimal" or "standard").
func WithTracing ¶
func WithTracing() Option
WithTracing enables always-on distributed tracing with W3C traceparent propagation. When enabled, a TraceStore is created and wired to the gateway, and the in-process transport propagates trace context from the Go context as traceparent headers.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is an http.RoundTripper that wraps another RoundTripper and captures all request/response pairs as traffic.CapturedEntry values. It is intended to be used with the AWS SDK v2 HTTP client for recording real AWS traffic.
func NewRecorder ¶
func NewRecorder() *Recorder
NewRecorder creates a Recorder that wraps http.DefaultTransport.
func (*Recorder) Entries ¶
func (r *Recorder) Entries() []*traffic.CapturedEntry
Entries returns a copy of the captured entries.
func (*Recorder) RoundTrip ¶
RoundTrip implements http.RoundTripper. It captures the request and response as a CapturedEntry, then returns the original response unchanged.
func (*Recorder) SaveToFile ¶
SaveToFile marshals the recording to JSON and writes it to the given path.