private object CreateDynamicProxy <TActorInterface>(object target, IActorProxy actorProxy) where TActorInterface : IActor { var generator = new ProxyGenerator(new PersistentProxyBuilder()); var selector = new InterceptorSelector(); var actorInterceptor = new ActorInterceptor(PreActorMethod, PostActorMethod); var actorProxyInterceptor = new ActorProxyInterceptor(actorProxy); var options = new ProxyGenerationOptions() { Selector = selector }; var proxy = generator.CreateInterfaceProxyWithTarget(typeof(TActorInterface), new Type[] { typeof(IActorProxy) }, target, options, actorInterceptor, actorProxyInterceptor); return(proxy); }
public ActorProxyInterceptor(IActorProxy actorProxy) { _actorProxy = actorProxy; }
public static async Task AddCertificateOrchestrator( [OrchestrationTrigger] IDurableOrchestrationContext ctx, [OrchestrationClient] IDurableOrchestrationClient starter, [ActorService(Name = "AcmeContext")] IActorProxy actorProxy, ILogger log) { var input = ctx.GetInput <AddCertificateRequest>(); ctx.SetCustomStatus(new { status = "Pending" }); var arcmeId = new EntityId("AcmeContext", input.SignerEmail.ToMD5Hash()); { if (input.Target.Properties is AzureWebAppProperties azurewebapp) { var site = await ctx.CallEntityAsync <SiteInner>(new EntityId("AzureWebsite", input.Target.PropertiesHash), nameof(AzureWebsiteActor.Load), new LoadWebsiteInput { ResourceGroupname = azurewebapp.ResourceGroupName, SiteName = azurewebapp.SiteName, SlotName = azurewebapp.SlotName, SubscriptionId = azurewebapp.SubscriptionId, Domains = input.Domains }); ctx.SetCustomStatus(new { status = "SiteLoaded" }); } } await ctx.CallEntityAsync(arcmeId, nameof(AcmeContextActor.Initialize), new AcmeContextInitializeInput { SignerEmail = input.SignerEmail, LetsEncryptEndpoint = input.LetsEncryptEndpoint }); ctx.SetCustomStatus(new { status = "AcmeInitialized" }); await ctx.CallEntityAsync(arcmeId, nameof(AcmeContextActor.CreateOrder), new OrderInput { Domains = input.Domains, MonitorInstanceId = ctx.InstanceId }); await ctx.WaitForExternalEvent("Completed"); ctx.SetCustomStatus(new { status = "OrderCreated" }); var pfx = await ctx.CallEntityAsync <FinalizeOutput>(arcmeId, nameof(AcmeContextActor.FinalizeOrder), new FinalizeInput { CsrInfo = input.CsrInfo, Domains = input.Domains }); ctx.SetCustomStatus(new { status = "OrderFinalized" }); if (input?.Target.Properties is FileSystemProperties filesystem) { File.WriteAllBytes(filesystem.Path, pfx.Pfx); } { if (input.Target.Properties is AzureWebAppProperties azurewebapp) { await ctx.CallEntityAsync <SiteInner>(new EntityId("AzureWebsite", input.Target.PropertiesHash), nameof(AzureWebsiteActor.UpdateCertificate), new UpdateCertificateInput { Pfx = pfx, Domains = input.Domains, UseIpBasedSsl = azurewebapp.UseIpBasedSsl }); } } ctx.SetCustomStatus(new { status = "CertificateUpdated" }); }
async Task<OperationResult> Process(UseActor msg, IOperationContext context) { _actor = await _actorSystem.GetActor(new ActorKey(msg.ActorName)); return OperationResult.Success; }
async Task <OperationResult> Process(UseActor msg, IOperationContext context) { _actor = await _actorSystem.GetActor(new ActorKey(msg.ActorName)); return(OperationResult.Success); }