Skip to content

Commit a6a5d0d

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

File tree

4 files changed

+72
-19
lines changed

4 files changed

+72
-19
lines changed

README.md

+67-14
Original file line numberDiff line numberDiff line change
@@ -49,43 +49,72 @@ 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
58-
POSTGRES_DB="sentry_leader" PORT=8006 cargo run -p sentry -- --adapter ethereum --keystoreFile ./adapter/resources/keystore.json ./docs/config/dev.toml
62+
POSTGRES_DB="sentry_leader" PORT=8006 cargo run -p sentry -- \
63+
--adapter ethereum \
64+
--keystoreFile ./adapter/resources/keystore.json \
65+
./docs/config/dev.toml
5966
```
6067

6168
- Follower
6269
```bash
63-
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- --adapter ethereum --keystoreFile ./adapter/resources/keystore.json ./docs/config/dev.toml
70+
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- \
71+
--adapter ethereum \
72+
--keystoreFile ./adapter/resources/keystore.json
73+
./docs/config/dev.toml
6474
```
6575

6676
#### Using the `Dummy Adapter`:
6777

68-
Dummy identities:
78+
**Dummy** identities:
6979

7080
- Leader: `ce07CbB7e054514D590a0262C93070D838bFBA2e`
7181

7282
```bash
73-
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e ./docs/config/dev.toml
83+
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- \
84+
--adapter dummy \
85+
--dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e \
86+
./docs/config/dev.toml
7487
```
7588
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
7689

7790
```bash
78-
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 ./docs/config/dev.toml
91+
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- \
92+
--adapter dummy \
93+
--dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 \
94+
./docs/config/dev.toml
7995
```
8096

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

8399
#### Environment variables:
84100

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`
101+
- `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.
102+
- `PORT` - *default*: `8005` - The local port that Sentry API will be accessible at
103+
- `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`)
104+
##### Adapter
105+
- `KEYSTORE_PWD` - Password for the `Keystore file`, only available when using `Ethereum Adapter` (`--adapter ethereum`)
106+
107+
##### Redis
108+
- `REDIS_URL` - *default*: `redis://127.0.0.1:6379`
109+
110+
##### Postgres
111+
- `POSTGRES_HOST` - *default*: `localhost`
112+
- `POSTGRES_USER` - *default*: `postgres`
113+
- `POSTGRES_PASSWORD` - *default*: `postgres`
114+
- `POSTGRES_DB` - *default*: `user` name - Database name in Postgres to be used for this instance
115+
- `POSTGRES_PORT` - *default*: `5432`
116+
117+
#####
89118

90119
### Running the Validator Worker
91120

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

106135
```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
136+
cargo run -p validator_worker
137+
--adapter ethereum
138+
--keystoreFile ./adapter/resources/keystore.json
139+
--sentryUrl http://127.0.0.1:8005
140+
./docs/config/dev.toml
108141
```
109142

110143
- Follower
111144

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

114147
```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
148+
cargo run -p validator_worker
149+
--adapter ethereum
150+
--keystoreFile ./adapter/resources/keystore.json
151+
--sentryUrl http://127.0.0.1:8006
152+
./docs/config/dev.toml
116153
```
117154

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

123160
```bash
124-
cargo run -p validator_worker --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e --sentryUrl http://127.0.0.1:8005 ./docs/config/dev.toml
161+
cargo run -p validator_worker
162+
--adapter dummy
163+
--dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e
164+
--sentryUrl http://127.0.0.1:8005
165+
./docs/config/dev.toml
125166
```
126167

127168
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
128169

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

131172
```bash
132-
cargo run -p validator_worker --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 --sentryUrl http://127.0.0.1:8006 ./docs/config/dev.toml
173+
cargo run -p validator_worker
174+
--adapter dummy
175+
--dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3
176+
--sentryUrl http://127.0.0.1:8006
177+
./docs/config/dev.toml
133178
```
134179

180+
#### Environment variables:
181+
182+
- `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.
183+
- `PORT` - The local port that Sentry API will accessible at
184+
185+
##### Adapter
186+
- `KEYSTORE_PWD` - Password for the `Keystore file`, only available when using `Ethereum Adapter` (`--adapter ethereum`)
187+
135188
## Development environment
136189

137190
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)