Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Redis Sentinel #15

Merged
merged 4 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.8.0
======

- Support for connecting to sentinels

v1.7.1
======

Expand Down Expand Up @@ -60,4 +65,4 @@ v1.0.1
v1.0.0
======

- Initial Version
- Initial Version
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,49 @@ Call the tool and get a help on the options:

Options:

-V, --version output the version number
-n, --name [name] connection name [My Connection] (default: "My Connection")
-t, --token [token] api token (get yours at https://taskforce.sh)
-p, --port [port] redis port [6379] (default: "6379")
--tls [tls] (default: "Activate secured TLS connection to Redis")
-h, --host [host] redis host [localhost] (default: "localhost")
-d, --database [db] redis database [0] (default: "0")
--passwd [passwd] redis password
-u, --uri [uri] redis uri
--team [team] specify team where to put the connection
-b, --backend [host] backend domain [api.taskforce.sh] (default: "wss://api.taskforce.sh")
-h, --help output usage information
-V, --version output the version number
-n, --name [name] connection name [My Connection] (default: "My Connection")
-t, --token [token] api token (get yours at https://taskforce.sh)
-p, --port [port] redis port [6379] (default: "6379")
--tls [tls] (default: "Activate secured TLS connection to Redis")
-h, --host [host] redis host [localhost] (default: "localhost")
-d, --database [db] redis database [0] (default: "0")
--passwd [passwd] redis password
-u, --uri [uri] redis uri
--team [team] specify team where to put the connection
-b, --backend [host] backend domain [api.taskforce.sh] (default: "wss://api.taskforce.sh")
-s, --sentinels [host:port] comma-separated list of sentinel host/port pairs
-m, --master [name] name of master node used in sentinel configuration
-h, --help output usage information
```

Example:

```bash
✗ taskforce -n "transcoder connection" -t 2cfe6a1b-5f0e-466f-99ad-12f51bea79a7

```

The token `2cfe6a1b-5f0e-466f-99ad-12f51bea79a7` is a private token that can be retrieved at your [Taskforce account](https://taskforce.sh/account).

After running the command, you should be able to see the connection appear automatically on the dashboard.

Note: You can also specify the taskforce token with the environment variable TASKFORCE_TOKEN
Sentinel Example:

```bash
✗ taskforce -n "transcoder connection" -t 2cfe6a1b-5f0e-466f-99ad-12f51bea79a7 -s sentinel1.mydomain:6379,sentinel2.mydomain:6379 -m mymaster
```

Note: You can also specify the following with environment variables.

```bash
token TASKFORCE_TOKEN
port REDIS_PORT
host REDIS_HOST
password REDIS_PASSWD
uri REDIS_URI
sentinels REDIS_SENTINELS
master REDIS_MASTER
```

## Secured TLS Connections

Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ program
"backend domain [api.taskforce.sh]",
"wss://api.taskforce.sh"
)
.option("-s, --sentinels [host:port]", "comma-separated list of sentinel host/port pairs", process.env.REDIS_SENTINELS)
.option("-m, --master [name]", "name of master node used in sentinel configuration", process.env.REDIS_MASTER)
.parse(process.argv);

console.info(
Expand Down Expand Up @@ -80,6 +82,11 @@ lastestVersion(pkg.name).then(function (version) {
agent: false,
}
: void 0,
sentinels: program.sentinels && program.sentinels.split(",").map(hostPort => {
const [host, port] = hostPort.split(":");
return { host, port };
}),
name: program.master,
};

const socket = require("./dist/socket");
Expand Down
2 changes: 1 addition & 1 deletion lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ module.exports = (

function redisOptsFromConnection(connection: Connection): RedisOptions {
let opts: RedisOptions = {
...pick(connection, ["port", "host", "family", "password", "db", "tls"]),
...pick(connection, ["port", "host", "family", "password", "db", "tls", "sentinels", "name"]),
};

if (connection.uri) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taskforce-connector",
"version": "1.7.1",
"version": "1.8.0",
"description": "Connects queues to Taskforce",
"preferGlobal": true,
"bin": {
Expand Down