Implement PartitionStrategy in Gremlin JavaScript

Viewed 303

I'm developing a multi-tenant service that utilizes a graph database. I want to store multiple tenants in a single cluster to reduce costs. However, I want to ensure that their resources are isolated. I know in Gremlin that one can use the PartitionStrategy to cause traversals to only explore certain subgraphs. I'm using NodeJS and can't seem to find a PartitionStrategy object. Is there a way to implement it or create a custom class that carries out the same functionality? Also, would labeling every node with a :Tenant property suffice?

Thanks!

1 Answers

Until the functionality of TINKERPOP-2054 is implemented it will not be possible to specify TraversalStrategy implementations of any sort with Gremlin in Javascript. It's not an especially hard thing to implement actually...it is mostly implementing the serialization infrastructure to make it all work I think.

You could implement your own paritioning but it would mean that you would have to write your Gremlin in such a way to respect your partitioning semantics. You could add a :Tenant property but you would have to always make sure that your application added it to all the appropriate vertices/edges for a particular tenant and then you would have to ensure that all of your traversals include filters based on that property when you were doing reads. PartitionStrategy abstracts all of those concerns away so that you don't need to muddy up your Gremlin with such worries.

Related