Skip to content

Commit cf059eb

Browse files
committed
README information & clean-up
1 parent 7eb8357 commit cf059eb

File tree

4 files changed

+64
-17
lines changed

4 files changed

+64
-17
lines changed

README.md

+59-12
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ For a full list of all available CLI options on Sentry run `--help`:
4949
cargo run -p sentry -- --help
5050
```
5151

52+
Starting the Sentry API in will always run migrations, this will make sure the database is always up to date with the latest migrations, before starting and exposing the web server.
53+
54+
In `development` ( [`ENV` environment variable](#environment-variables) ) it will seed the database as well.
55+
5256
#### Using the `Ethereum Adapter`
5357

54-
The password for the Keystore file can be set using the environment variable `KEYSTORE_PWD`.
58+
The password for the Keystore file can be set using the [environment variable `KEYSTORE_PWD`](#adapter).
5559

5660
- Leader
5761
```bash
@@ -65,27 +69,46 @@ The password for the Keystore file can be set using the environment variable `KE
6569

6670
#### Using the `Dummy Adapter`:
6771

68-
Dummy identities:
72+
**Dummy** identities:
6973

7074
- Leader: `ce07CbB7e054514D590a0262C93070D838bFBA2e`
7175

7276
```bash
73-
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e ./docs/config/dev.toml
77+
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- \
78+
--adapter dummy \
79+
--dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e \
80+
./docs/config/dev.toml
7481
```
7582
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
7683

7784
```bash
78-
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 ./docs/config/dev.toml
85+
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- \
86+
--adapter dummy \
87+
--dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 \
88+
./docs/config/dev.toml
7989
```
8090

8191
For full list, check out (primitives/src/util/tests/prep_db.rs#L29-L43)[./primitives/src/util/tests/prep_db.rs#L29-L43]
8292

8393
#### Environment variables:
8494

85-
- `ENV`: `production` or `development` - pass this env. variable if you want to use the default configuration paths - [`docs/config/dev.toml`](./docs/config/dev.toml) (for development) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for production)
86-
- `PORT`
87-
- `KEYSTORE_PWD`
88-
- `POSTGRES_DB`
95+
- `ENV` - `production` or `development`; *default*: `development` - passing this env. variable will use the default configuration paths - [`docs/config/dev.toml`](./docs/config/dev.toml) (for `development`) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for `production`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). In `development` it will make sure Sentry to seed the database.
96+
- `PORT` - *default*: `8005` - The local port that Sentry API will be accessible at
97+
- `ANALYTICS_RECORDER` - accepts any non-zero value - whether or not to start the `Analytics recorder` that will track analytics stats for payout events (`IMPRESSION` & `CLICK`)
98+
##### Adapter
99+
- `KEYSTORE_PWD` - Password for the `Keystore file`, only available when using `Ethereum Adapter` (`--adapter ethereum`)
100+
101+
##### Redis
102+
- `REDIS_URL` - *default*: `redis://127.0.0.1:6379`
103+
104+
##### Postgres
105+
- `POSTGRES_HOST` - *default*: `localhost`
106+
- `POSTGRES_USER` - *default*: `postgres`
107+
- `POSTGRES_PASSWORD` - *default*: `postgres`
108+
- `POSTGRES_DB` - *default*: `user` name - Database name in Postgres to be used for this instance
109+
- `POSTGRES_PORT` - *default*: `5432`
110+
111+
#####
89112

90113
### Running the Validator Worker
91114

