Skip to content

Commit 9c37e21

Browse files
authored
READMEs updates (#90)
* domain - README update * sentry - README - add file and move text from main README * README - update README and add the additional crates info * adapter - README * .env.dist - update * validator - README * README - update
1 parent a92e638 commit 9c37e21

File tree

6 files changed

+100
-25
lines changed

6 files changed

+100
-25
lines changed

.env.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
DATABASE_URL=postgresql://postgres:docker@localhost:5432/sentry
12
SENTRY_CHANNEL_LIST_LIMIT=200
23

3-
VALIDATOR_TICKS_WAIT_TIME=500
4+
VALIDATOR_TICKS_WAIT_TIME=500
5+
VALIDATOR_SENTRY_URL=http://localhost:8005
6+
VALIDATOR_VALIDATION_TICK_TIMEOUT=5000

README.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Components:
88

99
* Domain crate
1010
* Sentry - check the list of [opened issues](https://github.com/AdExNetwork/adex-validator-stack-rust/issues?q=is:open is:issue project:AdExNetwork/adex-validator-stack-rust/1)
11-
* Validator worker - TODO
11+
* Validator worker - The validator worker(`Leader` or `Follower`) that validates/proposes new states.
12+
* memory-repository - Generic helper crate for creating InMemory repositories for testing.
13+
* adapter - Adapter trait for `sign`, `verify` and `validate_channel` with Dummy implementation for testing.
14+
15+
**Note:** Please refer to the README.md of the component for a more detailed overview of it.
1216

1317
## Domain
1418
Contains all the Domain `Aggregates`, `Entities`, `Value Objects`, interfaces (traits) and `Domain Error`.
@@ -18,23 +22,19 @@ All the structs have defined (de)serialization. The also have incorporated domai
1822
`TargetingTag.score` (the `Score` struct) should be with a value between `0` and `100`.
1923
This means that once we have a `Score` object, we are guaranteed to have a valid object everywhere.
2024

21-
The `Repository` traits are meant for retrieving the underlying object types, this includes implementations with
22-
Databases (like `Postgres` for `Sentry`), API calls (for the `Validator` to fetch the objects from `Sentry`),
23-
memory (for testing) and etc.
24-
25-
## Sentry: API
26-
27-
#### Do not require authentication, can be cached:
28-
29-
The API documentation can be found on the [adex-validator](https://github.com/AdExNetwork/adex-validator/blob/master/docs/api.md).
30-
Currently implemented endpoints:
25+
The `Repository` traits are meant to help you create the correct abstractions in the underlying application,
26+
as every application has different requirements for the way and things it will fetch.
3127

32-
- POST `/channel` - creates a new channel
33-
- GET `/channel/list` - get a list of all channels
28+
## Sentry & Validator worker
3429

35-
## Validator worker
36-
37-
TODO
30+
Split into 3 layer - Domain, Infrastructure & Application.
31+
- Domain - the domain objects/structs that are defining the business rules and constraints.
32+
- Infrastructure - specific implementations of e.g. Repositories, Logging and etc.
33+
like `Memory__Repository`, `Api__Repository` and so on.
34+
- Application - all the application specific logic, which means services, structs and etc. that use the Domain and it's
35+
traits to achieve the task at hand. For example: In sentry we have the `resource`s, there we define the
36+
`channel_create`. Which handles the request, validates it and uses the `ChannelRepository` trait to
37+
`add` the new Channel and returns the appropriate Response. It is not however limited to Request -> Response.
3838

3939
## Testing setup
4040

@@ -57,10 +57,37 @@ We've setup `rust-toolchain` but you can manually override it as well with `rust
5757

5858
`DATABASE_URL=postgresql://postgres:docker@localhost:5432/sentry cargo run --bin sentry`
5959

60+
### Run Validator Worker
61+
62+
`cargo run --bin validator`
63+
64+
For the available options:
65+
66+
`cargo run --bin validator -- --help`
67+
6068
#### Environment variables:
6169

70+
**NOTE: Currently we use `.env` file to define values for those environment variables.
71+
We need to see if we want configuration files per binary instead.**
72+
73+
##### Sentry:
6274
- `DATABASE_URL` - The url of the Postgres database used for production.
75+
- `SENTRY_CHANNEL_LIST_LIMIT` - the limit per page for listing channels from the `/channel/list` request.
76+
77+
##### Validator:
78+
- `VALIDATOR_TICKS_WAIT_TIME` - The time for a whole cycle(tick) of the validator worker to get & loop channels,
79+
validate and send statuses and etc.
80+
- `VALIDATOR_SENTRY_URL` - The url of the Sentry API that should be used
81+
- `VALIDATOR_VALIDATION_TICK_TIMEOUT` - The maximum time for validation of a single channel as a `Leader` or `Follower`
82+
83+
## Development environment
84+
85+
We use [cargo-make](https://github.com/sagiegurari/cargo-make) for running the checks and build project locally
86+
as well as on CI. For a complete list of out-of-the-box commands you can check
87+
[Makefile.stable.toml](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/Makefile.stable.toml).
6388

64-
**NOTE: For development & testing purposes we use `.env` file to define values for those environment variables.**
89+
Locally it's enough to ensure that `cargo make` command (it will execute the default dev. command) is passing.
90+
It will run `rustfmt` for you, it will fail on `clippy` warnings and it will run all the tests.
6591

66-
- `CHANNEL_LIST_LIMIT` - the limit per page for listing channels from the `/channel/list` request.
92+
You can related to the [Makefile.stable.toml](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/Makefile.stable.toml)
93+
for more commands and cargo-make as a whole.

adapter/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Adapter crate
2+
3+
Adapter trait and a DummyAdapter implementation for testing.
4+
It is checking the "sanity" of a channel by checking some rules we have in order for a Channel to
5+
be valid (`validate_channel()`).
6+
The Adapter can also `sign()` and `validate()` `StateRoot`s and can provide the Authentication by which
7+
it can be recognized.
8+
9+
## Features
10+
11+
### DummyAdapter (`dummy-adapter`)
12+
13+
When you enable this feature you get an access to the DummyAdapter implementation, which you can use for testing.

domain/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# `Domain` crate for validator/sentry stack
22

33
This crate is meant to hold all Domain structures required for both the Validator and Sentry.
4-
It defines all the structs(Entities, Value Objects and etc.) and Repository traits and Domain errors.
4+
It defines all the structs(Entities, Value Objects and etc.), Domain errors and the generic Repository
5+
types and Errors.
56
It also defines the serialization and deserialization of them.
6-
The actual implementations of Repositories is left to the underlying usage, whether it is
7-
using Postgres, some sort of Memory implementation and etc.
7+
8+
The Repository traits and the actual implementations of them is left to the underlying usage.
9+
The traits can have different interfaces based on the requirements of the application and can have
10+
different implementation based on the needs, whether this is: Postgres, InMemory, RestAPI and etc. implementations.
811

912
### Features:
1013

1114
#### Repositories
1215

1316
If the usage of this crate, requires not only (de)serialization, but also retrieving or storing
14-
the objects in any way (database, API calls, memory and etc.) you would need this feature, as it defines
15-
the Repository traits that should be implemented, as a common interface, for handling such operations.
17+
the objects in any way (database, API calls, memory and etc.) you would need this feature, to use
18+
the generic types and traits to define the underling Repository interfaces for the domain objects
19+
and implementations.
1620

1721
The trait `RepositoryFuture` with a generic `RepositoryError` is used as the common return type for
1822
repository methods.
@@ -26,7 +30,8 @@ There is also the `domain::test_util` module that gives you some handy functions
2630
for usage in tests:
2731

2832
- `take_one` which gives you a random element from a slice.
29-
33+
- `time::datetime_between`
34+
- `time::past_datetime`
3035

3136
### Utils
3237

sentry/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Sentry RestAPI
2+
3+
## Endpoints:
4+
5+
#### Do not require authentication, can be cached:
6+
7+
The API documentation can be found on the [adex-validator](https://github.com/AdExNetwork/adex-validator/blob/master/docs/api.md).
8+
Currently implemented endpoints:
9+
10+
- POST `/channel` - creates a new channel
11+
- GET `/channel/list` - get a list of all channels

validator/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Validator worker
2+
3+
For more information on the possible options on the binary please run:
4+
5+
`cargo run --bin validator -- --help`
6+
7+
The default mode is running the validator in infinite tick mode, basically constantly waiting and never finishing.
8+
9+
It is possible to run it in single tick mode with the `-s` option
10+
11+
Currently you can run the Validator worker only with DummyAdapter as we do not have any other implementations.
12+
13+
The DummyAdapter requires you to specify the Identity that will be used for the adapter in the form of a string.
14+
You can still pass `-s` for single tick mode.
15+
16+
For tracking issue on the options and the configuration of the validator refer to issue [#68](https://github.com/AdExNetwork/adex-validator-stack-rust/issues/68)

0 commit comments

Comments
 (0)