hiett commited on
Commit
48432f0
·
1 Parent(s): 8f1b0f2

Further documentation updates

Browse files
Files changed (1) hide show
  1. README-UPDATED.md +33 -6
README-UPDATED.md CHANGED
@@ -5,11 +5,11 @@ The aim of this project is to be entirely compatible with Upstash, and work with
5
 
6
  Use cases for SRH:
7
  - For usage in your CI pipelines, creating Upstash databases is tedious, or you have lots of parallel runs.
8
- - See Using in GitHub Actions on how to quickly get SRH setup for this context.
9
  - For usage inside of Kubernetes, or any network whereby the Redis server is not exposed to the internet.
10
- - See Using in Docker Compose for the various setup options directly using the Docker Container.
11
  - For local development environments, where you have a local Redis server running, or require offline access.
12
- - See Using the Docker Command, or Using Docker Compose.
13
 
14
  ## Differences between Upstash and Redis to note
15
  SRH tests are ran nightly against the `@upstash/redis` JavaScript package. However, there are some minor differences between Upstash's implementation of Redis and the official Redis code.
@@ -17,7 +17,7 @@ SRH tests are ran nightly against the `@upstash/redis` JavaScript package. Howev
17
  - The `UNLINK` command will not throw an error when 0 keys are given to it. In Redis, and as such SRH, an error will be thrown.
18
  - In the `ZRANGE` command, in Upstash you are not required to provide `BYSCORE` or `BYLEX` in order to use the `LIMIT` argument. With Redis/SRH, this will throw an error if not provided.
19
  - The Upstash implementation of `RedisJSON` contains a number of subtle differences in what is returned in responses. For this reason, **it is not advisable to use SRH with Redis Stack if you are testing your Upstash implementation that uses JSON commands**. If you don't use any JSON commands, then all is good :)
20
- - **SRH does not implement commands via paths, or accepting the token via a query param**. Only the body method is implemented, which the `@upstash/redis` SDK implements.
21
 
22
  ### Similarities to note:
23
 
@@ -71,7 +71,7 @@ services:
71
 
72
  ## In GitHub Actions
73
 
74
- SRH works nicely in GitHub actions because you can run it as a container in a job's services. Simply start a Redis server, and then
75
  SRH alongside it. You don't need to worry about a race condition of the Redis instance not being ready, because SRH doesn't create a Redis connection until the first command comes in.
76
 
77
  ```yml
@@ -113,6 +113,33 @@ jobs:
113
 
114
  # Configuration Options
115
 
 
 
116
  ## Connecting to multiple Redis servers at the same time
117
 
118
- ## Environment Variables
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  Use cases for SRH:
7
  - For usage in your CI pipelines, creating Upstash databases is tedious, or you have lots of parallel runs.
8
+ - See [Using in GitHub Actions](#in-github-actions) on how to quickly get SRH setup for this context.
9
  - For usage inside of Kubernetes, or any network whereby the Redis server is not exposed to the internet.
10
+ - See [Using in Docker Compose](#via-docker-compose) for the various setup options directly using the Docker Container.
11
  - For local development environments, where you have a local Redis server running, or require offline access.
12
+ - See [Using the Docker Command](#via-docker-command), or [Using Docker Compose](#via-docker-compose).
13
 
14
  ## Differences between Upstash and Redis to note
15
  SRH tests are ran nightly against the `@upstash/redis` JavaScript package. However, there are some minor differences between Upstash's implementation of Redis and the official Redis code.
 
17
  - The `UNLINK` command will not throw an error when 0 keys are given to it. In Redis, and as such SRH, an error will be thrown.
18
  - In the `ZRANGE` command, in Upstash you are not required to provide `BYSCORE` or `BYLEX` in order to use the `LIMIT` argument. With Redis/SRH, this will throw an error if not provided.
19
  - The Upstash implementation of `RedisJSON` contains a number of subtle differences in what is returned in responses. For this reason, **it is not advisable to use SRH with Redis Stack if you are testing your Upstash implementation that uses JSON commands**. If you don't use any JSON commands, then all is good :)
20
+ - **SRH does not implement commands via paths, or accepting the token via a query param**. Only the body method is implemented, which the `@upstash/redis` SDK uses.
21
 
22
  ### Similarities to note:
23
 
 
71
 
72
  ## In GitHub Actions
73
 
74
+ SRH works nicely in GitHub Actions because you can run it as a container in a job's services. Simply start a Redis server, and then
75
  SRH alongside it. You don't need to worry about a race condition of the Redis instance not being ready, because SRH doesn't create a Redis connection until the first command comes in.
76
 
77
  ```yml
 
113
 
114
  # Configuration Options
115
 
116
+ SRH works with multiple Redis servers, and can pool however many connections you wish it to. It will shut down un-used pools after 15 minutes of inactivity. Upon the next command, it will re-build the pool.
117
+
118
  ## Connecting to multiple Redis servers at the same time
119
 
120
+ The examples above use environment variables in order to tell SRH which Redis server to connect to. However, you can also use a configuration JSON file, which lets you create as many connections as you wish. The token provided in each request will decide which pool is used.
121
+
122
+ Create a JSON file, in this example called `tokens.json`:
123
+ ```json
124
+ {
125
+ "example_token": {
126
+ "srh_id": "some_unique_identifier",
127
+ "connection_string": "redis://localhost:6379",
128
+ "max_connections": 3
129
+ }
130
+ }
131
+ ```
132
+ You can provide as many entries to the base object as you wish, and configure the number of max connections per pool. The `srh_id` is used internally to keep track of instances. It can be anything you want.
133
+
134
+ Once you have created this, mount it to the docker container to the `/app/srh-config/tokens.json` file. Here is an example docker command:
135
+
136
+ `docker run -it -d -p 8079:80 --name srh --mount type=bind,source=$(pwd)/tokens.json,target=/app/srh-config/tokens.json hiett/serverless-redis-http:latest`
137
+
138
+ ## Environment Variables
139
+
140
+ | Name | Default Value | Notes |
141
+ | ---- | ------------- | ----- |
142
+ | SRH_MODE | `file` | Can be `env` or `file`. If `file`, see [Connecting to multiple Redis servers](#connecting-to-multiple-redis-servers-at-the-same-time). If set to `env`, you are required to provide the following environment variables: |
143
+ | SRH_TOKEN | `<required if SRH_MODE = env>` | Set the token that the Rest API will require |
144
+ | SRH_CONNECTION_STRING | `<required if SRH_MODE = env>` | Sets the connection string to the Redis server. |
145
+ | SRH_MAX_CONNECTIONS | `3` | Only used if `SRH_MODE=env`.