public static bool TryGet(int id, out InMemoryDataStore dataStore) { lock (_dataStoreMap) { return(_dataStoreMap.TryGetValue(id, out dataStore)); } }
public InMemoryFabricConnector( InMemoryDataStore dataStore, ISerializer serializer, string serializerFormat) { _dataStore = dataStore; _serializer = serializer; _serializerFormat = serializerFormat; }
public InMemoryFabric(ITransitionRunner transitionRunner, IInMemoryFabricSerializerFactoryAdvisor serializerFactoryAdvisor) { _transitionRunner = transitionRunner; DataStore = InMemoryDataStore.Create(ScheduleMessage); var serializerFactory = serializerFactoryAdvisor.Advise(); _serializationFormat = serializerFactory.Format; Serializer = serializerFactory.Create(); Connector = new InMemoryFabricConnector(DataStore, Serializer, _serializationFormat); }
public Task PublishEventAsync(RaiseEventIntent intent, CancellationToken ct) { var message = new Message { IsEvent = true, [nameof(ServiceId)] = _serializer.SerializeToString(intent.ServiceId), [nameof(EventId)] = _serializer.SerializeToString(intent.EventId), ["Parameters"] = _serializer.SerializeToString(intent.Parameters) }; InMemoryDataStore.BroadcastMessage(message); return(Task.FromResult(0)); }
public static InMemoryDataStore Create(Action <Message> scheduleMessageAction) { var id = Interlocked.Increment(ref _idCounter); var dataStore = new InMemoryDataStore { Id = id, ScheduleMessage = scheduleMessageAction }; lock (_dataStoreMap) { _dataStoreMap.Add(id, dataStore); } return(dataStore); }
public InMemoryFabric(ITransitionRunner transitionRunner, IInMemoryFabricSerializerFactoryAdvisor serializerFactoryAdvisor, IUniqueIdGenerator numericIdGenerator, IServiceProviderScope serviceProviderScope) { _transitionRunner = transitionRunner; _uniqueIdGenerator = numericIdGenerator; _serviceProviderScope = serviceProviderScope; DataStore = InMemoryDataStore.Create(ScheduleMessage); var serializerFactory = serializerFactoryAdvisor.Advise(); _serializationFormat = serializerFactory.Format; Serializer = serializerFactory.Create(); Connector = new InMemoryFabricConnector(DataStore, Serializer, _serializationFormat); }
public IFabricConnector Create(ServiceId serviceId, object configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var config = (InMemoryFabricConnectorConfiguration)configuration; if (!InMemoryDataStore.TryGet(config.DataStoreId, out var dataStore)) { throw new InvalidOperationException($"In-memory data store with ID '{config.DataStoreId}' does not exist."); } var serializerFactory = _serializerFactorySelector.Select(config.SerializerFormat); var serializer = serializerFactory.Create(); return(new InMemoryFabricConnector(dataStore, serializer, config.SerializerFormat)); }