You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if Orleans would entertain the idea of adding a new overload to IPartitionKeyProvider to enable generating the PartitionKey from something other than the GrainId.
For example, in \src\Azure\Orleans.Persistence.Cosmos\IPartitionKeyProvider.cs:
namespaceOrleans.Persistence.Cosmos;/// <summary>/// Creates a partition key for the provided grain./// </summary>publicinterfaceIPartitionKeyProvider{/// <summary>/// Creates a partition key for the provided grain./// </summary>/// <param name="grainType">The grain type.</param>/// <param name="grainId">The grain identifier.</param>/// <returns>The partition key.</returns>ValueTask<string>GetPartitionKey(stringgrainType,GrainIdgrainId);// ↓ Add this overload. ↓/// <summary>/// Creates a partition key for the provided grain using a generic type./// </summary>/// <typeparam name="T">The type of the object to use to derive the partition key.</typeparam>/// <param name="grainType">The grain type.</param>/// <param name="obj">The object to use to derive the partition key.</param>/// <returns>The partition key.</returns>ValueTask<string>GetPartitionKey<T>(stringgrainType,Tobj)=>new(CosmosIdSanitizer.Sanitize(grainType));}internalclassDefaultPartitionKeyProvider:IPartitionKeyProvider{publicValueTask<string>GetPartitionKey(stringgrainType,GrainIdgrainId)=>new(CosmosIdSanitizer.Sanitize(grainType));}
Here's my use case:
I'm writing a version control system, and in Cosmos DB, I'd like to group all of the metadata for a repository (branches, references, directory versions, etc.) in the same Partition. This will enable me to include WHERE c.partitionKey = @repositoryId when I'm running queries, which will
tell Cosmos DB to only run the query against that partition, saving me time and money (in the form of fewer Request Units).
Without this change, the GrainId is too granular as a PartitionKey, and all of my queries would be cross-partition, which would take longer and cost me more.
I'm happy to send a PR, of course, but wanted to discuss this as an approach before doing anything rash. 😉
Thanks!
The text was updated successfully, but these errors were encountered:
Hi!
I was wondering if Orleans would entertain the idea of adding a new overload to
IPartitionKeyProvider
to enable generating the PartitionKey from something other than the GrainId.For example, in
\src\Azure\Orleans.Persistence.Cosmos\IPartitionKeyProvider.cs
:Here's my use case:
I'm writing a version control system, and in Cosmos DB, I'd like to group all of the metadata for a repository (branches, references, directory versions, etc.) in the same Partition. This will enable me to include
WHERE c.partitionKey = @repositoryId
when I'm running queries, which willtell Cosmos DB to only run the query against that partition, saving me time and money (in the form of fewer Request Units).
Without this change, the GrainId is too granular as a PartitionKey, and all of my queries would be cross-partition, which would take longer and cost me more.
I'm happy to send a PR, of course, but wanted to discuss this as an approach before doing anything rash. 😉
Thanks!
The text was updated successfully, but these errors were encountered: