-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More MemoryCache extension work; cleaned up all uses of .CreateActorP…
…roxy; enabled CorrelationId's to show up in Actor OnActivateAsync() by using MemoryCache.
- Loading branch information
1 parent
83567de
commit 51895ed
Showing
35 changed files
with
822 additions
and
856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
namespace Grace.Actors.Extensions | ||
|
||
open Dapr.Actors | ||
open Grace.Actors.Extensions.MemoryCache | ||
open Grace.Actors.Constants | ||
open Grace.Actors.Context | ||
open Grace.Actors.Interfaces | ||
open Grace.Shared.Constants | ||
open Grace.Shared.Types | ||
open System | ||
|
||
module ActorProxy = | ||
|
||
type Dapr.Actors.Client.IActorProxyFactory with | ||
|
||
member this.CreateActorProxyWithCorrelationId<'T when 'T :> IActor> (actorId: ActorId, actorType: string, correlationId: CorrelationId) = | ||
let actorProxy = actorProxyFactory.CreateActorProxy<'T>(actorId, actorType) | ||
memoryCache.CreateCorrelationIdEntry actorId correlationId | ||
actorProxy | ||
|
||
module Branch = | ||
let GetActorId (branchId: BranchId) = ActorId($"{branchId}") | ||
let CreateActorProxy (branchId: BranchId) correlationId = actorProxyFactory.CreateActorProxyWithCorrelationId<IBranchActor>(GetActorId branchId, ActorName.Branch, correlationId) | ||
|
||
module BranchName = | ||
let GetActorId (repositoryId: RepositoryId) (branchName: BranchName) = ActorId($"{branchName}|{repositoryId}") | ||
let CreateActorProxy (repositoryId: RepositoryId) (branchName: BranchName) correlationId = actorProxyFactory.CreateActorProxyWithCorrelationId<IBranchNameActor>(GetActorId repositoryId branchName, ActorName.BranchName, correlationId) | ||
|
||
module Diff = | ||
/// Gets an ActorId for a Diff actor. | ||
let GetActorId (directoryId1: DirectoryVersionId) (directoryId2: DirectoryVersionId) = | ||
if directoryId1 < directoryId2 then | ||
ActorId($"{directoryId1}*{directoryId2}") | ||
else | ||
ActorId($"{directoryId2}*{directoryId1}") | ||
|
||
let CreateActorProxy (directoryId1: DirectoryVersionId) (directoryId2: DirectoryVersionId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IDiffActor>(GetActorId directoryId1 directoryId2, ActorName.Diff, correlationId) | ||
|
||
module DirectoryVersion = | ||
let GetActorId (directoryVersionId: DirectoryVersionId) = ActorId($"{directoryVersionId}") | ||
let CreateActorProxy (directoryVersionId: DirectoryVersionId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IDirectoryVersionActor>(GetActorId directoryVersionId, ActorName.DirectoryVersion, correlationId) | ||
|
||
module Organization = | ||
let GetActorId (organizationId: OrganizationId) = ActorId($"{organizationId}") | ||
let CreateActorProxy (organizationId: OrganizationId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IOrganizationActor>(GetActorId organizationId, ActorName.Organization, correlationId) | ||
|
||
module OrganizationName = | ||
let GetActorId (ownerId: OwnerId) (organizationName: OrganizationName) = ActorId($"{organizationName}|{ownerId}") | ||
let CreateActorProxy (ownerId: OwnerId) (organizationName: OrganizationName) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IOrganizationNameActor>(GetActorId ownerId organizationName, ActorName.OrganizationName, correlationId) | ||
|
||
module Owner = | ||
let GetActorId (ownerId: OwnerId) = ActorId($"{ownerId}") | ||
let CreateActorProxy (ownerId: OwnerId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IOwnerActor>(GetActorId ownerId, ActorName.Owner, correlationId) | ||
|
||
module OwnerName = | ||
let GetActorId (ownerName: OwnerName) = ActorId(ownerName) | ||
let CreateActorProxy (ownerName: OwnerName) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IOwnerNameActor>(GetActorId ownerName, ActorName.OwnerName, correlationId) | ||
|
||
module Reference = | ||
let GetActorId (referenceId: ReferenceId) = ActorId($"{referenceId}") | ||
let CreateActorProxy (referenceId: ReferenceId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IReferenceActor>(GetActorId referenceId, ActorName.Reference, correlationId) | ||
|
||
module Repository = | ||
let GetActorId (repositoryId: RepositoryId) = ActorId($"{repositoryId}") | ||
let CreateActorProxy (repositoryId: RepositoryId) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IRepositoryActor>(GetActorId repositoryId, ActorName.Repository, correlationId) | ||
|
||
module RepositoryName = | ||
let GetActorId (ownerId: OwnerId) (organizationId: OrganizationId) (repositoryName: RepositoryName) = ActorId($"{repositoryName}|{ownerId}|{organizationId}") | ||
let CreateActorProxy (ownerId: OwnerId) (organizationId: OrganizationId) (repositoryName: RepositoryName) correlationId = | ||
actorProxyFactory.CreateActorProxyWithCorrelationId<IRepositoryNameActor>(GetActorId ownerId organizationId repositoryName, ActorName.RepositoryName, correlationId) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Grace.Actors | ||
|
||
open Dapr.Actors.Client | ||
open Grace.Shared.Types | ||
open Microsoft.Azure.Cosmos | ||
open Microsoft.Extensions.Caching.Memory | ||
open Microsoft.Extensions.Logging | ||
open System | ||
|
||
module Context = | ||
|
||
/// Actor proxy factory instance | ||
let mutable internal actorProxyFactory: IActorProxyFactory = null | ||
|
||
/// Setter for actor proxy factory | ||
let setActorProxyFactory proxyFactory = actorProxyFactory <- proxyFactory | ||
|
||
/// Actor state storage provider instance | ||
let mutable internal actorStateStorageProvider: ActorStateStorageProvider = ActorStateStorageProvider.Unknown | ||
|
||
/// Setter for actor state storage provider | ||
let setActorStateStorageProvider storageProvider = actorStateStorageProvider <- storageProvider | ||
|
||
/// Cosmos client instance | ||
let mutable internal cosmosClient: CosmosClient = null | ||
|
||
/// Setter for Cosmos client | ||
let setCosmosClient (client: CosmosClient) = cosmosClient <- client | ||
|
||
/// Cosmos container instance | ||
let mutable internal cosmosContainer: Container = null | ||
|
||
/// Setter for Cosmos container | ||
let setCosmosContainer (container: Container) = cosmosContainer <- container | ||
|
||
/// Host services collection | ||
let mutable internal hostServiceProvider: IServiceProvider = null | ||
|
||
/// Setter for services collection | ||
let setHostServiceProvider (hostServices: IServiceProvider) = hostServiceProvider <- hostServices | ||
|
||
/// Logger factory instance | ||
let mutable internal loggerFactory : ILoggerFactory = null //hostServiceProvider.GetService(typeof<ILoggerFactory>) :?> ILoggerFactory | ||
|
||
/// Setter for logger factory | ||
let setLoggerFactory (factory: ILoggerFactory) = loggerFactory <- factory | ||
|
||
/// Grace Server's universal .NET memory cache | ||
let mutable internal memoryCache: IMemoryCache = null | ||
|
||
/// Setter for memory cache | ||
let setMemoryCache (cache: IMemoryCache) = memoryCache <- cache |
Oops, something went wrong.