io.vlingo.symbio.store.Result Java Examples

The following examples show how to use io.vlingo.symbio.store.Result. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectEntity.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void persistResultedIn(final Outcome<StorageException, Result> outcome, final Object persistentObject, final int possible, final int actual, final Object supplier) {
  outcome
  .andThen(result -> {
    stateObject((T) persistentObject);
    afterApply();
    completeUsing(supplier);
    disperseStowedMessages();
    return result;
  })
  .otherwise(cause -> {
    disperseStowedMessages();
    final String message = "State not preserved for: " + getClass() + "(" + this.id + ") because: " + cause.result + " with: " + cause.getMessage();
    logger().error(message, cause);
    throw new IllegalStateException(message, cause);
  });
}
 
Example #2
Source File: StateStoreQueryActor.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * FOR INTERNAL USE ONLY.
 */
@Override
@SuppressWarnings("unchecked")
final public <S> void readResultedIn(final Outcome<StorageException, Result> outcome, final String id, final S state, final int stateVersion, final Metadata metadata, final Object object) {
  outcome.andThen(result -> {
    QueryResultHandler.from(object).completeFoundWith(id, state, stateVersion, metadata);
    return result;
  }).otherwise(cause -> {
    if (cause.result.isNotFound()) {
      QueryResultHandler.from(object).completeNotFound();
    } else {
      logger().info("Query state not read for update because: " + cause.getMessage(), cause);
    }
    return cause.result;
  });
}
 
Example #3
Source File: InMemoryObjectStoreDelegate.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public QuerySingleResult queryObject(final QueryExpression expression) {
  final String id;
  if (expression.isListQueryExpression()) {
    id = idParameterAsString(expression.asListQueryExpression().parameters.get(0));
  } else if (expression.isMapQueryExpression()) {
    id = idParameterAsString(expression.asMapQueryExpression().parameters.get("id"));
  } else {
    throw new StorageException(Result.Error, "Unknown query type: " + expression);
  }

  final Map<Long, State<?>> store = stores.computeIfAbsent(expression.type, (type) -> new HashMap<>());
  final State<?> found = (id == null || id.equals("-1")) ? null : store.get(Long.parseLong(id));

  final Object result = Optional
          .ofNullable(found)
          .map(stateAdapterProvider::fromRaw)
          .orElse(null);
  return new QuerySingleResult(result);
}
 
Example #4
Source File: Sourced.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Restore the state of my concrete extender from a possibly snaptshot
 * and stream of events.
 */
@Override
protected final void restore() {
  stowMessages(Stoppable.class);

  journalInfo.journal.streamReader(getClass().getSimpleName())
    .andThenTo(reader -> reader.streamFor(this.streamName))
    .andThenConsume(stream -> {
      restoreSnapshot(stream.snapshot);
      restoreFrom(journalInfo.entryAdapterProvider.asSources(stream.entries), stream.streamVersion);
      disperseStowedMessages();
    })
    .otherwiseConsume(stream -> {
      disperseStowedMessages();
    })
    .recoverFrom(cause -> {
      disperseStowedMessages();
      final String message = "Stream not recovered for: " + type() + "(" + this.streamName + ") because: " + cause.getMessage();
      throw new StorageException(Result.Failure, message, cause);
    });
}
 
Example #5
Source File: InMemoryObjectStoreActor.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public <T extends StateObject, E> void persist(StateSources<T, E> stateSources, Metadata metadata, long updateId, PersistResultInterest interest, Object object) {
  try {
    final T stateObject = stateSources.stateObject();
    final List<Source<E>> sources = stateSources.sources();

    final State<?> raw = storeDelegate.persist(stateObject, updateId, metadata);

    final int entryVersion = (int) stateSources.stateObject().version();
    final List<BaseEntry<?>> entries = entryAdapterProvider.asEntries(sources, entryVersion, metadata);
    final Dispatchable<BaseEntry<?>, State<?>> dispatchable = buildDispatchable(raw, entries);

    this.storeDelegate.persistEntries(entries);
    this.storeDelegate.persistDispatchable(dispatchable);

    dispatch(dispatchable);
    interest.persistResultedIn(Success.of(Result.Success), stateObject, 1, 1, object);
  } catch (StorageException e){
    logger().error("Failed to persist all objects", e);
    interest.persistResultedIn(Failure.of(e), null, 0, 0, object);
  }
}
 
Example #6
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void testThatStateStoreWritesAndReadsObject() {
  final AccessSafely access1 = interest.afterCompleting(2);
  dispatcher.afterCompleting(2);

  final Entity1 entity = new Entity1("123", 5);

  store.write(entity.id, entity, 1, interest);
  store.read(entity.id, Entity1.class, interest);

  assertEquals(1, (int) access1.readFrom("readObjectResultedIn"));
  assertEquals(1, (int) access1.readFrom("writeObjectResultedIn"));
  assertEquals(Result.Success, access1.readFrom("objectReadResult"));
  assertEquals(entity, access1.readFrom("objectState"));

  final Entity1 readEntity = (Entity1) access1.readFrom("objectState");

  assertEquals("123", readEntity.id);
  assertEquals(5, readEntity.value);
}
 
Example #7
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void testThatStateStoreWritesAndReadsMetadataValue() {
  final AccessSafely access1 = interest.afterCompleting(2);
  dispatcher.afterCompleting(2);

  final Entity1 entity = new Entity1("123", 5);
  final Metadata sourceMetadata = Metadata.withValue("value");

  store.write(entity.id, entity, 1, sourceMetadata, interest);
  store.read(entity.id, Entity1.class, interest);

  assertEquals(1, (int) access1.readFrom("readObjectResultedIn"));
  assertEquals(1, (int) access1.readFrom("writeObjectResultedIn"));
  assertEquals(Result.Success, access1.readFrom("objectReadResult"));
  assertEquals(entity, access1.readFrom("objectState"));
  assertNotNull(access1.readFrom("metadataHolder"));
  final Metadata metadata = access1.readFrom("metadataHolder");
  assertTrue(metadata.hasValue());
  assertEquals("value", metadata.value);

  final Entity1 readEntity = (Entity1) access1.readFrom("objectState");

  assertEquals("123", readEntity.id);
  assertEquals(5, readEntity.value);
}
 
Example #8
Source File: StateStoreReader.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Single result collector.
 */
@Override
public <S> void readResultedIn(
        final Outcome<StorageException, Result> outcome,
        final String id,
        final S state,
        final int stateVersion,
        final Metadata metadata,
        final Object object) {
  outcome.andThen(result -> {
    readBundles.add(new TypedStateBundle(id, state, stateVersion, metadata));
    return result;
  })
  .otherwise(cause -> {
    readOutcome.set(outcome);
    success.set(false);
    return cause.result;
  });
}
 
Example #9
Source File: StatefulEntity.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
final public <ST> void readResultedIn(final Outcome<StorageException, Result> outcome, final String id, final ST state, final int stateVersion, final Metadata metadata, final Object object) {
  outcome
    .andThen(result -> {
      state((S) state);
      currentVersion = stateVersion;
      disperseStowedMessages();
      return result;
    })
    .otherwise(cause -> {
      disperseStowedMessages();
      final boolean ignoreNotFound = (boolean) object;
      if (!ignoreNotFound) {
        final String message = "State not restored for: " + getClass() + "(" + id + ") because: " + cause.result + " with: " + cause.getMessage();
        logger().error(message, cause);
        throw new IllegalStateException(message, cause);
      }
      return cause.result;
    });
}
 
