Skip to content

Commit

Permalink
Use GrainId since in v4 that's better
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex McAuliffe authored and Romanx committed Aug 11, 2022
1 parent 07eaf57 commit a39a426
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public AzureBlobGrainStorage(
public async Task ReadStateAsync<T>(string grainType, GrainReference grainId, IGrainState<T> grainState)
{
var blobName = GetBlobName(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainId.GrainId);

if (this.logger.IsEnabled(LogLevel.Trace)) this.logger.LogTrace((int)AzureProviderErrorCode.AzureBlobProvider_Storage_Reading,
"Reading: GrainType={GrainType} Grainid={GrainId} ETag={ETag} from BlobName={BlobName} in Container={ContainerName}",
Expand Down Expand Up @@ -149,7 +149,7 @@ private static string GetBlobName(string grainType, GrainReference grainId)
public async Task WriteStateAsync<T>(string grainType, GrainReference grainId, IGrainState<T> grainState)
{
var blobName = GetBlobName(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainId.GrainId);

try
{
Expand Down Expand Up @@ -195,7 +195,7 @@ public async Task WriteStateAsync<T>(string grainType, GrainReference grainId, I
public async Task ClearStateAsync<T>(string grainType, GrainReference grainId, IGrainState<T> grainState)
{
var blobName = GetBlobName(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainId.GrainId);

try
{
Expand Down Expand Up @@ -248,7 +248,7 @@ await DoOptimisticUpdate(() => blob.DeleteIfExistsAsync(DeleteSnapshotsOption.No

private async Task WriteStateAndCreateContainerIfNotExists<T>(string grainType, GrainReference grainId, IGrainState<T> grainState, BinaryData contents, string mimeType, BlobClient blob)
{
var container = this.blobContainerFactory.BuildContainerClient(grainType, grainId);
var container = this.blobContainerFactory.BuildContainerClient(grainId.GrainId);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public interface IBlobContainerFactory
/// <summary>
/// Build a container for the specific grain type and grain id
/// </summary>
/// <param name="grainType">The grain type</param>
/// <param name="grainId">The grain id</param>
/// <returns>A configured blob client</returns>
public BlobContainerClient BuildContainerClient(string grainType, GrainReference grainId);
public BlobContainerClient BuildContainerClient(GrainId grainId);

/// <summary>
/// Initialize any required dependencies using the provided client and options
Expand Down Expand Up @@ -48,7 +47,7 @@ public DefaultBlobContainerFactory(AzureBlobStorageOptions options)
}

/// <inheritdoc/>
public BlobContainerClient BuildContainerClient(string grainType, GrainReference grainId)
public BlobContainerClient BuildContainerClient(GrainId grainId)
=> _defaultContainer;

/// <inheritdoc/>
Expand Down

0 comments on commit a39a426

Please sign in to comment.