コード例 #1
0
 public void fail_when_trying_to_create_daemon_with_no_tenant_sync()
 {
     Should.Throw <DefaultTenantUsageDisabledException>(() =>
     {
         theStore.BuildProjectionDaemon();
     });
 }
コード例 #2
0
 public IDaemon CreateDaemon(Type loggerType, Type[] viewTypes = null, DaemonSettings settings = null, IProjection[] projections = null)
 {
     return(_store.BuildProjectionDaemon(
                logger: new DaemonLogger(_factory, loggerType),
                viewTypes: viewTypes,
                settings: settings,
                projections: projections
                ));
 }
コード例 #3
0
        public static IDaemon CreateAndStart(IDocumentStore store)
        {
            var daemon = store.BuildProjectionDaemon();

            daemon.StartAll();
            return(daemon);
        }
コード例 #4
0
    public async Task <Unit> Handle(RebuildProjection command, CancellationToken cancellationToken)
    {
        using var daemon = documentStore.BuildProjectionDaemon();
        await daemon.RebuildProjection(command.ViewName, cancellationToken);

        return(Unit.Value);
    }
コード例 #5
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            switch (_store.Options.Events.Daemon.Mode)
            {
            case DaemonMode.Disabled:
                return;

            case DaemonMode.Solo:
                Coordinator = new SoloCoordinator();
                break;

            case DaemonMode.HotCold:
                Coordinator = new HotColdCoordinator(_store, (DaemonSettings)_store.Options.Events.Daemon, _logger);
                break;
            }

            try
            {
                Agent = _store.BuildProjectionDaemon(_logger);
                await Coordinator.Start(Agent, cancellationToken);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Unable to start the asynchronous projection agent");
                throw;
            }
        }
コード例 #6
0
        public static async Task UseAsyncDaemon(IDocumentStore store, CancellationToken cancellation)
        {
            using var daemon = store.BuildProjectionDaemon();

            // Fire up everything!
            await daemon.StartAllShards();


            // or instead, rebuild a single projection
            await daemon.RebuildProjection("a projection name", 5.Minutes(), cancellation);

            // or a single projection by its type
            await daemon.RebuildProjection <TripAggregationWithCustomName>(5.Minutes(), cancellation);

            // Be careful with this. Wait until the async daemon has completely
            // caught up with the currently known high water mark
            await daemon.WaitForNonStaleData(5.Minutes());

            // Start a single projection shard
            await daemon.StartShard("shard name", cancellation);

            // Or change your mind and stop the shard you just started
            await daemon.StopShard("shard name");

            // No, shut them all down!
            await daemon.StopAll();
        }
コード例 #7
0
 public AsyncProjectionsService(IDocumentStore store)
 {
     daemon = store.BuildProjectionDaemon(settings: new DaemonSettings
     {
         LeadingEdgeBuffer = 0.Seconds()
     });
 }
コード例 #8
0
        private IDaemon GetDaemon(ProjectionInput.ProjectionKind inputKind, IDocumentStore store)
        {
            var logger = GetDaemonLogger();

            switch (inputKind)
            {
            case ProjectionInput.ProjectionKind.async:
                return(store.BuildProjectionDaemon(logger: logger));

            case ProjectionInput.ProjectionKind.inline:
                return(store.BuildProjectionDaemon(projections: store.Events.InlineProjections.ToArray(),
                                                   logger: GetDaemonLogger()));

            default:
                throw new ArgumentOutOfRangeException(nameof(inputKind), inputKind, null);
            }
        }
        public async Task <Unit> Handle(RebuildProjection command, CancellationToken cancellationToken)
        {
            Guard.Against.Null(command, nameof(command));

            using (var daemon = documentStore.BuildProjectionDaemon())
            {
                await daemon.RebuildProjection(command.ViewName, cancellationToken);
            }

            return(Unit.Value);
        }
コード例 #10
0
ファイル: RunDaemon.cs プロジェクト: jmaragon/JasperSamples
        protected override bool execute(IDocumentStore store, MartenInput input)
        {
            var daemon = store.BuildProjectionDaemon(logger: new ConsoleDaemonLogger());

            daemon.StartAll();
            input.WriteLine(ConsoleColor.Green, "Daemon started. Press enter to stop.");
            Console.ReadLine();
            daemon.StopAll();
            input.WriteLine(ConsoleColor.DarkCyan, "Daemon stopped");
            return(true);
        }
コード例 #11
0
        private static IDocumentStore SetupMarten()
        {
            IDocumentStore store = DocumentStore.For(_ =>
            {
                _.Connection(
                    "host=10.0.75.2;port=5433;database=daemon;password=postgres;username=postgres;MaxPoolSize=200;ConnectionIdleLifetime=30");
                _.PLV8Enabled = false;
                _.UseDefaultSerialization(EnumStorage.AsInteger, Casing.CamelCase);
                _.DatabaseSchemaName      = "public";
                _.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;
                _.Events.AddEventTypes(new[]
                {
                    typeof(EventType1), typeof(EventType2), typeof(EventType3), typeof(EventType4), typeof(EventType5), typeof(EventType6),
                    typeof(EventType7), typeof(EventType8), typeof(EventType9), typeof(EventType10), typeof(EventType11), typeof(EventType12)
                });
                _.Events.AsyncProjections.Add(new P1());
                _.Events.AsyncProjections.Add(new P2());
                _.Events.AsyncProjections.Add(new P3());
                _.Events.AsyncProjections.Add(new P4());
                _.Events.AsyncProjections.Add(new P5());
                _.Events.AsyncProjections.Add(new P6());
                _.Events.AsyncProjections.Add(new P7());
                _.Events.AsyncProjections.Add(new P8());
                _.Events.AsyncProjections.Add(new P9());
                _.Events.AsyncProjections.Add(new P10());
                _.Events.AsyncProjections.Add(new P11());
                _.Events.AsyncProjections.Add(new P12());
            });

            store.Schema.ApplyAllConfiguredChangesToDatabase();
            store.Schema.AssertDatabaseMatchesConfiguration();

            var daemonSetting = new DaemonSettings {
                LeadingEdgeBuffer = 0.Seconds()
            };

            daemonSetting.ExceptionHandling.OnException(e => true).Retry(3, 3.Seconds());
            daemonSetting.ExceptionHandling.Cooldown = 10.Seconds();

            var daemon = store.BuildProjectionDaemon(settings: daemonSetting);

            daemon.StartAll();

            return(store);
        }
コード例 #12
0
        public async Task <Unit> Handle(RebuildProjection command, CancellationToken cancellationToken)
        {
            Guard.Against.Null(command, nameof(command));

            var viewType = Assembly.GetExecutingAssembly().GetTypes().SingleOrDefault(t => t.Name == command.ViewName);

            using (var daemon = documentStore.BuildProjectionDaemon(
                       new[] { viewType },
                       settings: new DaemonSettings
            {
                LeadingEdgeBuffer = 0.Seconds()
            }))
            {
                await daemon.Rebuild(viewType, cancellationToken);
            }

            return(Unit.Value);
        }
コード例 #13
0
        private static async Task RunTest(IDocumentStore documentStore)
        {
            await documentStore.Advanced.Clean.CompletelyRemoveAllAsync();

            await using (var session = documentStore.OpenSession())
            {
                for (var i = 0; i < 499; i++)
                {
                    var id = Guid.NewGuid();
                    session.Events.StartStream(id, new Bug1995.IssueCreated {
                        Id = id
                    });
                }

                await session.SaveChangesAsync();
            }

            using var daemon = documentStore.BuildProjectionDaemon();
            await daemon.RebuildProjection <Bug1995.IssueAggregate>(default);