Example #10
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void testThatStateStoreWritesAndReadsMetadataOperation() {
  final AccessSafely access1 = interest.afterCompleting(2);
  dispatcher.afterCompleting(2);

  final Entity1 entity = new Entity1("123", 5);
  final Metadata sourceMetadata = Metadata.with("value", "operation");

  store.write(entity.id, entity, 1, sourceMetadata, interest);
  store.read(entity.id, Entity1.class, interest);

  assertEquals(1, (int) access1.readFrom("readObjectResultedIn"));
  assertEquals(1, (int) access1.readFrom("writeObjectResultedIn"));
  assertEquals(Result.Success, access1.readFrom("objectReadResult"));
  assertEquals(entity, access1.readFrom("objectState"));
  final Metadata metadata = access1.readFrom("metadataHolder");
  assertNotNull(metadata);
  assertTrue(metadata.hasOperation());
  assertEquals("operation", metadata.operation);

  final Entity1 readEntity = (Entity1) access1.readFrom("objectState");

  assertEquals("123", readEntity.id);
  assertEquals(5, readEntity.value);
}
 
Example #11
Source File: ObjectEntity.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
final public void queryObjectResultedIn(
        final Outcome<StorageException, Result> outcome,
        final QuerySingleResult queryResult,
        final Object object) {
  outcome
    .andThen(result -> {
      stateObject((T) queryResult.stateObject);
      disperseStowedMessages();
      return result;
    })
    .otherwise(cause -> {
      disperseStowedMessages();
      final boolean ignoreNotFound = (boolean) object;
      if (!ignoreNotFound) {
        final String message = "State not restored for: " + getClass() + "(" + this.id + ") because: " + cause.result + " with: " + cause.getMessage();
        logger().error(message, cause);
        throw new IllegalStateException(message, cause);
      }
      return cause.result;
    });
}
 
Example #12
Source File: InMemoryJournal.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public <S, ST> void appendAllWith(final String streamName, final int fromStreamVersion, final List<Source<S>> sources,
        final Metadata metadata, final ST snapshot, final AppendResultInterest interest, final Object object) {
  final List<Entry<T>> entries = entryAdapterProvider.asEntries(sources, fromStreamVersion, metadata);
  insert(streamName, fromStreamVersion, entries);
  final RS raw;
  final Optional<ST> snapshotResult;
  if (snapshot != null) {
    raw = stateAdapterProvider.asRaw(streamName, snapshot, fromStreamVersion);
    snapshots.put(streamName, raw);
    snapshotResult = Optional.of(snapshot);
  } else {
    raw = null;
    snapshotResult = Optional.empty();
  }

  dispatch(streamName, fromStreamVersion, entries, raw);
  interest.appendAllResultedIn(Success.of(Result.Success), streamName, fromStreamVersion, sources, snapshotResult, object);
}
 
Example #13
Source File: InMemoryJournal.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public <S, ST> void appendWith(final String streamName, final int streamVersion, final Source<S> source, final Metadata metadata, final ST snapshot,
        final AppendResultInterest interest, final Object object) {
  final Entry<T> entry = entryAdapterProvider.asEntry(source, streamVersion, metadata);
  insert(streamName, streamVersion, entry);
  final RS raw;
  final Optional<ST> snapshotResult;
  if (snapshot != null) {
    raw = stateAdapterProvider.asRaw(streamName, snapshot, streamVersion);
    snapshots.put(streamName, raw);
    snapshotResult = Optional.of(snapshot);
  } else {
    raw = null;
    snapshotResult = Optional.empty();
  }

  dispatch(streamName, streamVersion, Collections.singletonList(entry), raw);
  interest.appendResultedIn(Success.of(Result.Success), streamName, streamVersion, source, snapshotResult, object);
}
 
