https://github.com/hyper63/hyper-adapter-sqs
SQS Adapter for hyper queue port
https://github.com/hyper63/hyper-adapter-sqs
Last synced: 4 months ago
JSON representation
SQS Adapter for hyper queue port
- Host: GitHub
- URL: https://github.com/hyper63/hyper-adapter-sqs
- Owner: hyper63
- License: apache-2.0
- Created: 2021-06-16T11:37:00.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-29T01:01:03.000Z (over 2 years ago)
- Last Synced: 2025-01-13T05:41:39.393Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 213 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hyper-adapter-sqs
A Queue port adapter for AWS SQS in the hyper service framework
- [Getting Started](#getting-started)
- [ENV VARS](#env-vars)
- [Sleep](#sleep)
- [Installation](#installation)
- [Contributing](#contributing)
- [Testing](#testing)
- [License](#license)
## Getting Started
`hyper.config.js`
```js
import { default as sqs } from 'https://x.nest.land/hyper-adapter-sqs@0.1.4/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
### ENV VARS
You may set envrionment variables like so, and the adapter will use them:
```txt
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`
```js
import { default as sqs } from 'https://x.nest.land/hyper-adapter-sqs@0.1.4/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.
```js
sqs(UNIQUE_NAME, {
awsAccessKeyId,
awsSecretKey,
sessionToken,
region: 'us-east-1',
})
```
## Sleep
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:
```js
sqs(UNIQUE_NAME, { sleep: 5000, awsAccessKeyId: ...})
```
## Installation
This is a Deno module available to import from
[nest.land](https://nest.land/package/hyper-adapter-sqs)
deps.js
```js
export { default as sqs } from 'https://x.nest.land/hyper-adapter-sqs@0.1.4/mod.js'
```
## Contributing
Contributions are welcome! See the hyper
[contribution guide](https://docs.hyper.io/contributing-to-hyper)
## Testing
```
./scripts/test.sh
```
To lint, check formatting, and run unit tests
## License
Apache License 2.0 SEE [LICENSE](LICENSE)