Skip to content

Commit

Permalink
feat: add multiple env variables for configuring Redis (#202)
Browse files Browse the repository at this point in the history
* docs: Added auto generation of markdown help
  • Loading branch information
Christopher Kolstad authored Jun 5, 2023
1 parent 46fd893 commit 1074674
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 5 deletions.
120 changes: 120 additions & 0 deletions CLI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Command-Line Help for `unleash-edge`

This document contains the help content for the `unleash-edge` command-line program.

**Command Overview:**

* [`unleash-edge`](#unleash-edge)
* [`unleash-edge edge`](#unleash-edge-edge)
* [`unleash-edge offline`](#unleash-edge-offline)

## `unleash-edge`

**Usage:** `unleash-edge [OPTIONS] <COMMAND>`

###### **Subcommands:**

* `edge` — Run in edge mode
* `offline` — Run in offline mode

###### **Options:**

* `-p`, `--port <PORT>` — Which port should this server listen for HTTP traffic on

Default value: `3063`
* `-i`, `--interface <INTERFACE>` — Which interfaces should this server listen for HTTP traffic on

Default value: `0.0.0.0`
* `-b`, `--base-path <BASE_PATH>` — Which base path should this server listen for HTTP traffic on

Default value: ``
* `-w`, `--workers <WORKERS>` — How many workers should be started to handle requests. Defaults to number of physical cpus

Default value: `16`
* `--enable-post-features` — Exposes the api/client/features endpoint for POST requests. This may be removed in a future release

Default value: `false`
* `--tls-enable` — Should we bind TLS

Default value: `false`
* `--tls-server-key <TLS_SERVER_KEY>` — Server key to use for TLS
* `--tls-server-cert <TLS_SERVER_CERT>` — Server Cert to use for TLS
* `--tls-server-port <TLS_SERVER_PORT>` — Port to listen for https connection on (will use the interfaces already defined)

Default value: `3043`
* `--instance-id <INSTANCE_ID>` — Instance id. Used for metrics reporting

Default value: `01H25S347DVN3YGHBYTV8GBRFM`
* `-a`, `--app-name <APP_NAME>` — App name. Used for metrics reporting

Default value: `unleash-edge`
* `--markdown-help`



## `unleash-edge edge`

Run in edge mode

**Usage:** `unleash-edge edge [OPTIONS] --upstream-url <UPSTREAM_URL>`

###### **Options:**

* `-u`, `--upstream-url <UPSTREAM_URL>` — Where is your upstream URL. Remember, this is the URL to your instance, without any trailing /api suffix
* `--redis-url <REDIS_URL>`
* `--redis-password <REDIS_PASSWORD>`
* `--redis-username <REDIS_USERNAME>`
* `--redis-port <REDIS_PORT>`
* `--redis-host <REDIS_HOST>`
* `--redis-secure`

Default value: `false`
* `--redis-scheme <REDIS_SCHEME>`

Default value: `redis`

Possible values: `redis`, `rediss`, `redis-unix`, `unix`

* `-b`, `--backup-folder <BACKUP_FOLDER>` — A path to a local folder. Edge will write feature and token data to disk in this folder and read this back after restart. Mutually exclusive with the --redis-url option
* `-m`, `--metrics-interval-seconds <METRICS_INTERVAL_SECONDS>` — How often should we post metrics upstream?

Default value: `60`
* `-f`, `--features-refresh-interval-seconds <FEATURES_REFRESH_INTERVAL_SECONDS>` — How long between each refresh for a token

Default value: `10`
* `--token-revalidation-interval-seconds <TOKEN_REVALIDATION_INTERVAL_SECONDS>` — How long between each revalidation of a token

Default value: `3600`
* `-t`, `--tokens <TOKENS>` — Get data for these client tokens at startup. Hot starts your feature cache
* `-H`, `--custom-client-headers <CUSTOM_CLIENT_HEADERS>` — Expects curl header format (-H <HEADERNAME>: <HEADERVALUE>) for instance `-H X-Api-Key: mysecretapikey`
* `-s`, `--skip-ssl-verification` — If set to true, we will skip SSL verification when connecting to the upstream Unleash server

Default value: `false`
* `--pkcs8-client-certificate-file <PKCS8_CLIENT_CERTIFICATE_FILE>` — Client certificate chain in PEM encoded X509 format with the leaf certificate first. The certificate chain should contain any intermediate certificates that should be sent to clients to allow them to build a chain to a trusted root
* `--pkcs8-client-key-file <PKCS8_CLIENT_KEY_FILE>` — Client key is a PEM encoded PKCS#8 formatted private key for the leaf certificate
* `--pkcs12-identity-file <PKCS12_IDENTITY_FILE>` — Identity file in pkcs12 format. Typically this file has a pfx extension
* `--pkcs12-passphrase <PKCS12_PASSPHRASE>` — Passphrase used to unlock the pkcs12 file
* `--upstream-certificate-file <UPSTREAM_CERTIFICATE_FILE>` — Extra certificate passed to the client for building its trust chain. Needs to be in PEM format (crt or pem extensions usually are)



## `unleash-edge offline`

Run in offline mode

**Usage:** `unleash-edge offline [OPTIONS]`

###### **Options:**

* `-b`, `--bootstrap-file <BOOTSTRAP_FILE>`
* `-t`, `--tokens <TOKENS>`



<hr/>

<small><i>
This document was generated automatically by
<a href="https://crates.io/crates/clap-markdown"><code>clap-markdown</code></a>.
</i></small>

10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ anyhow = "1.0.71"
async-trait = "0.1.68"
chrono = {version = "0.4.24", features = ["serde"]}
clap = {version = "4.2.7", features = ["derive", "env"]}
clap-markdown = "0.1.3"
dashmap = "5.4.0"
dotenv = {version = "0.15.0", features = ["clap"]}
futures = "0.3.28"
Expand Down
2 changes: 1 addition & 1 deletion server/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn build_offline(offline_args: OfflineArgs) -> EdgeResult<CacheContainer> {
}

async fn get_data_source(args: &EdgeArgs) -> Option<Arc<dyn EdgePersistence>> {
if let Some(redis_url) = args.redis_url.clone() {
if let Some(redis_url) = args.redis.clone().and_then(|r| r.to_url()) {
let redis_client = RedisPersister::new(&redis_url).expect("Failed to connect to Redis");
return Some(Arc::new(redis_client));
}
Expand Down
Loading

0 comments on commit 1074674

Please sign in to comment.