Esempio n. 1
0
        public SampleApp(IPersistence store, string name, bool useSnapshots, bool quiet, bool fast)
        {
            _quiet        = quiet;
            _name         = name;
            _rooms        = 32;
            _storeProfile = new ProfileDecorator(store);

            _streams          = new StreamsFactory(_storeProfile);
            _aggregateFactory = new DefaultAggregateFactory();

            var network = fast
                ? (INetworkSimulator) new NoNetworkLatencySimulator()
                : (INetworkSimulator) new ReliableNetworkSimulator(10, 50);

            _appProjections = new AppProjections(network, quiet);

            _poller = new PollingClient(_storeProfile, 0, _appProjections, this._loggerFactory);

            if (useSnapshots)
            {
                _cloneProfiler = new TaskProfilingInfo("Cloning state");

                var inMemoryPersistence = new InMemoryPersistence(new InMemoryPersistenceOptions
                {
                    CloneFunc = CloneSnapshot
                });
                _snapshotProfile = new ProfileDecorator(inMemoryPersistence);
                _snapshots       = new DefaultSnapshotStore(_snapshotProfile);
            }

            _unboundedOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = DataflowBlockOptions.Unbounded,
                BoundedCapacity        = DataflowBlockOptions.Unbounded,
                EnsureOrdered          = false,
                MaxMessagesPerTask     = DataflowBlockOptions.Unbounded
            };

            _boundedOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount * 8,
                BoundedCapacity        = 500,
                EnsureOrdered          = true
            };


            if (store is MongoPersistence)
            {
                _unboundedOptions.MaxDegreeOfParallelism = Environment.ProcessorCount * 4;
                _unboundedOptions.BoundedCapacity        = 2000;
            }
        }
Esempio n. 2
0
        private TutorialRuntime(IPersistence streamsPersistence, IPersistence snapshotsPersistence)
        {
            StreamsPersistence   = streamsPersistence;
            SnapshotsPersistence = snapshotsPersistence;
            Configure();

            Logger.LogInformation("Runtime Started");

            // configure aggregate factory delegation to DI container
            _aggregateFactory = new AggregateFactory(
                aggregateType => (IAggregate)this._serviceProvider.GetService(aggregateType)
                );

            _streamsFactory = new StreamsFactory(Instrument(streamsPersistence, "streams"));
            _snapshotStore  = new DefaultSnapshotStore(Instrument(snapshotsPersistence, "snapshots"));
        }
        public AppEngine()
        {
            var pathToDb = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "sample.db");

            if (File.Exists(pathToDb))
            {
                File.Delete(pathToDb);
            }

            var options = new SqlitePersistenceOptions(new NStore.Core.Logging.NStoreNullLoggerFactory())
            {
                ConnectionString = $"Data Source={pathToDb}",
                Serializer       = new TypeAsSchemaJsonSerializer()
            };
            var persitence = new SqlitePersistence(options);

            _streams = new StreamsFactory(persitence);

            SQLitePCL.Batteries_V2.Init();

            persitence.InitAsync(CancellationToken.None).GetAwaiter().GetResult();
        }
Esempio n. 4
0
        public DomainRuntime(
            IPersistence persistence,
            IAggregateFactory aggregateFactory,
            ISnapshotStore snapshots,
            ChunkProcessor processor)
        {
            _persistence      = persistence;
            _aggregateFactory = aggregateFactory;
            _snapshots        = snapshots;
            _streamsFactory   = new StreamsFactory(persistence);

            if (processor != null)
            {
                _pollingClient = new PollingClient(
                    persistence,
                    0, // <----- TODO: read from state?
                    new LambdaSubscription(processor),
                    NStoreNullLoggerFactory.Instance
                    );
                _pollingClient.Start();
            }
        }
Esempio n. 5
0
 public Repository(IAggregateFactory factory, IStreamsFactory streams, ISnapshotStore snapshots)
 {
     _factory   = factory;
     _streams   = streams;
     _snapshots = snapshots;
 }
Esempio n. 6
0
 public Repository(IAggregateFactory factory, IStreamsFactory streams)
     : this(factory, streams, (ISnapshotStore)null)
 {
 }
Esempio n. 7
0
 public OptimisticConcurrencyStreamTests()
 {
     _streams = new StreamsFactory(Store);
 }
Esempio n. 8
0
 public ReadOnlyStreamTests()
 {
     _streams = new StreamsFactory(Store);
 }
Esempio n. 9
0
 public StreamTests()
 {
     _streams = new StreamsFactory(Store);
 }
Esempio n. 10
0
 public TplRepository(IAggregateFactory factory, IStreamsFactory streams, ISnapshotStore snapshots) : base(factory, streams, snapshots)
 {
 }
Esempio n. 11
0
 public TplRepository(IAggregateFactory factory, IStreamsFactory streams) : base(factory, streams)
 {
 }
Esempio n. 12
0
 public TwitterViews(IPersistence persistence)
 {
     _streams = new StreamsFactory(persistence);
 }
Esempio n. 13
0
 public Repository(IAggregateFactory factory, IStreamsFactory streams)
     : this(factory, streams, null)
 {
 }