Gremlinq / ExRam.Gremlinq

A .NET object-graph-mapper for Apache TinkerPop™ Gremlin enabled databases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A way to dynamically specify partition key within IGremlinQuerySource

mike-kolback opened this issue · comments

Is your feature request related to a problem? Please describe.
We are building an application that requires a certain level of data segregation. For this reason, we plan to utilize Azure Cosmos DB which supports graph partitioning via partition key. Currently, I'm not aware of any way to dynamically change the Parition Key during a request within my Azure Functions App in order to achieve this functionality.

Describe the solution you'd like
A method by which to dynamically adjust the Partition Key within IGremlinQuerySource. If there is a way to do this currently, that would be ideal, but I haven't had any luck.

Not sure I got an idea of what you're trying to achieve....graphs in CosmosDB are not confined to a single partition, vertices can live in different partitions. An edge lives in the same partition as the out-vertex. What is your use case?

Our goal is to scope each partition to a customer. This allows us to properly segregate sensitive customer data all within one Container while taking advantage of a single container's allocated RU's.

The issue is, when we receive a request to our API, we need to dynamically specify the partition key value (Customer ID) provided via the request.

For whenever you have a query starting with V(...) or E(...), have a look at CosmosDbKey which can be passed in. When adding vertices, make sure you have a corresponding partition key on your entities (as shown in the samples).

While I don't have too much experience in scoping partitions to individual customers etc., I would intuitively suggest that you use separate containers. AFAIK they may share RUs as well. Especially when dealing with graph queries, the danger of accidentially crossing partition boundaries is high IMO.

Thanks @danielcweber! I think I'll have to look into this a bit more.