public AzureEventStoreClient(AzureStoreConfiguration config, EventStoreId storeId, string serverEndpoint = null) : base(storeId, serverEndpoint) { Config = config; _blob = config.GetPageBlob(storeId.Name + "/stream.dat"); _blob.Container.CreateIfNotExist(); }
protected override object Run(ClientApi.WriteEvent request) { var token = new ManualResetEventSlim(false); var name = EventStoreId.Parse(request.StoreId); _publisher.Publish(new ClientMessage.AppendEvents( name, request.StreamId, request.Data, s => token.Set())); return(Task.Factory.StartNew(() => { try { token.Wait(); return new ClientApi.WriteEventResponse() { Result = "Completed", Success = true }; } finally { token.Dispose(); } })); }
protected override object Run(ClientApi.WriteBatch request) { var token = new ManualResetEventSlim(false); if (request.Length <= 0) { return(Error("WriteBatch request must have length more than 0 bytes")); } var container = EventStoreId.Parse(request.StoreId); _publisher.Publish(new ClientMessage.ImportEvents(container, request.StreamId, request.BatchLocation, request.Length, s => token.Set())); return(Task.Factory.StartNew(() => { try { token.Wait(); return new ClientApi.WriteBatchResponse() { Result = "Completed", Success = true }; } finally { token.Dispose(); } })); }
public FileEventStoreManager(string rootDirectory) { if (null == rootDirectory) { throw new ArgumentNullException("rootDirectory"); } _rootDirectory = rootDirectory; if (!Directory.Exists(rootDirectory)) { Directory.CreateDirectory(rootDirectory); } var info = new DirectoryInfo(rootDirectory); foreach (var child in info.GetDirectories()) { if (EventStoreId.IsValid(child.Name) != EventStoreId.Rule.Valid) { Log.Info("Skipping invalid folder {0} (invalid name)", child.Name); continue; } var container = EventStoreId.Parse(child.Name); if (FileEventStore.ExistsValid(rootDirectory, container)) { var writer = FileEventStore.OpenExistingForWriting(rootDirectory, container); _stores.Add(container.Name, writer); } else { Log.Info("Skipping invalid folder {0} (can't open)", child.Name); } } }
protected JsonEventStoreClientBase(EventStoreId storeId, string uri) { StoreId = storeId; if (!string.IsNullOrWhiteSpace(uri)) { WriteClient = new JsonServiceClient(uri); } }
public static FileEventStore OpenForReading(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); var check = FileEventPointer.OpenOrCreateForReading(Path.Combine(folder, "stream.chk")); var store = FileEventStoreChunk.OpenForReading(Path.Combine(folder, "stream.dat")); return(new FileEventStore(storeId, store, check)); }
public static FileEventStore OpenForReading(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); var check = FileEventPointer.OpenOrCreateForReading(Path.Combine(folder, "stream.chk")); var store = FileEventStoreChunk.OpenForReading(Path.Combine(folder, "stream.dat")); return new FileEventStore(storeId, store, check); }
public static AzureEventStore OpenExistingForReading(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); var check = AzureEventPointer.OpenReadable(blob); blob.FetchAttributes(); var store = AzureEventStoreChunk.OpenExistingForReading(blob, blob.Properties.Length); return new AzureEventStore(container, store, check); }
public AppendEvents(EventStoreId storeId, string streamId, byte[] eventData, Action <AppendEventsCompleted> envelope) { StoreId = storeId; StreamId = streamId; EventData = eventData; Envelope = envelope; }
public AppendEvents(EventStoreId storeId, string streamId, byte[] eventData, Action<AppendEventsCompleted> envelope) { StoreId = storeId; StreamId = streamId; EventData = eventData; Envelope = envelope; }
public static AzureEventStore OpenExistingForWriting(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); var check = AzureEventPointer.OpenWriteable(blob); var offset = check.Read(); var length = blob.Properties.Length; var store = AzureEventStoreChunk.OpenExistingForWriting(blob, offset, length); return new AzureEventStore(container, store, check); }
public ImportEvents(EventStoreId storeId, string streamId, string stagingLocation, long size, Action<ImportEventsCompleted> envelope) { StoreId = storeId; StreamId = streamId; StagingLocation = stagingLocation; Envelope = envelope; Size = size; }
public ImportEvents(EventStoreId storeId, string streamId, string stagingLocation, long size, Action <ImportEventsCompleted> envelope) { StoreId = storeId; StreamId = streamId; StagingLocation = stagingLocation; Envelope = envelope; Size = size; }
public static FileEventStore CreateNew(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); var check = FileEventPointer.OpenOrCreateForWriting((Path.Combine(folder, "stream.chk"))); var store = FileEventStoreChunk.CreateNew(Path.Combine(folder, "stream.dat")); return new FileEventStore(storeId,store,check); }
public static bool ExistsValid(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); if (!Directory.Exists(folder)) return false; var check = Path.Combine(folder, "stream.chk"); var store = Path.Combine(folder, "stream.dat"); return (System.IO.File.Exists(check) && System.IO.File.Exists(store)); }
public void AppendEventsToStore(EventStoreId storeId, string streamId, IEnumerable<byte[]> eventData) { AzureEventStore store; if (!_stores.TryGetValue(storeId.Name, out store)) { store = AzureEventStore.CreateNewForWriting(_config, storeId); _stores.Add(storeId.Name, store); } store.Write(streamId, eventData); }
public static AzureEventStore CreateNewForWriting(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); blob.Container.CreateIfNotExist(); var store = AzureEventStoreChunk.CreateNewForWriting(blob); var check = AzureEventPointer.OpenWriteable(blob); return new AzureEventStore(container, store, check); }
public void AppendEventsToStore(EventStoreId storeId, string streamId, IEnumerable<byte[]> eventData) { FileEventStore value; if (!_stores.TryGetValue(storeId.Name, out value)) { value = FileEventStore.CreateNew(_rootDirectory, storeId); _stores.Add(storeId.Name, value); } value.Write(streamId, eventData); }
public void AppendEventsToStore(EventStoreId storeId, string streamId, IEnumerable <byte[]> eventData) { FileEventStore value; if (!_stores.TryGetValue(storeId.Name, out value)) { value = FileEventStore.CreateNew(_rootDirectory, storeId); _stores.Add(storeId.Name, value); } value.Write(streamId, eventData); }
public FileEventStoreClient(string serverFolder, EventStoreId storeId, string serverEndpoint = null) : base(storeId, serverEndpoint) { // open for reading or new _serverFolder = serverFolder; var path = Path.Combine(Path.GetFullPath(serverFolder ?? ""), storeId.Name); if (!Directory.Exists(path)) Directory.CreateDirectory(path); }
public void AppendEventsToStore(EventStoreId storeId, string streamId, IEnumerable <byte[]> eventData) { AzureEventStore store; if (!_stores.TryGetValue(storeId.Name, out store)) { store = AzureEventStore.CreateNewForWriting(_config, storeId); _stores.Add(storeId.Name, store); } store.Write(streamId, eventData); }
public FileEventStoreClient(string serverFolder, EventStoreId storeId, string serverEndpoint = null) : base(storeId, serverEndpoint) { // open for reading or new _serverFolder = serverFolder; var path = Path.Combine(Path.GetFullPath(serverFolder ?? ""), storeId.Name); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } }
public static bool TryGetContainerName( AzureStoreConfiguration config, CloudBlobDirectory dir, out EventStoreId container) { var topic = dir.Uri.ToString().Remove(0, dir.Container.Uri.ToString().Length).Trim('/'); container = null; if (EventStoreId.IsValid(topic)!= EventStoreId.Rule.Valid) return false; container = EventStoreId.Parse(topic); return IsValid(config, container); }
public static bool ExistsValid(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); if (!Directory.Exists(folder)) { return(false); } var check = Path.Combine(folder, "stream.chk"); var store = Path.Combine(folder, "stream.dat"); return(System.IO.File.Exists(check) && System.IO.File.Exists(store)); }
public static FileEventStore CreateNew(string root, EventStoreId storeId) { var folder = Path.Combine(root, storeId.Name); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var check = FileEventPointer.OpenOrCreateForWriting((Path.Combine(folder, "stream.chk"))); var store = FileEventStoreChunk.CreateNew(Path.Combine(folder, "stream.dat")); return(new FileEventStore(storeId, store, check)); }
public static bool TryGetContainerName ( AzureStoreConfiguration config, CloudBlobDirectory dir, out EventStoreId container) { var topic = dir.Uri.ToString().Remove(0, dir.Container.Uri.ToString().Length).Trim('/'); container = null; if (EventStoreId.IsValid(topic) != EventStoreId.Rule.Valid) { return(false); } container = EventStoreId.Parse(topic); return(IsValid(config, container)); }
public bool Execute(CommandProcessorContext context, CancellationToken token, string[] args) { if (args.Length != 1) { context.Log.Error("Container name expected"); return(false); } var isValid = EventStoreId.IsValid(args[0]); if (isValid != EventStoreId.Rule.Valid) { context.Log.Error("Container name is invalid: {0}", isValid); return(false); } context.Log.Info("Switching to container '{0}'", args[0]); context.Client.UseEventStore(args[0]); return(true); }
public FileEventStore(EventStoreId storeId, FileEventStoreChunk store, FileEventPointer checkpoint) { StoreId = storeId; _store = store; _checkpoint = checkpoint; }
public static bool IsValid(AzureStoreConfiguration config, EventStoreId container) { var store = config.GetPageBlob(container.Name + "/stream.dat"); return Exists(store); }
public AzureEventStore(EventStoreId container, AzureEventStoreChunk store, AzureEventPointer checkpoint) { Container = container; _store = store; _checkpoint = checkpoint; }
public static AzureEventStore OpenExistingForReading(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); var check = AzureEventPointer.OpenReadable(blob); blob.FetchAttributes(); var store = AzureEventStoreChunk.OpenExistingForReading(blob, blob.Properties.Length); return(new AzureEventStore(container, store, check)); }
public static bool IsValid(AzureStoreConfiguration config, EventStoreId container) { var store = config.GetPageBlob(container.Name + "/stream.dat"); return(Exists(store)); }
public static AzureEventStore OpenExistingForWriting(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); var check = AzureEventPointer.OpenWriteable(blob); var offset = check.Read(); var length = blob.Properties.Length; var store = AzureEventStoreChunk.OpenExistingForWriting(blob, offset, length); return(new AzureEventStore(container, store, check)); }
public static AzureEventStore CreateNewForWriting(AzureStoreConfiguration config, EventStoreId container) { var blob = config.GetPageBlob(container.Name + "/stream.dat"); blob.Container.CreateIfNotExist(); var store = AzureEventStoreChunk.CreateNewForWriting(blob); var check = AzureEventPointer.OpenWriteable(blob); return(new AzureEventStore(container, store, check)); }
void Should(EventStoreId.Rule validity, string asdAsd) { Assert.AreEqual(validity, EventStoreId.IsValid(asdAsd), asdAsd); }