-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cd66019
Showing
11 changed files
with
5,767 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test-node: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
strategy: | ||
matrix: | ||
node-version: | ||
- 20 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
# would require AWS credentials | ||
# run: npm test | ||
run: npm run format:check && npm run compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
npm-debug.log | ||
node_modules | ||
.idea | ||
.nyc_output/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2024 The Socket.IO team | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Socket.IO AWS SQS adapter | ||
|
||
The @socket.io/aws-sqs-adapter` package allows broadcasting packets between multiple Socket.IO servers. | ||
|
||
Unlike the existing [`socket.io-sqs`](https://github.com/thinkalpha/socket.io-sqs) package, this package supports binary payloads and dynamic namespaces. | ||
|
||
**Table of contents** | ||
|
||
- [Supported features](#supported-features) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Options](#options) | ||
- [License](#license) | ||
|
||
## Supported features | ||
|
||
| Feature | `socket.io` version | Support | | ||
|---------------------------------|---------------------|------------------------------------------------| | ||
| Socket management | `4.0.0` | :white_check_mark: YES (since version `0.1.0`) | | ||
| Inter-server communication | `4.1.0` | :white_check_mark: YES (since version `0.1.0`) | | ||
| Broadcast with acknowledgements | `4.5.0` | :white_check_mark: YES (since version `0.1.0`) | | ||
| Connection state recovery | `4.6.0` | :x: NO | | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @socket.io/aws-sqs-adapter | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { SNS } from "@aws-sdk/client-sns"; | ||
import { SQS } from "@aws-sdk/client-sqs"; | ||
import { Server } from "socket.io"; | ||
import { createAdapter } from "@socket.io/aws-sqs-adapter"; | ||
|
||
const snsClient = new SNS(); | ||
const sqsClient = new SQS(); | ||
|
||
const io = new Server({ | ||
adapter: createAdapter(snsClient, sqsClient) | ||
}); | ||
|
||
// wait for the creation of the SQS queue | ||
await io.of("/").adapter.init(); | ||
|
||
io.listen(3000); | ||
``` | ||
|
||
## Options | ||
|
||
| Name | Description | Default value | | ||
|---------------------|--------------------------------------------------------------------|---------------| | ||
| `topicName` | The name of the SNS topic. | `socket.io` | | ||
| `topicTags` | The tags to apply to the new SNS topic. | `-` | | ||
| `queuePrefix` | The prefix of the SQS queue. | `socket.io` | | ||
| `queueTags` | The tags to apply to the new SQS queue. | `-` | | ||
| `heartbeatInterval` | The number of ms between two heartbeats. | `5_000` | | ||
| `heartbeatTimeout` | The number of ms without heartbeat before we consider a node down. | `10_000` | | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
for q in $(aws sqs list-queues --output text --no-paginate --query 'QueueUrls' --queue-name-prefix 'socket-io'); do | ||
if [ "$q" != "None" ] | ||
then | ||
echo "deleting queue $q"; | ||
aws sqs delete-queue --queue-url $q; | ||
fi | ||
done | ||
|
||
for t in $(aws sns list-topics --output text --no-paginate --query 'Topics[].[TopicArn]' | grep 'socket-io'); do | ||
for s in $(aws sns list-subscriptions-by-topic --output text --no-paginate --query 'Subscriptions[].[SubscriptionArn]' --topic-arn $t); do | ||
echo "deleting subscription $s"; | ||
aws sns unsubscribe --subscription-arn $s | ||
done | ||
|
||
echo "deleting topic $t"; | ||
aws sns delete-topic --topic-arn $t | ||
done |
Oops, something went wrong.