Skip to content

Commit

Permalink
Merge branch 'main' into chore/improve-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobressan committed Aug 10, 2023
2 parents b9b249c + cd28f9e commit 6ae4421
Show file tree
Hide file tree
Showing 9 changed files with 387 additions and 31 deletions.
37 changes: 25 additions & 12 deletions Cargo.lock

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

37 changes: 18 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ license = "Apache-2.0"
readme = "README.md"
authors = ["Santiago Carmuega <[email protected]>"]

[features]
default = ["deno"]
deno = ["deno_core", "deno_runtime"]
sink-file-rotate = ["file-rotate"]
sink-webhook = ["reqwest"]
sink-rabbitmq = ["lapin"]
sink-kafka = ["kafka"]
sink-aws-sqs = ["aws-config", "aws-types", "aws-sdk-sqs"]
sink-aws-lambda = ["aws-config", "aws-types", "aws-sdk-lambda"]
sink-aws-s3 = ["aws-config", "aws-types", "aws-sdk-s3"]
sink-gcp-pubsub = ["google-cloud-pubsub", "google-cloud-googleapis", "google-cloud-default"]
sink-gcp-cloudfunction = ["reqwest", "jsonwebtoken"]
sink-redis = ["r2d2_redis"]
sink-elasticsearch = ["elasticsearch"]
source-utxorpc = ["tonic","futures"]

[dependencies]
pallas = "0.19.0-alpha.1"
Expand All @@ -28,11 +43,7 @@ clap = { version = "4.2.7", features = ["derive"] }
env_logger = "0.10.0"
crossterm = "0.26"
merge = "0.1.0"
config = { version = "0.13.2", default-features = false, features = [
"toml",
"yaml",
"json",
] }
config = { version = "0.13.2", default-features = false, features = ["toml","yaml","json"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = { version = "1.0.104", features = ["arbitrary_precision"] }
strum = "0.24"
Expand Down Expand Up @@ -65,18 +76,6 @@ deno_core = { version = "0.188.0", optional = true }
deno_runtime = { version = "0.114.0", optional = true }
jsonwebtoken = { version = "8.3.0", optional = true }
file-rotate = { version = "0.7.5", optional = true }
tonic = { version = "0.9.2", features = ["tls", "tls-roots"], optional = true}
futures = { version = "0.3.28", optional = true }

[features]
default = ["deno"]
deno = ["deno_core", "deno_runtime"]
sink-file-rotate = ["file-rotate"]
sink-webhook = ["reqwest"]
sink-rabbitmq = ["lapin"]
sink-kafka = ["kafka"]
sink-aws-sqs = ["aws-config", "aws-types", "aws-sdk-sqs"]
sink-aws-lambda = ["aws-config", "aws-types", "aws-sdk-lambda"]
sink-aws-s3 = ["aws-config", "aws-types", "aws-sdk-s3"]
sink-gcp-pubsub = ["google-cloud-pubsub", "google-cloud-googleapis", "google-cloud-default"]
sink-gcp-cloudfunction = ["reqwest", "jsonwebtoken"]
sink-redis = ["r2d2_redis"]
sink-elasticsearch = ["elasticsearch"]
31 changes: 31 additions & 0 deletions docs/pages/v2/sources/utxorpc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# UtxoRPC with Dolos

The UtxoRPC with Dolos (UtxoRPC) source uses gRPC to fetch blocks and receive blocks from a no Dolos.

## Configuration

The following snippet shows an example of how to set up a typical UtxoRPC source:

```toml
[source]
type = "UtxoRPC"
url = ["https://<hostname>"]
max_items_per_page = 20
```

### Section `source`:

- `type`: this field must be set to the literal value `UtxoRPC`
- `url`: A string contains Dolos gRPC url
- `max_items_per_page`: Number of blocks that will be requested from Dolos when using a chain distance point. Default value is `20`

## Examples

Connecting to a remote Dolos node in preprod through gRPC:

```toml
[source]
type = "UtxoRPC"
url = ["https://50051-romantic-calmness-b55bqg.us1.demeter.run"]
max_items_per_page = 20
```
9 changes: 9 additions & 0 deletions examples/dolos_source/daemon.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[source]
type = "UtxoRPC"
url = "https://50051-romantic-calmness-b55bqg.us1.demeter.run"

[intersect]
type = "Tip"

[sink]
type = "Stdout"
1 change: 1 addition & 0 deletions examples/n2c_source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node
9 changes: 9 additions & 0 deletions examples/n2c_source/daemon.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[source]
type = "N2C"
socket_path = "examples/n2c_source/node/node.socket"

[intersect]
type = "Tip"

[sink]
type = "Stdout"
20 changes: 20 additions & 0 deletions examples/n2c_source/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"
services:
node:
image: inputoutput/cardano-node
container_name: node
ports:
- 3001:3001
volumes:
- ./node:/data:rw
- ./node:/ipc:rw
environment:
- NETWORK=preprod
- CARDANO_BIND_ADDR=0.0.0.0
- CARDANO_PORT=3001
networks:
- dolos-network

networks:
dolos-network:
driver: bridge
18 changes: 18 additions & 0 deletions src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ pub mod n2n;
#[cfg(feature = "aws")]
pub mod s3;

#[cfg(feature = "source-utxorpc")]
pub mod utxorpc;

pub enum Bootstrapper {
N2N(n2n::Stage),
N2C(n2c::Stage),

#[cfg(feature = "aws")]
S3(s3::Stage),

#[cfg(feature = "source-utxorpc")]
UtxoRPC(utxorpc::Stage),
}

impl StageBootstrapper for Bootstrapper {
Expand All @@ -28,6 +34,9 @@ impl StageBootstrapper for Bootstrapper {

#[cfg(feature = "aws")]
Bootstrapper::S3(p) => p.output.connect(adapter),

#[cfg(feature = "source-utxorpc")]
Bootstrapper::UtxoRPC(p) => p.output.connect(adapter),
}
}

Expand All @@ -42,6 +51,9 @@ impl StageBootstrapper for Bootstrapper {

#[cfg(feature = "aws")]
Bootstrapper::S3(x) => gasket::runtime::spawn_stage(x, policy),

#[cfg(feature = "source-utxorpc")]
Bootstrapper::UtxoRPC(x) => gasket::runtime::spawn_stage(x, policy),
}
}
}
Expand All @@ -56,6 +68,9 @@ pub enum Config {

#[cfg(feature = "aws")]
S3(s3::Config),

#[cfg(feature = "source-utxorpc")]
UtxoRPC(utxorpc::Config),
}

impl Config {
Expand All @@ -66,6 +81,9 @@ impl Config {

#[cfg(feature = "aws")]
Config::S3(c) => Ok(Bootstrapper::S3(c.bootstrapper(ctx)?)),

#[cfg(feature = "source-utxorpc")]
Config::UtxoRPC(c) => Ok(Bootstrapper::UtxoRPC(c.bootstrapper(ctx)?)),
}
}
}
Loading

0 comments on commit 6ae4421

Please sign in to comment.