protected Engine(Model model, EngineConfiguration config) { _config = config; _synchronizer = _config.CreateSynchronizer(); _authorizer = _config.CreateAuthorizer(); IsolatedReturnTypes.AddRange(_config.IsolatedTypes); _config.Isolation.Commands.SetFormatter(_config.CreateFormatter(FormatterUsage.Messages)); _config.Isolation.ReturnValues.SetFormatter(_config.CreateFormatter(FormatterUsage.Results)); Configure(model); if (_config.SnapshotBehavior == SnapshotBehavior.AfterRestore) { Logger.Info("Starting snaphot job on threadpool"); ThreadPool.QueueUserWorkItem(_ => CreateSnapshot()); //Give the snapshot thread a chance to start and aquire the readlock Thread.Sleep(TimeSpan.FromMilliseconds(10)); } if (_config.PersistenceMode == PersistenceMode.SnapshotPerTransaction) { CommandExecuted += (s, e) => CreateSnapshot(); } model.Starting(this); Core.Config.Engines.AddEngine(config.JournalPath, this); }
public StreamJournalWriter(EngineConfiguration config, Func <ulong, Stream> streamFactory) { _streamProvider = streamFactory; _journalFormatter = config.CreateFormatter(FormatterUsage.Journal); _rolloverStrategy = config.CreateRolloverStrategy(); }
public RoyalFoodTaster(EngineConfiguration config, Model model) : base(config, model) { _formatter = config.CreateFormatter(FormatterUsage.Snapshot); _foodTaster = _formatter.Clone(_model); }
/// <summary> /// Serialize the current model to a stream /// </summary> /// <param name="stream">A writeable stream</param> /// <param name="formatter">A specific formatter, otherwise the default formatter</param> public void WriteSnapshotToStream(Stream stream, IFormatter formatter = null) { formatter = formatter ?? _config.CreateFormatter(FormatterUsage.Snapshot); _kernel.Read(model => formatter.Serialize(stream, model)); }
protected Kernel(EngineConfiguration config, Model model) { _resultFormatter = config.CreateFormatter(FormatterUsage.Results); _synchronizer = config.CreateSynchronizer(); _model = model; }