Checkpointed stream stored in file system with some specific naming conventions
Inheritance: IDisposable
Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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);
        }