Beispiel #1
0
 static Props CreatePropsFor(GrainAndActor grainAndActor, IServiceProvider provider)
 => Props.FromProducer(() => Activator.CreateInstance(
                           grainAndActor.Actor,
                           grainAndActor.IsPerTenant
             ? GetTenantGrainFactory(grainAndActor, provider)
             : GetGrainFactory(grainAndActor, provider)) as IActor)
 .WithTracing()
 .WithClusterRequestDeduplication(TimeSpan.FromSeconds(60)
                                  );
Beispiel #2
0
    static object GetTenantGrainFactory(GrainAndActor grainAndActor, IServiceProvider provider)
    {
        var tenantDelegateType = typeof(Func <, , ,>).MakeGenericType(
            typeof(TenantId),
            typeof(IContext),
            typeof(ClusterIdentity),
            grainAndActor.Grain);
        var resolvedTenantDelegate   = provider.GetRequiredService(tenantDelegateType);
        var contextParameter         = Expression.Parameter(typeof(IContext), "context");
        var clusterIdentityParameter = Expression.Parameter(typeof(ClusterIdentity), "identity");

        return(Expression.Lambda(
                   Expression.Invoke(
                       Expression.Constant(resolvedTenantDelegate),
                       Expression.Invoke(_parseIdentity, clusterIdentityParameter),
                       contextParameter,
                       clusterIdentityParameter
                       ),
                   contextParameter,
                   clusterIdentityParameter
                   ).Compile());
    }
Beispiel #3
0
 static object GetGrainFactory(GrainAndActor grainAndActor, IServiceProvider provider)
 => provider.GetRequiredService(typeof(Func <, ,>).MakeGenericType(
                                    typeof(IContext),
                                    typeof(ClusterIdentity),
                                    grainAndActor.Grain));