clojurewerkz / ogre

Clojure library for querying Apache TinkerPop graphs
http://ogre.clojurewerkz.org/
128 stars 28 forks source link

The documentation would benefit from an example of connecting to AWS Neptune #109

Closed danielmartincraig closed 3 years ago

danielmartincraig commented 3 years ago

Hi, I've been itching to try this library but I'm hung up on this - could you provide an example of connecting to AWS Neptune?

spmallette commented 3 years ago

I'd say the docs could use an example of how to connect to a remote graph (which is what Neptune is). Right now I'd say that you'd have to do a fair bit of java interop in your clojure to get it to work. That part connecting isn't wrapped inside of Ogre at this point with nice Clojure. Since there is some interest I'll see if I can make some time to look into that for you. At the very least I can post some sample code here on this issue, but perhaps better would be to bring Ogre up to newer versions of TinkerPop and wrapping remoting a bit.

danielmartincraig commented 3 years ago
(let [builder (-> (Cluster/build)
                    (.addContactPoint "endpoint.tld")
                    (.port portnum)
                    (.enableSsl true)
                    (.keyCertChainFile "SFSRootCAG2.pem")
                    )
        cluster (.create builder)
        g       (.withRemote (AnonymousTraversalSource/traversal) (DriverRemoteConnection/using cluster))]
    (ogre/traverse g ogre/V (ogre/count) (ogre/next!))
    )

This is my first effort at the java interop, but I'm kinda new to java interop so I might be wrong here

spmallette commented 3 years ago

yes, that's basically it. Build a DriverRemoteConnection with java interop and then use it to construct g. Note that i just pushed this to master:

https://github.com/clojurewerkz/ogre/commit/04573451a9f4d47c6a18430ea492137613db45c7

Note that we no longer really promote withRemote() in TinkerPop so for 3.4.8.0 I removed it (perhaps that was a bit much...might add that back and deprecate instead) and made it more TinkerPop-like where you can give a Graph or a RemoteConnection to the traversal function.

danielmartincraig commented 3 years ago

Do you think you’d be interested in presenting Ogre to our Dallas-based online Clojure meetup?

danielmartincraig commented 3 years ago

Thanks for adding the documentation on remote connections!

danielmartincraig commented 3 years ago

With the new example on remote connections, I wrote this:

(let [conn (org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection/using "localhost" 8182 "g")
        g (traversal conn)]
    (traverse g V (has :name "josh") (values :age) (into-seq!))
    )

but I got this result: Unhandled java.lang.ClassCastException class org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection cannot be cast to class org.apache.tinkerpop.gremlin.structure.Graph (org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection and org.apache.tinkerpop.gremlin.structure.Graph are in unnamed module of loader 'app')

danielmartincraig commented 3 years ago

When I see this line, https://github.com/clojurewerkz/ogre/blob/master/src/clojure/clojurewerkz/ogre/core.clj#L39 it seems to me that it might benefit from including a case for DriverRemoteConnection, because when I do

  (instance? RemoteConnection DriverRemoteConnection)

I get false

But on second try, I thought to try

(instance? RemoteConnection (org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection/using "localhost" 8182 "g"))

and that gets true so nevermind

danielmartincraig commented 3 years ago

I'm a dummy; you already fixed this issue, and I simply need to update my version 🤦🏻

danielmartincraig commented 3 years ago

Has the latest version been released to Clojars yet?

spmallette commented 3 years ago

Do you think you’d be interested in presenting Ogre to our Dallas-based online Clojure meetup?

I've always wanted to do a talk on Ogre but haven't done so yet. Perhaps something like that would be possible.

Has the latest version been released to Clojars yet?

No, not just yet. I'll post back here when it's available.

spmallette commented 3 years ago

hello - 3.4.8.0 is available in clojars: https://clojars.org/clojurewerkz/ogre/versions/3.4.8.0

as i think the changes added resolve this issue i'll go ahead and close it. as for the speaking opportunity, i see your email address is on github - i can reach out to you there and perhaps go into more details. thanks