コード例 #1
0
        protected override void Given()
        {
            _timeProvider = new FakeTimeProvider();
            _mp           = CreateManagedProjection();
            _mp.InitializeNew(
                new ManagedProjection.PersistedState
            {
                Enabled             = false,
                HandlerType         = "JS",
                Query               = "fromAll().when({});",
                Mode                = ProjectionMode.Continuous,
                EmitEnabled         = true,
                CheckpointsDisabled = false,
                Epoch               = -1,
                Version             = -1,
                RunAs               = SerializedRunAs.SerializePrincipal(ProjectionManagementMessage.RunAs.Anonymous),
            },
                null);

            _mp.Handle(new CoreProjectionStatusMessage.Prepared(_projectionId, new ProjectionSourceDefinition()));
            OneWriteCompletes();
            _consumer.HandledMessages.Clear();

            _mp.Handle(new CoreProjectionStatusMessage.Faulted(
                           _projectionId,
                           "test"));

            _updateConfig = CreateConfig();
            try {
                _mp.Handle(_updateConfig);
            } catch (Exception ex) {
                _thrownException = ex;
            }
        }
コード例 #2
0
        private void OnProjectionConfigPut(HttpEntityManager http, UriTemplateMatch match)
        {
            if (_httpForwarder.ForwardRequest(http))
            {
                return;
            }

            var envelope = new SendToHttpEnvelope <ProjectionManagementMessage.Updated>(
                _networkSendQueue, http, DefaultFormatter, OkResponseConfigurator, ErrorsEnvelope(http));

            http.ReadTextRequestAsync(
                (o, s) => {
                var config = http.RequestCodec.From <ProjectionConfigData>(s);
                if (config == null)
                {
                    SendBadRequest(o, "Failed to parse the projection config");
                    return;
                }

                var message = new ProjectionManagementMessage.Command.UpdateConfig(
                    envelope, match.BoundVariables["name"], config.EmitEnabled, config.TrackEmittedStreams,
                    config.CheckpointAfterMs, config.CheckpointHandledThreshold,
                    config.CheckpointUnhandledBytesThreshold, config.PendingEventsThreshold,
                    config.MaxWriteBatchLength, config.MaxAllowedWritesInFlight, GetRunAs(http, match));
                Publish(message);
            }, ex => Log.Debug("Failed to update projection configuration. Error: {e}", ex));
        }