Example #14
Source File: MockResultInterest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public <S> void readResultedIn(final Outcome<StorageException, Result> outcome, final String id, final S state, final int stateVersion, final Metadata metadata, final Object object) {
  outcome
    .andThen(result -> {
      readTextResultedIn.incrementAndGet();
      textReadResult.set(result);
      stateHolder.set(state);
      metadataHolder.set(metadata);
      until.happened();
      return result;
    })
    .otherwise(cause -> {
      readTextResultedIn.incrementAndGet();
      textReadResult.set(cause.result);
      stateHolder.set(state);
      metadataHolder.set(metadata);
      errorCauses.add(cause);
      until.happened();
      return cause.result;
    });
}
 
Example #15
Source File: MockResultInterest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public <S,C> void writeResultedIn(final Outcome<StorageException, Result> outcome, final String id, final S state, final int stateVersion, final List<Source<C>> sources, final Object object) {
  outcome
    .andThen(result -> {
      writeTextResultedIn.incrementAndGet();
      textWriteResult.set(result);
      textWriteAccumulatedResults.add(result);
      stateHolder.set(state);
      until.happened();
      return result;
    })
    .otherwise(cause -> {
      writeTextResultedIn.incrementAndGet();
      textWriteResult.set(cause.result);
      textWriteAccumulatedResults.add(cause.result);
      stateHolder.set(state);
      errorCauses.add(cause);
      until.happened();
      return cause.result;
    });
}
 
Example #16
Source File: MockPersistResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void persistResultedIn(
        final Outcome<StorageException, Result> outcome,
        final Object stateObject,
        final int possible,
        final int actual,
        final Object object) {

  if (actual == 1) {
    access.writeUsing("add", stateObject);
  } else if (actual > 1) {
    access.writeUsing("addAll", stateObject);
  } else {
    throw new IllegalArgumentException("Possible is:" + possible + " Actual is: " + actual);
  }
}
 
Example #17
Source File: StateStoreProjectionActor.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * FOR INTERNAL USE ONLY.
 */
@Override
@SuppressWarnings("unchecked")
final public <S> void readResultedIn(final Outcome<StorageException, Result> outcome, final String id, final S state, final int stateVersion, final Metadata metadata, final Object object) {
  outcome.andThen(result -> {
    ((BiConsumer<S,Integer>) object).accept(state, stateVersion);
    return result;
  }).otherwise(cause -> {
    if (cause.result.isNotFound()) {
      ((BiConsumer<S,Integer>) object).accept(null, -1);
    } else {
      // log but don't retry, allowing re-delivery of Projectable
      logger().info("Query state not read for update because: " + cause.getMessage(), cause);
    }
    return cause.result;
  });
}
 
Example #18
Source File: StateObjectQueryActor.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
@Override
final public void queryObjectResultedIn(
        final Outcome<StorageException, Result> outcome,
        final QuerySingleResult queryResult,
        final Object attempt) {
  outcome
    .andThen(result -> {
      completeUsing(attempt, queryResult.stateObject);
      return result;
    })
    .otherwise(cause -> {
      switch (cause.result) {
      case NotFound:
        completeUsing(attempt, queryResult.stateObject);
        return cause.result;
      default:
        break;
      }
      final String message = "Query failed because: " + cause.result + " with: " + cause.getMessage();
      final ObjectQueryFailedException exception = new ObjectQueryFailedException(QueryAttempt.from(attempt), message, cause);
      final Optional<ObjectQueryFailedException> maybeException = afterQueryFailed(exception);
      if (maybeException.isPresent()) {
        logger().error(message, maybeException.get());
        throw maybeException.get();
      }
      logger().error(message, exception);
      return cause.result;
    });
}
 
Example #19
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testThatWriteErrorIsReported() {
  final AccessSafely access1 = interest.afterCompleting(1);
  dispatcher.afterCompleting(1);

  store.write(null, null, 0, interest);

  assertEquals(1, (int) access1.readFrom("errorCausesCount"));
  final Exception cause1 = access1.readFrom("errorCauses");
  assertEquals("The state is null.", cause1.getMessage());
  final Result result1 = access1.readFrom("objectWriteAccumulatedResults");
  assertTrue(result1.isError());
  final Object objectState = access1.readFrom("objectState");
  assertNull(objectState);
}
 
Example #20
Source File: MockQueryResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void queryAllResultedIn(
        final Outcome<StorageException, Result> outcome,
        final QueryMultiResults results,
        final Object object) {

  access.writeUsing("addAll", results.stateObjects);
}
 
Example #21
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testThatStateStoreWritesTextWithDefaultAdapter() {
  final AccessSafely access1 = interest.afterCompleting(1);
  dispatcher.afterCompleting(1);

  final Entity2 entity = new Entity2("123", "5");

  store.write(entity.id, entity, 1, interest);

  assertEquals(0, (int) access1.readFrom("readObjectResultedIn"));
  assertEquals(1, (int) access1.readFrom("writeObjectResultedIn"));
  assertEquals(Result.Success, access1.readFrom("objectWriteResult"));
  assertEquals(entity, access1.readFrom("objectState"));
}
 
Example #22
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testThatReadErrorIsReported() {
  final AccessSafely access1 = interest.afterCompleting(2);
  dispatcher.afterCompleting(2);

  final Entity1 entity = new Entity1("123", 1);
  store.write(entity.id, entity, 1, interest);
  store.read(null, Entity1.class, interest);

  assertEquals(1, (int) access1.readFrom("errorCausesCount"));
  final Exception cause1 = access1.readFrom("errorCauses");
  assertEquals("The id is null.", cause1.getMessage());
  Result result1 = access1.readFrom("objectReadResult");
  assertTrue(result1.isError());

  interest = new MockStateStoreResultInterest();
  final AccessSafely access2 = interest.afterCompleting(1);
  dispatcher.afterCompleting(1);

  store.read(entity.id, null, interest);

  final Exception cause2 = access2.readFrom("errorCauses");
  assertEquals("The type is null.", cause2.getMessage());
  Result result2 = access2.readFrom("objectReadResult");
  assertTrue(result2.isError());
  final Object objectState = access2.readFrom("objectState");
  assertNull(objectState);
}
 
Example #23
Source File: MockQueryResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void queryObjectResultedIn(
        final Outcome<StorageException, Result> outcome,
        final QuerySingleResult result,
        final Object object) {

  outcome
    .andThen(good -> good)
    .otherwise(bad -> { throw new IllegalStateException("Bogus outcome: " + bad.getMessage()); });

  access.writeUsing("add", result.stateObject);
}
 
Example #24
Source File: MockAppendResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <S, ST> void appendResultedIn(Outcome<StorageException, Result> outcome, String streamName, int streamVersion,
        Source<S> source, Metadata metadata, Optional<ST> snapshot, Object object) {
  outcome.andThen(result -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, null, result, Collections.singletonList(source), snapshot));
    return result;
  }).otherwise(cause -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, cause, null, Collections.singletonList(source), snapshot));
    return cause.result;
  });
}
 
Example #25
Source File: InMemoryEventJournalActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testThatJournalAppendsOneEventWithSnapshot() {
  dispatcher.afterCompleting(1);
  interest.afterCompleting(1);

  final Test1Source source = new Test1Source();
  final String streamName = "123";
  final int streamVersion = 1;

  journal.appendWith(streamName, streamVersion, new Test1Source(), new SnapshotState(), interest, object);

  final List<JournalData<String, SnapshotState>> entries = interest.getEntries();
  final JournalData<String, SnapshotState> journalData = entries.get(0);
  assertNotNull(journalData);
  Assert.assertEquals(streamName, journalData.streamName);
  Assert.assertEquals(streamVersion, journalData.streamVersion);
  Assert.assertEquals(Result.Success, journalData.result);
  Assert.assertTrue(journalData.snapshot.isPresent());

  final List<Source<String>> sourceList = journalData.sources;
  Assert.assertEquals(1, sourceList.size());
  Assert.assertEquals(source, sourceList.get(0));

  assertEquals(1, dispatcher.dispatchedCount());
  final Dispatchable<Entry<?>, ?> dispatched = dispatcher.getDispatched().get(0);

  Assert.assertNotNull(dispatched.createdOn());
  Assert.assertTrue(dispatched.state().isPresent());
  Assert.assertNotNull(dispatched.id());
  final Collection<Entry<?>> dispatchedEntries = dispatched.entries();
  Assert.assertEquals(1, dispatchedEntries.size());
}
 
