/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. */ default EventSubscription fromSubscriptionHandler(final EventSubscriptionHandler<T> handler) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(256)); }
public static <TEvent> Operation<Object, Object, TEvent> constructorOf( final ConstructorHandler<TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
/** * Creates an update operation, requiring an existing aggregate. * * @param handler The handler to invoke with the current state to apply updates. * @return An operation representing the supplied logic, with metadata. */ public static <TState, TEvent> Operation<TState, Object, TEvent> updateOf( final UpdateHandlerSingle<TState, TEvent> handler) { return updateOf(handler, false); }
private void assertMerge( final ExpectedVersion first, final ExpectedVersion second, final ExpectedVersion expected) { assertEqual(first + " merged with " + second, expected, merge(first, second)); assertEqual(second + " merged with " + first, expected, merge(second, first)); }
/** * Reads all events for a given stream id from the beginning. * * @param streamId The id of the stream to read events for. * @return A result record describing the outcome of the read and the events themselves, or null * if no stream was found. */ default EventReadResult<T> read(final String streamId) { return read(streamId, 0); }
public SubscriptionWorkerConfig withBatchSize(final int batchSize) { return new SubscriptionWorkerConfig( batchSize, this.initialRetryDelayMillis, this.maxRetryDelayMillis); }
/** * Reads from the stream of all events kept in the event repository. * * @return A result record describing the outcome of the read and the events themselves, or null * if no events exist in this repository. */ default EventReadResult<T> readAll() { return readAll(0); }
public static ExpectedVersion notCreated() { return new ExpectedVersion( ExpectedVersionType.NOT_CREATED, Aggregate.VERSION_NOT_CREATED); }
@Override public ImmutableAggregate<TState, TEvent> toImmutable() { return new DefaultImmutableAggregate<>( projection, id, sourceVersion, state, appliedEvents); }
public static <TEvent> Operation<Object, Object, TEvent> constructorOf( final ConstructorHandlerSingle<TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. */ default EventSubscription fromSubscriptionHandler(final EventSubscriptionHandler<T> handler) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(256)); }
/** * Creates an update operation, requiring an existing aggregate. * * @param handler The handler to invoke with the current state to apply updates. * @return An operation representing the supplied logic, with metadata. */ public static <TState, TEvent> Operation<TState, Object, TEvent> updateOf( final UpdateHandlerAggregate<TState, TEvent> handler) { return updateOf(handler, false); }
public static <TParams, TEvent> Operation<Object, TParams, TEvent> constructorOf( final ParameterizedConstructorHandlerSingle<TParams, TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
/** * Creates an update operation, requiring an existing aggregate. * * @param handler The handler to invoke with the current state to apply updates. * @return An operation representing the supplied logic, with metadata. */ public static <TState, TParams, TEvent> Operation<TState, TParams, TEvent> updateOf( final ParameterizedUpdateHandler<TState, TParams, TEvent> handler) { return updateOf(handler, false); }
public static <TParams, TEvent> Operation<Object, TParams, TEvent> constructorOf( final ParameterizedConstructorHandler<TParams, TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
/** * Creates an update operation, requiring an existing aggregate. * * @param handler The handler to invoke with the current state to apply updates. * @return An operation representing the supplied logic, with metadata. */ public static <TState, TParams, TEvent> Operation<TState, TParams, TEvent> updateOf( final ParameterizedPojoUpdateHandler<TState, TParams, TEvent> handler) { return updateOf(handler, false); }
public static <TEvent> Operation<Object, Object, TEvent> constructorOf( final ConstructorHandlerSingle<TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
public static <TParams, TEvent> Operation<Object, TParams, TEvent> constructorOf( final ParameterizedConstructorHandler<TParams, TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
public static <TParams, TEvent> Operation<Object, TParams, TEvent> constructorOf( final ParameterizedConstructorHandlerSingle<TParams, TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }
public static <TEvent> Operation<Object, Object, TEvent> constructorOf( final ConstructorHandler<TEvent> handler) { return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated()); }