gas/queue
queue/sqs
import "github.com/gasmod/gas/queue/sqs"Package sqs is a queue store on Amazon SQS, as a gas.JobQueueProvider. It sends its requests with the AWS SDK for Go v2, so it also reaches an emulator that speaks the SQS API, such as ElasticMQ or LocalStack.
Service implements gas.Service, gas.JobQueueProvider and gas.ReadyReporter, and keeps the contract of the queue package.
In an app, the container builds the store from New and calls its Init. By hand, with a configuration given in code:
cfg := sqs.DefaultConfig()cfg.Queue.Region = "eu-west-1"
q, err := sqs.New(sqs.WithConfig(cfg))(nil, logger)if err != nil { return err}if err := q.Init(ctx); err != nil { return err}defer q.Close(ctx)
err = q.Enqueue(ctx, "orders", []byte(`{"id":42}`))After this the SQS queue orders of the account the credentials
belong to holds the message.
Configuration
Section titled “Configuration”The settings live in the queue section, in Settings:
queue.region: the AWS region. Default: none; the AWS SDK’s default chain decides, as under Credentials.queue.endpoint: the URL requests go to,httporhttps, with a host and nothing after it but/(no user information, path, query or fragment), such as an emulator’s. Default: none, the region’s SQS endpoint. Anhttpendpoint sends every request in clear text, the access key ID, the session token and the payloads included. Use it only for an emulator on a network of its own, such ashttp://elasticmq:9324in a compose file.queue.accesskeyid,queue.secretaccesskey,queue.sessiontoken: static credentials, as under Credentials. The access key ID is not a secret, but it maps to the AWS account ID, and the store never logs it. The secret key and the token are each a Secret, which prints, marshals to JSON or YAML, and logs with log/slog as[redacted]. Default: none.queue.optimeout: the bound of each request, retries included, above 0, as under Timeouts. Default: DefaultOpTimeout (10s).queue.visibilitytimeout: how long a message Dequeue returns stays hidden, 1s to 12h, rounded up to a whole second, or 0, which sends none, for the queue’s own. Default: DefaultVisibilityTimeout, 0.queue.maxretries: how many times a failed request is retried, 0 to MaxRetries (10), with the AWS SDK’s standard retryer and its backoff. Default: DefaultMaxRetries, 2, so 3 attempts.queue.rawerrors: whether a failed request’s error also shows and wraps the AWS SDK’s error, as under Raw errors. It breaks the guarantees under Security, so use it to debug. Default: false.
Service.Init resolves the configuration each time it runs, from one of two sources:
- Without WithConfig, it binds DefaultConfig from the
gas.ConfigProvider, which checks the
validatetags. A nil ConfigProvider is the error queue.ErrNoConfigProvider. - With WithConfig, it takes a copy of the given Config, never changing the caller’s struct, and checks the same tags. A nil Config is the error queue.ErrNilConfig.
Either way, these rules then run, in this order, and the first that fails is the error:
visibilitytimeoutis 0 or at least a second.endpoint, when set, is anhttporhttpsURL with a host and nothing more but/.
A failure wraps queue.ErrInvalidConfig and names the setting, never its value.
Service.Config returns a copy of the configuration the last
successful Init resolved, defaults included, or the zero Config before
one. A failed Init and Close leave it as it was. Its secretaccesskey
and sessiontoken stay a Secret, which prints as [redacted].
Credentials
Section titled “Credentials”Init builds the client with the AWS SDK’s default configuration, which comes from:
- the environment, such as
AWS_REGIONandAWS_ACCESS_KEY_ID; - the shared configuration and credentials files, and their profile;
- the container and instance roles.
Its HTTP client is the store’s own, on the AWS SDK’s default transport. It follows no redirect, as the SDK’s does not.
A region setting takes precedence over the chain’s region. Without
one, a region the chain does not find fails Init with ErrNoRegion.
Static credentials are used when both accesskeyid and
secretaccesskey are set, with sessiontoken when it is set too. With
either key empty, the chain’s credentials apply, as
config/secretsmanager does it, and the other static values are not
used. When some of them are set, but not both keys, Init logs
static credentials incomplete, using the default chain at warn
level, with missing naming the keys that are not set, never a value.
AWS configuration that fails to load, such as a profile that does not exist, fails Init with queue.ErrInvalidConfig.
Init retrieves the credentials within its context and optimeout, so
that it fails, with ErrNoCredentials, when there are none, rather
than the first request. The client then refreshes them as they expire.
Init sends no request to SQS.
WithClient gives the store a client to use instead, such as an
*sqs.Client built elsewhere or a fake of API. region, endpoint,
the credentials and maxretries then have no effect, and Init neither
checks a region nor retrieves credentials.
Queues
Section titled “Queues”A queue is named as the queue package describes. A queue URL is sent as it is.
A queue name is resolved with GetQueueUrl, which needs the
sqs:GetQueueUrl permission, on the first call that uses it:
- The URL is kept until Close.
- It is dropped when a request finds the queue does not exist, so a queue deleted and created again is resolved anew.
- A reply that is not a queue URL, as queue.ParseQueue reads one, of the name asked for, fails the call with an invalid reply, and is not kept.
Requests go to endpoint, or to the region’s endpoint, whatever the
host of a queue URL.
Sending
Section titled “Sending”Enqueue is SendMessage:
- Every attribute is sent as a
String. - A delay is sent in whole seconds, rounded up, and none when it is 0, so the queue’s own delay applies.
- The AWS SDK checks the MD5 digest SQS returns against the payload, which the payload rules keep valid.
On a FIFO queue, a message without a dedupe ID that SQS refuses with InvalidParameterValue, as it does on a queue without content-based deduplication, gets an error that wraps queue.ErrInvalidArgument too.
Receiving
Section titled “Receiving”Dequeue is ReceiveMessage. It sends:
- maxMessages;
- its wait in whole seconds, rounded up, and a wait of 0 as
"WaitTimeSeconds":0, which the AWS SDK otherwise leaves out, so a queue whose ReceiveMessageWaitTimeSeconds attribute is set still answers a short poll at once; visibilitytimeout, unless it is 0;- a request for every message attribute, and for the system attributes the queue package lists;
- on a FIFO queue, a ReceiveRequestAttemptId of its own, so that a retry by the AWS SDK gets the same messages instead of hiding them.
A job holds each message attribute with a string value, Number ones included. It does not hold Binary ones, which a producer outside the module may send, nor one with the name of a system attribute, whose place the system attribute takes.
A reply with more than maxMessages messages, or with a message without an ID or a receipt handle, is an invalid reply. Dequeue makes its messages that have both visible again, as Close’s release does, and returns the error, with no jobs.
Acknowledging
Section titled “Acknowledging”Ack is DeleteMessage. Nack, NackAfter and Extend are ChangeMessageVisibility, with the visibility timeout in whole seconds, rounded up, 0 for Nack; the AWS SDK sends 0 too.
A message no longer leased under the job’s receipt handle gets an error reply:
- MessageNotInflight wraps queue.ErrNotInFlight.
- ReceiptHandleIsInvalid wraps queue.ErrInvalidReceipt.
- InvalidParameterValue, which LocalStack sends, wraps ErrCommand alone.
ElasticMQ and LocalStack accept a Nack of a message whose lease has ended, which SQS documents as MessageNotInflight.
Timeouts
Section titled “Timeouts”Every request runs within its context and optimeout, whichever ends
first, the AWS SDK’s retries and their backoff included. So a server
that stops answering cannot hold a call longer than optimeout, even
with a context that never ends. A Dequeue runs within its wait plus
optimeout.
The SDK retries a request after a network error, a throttle and a
server error, up to maxretries times. A send whose reply was lost can
then be stored twice, as at-least-once delivery allows.
Connection errors
Section titled “Connection errors”A request that fails at the connection returns an error wrapping
ErrConnect and a reason, never the AWS SDK’s error, which holds the
endpoint, unless queue.rawerrors is set, as under Raw errors. The
reasons:
timed out: a deadline passed, in a context or on the network. The error then wraps context.DeadlineExceeded too.connection refused: the endpoint refused the TCP connection.unreachable: any other network error, such as a failed name lookup.
A call whose own context ended returns the context’s error after
<op> "<queue>": , wrapped, without ErrConnect.
Which of the two a timeout is depends on which deadline was in force. A
timeout of a call whose context’s deadline is no later than
optimeout’s is the context’s error.
Error replies
Section titled “Error replies”An error reply of SQS returns an error wrapping ErrCommand, with a
reason told by its AWS error code. The code follows, in parentheses,
when it is one SQS or the AWS APIs document. The reply’s message, which
can quote a receipt handle, an attribute name or a parameter’s value,
is never kept, nor a code of any other text, unless queue.rawerrors
is set, as under Raw errors.
The reasons, in the order they are told:
queue does not exist: QueueDoesNotExist, also wrapping queue.ErrQueueNotFound.access denied: AccessDenied, InvalidClientTokenId, SignatureDoesNotMatch, ExpiredToken and the other codes of refused credentials or permissions, also wrapping ErrAccessDenied.throttled: RequestThrottled, ThrottlingException and the KMS throttles, also wrapping ErrThrottled.invalid receipt handle: ReceiptHandleIsInvalid, also wrapping queue.ErrInvalidReceipt.message not in flight: MessageNotInflight, also wrapping queue.ErrNotInFlight.invalid reply: a reply SQS does not send: a body larger than 64 MiB, which the client Init builds stops reading at, a client of WithClient that returns neither an output nor an error, a ReceiveMessage or GetQueueUrl reply as under Receiving and Queues.failed: any other reply, or a request that failed for another reason, such as a reply that is not valid JSON.
Raw errors
Section titled “Raw errors”With queue.rawerrors set, the error of a failed request’s text ends
with : and the AWS SDK’s error, its operation, HTTP status, request
ID, code and message, or its transport error, and the error wraps it,
so errors.As reaches the SDK’s types, such as smithy.APIError. It does
the same for the failure of Init to load the AWS configuration or to
retrieve credentials. The reason, the code, the sentinels and the
context’s errors are as without it. An invalid reply of Dequeue and an
entry of a release that SQS reports failed have no error of the SDK’s,
and stay as they are. Init logs a warning when it is set.
Lifecycle
Section titled “Lifecycle”A successful Init publishes the client and logs service initialized
at info level, with:
region;- whether an
endpointand aclientwere given; credentials, where the client Init built takes them from,staticordefault chain, left out with WithClient;op_timeout.
Only then do the methods use the client. Init on an initialized store returns queue.ErrAlreadyInitialized and changes nothing. A failed Init leaves the store as it was.
Out of the initialized state:
- Before the first successful Init, every method but Init, Close, Name, Client and Config returns an error wrapping queue.ErrNotInitialized.
- After Close, until Init succeeds, they return queue.ErrClosed.
New’s constructor fails with queue.ErrNilLogger for a nil logger. A nil ConfigProvider is accepted, and Init then requires WithConfig. A nil client given to WithClient fails Init with ErrNilClient.
Closing
Section titled “Closing”Service.Close runs these steps, in order:
- It makes the store closed, so that every later call returns queue.ErrClosed.
- It waits for every call in flight to return. While its context lasts, it does not cut a call short.
- It closes the idle connections of the client Init built.
- It logs
service closedat info level.
A Dequeue that has not sent its receive when Close begins sends none and returns queue.ErrClosed. A Dequeue in flight:
- finishes its receive, which ends when a message comes or its wait ends;
- makes what it received visible again, with one
ChangeMessageVisibilityBatch of 0, all within one
optimeout; - returns queue.ErrClosed, joined with the error of the request, or of each entry SQS reports failed.
So Close can take as long as the longest wait in flight plus twice
optimeout: one for the receive, one for the release.
Cutting the receive short instead could strand messages. ElasticMQ and LocalStack both hand a message sent during a receive to that receive after its client has gone, where it stays hidden for its visibility timeout, and SQS documents nothing that rules it out. A Dequeue whose own context ends while it waits cuts its receive the same way, so give a worker’s Dequeue a context that outlives its wait.
When Close’s context ends before the calls in flight return, Close:
- cancels their requests, which may strand what a receive was handed as above;
- logs
service closed, calls in flight canceledat warn level; - returns an error wrapping the context’s error.
The store stays closed, and the canceled calls return queue.ErrClosed.
Close on a store that is not initialized returns nil and logs nothing. Init after Close builds a new client, with a configuration resolved afresh.
Readiness
Section titled “Readiness”Service.CheckReady does no I/O: it fails only when the store is not initialized or its context has ended. There is no queue it could check without being told one.
Client
Section titled “Client”Service.Client returns the *sqs.Client, for the operations the store has no method for, such as CreateQueue and PurgeQueue. It returns nil when the store is not initialized or was given another API.
Requests sent on it are bounded only by their own context, and return the AWS SDK’s errors as they are, which can hold the endpoint and the queue URL.
Security
Section titled “Security”No error the store makes and no log it writes holds a payload, an
attribute, a receipt handle, a queue URL, the endpoint, or a
credential, the access key ID included, unless queue.rawerrors is
set: then an error can hold what the AWS SDK’s error holds, such as the
endpoint, a queue URL, the account ID, a receipt handle and the
server’s message. The logs carry:
- the region;
- whether an endpoint and a client were given;
- where the credentials come from;
- the names of the static keys missing;
- the operation timeout.
fmt, encoding/json, YAML encoders that use encoding.TextMarshaler, and
log/slog write the secret key and the session token of a Settings or
a Config as [redacted]. encoding/gob fails on them rather than
encode them.
Static credentials in configuration are a secret of the app’s. Prefer a role, which the default chain finds.
An http endpoint sends the access key ID, the session token and the
payloads in clear text, as under Configuration. The secret key only
signs requests and is never sent.
The client Init builds reads no reply past 64 MiB, so an endpoint cannot make it read without bound. It logs nothing: the AWS SDK’s default logger, which writes raw transport errors holding the endpoint, is replaced with one that discards them.
Concurrency
Section titled “Concurrency”A Service is safe for concurrent use. Init and Close run one at a time.
Init swaps in what it built at once. So the other methods, which take no lock but to count themselves in flight, use one Init’s client throughout a call. The resolved queue URLs are kept under a lock.
Errors
Section titled “Errors”The sentinel errors of this package, to be tested with errors.Is:
- ErrNoRegion: Init found no region.
- ErrNoCredentials: Init could not retrieve credentials.
- ErrNilClient: WithClient was given a nil client.
- ErrConnect: a request got no reply, as under Connection errors.
- ErrCommand: SQS replied with an error, or with an invalid reply, or a request failed for another reason, as under Error replies.
- ErrAccessDenied, ErrThrottled: kinds of ErrCommand.
The other errors wrap a sentinel of the queue package, as the queue
package describes. Every error starts with ServiceName and the
operation. A configuration that fails its tags gets the validator’s
error after gas/queue/sqs: init: invalid config: validate config: ,
such as:
Key: 'Config.Queue.OpTimeout' Error:Field validation for 'OpTimeout' failed on the 'gt' tagThe other errors, as returned, with enqueue standing for each
operation that can fail the same way:
gas/queue/sqs: logger is nilgas/queue/sqs: init: config is nilgas/queue/sqs: init: no config providergas/queue/sqs: init: invalid config: Queue.VisibilityTimeout must be 0 or 1s to 12hgas/queue/sqs: init: invalid config: Queue.Endpoint must be an http or https URL with a host and nothing more but /gas/queue/sqs: init: invalid config: AWS configuration failed to loadgas/queue/sqs: init: no regiongas/queue/sqs: init: no credentials: failedgas/queue/sqs: init: no credentials: timed outgas/queue/sqs: init: no credentials: timed out: context deadline exceededgas/queue/sqs: init: client is nilgas/queue/sqs: init: service already initializedgas/queue/sqs: init: context canceledgas/queue/sqs: ready: service not initializedgas/queue/sqs: enqueue: invalid queue: emptygas/queue/sqs: enqueue "orders": invalid payload: emptygas/queue/sqs: enqueue "orders": service not initializedgas/queue/sqs: enqueue "orders": service closedgas/queue/sqs: enqueue "orders": context canceledgas/queue/sqs: enqueue "orders": context deadline exceededgas/queue/sqs: enqueue "orders": timed outgas/queue/sqs: enqueue "orders": connection refusedgas/queue/sqs: enqueue "orders": unreachablegas/queue/sqs: enqueue "orders": queue does not exist (QueueDoesNotExist)gas/queue/sqs: enqueue "orders": access denied (AccessDenied)gas/queue/sqs: enqueue "orders": throttled (RequestThrottled)gas/queue/sqs: enqueue "orders": failed (InvalidParameterValue)gas/queue/sqs: enqueue "orders": failedgas/queue/sqs: ack "orders": invalid receipt handle (ReceiptHandleIsInvalid)gas/queue/sqs: nack "orders": message not in flight (MessageNotInflight)gas/queue/sqs: dequeue "orders": service closedgas/queue/sqs: dequeue "orders": invalid replygas/queue/sqs: close: context deadline exceededAPI reference
Section titled “API reference”Constants
Section titled “Constants”const ( // DefaultOpTimeout is the bound of each request of DefaultConfig, and // what a Dequeue may take past its wait. DefaultOpTimeout = 10 * time.Second // DefaultVisibilityTimeout is the visibility timeout of Dequeue in // DefaultConfig: 0, the queue's own. DefaultVisibilityTimeout time.Duration = 0 // DefaultMaxRetries is how many times DefaultConfig retries a failed // request: 2, so 3 attempts, as the AWS SDK's standard retryer makes // by default. DefaultMaxRetries = 2 // MaxRetries is the most retries the MaxRetries setting allows. MaxRetries = 10)const ServiceName = "gas/queue/sqs"ServiceName is the name of the SQS store, returned by Service.Name and prefixed to every error the store returns.
Variables
Section titled “Variables”var ( // ErrNoRegion indicates that Init found no AWS region, in the Region // setting or the AWS SDK's default chain. ErrNoRegion = errors.New("no region") // ErrNoCredentials indicates that Init could not retrieve AWS // credentials. ErrNoCredentials = errors.New("no credentials") // ErrNilClient indicates that WithClient was given a nil client. ErrNilClient = errors.New("client is nil") // ErrConnect indicates that a request got no reply from SQS: it timed // out, its connection was refused, or the endpoint was unreachable, as // described in the package documentation. ErrConnect = errors.New("no reply") // ErrCommand indicates that SQS replied to a request with an error, or // that a request failed for another reason than ErrConnect's, as // described in the package documentation. ErrCommand = errors.New("request failed") // ErrAccessDenied indicates that SQS refused the credentials, or their // permission for the request. It comes with ErrCommand. ErrAccessDenied = errors.New("access denied") // ErrThrottled indicates that SQS throttled the request, past the // retries. It comes with ErrCommand. ErrThrottled = errors.New("throttled"))func New
Section titled “func New”func New(opts ...Option) func(gas.ConfigProvider, gas.Logger) (*Service, error)New returns the constructor of a Service with opts applied, in the shape the gas container expects. The constructor returns an error wrapping queue.ErrNilLogger for a nil logger; a nil ConfigProvider is accepted, and Init then requires WithConfig.
type API
Section titled “type API”type API interface { // SendMessage sends a message, for Enqueue. SendMessage( ctx context.Context, params *awssqs.SendMessageInput, optFns ...func(*awssqs.Options), ) (*awssqs.SendMessageOutput, error) // ReceiveMessage receives messages, for Dequeue. ReceiveMessage( ctx context.Context, params *awssqs.ReceiveMessageInput, optFns ...func(*awssqs.Options), ) (*awssqs.ReceiveMessageOutput, error) // DeleteMessage deletes a message, for Ack. DeleteMessage( ctx context.Context, params *awssqs.DeleteMessageInput, optFns ...func(*awssqs.Options), ) (*awssqs.DeleteMessageOutput, error) // ChangeMessageVisibility changes a message's visibility timeout, for // Nack, NackAfter and Extend. ChangeMessageVisibility( ctx context.Context, params *awssqs.ChangeMessageVisibilityInput, optFns ...func(*awssqs.Options), ) (*awssqs.ChangeMessageVisibilityOutput, error) // ChangeMessageVisibilityBatch changes the visibility timeout of up to // ten messages, to make visible again what a Dequeue received but // does not return. ChangeMessageVisibilityBatch( ctx context.Context, params *awssqs.ChangeMessageVisibilityBatchInput, optFns ...func(*awssqs.Options), ) (*awssqs.ChangeMessageVisibilityBatchOutput, error) // GetQueueUrl returns the URL of a queue name. GetQueueUrl( ctx context.Context, params *awssqs.GetQueueUrlInput, optFns ...func(*awssqs.Options), ) (*awssqs.GetQueueUrlOutput, error)}API is the part of the SQS client the store uses. *sqs.Client implements it.
type Config
Section titled “type Config”type Config struct { // Queue holds the settings. Queue Settings}Config holds the SQS store’s configuration, read from the queue
section.
func DefaultConfig
Section titled “func DefaultConfig”func DefaultConfig() *ConfigDefaultConfig returns the configuration a store starts from before binding: no region, no endpoint, no static credentials, DefaultOpTimeout, DefaultVisibilityTimeout and DefaultMaxRetries.
type Option
Section titled “type Option”type Option func(*Service)Option configures a Service. Options only record what they are given; Init checks it.
func WithClient
Section titled “func WithClient”func WithClient(client API) OptionWithClient makes the store send its requests with client, such as an *sqs.Client built elsewhere or a fake, instead of building one, as described in the package documentation. The Region, Endpoint, credential and MaxRetries settings then have no effect. A nil client, or a nil *sqs.Client, makes Init fail with ErrNilClient.
Default: Init builds an *sqs.Client from the settings.
func WithConfig
Section titled “func WithConfig”func WithConfig(cfg *Config) OptionWithConfig makes Init use a copy of cfg instead of binding the configuration from the ConfigProvider. Init copies *cfg each time it runs and never changes it; the copy is checked against its validate tags as a bound configuration is. A nil cfg makes Init fail with queue.ErrNilConfig.
Default: bind the queue section from the ConfigProvider over
DefaultConfig.
type Secret
Section titled “type Secret”type Secret = gas.SecretSecret is gas.Secret: a string that is never printed, marshaled or logged, such as Settings.SecretAccessKey. Configuration binds into it as into a string, and string(s) is the value.
type Service
Section titled “type Service”type Service struct { // contains filtered or unexported fields}Service is a queue store on Amazon SQS, as described in the package documentation. It is safe for concurrent use.
func (*Service) Ack
Section titled “func (*Service) Ack”func (s *Service) Ack(ctx context.Context, id string, job gas.Job) errorAck deletes the job’s message, with DeleteMessage.
func (*Service) CheckReady
Section titled “func (*Service) CheckReady”func (s *Service) CheckReady(ctx context.Context) errorCheckReady reports readiness without I/O: an error wrapping queue.ErrNotInitialized or queue.ErrClosed when the store is not initialized, the context’s error when ctx has ended, and else nil.
func (*Service) Client
Section titled “func (*Service) Client”func (s *Service) Client() *awssqs.ClientClient returns the *sqs.Client the store sends its requests with, or nil when the store is not initialized or was given another API with WithClient, as described in the package documentation.
func (*Service) Close
Section titled “func (*Service) Close”func (s *Service) Close(ctx context.Context) errorClose makes every later call but Init return an error wrapping queue.ErrClosed, and waits for every call in flight to return, as described in the package documentation: a Dequeue in flight finishes its receive, makes what it received visible again, and returns queue.ErrClosed. When ctx ends first, Close cancels the requests in flight, whose calls return queue.ErrClosed, and returns an error wrapping ctx’s error; the store stays closed. Close then closes the idle connections of a client Init built. A Close that runs at the same time waits for it too. Close on a store that is not initialized returns nil and logs nothing.
func (*Service) Config
Section titled “func (*Service) Config”func (s *Service) Config() ConfigConfig returns a copy of the configuration the last successful Init resolved, defaults included, or the zero Config before one. A failed Init and Close leave it as it was. Config holds no slice, map or pointer, so the copy shares nothing with the store, and SecretAccessKey and SessionToken stay Secrets.
func (*Service) Dequeue
Section titled “func (*Service) Dequeue”func (s *Service) Dequeue( ctx context.Context, id string, maxMessages int, wait time.Duration,) ([]gas.Job, error)Dequeue receives up to maxMessages messages of the queue, waiting up to wait for the first, with ReceiveMessage, as described in the package documentation. It is bounded by ctx and by wait plus OpTimeout. When Close began before the receive is sent, it sends none; when Close begins before the receive returns, it makes what it received visible again and returns queue.ErrClosed. A reply with more than maxMessages messages, or with a message without an ID or a receipt handle, is an invalid reply, whose valid messages it makes visible again.
func (*Service) Enqueue
Section titled “func (*Service) Enqueue”func (s *Service) Enqueue( ctx context.Context, id string, payload []byte, opts ...gas.EnqueueOption,) errorEnqueue sends payload to the queue with opts, with SendMessage, as described in the package documentation.
func (*Service) Extend
Section titled “func (*Service) Extend”func (s *Service) Extend(ctx context.Context, id string, job gas.Job, d time.Duration) errorExtend keeps the job’s message hidden for d more, 0 to 12h, rounded up to a whole second, counted from now, with ChangeMessageVisibility, as described in the package documentation.
func (*Service) Init
Section titled “func (*Service) Init”func (s *Service) Init(ctx context.Context) errorInit resolves and checks the configuration, builds the client and retrieves the credentials, as described in the package documentation. On an initialized store it returns queue.ErrAlreadyInitialized and changes nothing. A failed Init leaves the store as it was.
func (*Service) Nack
Section titled “func (*Service) Nack”func (s *Service) Nack(ctx context.Context, id string, job gas.Job) errorNack makes the job’s message visible now, as NackAfter with 0.
func (*Service) NackAfter
Section titled “func (*Service) NackAfter”func (s *Service) NackAfter(ctx context.Context, id string, job gas.Job, d time.Duration) errorNackAfter makes the job’s message visible after d, 0 to 12h, rounded up to a whole second, counted from now, with ChangeMessageVisibility, as described in the package documentation.
func (*Service) Name
Section titled “func (*Service) Name”func (*Service) Name() stringName returns ServiceName.
type Settings
Section titled “type Settings”type Settings struct { // Region is the AWS region; empty leaves it to the AWS SDK's default // chain. Region string // Endpoint is the URL requests go to, such as an emulator's; empty is // the region's SQS endpoint. Endpoint string // AccessKeyID is the access key ID of static credentials, used only // with SecretAccessKey. It is not a secret, but an identifier that // maps to the AWS account ID, so the store never logs it. AccessKeyID string // SecretAccessKey is the secret access key of static credentials, // used only with AccessKeyID. It prints, marshals and logs as // `[redacted]`. SecretAccessKey Secret // SessionToken is the session token of temporary static credentials. // It prints, marshals and logs as `[redacted]`. SessionToken Secret // OpTimeout bounds each request, and a Dequeue past its wait. OpTimeout time.Duration `validate:"gt=0"` // VisibilityTimeout is how long a message Dequeue returns stays // hidden: 0 is the queue's own, else 1s to 12h. VisibilityTimeout time.Duration `validate:"min=0,max=12h"` // MaxRetries is how many times a failed request is retried. MaxRetries int `validate:"min=0,max=10"` // RawErrors makes a failed request's error also show and wrap the AWS // SDK's error, which can hold the endpoint, a queue URL, the account // ID, a receipt handle and the server's message. Off by default; use // it to debug. RawErrors bool}Settings are the SQS store’s settings, as described in the package documentation.