Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scala with zio #540

Closed
jxnu-liguobin opened this issue Aug 30, 2023 · 4 comments
Closed

Support scala with zio #540

jxnu-liguobin opened this issue Aug 30, 2023 · 4 comments
Labels
type/feature req Type: feature request

Comments

@jxnu-liguobin
Copy link
Contributor

jxnu-liguobin commented Aug 30, 2023

ZIO is a type-safe, composable library for async and concurrent programming in Scala.

This would allow nebula-java to be used directly in an asynchronous, composable way, for example:

object NebulaSessionPoolExampleMain extends ZIOAppDefault {

  override def run = (for {
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |INSERT VERTEX person(name, age) VALUES 
                         |'Bob':('Bob', 10), 
                         |'Lily':('Lily', 9),'Tom':('Tom', 10),
                         |'Jerry':('Jerry', 13),
                         |'John':('John', 11);""".stripMargin).flatMap(r => ZIO.logInfo(r.toString))
           )
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |INSERT EDGE like(likeness) VALUES
                         |'Bob'->'Lily':(80.0),
                         |'Bob'->'Tom':(70.0),
                         |'Lily'->'Jerry':(84.0),
                         |'Tom'->'Jerry':(68.3),
                         |'Bob'->'John':(97.2);""".stripMargin).flatMap(r => ZIO.logInfo(r.toString))
           )
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |USE test;
                         |MATCH (p:person) RETURN p LIMIT 4;
                         |""".stripMargin)
               .flatMap(r => ZIO.logInfo(r.getRows.toString()))
           )
  } yield ())
    .provide(
      Scope.default,
      NebulaSessionPool.layer,
      NebulaConfig.layer,
      NebulaSessionPoolService.layer
    )
}

Anyone can build their own nebula service using just NebulaSessionPool.layer and NebulaConfig.layer.
Using typesafe config and HOCON makes it easier to get the configuration from the configuration center.

I have completed the initial implementation, is it possible to move it to nebula-contrib? I will continue to maintain it in the meantime.

@Nicole00
Copy link
Contributor

Nicole00 commented Sep 6, 2023

ZIO is a type-safe, composable library for async and concurrent programming in Scala.

This would allow nebula-java to be used directly in an asynchronous, composable way, for example:

object NebulaSessionPoolExampleMain extends ZIOAppDefault {

  override def run = (for {
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |INSERT VERTEX person(name, age) VALUES 
                         |'Bob':('Bob', 10), 
                         |'Lily':('Lily', 9),'Tom':('Tom', 10),
                         |'Jerry':('Jerry', 13),
                         |'John':('John', 11);""".stripMargin).flatMap(r => ZIO.logInfo(r.toString))
           )
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |INSERT EDGE like(likeness) VALUES
                         |'Bob'->'Lily':(80.0),
                         |'Bob'->'Tom':(70.0),
                         |'Lily'->'Jerry':(84.0),
                         |'Tom'->'Jerry':(68.3),
                         |'Bob'->'John':(97.2);""".stripMargin).flatMap(r => ZIO.logInfo(r.toString))
           )
    _ <- ZIO.serviceWithZIO[NebulaSessionPoolService](
             _.execute("""
                         |USE test;
                         |MATCH (p:person) RETURN p LIMIT 4;
                         |""".stripMargin)
               .flatMap(r => ZIO.logInfo(r.getRows.toString()))
           )
  } yield ())
    .provide(
      Scope.default,
      NebulaSessionPool.layer,
      NebulaConfig.layer,
      NebulaSessionPoolService.layer
    )
}

Anyone can build their own nebula service using just NebulaSessionPool.layer and NebulaConfig.layer. Using typesafe config and HOCON makes it easier to get the configuration from the configuration center.

I have completed the initial implementation, is it possible to move it to nebula-contrib? I will continue to maintain it in the meantime.

Wow!!! A very novel way to build a nebula service. Of course you can migrate your implementation to nebula-contrib, looking forward to your contribution~ thanks very much.

@jxnu-liguobin
Copy link
Contributor Author

Hey @Nicole00 my repository is here https://github.com/hjfruit/zio-nebula, i'm ready to transfer zio-nebula to nebula-contribat at any time

@wey-gu
Copy link
Contributor

wey-gu commented Sep 6, 2023

This is amazing @jxnu-liguobin ! It's so very lucky to have you(another scala hacker!) in the community :-D.

I loved that logo!!!

cc @QingZ11 could you please help with @jxnu-liguobin 's donation journey?

nebula-contrib/zio-nebula#1 cc @Shinji-IkariG

@Nicole00
Copy link
Contributor

the implementation for scala is here , now close the issue. Thanks @jxnu-liguobin for your contribution~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature req Type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants