示例#1
0
 /// <summary>
 /// First time initialization and reconfig in case of restore
 /// </summary>
 /// <param name="model"></param>
 private void Configure(Model model)
 {
     _commandStore    = _config.CreateCommandStore();
     _snapshotStore   = _config.CreateSnapshotStore();
     _journalAppender = JournalAppender.Create(model.Revision + 1, _commandStore);
     _kernel          = _config.CreateKernel(model);
     _kernel.SetSynchronizer(_synchronizer);
 }
示例#2
0
文件: Engine.cs 项目: quanhb/OrigoDB
        /// <summary>
        /// First time initialization and reconfig in case of restore
        /// </summary>
        /// <param name="model"></param>
        private void Configure(Model model)
        {
            _commandStore    = _config.CreateCommandStore();
            _snapshotStore   = _config.CreateSnapshotStore();
            _journalAppender = JournalAppender.Create(model.Revision + 1, _commandStore);
            _kernel          = _config.CreateKernel(model);
            _kernel.SetSynchronizer(_synchronizer);

            //Capture events emitted during Command.Execute
            model.Events.Subscribe(e => _capturedEvents.Add(e));
        }
示例#3
0
        /// <summary>
        /// Create by writing a ModelCreated entry to the journal
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Engine <TModel> Create <TModel>(EngineConfiguration config = null) where TModel : Model, new()
        {
            config           = config ?? new EngineConfiguration();
            config.ModelType = typeof(TModel);
            var commandStore = config.CreateCommandStore();

            if (!commandStore.IsEmpty)
            {
                throw new InvalidOperationException("Cannot Create(): empty CommandStore required");
            }
            if (!config.CreateSnapshotStore().IsEmpty)
            {
                throw new InvalidOperationException("Can't Create(): empty SnapshotStore required");
            }
            var appender = JournalAppender.Create(0, commandStore);

            appender.AppendModelCreated <TModel>();
            appender.Dispose();
            return(Load <TModel>(config));
        }
示例#4
0
文件: Engine.cs 项目: quanhb/OrigoDB
        /// <summary>
        /// Create by writing a ModelCreated entry to the journal
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Engine <TModel> Create <TModel>(EngineConfiguration config = null) where TModel : Model, new()
        {
            config = config ?? EngineConfiguration.Create();
            if (!config.Location.HasJournal)
            {
                config.Location.SetLocationFromType <TModel>();
            }
            var commandStore = config.CreateCommandStore();

            if (!commandStore.IsEmpty)
            {
                throw new InvalidOperationException("Cannot Create(): empty CommandStore required");
            }
            if (!config.CreateSnapshotStore().IsEmpty)
            {
                throw new InvalidOperationException("Can't Create(): empty SnapshotStore required");
            }
            JournalAppender.Create(0, commandStore).AppendModelCreated <TModel>();
            return(Load <TModel>(config));
        }