Class ReactivePostgresEventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>

java.lang.Object
fr.maif.eventsourcing.ReactivePostgresEventStore<Tx,E,Meta,Context>
All Implemented Interfaces:
fr.maif.eventsourcing.EventStore<Tx,E,Meta,Context>, Closeable, AutoCloseable

public class ReactivePostgresEventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context> extends Object implements fr.maif.eventsourcing.EventStore<Tx,E,Meta,Context>, Closeable
  • Constructor Details

    • ReactivePostgresEventStore

      public ReactivePostgresEventStore(fr.maif.eventsourcing.EventPublisher<E,Meta,Context> eventPublisher, SimpleDb<Tx> simpleDb, TableNames tableNames, fr.maif.eventsourcing.format.JacksonEventFormat<?,E> eventFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Meta> metaFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Context> contextFormat)
  • Method Details

    • create

      public static <E extends fr.maif.eventsourcing.Event, Meta, Context> ReactivePostgresEventStore<fr.maif.jooq.PgAsyncTransaction,E,Meta,Context> create(fr.maif.eventsourcing.EventPublisher<E,Meta,Context> eventPublisher, fr.maif.jooq.PgAsyncPool pgAsyncPool, TableNames tableNames, fr.maif.eventsourcing.format.JacksonEventFormat<?,E> eventFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Meta> metaFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Context> contextFormat)
    • create

      public static <E extends fr.maif.eventsourcing.Event, Meta, Context> ReactivePostgresEventStore<fr.maif.jooq.reactor.PgAsyncTransaction,E,Meta,Context> create(fr.maif.eventsourcing.EventPublisher<E,Meta,Context> eventPublisher, fr.maif.jooq.reactor.PgAsyncPool pgAsyncPool, TableNames tableNames, fr.maif.eventsourcing.format.JacksonEventFormat<?,E> eventFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Meta> metaFormat, fr.maif.eventsourcing.format.JacksonSimpleFormat<Context> contextFormat)
    • openTransaction

      public CompletionStage<Tx> openTransaction()
      Specified by:
      openTransaction in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • commitOrRollback

      public CompletionStage<io.vavr.Tuple0> commitOrRollback(io.vavr.control.Option<Throwable> mayBeCrash, Tx pgAsyncTransaction)
      Specified by:
      commitOrRollback in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • persist

      public CompletionStage<io.vavr.Tuple0> persist(Tx transactionContext, io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> events)
      Specified by:
      persist in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • lastPublishedSequence

      public CompletionStage<Long> lastPublishedSequence()
      Specified by:
      lastPublishedSequence in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • loadEventsUnpublished

      public org.reactivestreams.Publisher<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> loadEventsUnpublished(Tx transaction, fr.maif.eventsourcing.EventStore.ConcurrentReplayStrategy concurrentReplayStrategy)
      Specified by:
      loadEventsUnpublished in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • loadEventsByQuery

      public org.reactivestreams.Publisher<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> loadEventsByQuery(Tx tx, fr.maif.eventsourcing.EventStore.Query query)
      Specified by:
      loadEventsByQuery in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • loadEventsByQuery

      public org.reactivestreams.Publisher<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> loadEventsByQuery(fr.maif.eventsourcing.EventStore.Query query)
      Specified by:
      loadEventsByQuery in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • nextSequence

      public CompletionStage<Long> nextSequence(Tx tx)
      Specified by:
      nextSequence in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • nextSequences

      public CompletionStage<io.vavr.collection.List<Long>> nextSequences(Tx tx, Integer count)
      Specified by:
      nextSequences in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • publish

      public CompletionStage<io.vavr.Tuple0> publish(io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> events)
      Specified by:
      publish in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • markAsPublished

      public CompletionStage<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> markAsPublished(fr.maif.eventsourcing.EventEnvelope<E,Meta,Context> eventEnvelope)
      Specified by:
      markAsPublished in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • markAsPublished

      public CompletionStage<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> markAsPublished(Tx transaction, fr.maif.eventsourcing.EventEnvelope<E,Meta,Context> eventEnvelope)
      Specified by:
      markAsPublished in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • markAsPublished

      public CompletionStage<io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>>> markAsPublished(Tx transaction, io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> eventEnvelopes)
      Specified by:
      markAsPublished in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • markAsPublished

      public CompletionStage<io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>>> markAsPublished(io.vavr.collection.List<fr.maif.eventsourcing.EventEnvelope<E,Meta,Context>> eventEnvelopes)
      Specified by:
      markAsPublished in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • eventPublisher

      public fr.maif.eventsourcing.EventPublisher<E,Meta,Context> eventPublisher()
      Specified by:
      eventPublisher in interface fr.maif.eventsourcing.EventStore<Tx extends fr.maif.jooq.PgAsyncTransaction,E extends fr.maif.eventsourcing.Event,Meta,Context>