Example #26
Source File: InMemoryEventJournalActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testThatJournalAppendsOneEvent() {
  dispatcher.afterCompleting(1);
  interest.afterCompleting(1);

  final Test1Source source = new Test1Source();
  final String streamName = "123";
  final int streamVersion = 1;
  journal.append(streamName, streamVersion, source, interest, object);

  assertEquals(1, interest.getReceivedAppendsSize());

  final List<JournalData<String, SnapshotState>> entries = interest.getEntries();
  final JournalData<String, SnapshotState> journalData = entries.get(0);
  assertNotNull(journalData);
  Assert.assertEquals(streamName, journalData.streamName);
  Assert.assertEquals(streamVersion, journalData.streamVersion);
  Assert.assertEquals(Result.Success, journalData.result);
  Assert.assertFalse(journalData.snapshot.isPresent());

  final List<Source<String>> sourceList = journalData.sources;
  Assert.assertEquals(1, sourceList.size());
  Assert.assertEquals(source, sourceList.get(0));

  assertEquals(1, dispatcher.dispatchedCount());
  final Dispatchable<Entry<?>, ?> dispatched = dispatcher.getDispatched().get(0);

  Assert.assertNotNull(dispatched.createdOn());
  Assert.assertFalse(dispatched.state().isPresent());
  Assert.assertNotNull(dispatched.id());
  final Collection<Entry<?>> dispatchedEntries = dispatched.entries();
  Assert.assertEquals(1, dispatchedEntries.size());
}
 
Example #27
Source File: MockAppendResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
public JournalData(String streamName, int streamVersion, Exception errorCauses, Result result,
        List<Source<T>> sources, Optional<ST> snapshot) {
  this.streamName = streamName;
  this.streamVersion = streamVersion;
  this.errorCauses = errorCauses;
  this.result = result;
  this.sources = sources;
  this.snapshot = snapshot;
}
 
Example #28
Source File: MockAppendResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <S, ST> void appendAllResultedIn(Outcome<StorageException, Result> outcome, String streamName,
        int streamVersion, List<Source<S>> sources, Metadata metadata, Optional<ST> snapshot, Object object) {
  outcome.andThen(result -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, null, result, sources, snapshot));
    return result;
  }).otherwise(cause -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, cause, null, sources, snapshot));
    return cause.result;
  });
}
 
Example #29
Source File: MockAppendResultInterest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <S, ST> void appendAllResultedIn(Outcome<StorageException, Result> outcome, String streamName,
        int streamVersion, List<Source<S>> sources, Optional<ST> snapshot, Object object) {
  outcome.andThen(result -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, null, result, sources, snapshot));
    return result;
  }).otherwise(cause -> {
    access.writeUsing("appendResultedIn",
            new JournalData<>(streamName, streamVersion, cause, null, sources, snapshot));
    return cause.result;
  });
}
 
Example #30
Source File: Sourced.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * FOR INTERNAL USE ONLY.
 */
@Override
public final <S, ST> void appendResultedIn(
        final Outcome<StorageException, io.vlingo.symbio.store.Result> outcome, final String streamName, final int streamVersion,
        final Source<S> source, final Optional<ST> snapshot, final Object supplier) {
    this.appendResultedIn(outcome, streamName, streamVersion, source, Metadata.nullMetadata(), snapshot, supplier);
}