Class InMemoryEventLog

java.lang.Object
es.urjc.etsii.grafo.events.InMemoryEventLog

@Service public class InMemoryEventLog extends Object
Append-only in-memory event replay log.
  • Constructor Details

    • InMemoryEventLog

      public InMemoryEventLog()
  • Method Details

    • append

      public void append(EventEnvelope envelope)
      Store a published event envelope.
      Parameters:
      envelope - event envelope
    • getEvents

      public List<EventEnvelope> getEvents(int from, int to)
      Get events in range [from, to).
      Parameters:
      from - inclusive start index
      to - exclusive end index
      Returns:
      event envelopes in the requested range
    • getEvent

      public EventEnvelope getEvent(int id)
      Get a single event by id.
      Parameters:
      id - event id
      Returns:
      event envelope
    • getLastEvent

      public EventEnvelope getLastEvent()
      Get the last published event.
      Returns:
      latest event envelope
    • size

      public int size()
      Count stored events.
      Returns:
      event count