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 neo4j driver for jooby #796

Merged
merged 1 commit into from
Jun 23, 2017
Merged

Conversation

sbcd90
Copy link
Contributor

@sbcd90 sbcd90 commented May 25, 2017

This PR is created to propose the addition of neo4j graph database driver for jooby.
The PR contains the implementation of

  • neo4j driver for jooby.
  • neo4j session store for jooby.

The test cases & documentation is also included with this PR.

Copy link
Member

@jknack jknack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. Looks good and made some comments.

@@ -0,0 +1,175 @@
# neo4j driver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to md/doc/neo4j

<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-neo4j</artifactId>
<version>1.1.1</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change 1.1.1 with {{version}}

<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-neo4j</artifactId>
<version>1.1.1</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: {{version}}


@Override
public void configure(Env env, Config config, Binder binder) throws Throwable {
configure(env, config, binder, (remoteClient) -> {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why consumer callback? We don't need it.

Merge the two configure methods


@Override
public Config config() {
return ConfigFactory.parseResources(Neo4j.class, "org.jooby.neo4j/neo4j.conf");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work? It should be: ConfigFactory.parseResources(Neo4j.class, "neo4j.conf");

properties.put(DBProperties.ARRAY_BLOCK_SIZE, config.getString("arrayBlockSize"));
}
properties.put(DBProperties.DATABASE_DIR,
config.hasPath("databaseDir") ? config.getString("databaseDir"): System.getProperty("java.io.tmpdir"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove: System.getProperty("java.io.tmpdir") with config.getString("application.tmpdir")

Properties properties = new Properties();

properties.put(DBProperties.SERVER_ROOT_URI, config.getString("uri"));
if (config.hasPath("arrayBlockSize")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to dump all the properties from config into the properties object. It simplifies the code (no ifs) but also it is more flexible

Config $neo4j = config.getConfig("neo4j");

if (config.hasPath("neo4j." + db)) {
$neo4j = config.getConfig("neo4j." + db);//.withFallback($neo4j);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually fallback to default configuration, why did you comment the fallback?

}

private static Pair<GraphDatabaseService, GraphAwareRuntime> getOrCreateGraph(String databaseDir) {
if (dbService == null && graphRuntime == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel we should export dbService and graphRuntime from Ne4j module. For example who/when all these services go down?
This two services should be exposes by Neo4j and injected at construction time here in Neo4jSessionStore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jknack , The dbService and graphRuntime cannot be exposed from Neo4j module because neo4j module should be used to access a remote neo4j db while the Neo4j session store creates a local neo4j db & tries to access it using the dbService and graphRuntime objects.

The test cases demonstrates how they should be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, but won't be useful too:

  • Add support for local db too Neo4j
  • Add support for remote db to Neo4jSessionStore

We can probably merge this and then add that in a new pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll add support for them in a new PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well kind of, we still need to figure it out how to shutdown the local instance created by Neo4jSessionStore

Copy link
Member

@jknack jknack May 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Something similar to that, but still we need to manage the lifecycle of those objects (like ehcache module does).

Will be nice to have something like:

db = fs

Or local and then if we do:

{
  use(new Neo4j());
}

The module exposes those services...but don't like is that module will exposes completely different services BoltDBAccess vs DbService/GraphRuntime :S

It is probably better to write a LocalNeo4j? or EmbeddedNeo4j module?

and add a note to Ne4jSessioStore that depends on EmbeddedNeo4j module.

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes. Lets first consider the embedded neo4j..I'll change the neo4j module to provide the
dbService & graphRuntime objects.
Plz let me know if you agree..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let;s create a new module: EmbeddedNeo4j and leave the existing Neo4j module as it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok..I'll create a new PR for the EmbeddedNeo4j module & leave this PR untocuhed..is it ok for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, np.

@sbcd90
Copy link
Contributor Author

sbcd90 commented May 25, 2017

Hi @jknack ,

Thanks for your review & comments. I have fixed most of them.
Plz have a look.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.886% when pulling 91c0231 on sbcd90:neo4j_jooby into 48b4ec2 on jooby-project:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.886% when pulling 91c0231 on sbcd90:neo4j_jooby into 48b4ec2 on jooby-project:master.

@jknack
Copy link
Member

jknack commented Jun 2, 2017

I changed the project structure and your pull can't be merge it, sorry for that.

But don't worry going to pick your commit and merge them my self later (unless you want to do it :)

@sbcd90
Copy link
Contributor Author

sbcd90 commented Jun 2, 2017

Hi @jknack ,

I can make the changes myself..however, do you want me to merge my 2 PRs into 1 module?
Plz let me know

@jknack
Copy link
Member

jknack commented Jun 2, 2017

That will be awesome!

@sbcd90
Copy link
Contributor Author

sbcd90 commented Jun 3, 2017

Hi @jknack , I have merged the modules & updated the PR. Please let me know if this PR can be merged now..

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.886% when pulling 5ece745 on sbcd90:neo4j_jooby into 9985a02 on jooby-project:master.

@jknack jknack added this to the 1.2.0 milestone Jun 23, 2017
@jknack jknack merged commit 2da4bbe into jooby-project:master Jun 23, 2017
jknack added a commit that referenced this pull request Jul 3, 2017
jknack added a commit that referenced this pull request Jul 3, 2017
jknack added a commit that referenced this pull request Jul 3, 2017
jknack added a commit that referenced this pull request Jul 3, 2017
jknack added a commit that referenced this pull request Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants