A Queue port adapter for AWS SQS in the hyper service framework
hyper.config.js
import { default as sqs } from 'https://x.nest.land/[email protected]/mod.js'
export default {
app: opine,
adapter: [
{ port: 'queue', plugins: [sqs('UNIQUE_NAME')] },
],
}
In order to use this adapter you will need to have an AWS Account and will need the following information:
- IAM User with access to SQS and S3 (AWS_ACCESS_KEY_ID, AWS_ACCESS_SECRET_KEY, and optional AWS_SESSION_TOKEN)
- AWS Region (default: us-east-1)
The AWS User will need the ability to manage s3 and SQS resources
You may set envrionment variables like so, and the adapter will use them:
AWS_ACCESS_KEY_ID=XXXXX
AWS_SECRET_ACCESS_KEY=XXXXX
AWS_SESSION_TOKEN=XXXXX
AWS_REGION=XXXXX
Then when you configure the hyper service, you can setup the sqs adapter like:
The unique name is an alphanumeric string that contains identifing information, this will enable you to identify the bucket and queue which will be prefixed by 'hyper-queue-' and whatever name you provide.
hyper.config.js
import { default as sqs } from 'https://x.nest.land/[email protected]/mod.js'
export default {
app: opine,
adapter: [
{ port: 'queue', plugins: [sqs('UNIQUE_NAME')] },
],
}
You can explictly pass in awsAccessKeyId, awsSecretKey, sessionToken, and region as options to the adapter method.
sqs(UNIQUE_NAME, {
awsAccessKeyId,
awsSecretKey,
sessionToken,
region: 'us-east-1',
})
This adapter's process task receives messages from SQS and sends them to your queue's worker url for processing. If no messages are received from SQS, this adapter's process task will pause, by default, for 10 seconds, before attempting to receive more messages from SQS
You can also pass a sleep
value to the adapter, which should be the number of milliseconds to
pause if no messages are received from SQS:
sqs(UNIQUE_NAME, { sleep: 5000, awsAccessKeyId: ...})
This is a Deno module available to import from nest.land
deps.js
export { default as sqs } from 'https://x.nest.land/[email protected]/mod.js'
Contributions are welcome! See the hyper contribution guide
./scripts/test.sh
To lint, check formatting, and run unit tests
Apache License 2.0 SEE LICENSE