public Activation_New(Fixture fx, Placement placement) { _fx = fx; _placement = placement; _serializer = fx.Serializer; _scheduler = new GrainTaskScheduler(fx.Scheduler, fx.Exceptions); _runner = new RequestRunner(_scheduler, fx.Exceptions, fx.Requests, true); //default isolation??? _timers = new MockTimerRegistry(_scheduler); _receivers = new StreamReceiverRegistry(_serializer); _storage = fx.Stores.GetStorage(placement); _reminders = fx.Reminders.GetRegistry(placement); Placement = placement; Dispatcher = new ActivationDispatcher(_runner, CreateGrainContext); }
public static async Task <Grain> New(Type concreteType, AbstractKey key, IGrainRuntime grainRuntime, IServiceProvider services, StorageCell storage, FakeSerializer serializer) { var creator = new GrainCreator(grainRuntime, services); var stateType = GetStateType(concreteType); var grain = stateType != null ? creator.CreateGrainInstance(concreteType, key, stateType, new DummyStorageProvider()) //IStorage will be hackily assigned below // new StorageProviderAdaptor(key, store)) : creator.CreateGrainInstance(concreteType, key); if (stateType != null) { var fnStateExtractor = _dStateExtractors.GetOrAdd(concreteType, t => BuildStateExtractor(t)); var fnStorageAssign = _dStorageAssigners.GetOrAdd(concreteType, t => BuildStorageAssigner(t)); var grainState = fnStateExtractor(grain); var bridge = new GrainStorageBridge(storage, serializer, grainState); fnStorageAssign(grain, bridge); await bridge.ReadStateAsync(); } return(grain); }
public GrainStorageBridge(StorageCell storageCell, FakeSerializer serializer, IGrainState state) { StorageCell = storageCell; Serializer = serializer; State = state; }