Skip to content

Commit

Permalink
feat: add Neo4j image (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Gerrit Meier <meistermeier@gmail.com>
  • Loading branch information
knutwalker and meistermeier authored Nov 23, 2023
1 parent eb134a1 commit c049d14
Show file tree
Hide file tree
Showing 4 changed files with 511 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kafka = []
minio = []
mongo = []
mysql = []
neo4j = []
orientdb = []
parity = []
postgres = []
Expand All @@ -44,6 +45,7 @@ futures = "0.3"
lapin = "2.3.1"
mongodb = "2.6.1"
mysql = "24.0.0"
neo4rs = "0.6.2"
orientdb-client = "0.6"
postgres = "0.19.7"
pretty_env_logger = "0.5.0"
Expand All @@ -58,3 +60,7 @@ zookeeper = "0.8"
[[example]]
name = "postgres"
required-features = ["postgres"]

[[example]]
name = "neo4j"
required-features = ["neo4j"]
34 changes: 34 additions & 0 deletions examples/neo4j.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use testcontainers_modules::{neo4j::Neo4j, testcontainers::clients::Cli};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
let docker = Cli::default();
let container = docker.run(Neo4j::default());

// prepare neo4rs client
let config = neo4rs::ConfigBuilder::new()
.uri(format!(
"bolt://localhost:{}",
container.image().bolt_port_ipv4()
))
.user(container.image().user().expect("default user is set"))
.password(
container
.image()
.password()
.expect("default password is set"),
)
.build()?;

// connect ot Neo4j
let graph = neo4rs::Graph::connect(config).await?;

// run a test query
let mut rows = graph.execute(neo4rs::query("RETURN 1 + 1")).await?;
while let Some(row) = rows.next().await? {
let result: i64 = row.get("1 + 1").unwrap();
assert_eq!(result, 2);
}

Ok(())
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub mod mongo;
#[cfg(feature = "mysql")]
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
pub mod mysql;
#[cfg(feature = "neo4j")]
#[cfg_attr(docsrs, doc(cfg(feature = "neo4j")))]
pub mod neo4j;
#[cfg(feature = "orientdb")]
#[cfg_attr(docsrs, doc(cfg(feature = "orientdb")))]
pub mod orientdb;
Expand Down
Loading

0 comments on commit c049d14

Please sign in to comment.