public StreamStoreConfigRepository( IStreamStore streamStore, string streamId = Constants.DefaultStreamName, IConfigurationSettingsHooks messageHooks = null, IChangeWatcher changeWatcher = null) { _streamStore = streamStore; _streamId = streamId; _changeWatcher = changeWatcher; _messageHooks = messageHooks ?? new NoOpHooks(); _changeWatcher = changeWatcher ?? new SubscriptionBasedChangeWatcher(_streamStore, _streamId, _messageHooks); }
/// <summary> /// Adds SQL Stream store backed configuraiton provider /// </summary> /// <param name="builder">The configuration builer that SSS will be aded to </param> /// <param name="streamStoreFactory">Builds the stream store implementation</param> /// <param name="subscribeToChanges">Should we subscribe to changes?</param> /// <param name="errorHandler">What to do if database is not available. </param> /// <param name="messageHooks">Message hooks that help you to implement encryption</param> /// <returns></returns> public static IConfigurationBuilder AddStreamStore(this IConfigurationBuilder builder, BuildStreamStoreFromConfig streamStoreFactory, bool subscribeToChanges = false, ErrorHandler errorHandler = null, IConfigurationSettingsHooks messageHooks = null) { builder.Add(new StreamStoreConfigurationSource(streamStoreFactory) { SubscribeToChanges = subscribeToChanges, ErrorHandler = errorHandler, MessageHooks = messageHooks }); return(builder); }
/// <summary> /// Builds the configuration settings from the stream message. /// </summary> /// <param name="message"></param> /// <param name="messageHooks"></param> /// <param name="ct"></param> /// <returns></returns> public static async Task <IConfigurationSettings> BuildConfigurationSettingsFromMessage( StreamMessage message, IConfigurationSettingsHooks messageHooks, CancellationToken ct) { var data = messageHooks.OnReadMessage(await message.GetJsonData(ct)); var configChanged = JsonConvert.DeserializeObject <ConfigChanged>(data, messageHooks.JsonSerializerSettings); return(new ConfigurationSettings( message.StreamVersion, message.CreatedUtc, configChanged.AllSettings, configChanged.ModifiedSettings, configChanged.DeletedSettings)); }
public SubscriptionBasedChangeWatcher(IStreamStore streamStore, StreamId streamId, IConfigurationSettingsHooks messageHooks) { _streamStore = streamStore; _streamId = streamId; _messageHooks = messageHooks; }