nebula4scala is a Scala client for NebulaGraph, designed to provide a type-safe and functional interface for interacting with NebulaGraph databases.
It supports Scala Future, ZIO, and Cats-Effect, making it versatile for various functional programming paradigms.
- Support for Multiple Scala Versions: Compatible with Scala 2.12, Scala 2.13, and Scala 3.
- Functional Programming Support: Integrates seamlessly with Scala
Try
,Future
, ZIO, and Cats-Effect. - Comprehensive Client Support: Provides full support for all NebulaGraph clients, including Session Pool, Connection Pool, Storage, and Meta.
- Type-Safe Configuration: Easily configure clients using pureconfig or zio-config for type-safe configuration management.
- Tagless Support: Provides tagless final style, making it easier to switch between different effect types or implementations without modifying the core logic.
Adding Dependencies
To use nebula4scala in your project, add the following dependencies to your build.sbt
file.
Choose the modules you need based on your project requirements.
For Scala Try and Future Support
// for `scala.concurrent.Future` and `scala.util.Try`
libraryDependencies += "io.github.jxnu-liguobin" %% "nebula4scala-core" % "<latest version>"
For ZIO Support
libraryDependencies += "io.github.jxnu-liguobin" %% "nebula4scala-zio" % "<latest version>"
For Cats-Effect Support
libraryDependencies += "io.github.jxnu-liguobin" %% "nebula4scala-cats-effect" % "<latest version>"
Below is the version correspondence between cats, zio, nebula4scala, and nebula-java:
cats-effect | zio | nebula4scala | nebula-java |
---|---|---|---|
3.5.x | 2.1.x | 0.2.0 | 3.8.4 |
Basic Example with Scala Try and Future
Here is a basic example of how to use nebula4scala with Scala Try and Future:
- Future: NebulaClientExample
- Try: NebulaClientExample
Example with ZIO
Here is an example of how to use nebula4scala with ZIO:
Example with Cats-Effect
Here is an example of how to use nebula4scala with Cats-Effect:
Note that these are not NebulaSessionClient, if you need a NebulaSessionClient, please see other examples.
The NebulaSessionClient
configuration is defined using a HOCON (Human-Optimized Config Object Notation) file.
Below is an example configuration for NebulaSessionClient
:
nebula {
graph {
address = [
{
host = "127.0.0.1",
port = 9669
}
]
auth = {
username = "root"
password = "nebula"
}
spaceName = "test"
reconnect = true
}
}
For the entire structure, see nebula4scala.data.NebulaClientConfig
.
Other configurations:
NebulaSessionClient
Configuration:nebula4scala.data.NebulaClientConfig#graph
.NebulaClient
Configuration:nebula4scala.data.NebulaClientConfig#pool
.NebulaMetaClient
Configuration:nebula4scala.data.NebulaMetaConfig
.NebulaStorageClient
Configuration:nebula4scala.data.NebulaStorageConfig
.
For more detailed examples and additional configurations, please refer to the examples directory in the repository.