@@ -104,15 +127,23 @@ The password for the Keystore file can be set using the environment variable `KE
104127
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
105128

106129
```bash
107-
cargo run -p validator_worker --adapter ethereum --keystoreFile ./adapter/resources/keystore.json --sentryUrl http://127.0.0.1:8005 ./docs/config/dev.toml
130+
cargo run -p validator_worker
131+
--adapter ethereum
132+
--keystoreFile ./adapter/resources/keystore.json
133+
--sentryUrl http://127.0.0.1:8005
134+
./docs/config/dev.toml
108135
```
109136

110137
- Follower
111138

112139
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Follower** on port `8006`:
113140

114141
```bash
115-
cargo run -p validator_worker --adapter ethereum --keystoreFile ./adapter/resources/keystore.json --sentryUrl http://127.0.0.1:8006 ./docs/config/dev.toml
142+
cargo run -p validator_worker
143+
--adapter ethereum
144+
--keystoreFile ./adapter/resources/keystore.json
145+
--sentryUrl http://127.0.0.1:8006
146+
./docs/config/dev.toml
116147
```
117148

118149
#### Using the `Dummy Adapter`:
@@ -121,17 +152,33 @@ The password for the Keystore file can be set using the environment variable `KE
121152
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
122153

123154
```bash
124-
cargo run -p validator_worker --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e --sentryUrl http://127.0.0.1:8005 ./docs/config/dev.toml
155+
cargo run -p validator_worker
156+
--adapter dummy
157+
--dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e
158+
--sentryUrl http://127.0.0.1:8005
159+
./docs/config/dev.toml
125160
```
126161

127162
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
128163

129164
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Follower** on port `8006`:
130165

131166
```bash
132-
cargo run -p validator_worker --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 --sentryUrl http://127.0.0.1:8006 ./docs/config/dev.toml
167+
cargo run -p validator_worker
168+
--adapter dummy
169+
--dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3
170+
--sentryUrl http://127.0.0.1:8006
171+
./docs/config/dev.toml
133172
```
134173

174+
#### Environment variables:
175+
176+
- `ENV`: `production` or `development` ( *default* ) - passing this env. variable will use the default configuration paths - [`docs/config/dev.toml`](./docs/config/dev.toml) (for `development`) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for `production`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). In `development` it will make sure Sentry to seed the database.
177+
- `PORT` - The local port that Sentry API will accessible at
178+
179+
##### Adapter
180+
- `KEYSTORE_PWD` - Password for the `Keystore file`, only available when using `Ethereum Adapter` (`--adapter ethereum`)
181+
135182
## Development environment
136183

137184
We use [`cargo-make`](https://github.com/sagiegurari/cargo-make#overview) for running automated checks (tests, builds, formatting, code linting, etc.) and building the project locally

sentry/src/db.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ lazy_static! {
3535
}
3636

3737
pub async fn redis_connection() -> Result<MultiplexedConnection, RedisError> {
38-
let client = redis::Client::open(REDIS_URL.as_str()).expect("Wrong redis connection url");
38+
let client = redis::Client::open(REDIS_URL.as_str())?;
3939
let (connection, driver) = client.get_multiplexed_async_connection().await?;
4040
tokio::spawn(driver);
4141
Ok(connection)

sentry/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![deny(clippy::all)]
22
#![deny(rust_2018_idioms)]
33

4-
use clap::{App, Arg};
4+
use clap::{crate_version, App, Arg};
55

66
use adapter::{AdapterTypes, DummyAdapter, EthereumAdapter};
77
use hyper::service::{make_service_fn, service_fn};
@@ -20,7 +20,7 @@ const DEFAULT_PORT: u16 = 8005;
2020
#[tokio::main]
2121
async fn main() -> Result<(), Box<dyn std::error::Error>> {
2222
let cli = App::new("Sentry")
23-
.version("0.1")
23+
.version(crate_version!())
2424
.arg(
2525
Arg::with_name("config")
2626
.help("the config file for the validator worker")

validator_worker/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::convert::TryFrom;
55
use std::error::Error;
66
use std::time::Duration;
77

8-
use clap::{App, Arg};
8+
use clap::{crate_version, App, Arg};
99
use futures::future::{join, join_all};
1010
use tokio::runtime::Runtime;
1111
use tokio::time::{delay_for, timeout};
@@ -29,7 +29,7 @@ struct Args<A: Adapter> {
2929

3030
fn main() -> Result<(), Box<dyn Error>> {
3131
let cli = App::new("Validator worker")
32-
.version("0.1")
32+
.version(crate_version!())
3333
.arg(
3434
Arg::with_name("config")
3535
.help("the config file for the validator worker")

0 commit comments

Comments
 (0)