public TransactionalState( ITransactionalStateConfiguration transactionalStateConfiguration, IGrainActivationContext context, ITransactionDataCopier <TState> copier, IProviderRuntime runtime, IGrainRuntime grainRuntime, ILoggerFactory loggerFactory, JsonSerializerSettings serializerSettings ) { this.config = transactionalStateConfiguration; this.context = context; this.copier = copier; this.runtime = runtime; this.grainRuntime = grainRuntime; this.loggerFactory = loggerFactory; this.serializerSettings = serializerSettings; this.copiers = new Dictionary <Type, object>(); this.copiers.Add(typeof(TState), copier); }
public Grain CreateGrainInstance(IGrainActivationContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var grain = (Grain)_activator.Create(context); var participant = grain as ILifecycleParticipant <IGrainLifecycle>; participant?.Participate(context.ObservableLifecycle); //Set the runtime and identity. This is equivalent to what Orleans' GrainCreator does //when creating new grains. It is messier but easier than trying to wrangle the values //in via a constructor which may or may exist on types inheriting from Grain. _runtimeProperty.SetValue(grain, _runtime); _identityField.SetValue(grain, context.GrainIdentity); return(grain); }
/// <inheritdoc /> public virtual object Create(IGrainActivationContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var grainType = context.GrainType; if (grainType == null) { throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "The '{0}' property of '{1}' must not be null.", nameof(context.GrainType), nameof(IGrainActivationContext))); } var serviceProvider = context.ActivationServices; var activator = this.typeActivatorCache.GetOrAdd(grainType, this.CreateFactory); var grain = activator(serviceProvider, this.argumentFactory.CreateArguments(context)); return(grain); }
public TransactionManagerExtension(IGrainActivationContext context) { this.factories = context.GetResourceFactoryRegistry <ITransactionManager>(); this.managers = new Dictionary <string, ITransactionManager>(); }
private static void SetGrainActivationContextInScopedServices(IServiceProvider sp, IGrainActivationContext context) { var contextFactory = sp.GetRequiredService <GrainActivationContextFactory>(); contextFactory.Context = context; }
public static void RegisterResourceFactory <T>(this IGrainActivationContext context, string name, Func <T> factory) { ResourceFactoryRegistry <T> registry = context.GetResourceFactoryRegistry <T>(true); registry[name] = factory; }
public NamedTransactionalStateStorageFactory(IGrainActivationContext context) { this.context = context; }
public NamedTransactionalStateStorageFactory(IGrainActivationContext context, ILoggerFactory loggerFactory) { this.context = context; this.loggerFactory = loggerFactory; }
public GrainWithSimpleService(IGrainActivationContext context, ISimpleGrainServiceClient client) { SimpleGrainServiceClient = client; }
private object Create(IGrainActivationContext context, MethodInfo genericCreate, object[] args) { IFaultInjectionTransactionalStateFactory factory = context.ActivationServices.GetRequiredService <IFaultInjectionTransactionalStateFactory>(); return(genericCreate.Invoke(factory, args)); }
public FaultInjectionTransactionalStateFactory(IGrainActivationContext context, ITypeResolver typeResolver, IGrainFactory grainFactory) { this.context = context; this.serializerSettings = TransactionalStateFactory.GetJsonSerializerSettings(typeResolver, grainFactory); }
public TransactionCommitterFactory(IGrainActivationContext context) { this.context = context; }
public ActivationLifetime(IGrainActivationContext activationContext) { activationContext.ObservableLifecycle.Subscribe(GrainLifecycleStage.First, this); activationContext.ObservableLifecycle.Subscribe(GrainLifecycleStage.Last, this); }
public SagaGrain(IGrainActivationContext grainContext, IServiceProvider serviceProvider, ILogger <SagaGrain> logger) { this.grainContext = grainContext; this.serviceProvider = serviceProvider; this.logger = logger; }
public GrainControlExtension(IGrainActivationContext context, IGrainRuntime runtime) { _context = context ?? throw new ArgumentNullException(nameof(context)); _runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); }
public PersistentStateBridge(string fullStateName, IGrainActivationContext context, IGrainStorage storageProvider) { this.fullStateName = fullStateName; this.context = context; this.storageProvider = storageProvider; }
public BlobExampleStorageFactory(IGrainActivationContext context) { this.context = context; }
public override Task Execute(Guid sagaId, IGrainFactory grainFactory, IGrainActivationContext grainContext) { throw new NotImplementedException(); }
public void Release(IGrainActivationContext context, object grain) { this.grainActivator.Release(context, grain); }
public TransactionalStateStorageProviderWrapper(IStorageProvider storageProvider, IGrainActivationContext context) { this.storageProvider = storageProvider; this.context = context; this.stateStorages = new ConcurrentDictionary <string, IStorage <TransactionalStateRecord <TState> > >(); }
public SagaGrain(IGrainActivationContext grainContext, ILogger <SagaGrain> logger) { this.grainContext = grainContext; this.logger = logger; }
public override Task Compensate(Guid sagaId, IGrainFactory grainFactory, IGrainActivationContext grainContext) { return(Task.CompletedTask); }
public ITransactionalStateStorage <TState> Create <TState>(string stateName, IGrainActivationContext context) where TState : class, new() { return(ActivatorUtilities.CreateInstance <MongoDBTransactionalStateStorage <TState> >( context.ActivationServices, this.db.GetCollection <BsonDocument>("tsr_" + stateName), jsonSettings)); }
public override Task Execute(Guid sagaId, IGrainFactory grainFactory, IGrainActivationContext grainContext) { // comment in to test compensation. //throw new SeatUnavailableException(); return(Task.CompletedTask); }
public ActivationLimit(IGrainActivationContext context, IActivationLimiter limiter) { this.context = context; this.limiter = limiter; }
public IndexedStateFactory(IGrainActivationContext activationContext, ITypeResolver typeResolver, IGrainFactory grainFactory) => this.activationContext = activationContext;
public TransactionalState(ITransactionalStateConfiguration transactionalStateConfiguration, IGrainActivationContext context, ITransactionDataCopier <TState> copier, ITransactionAgent transactionAgent, IProviderRuntime runtime, ILoggerFactory loggerFactory) { this.config = transactionalStateConfiguration; this.context = context; this.copier = copier; this.transactionAgent = transactionAgent; this.runtime = runtime; this.logger = loggerFactory.CreateLogger($"{this.GetType().FullName}.{this.context.GrainIdentity}.{this.config.StateName}"); this.transactionCopy = new Dictionary <long, TState>(); this.storageExecutor = new AsyncSerialExecutor <bool>(); this.log = new SortedDictionary <long, LogRecord <TState> >(); }
public ITransactionalStateStorage <TState> Create <TState>(string stateName, IGrainActivationContext context) where TState : class, new() { string partitionKey = MakePartitionKey(context, stateName); return(ActivatorUtilities.CreateInstance <AzureTableTransactionalStateStorage <TState> >(context.ActivationServices, this.table, partitionKey, stateName, this.jsonSettings)); }
private object Create(IGrainActivationContext context, MethodInfo genericCreate, object[] args) { INamedExampleStorageFactory factory = context.ActivationServices.GetRequiredService <INamedExampleStorageFactory>(); return(genericCreate.Invoke(factory, args)); }
protected virtual string GetFullStateName(IGrainActivationContext context, IPersistentStateConfiguration cfg) { return($"{RuntimeTypeNameFormatter.Format(context.GrainType)}.{cfg.StateName}"); }