Documentation
¶
Overview ¶
Package aws provides initialized AWS service clients (S3, SQS, DynamoDB), wired into the host as a module that reads the aws config section.
Index ¶
- func Module(services ...Service) host.Module
- func NamedModule(name string, services ...Service) host.Module
- type AWS
- func (a *AWS) Init() error
- func (a *AWS) ReadConfig(l configx.Reader) error
- func (a *AWS) S3DownloadFile(ctx context.Context, req *S3DownloadFileRequest) error
- func (a *AWS) S3DownloadFiles(ctx context.Context, reqs []S3DownloadFileRequest, maxWorkers int) error
- func (a *AWS) S3UploadFile(ctx context.Context, req *S3UploadFileRequest) error
- func (a *AWS) SQSSendMessage(ctx context.Context, message any) error
- type Config
- type S3DownloadFileRequest
- type S3UploadFileRequest
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Module ¶ added in v0.19.0
Module installs an AWS client as a managed service. The host loads its config (via the client's Configurable implementation) and initializes the requested service clients during the init phase:
host.MustNew().
WithModule(aws.Module(aws.S3, aws.SQS)).
MustRun()
Reach the client from a Setup hook or handler with aws.Of(app).
Types ¶
type AWS ¶
type AWS struct {
DefaultConfig awssdk.Config
DefaultS3BucketName *string
DefaultSQSQueueURL *string
Logger *slog.Logger
S3Client *s3.Client
SQSClient *sqs.Client
DynamoDBClient *dynamodb.Client
// contains filtered or unexported fields
}
func Lookup ¶ added in v0.23.0
Lookup returns the AWS client installed under the optional name and whether one was installed. Use it where absence is an expected, recoverable condition; prefer Of when the client must exist.
func NewAWS ¶ added in v0.4.0
NewAWS returns an AWS client ready to participate in the host service lifecycle. services lists which SDK clients (S3, SQS, DynamoDB) to initialize on Init.
func Of ¶ added in v0.19.0
Of returns the AWS client installed by Module/NamedModule under the optional name, panicking if none was installed.
func (*AWS) Init ¶ added in v0.4.0
Init implements core.Initer, building the AWS SDK config from the loaded credentials and region, then initializing the requested service clients.
func (*AWS) ReadConfig ¶ added in v0.11.0
ReadConfig implements configx.Configurable, reading the aws section into the AWS client's own config field.
func (*AWS) S3DownloadFile ¶
func (a *AWS) S3DownloadFile(ctx context.Context, req *S3DownloadFileRequest) error
func (*AWS) S3DownloadFiles ¶
func (*AWS) S3UploadFile ¶
func (a *AWS) S3UploadFile(ctx context.Context, req *S3UploadFileRequest) error
type Config ¶
type Config struct {
AccessKey string `mapstructure:"accessKey"`
SecretKey string `mapstructure:"secretKey"`
Region string `mapstructure:"region"`
EndpointURL *string `mapstructure:"endpointURL"`
S3BucketName *string `mapstructure:"s3BucketName"`
SQSQueueURL *string `mapstructure:"sqsQueueURL"`
DynamoDBEndpointURL *string `mapstructure:"dynamoDBEndpointURL"`
}
Config is MicroJet's AWS configuration, read from the aws section of the application config (with APP_AWS_* environment overrides). It lives in the aws module rather than in core so the core module stays vendor-neutral.