Class InMemoryScheduleStore

java.lang.Object
io.fluxzero.sdk.tracking.client.InMemoryMessageStore
io.fluxzero.sdk.scheduling.client.InMemoryScheduleStore
All Implemented Interfaces:
SchedulingClient, AutoCloseable

public class InMemoryScheduleStore extends InMemoryMessageStore implements SchedulingClient
An in-memory implementation of a scheduling store that allows the scheduling, retrieval, and management of scheduled messages. It extends `InMemoryMessageStore` to reuse the functionalities for storing and managing messages and implements `SchedulingClient` to support scheduling-specific operations.

This implementation provides thread-safe mechanisms for scheduling, retrieving, and cancelling messages. Messages are scheduled to be processed at specific timestamps, with support for expiration and filtering of schedules.

  • Constructor Details

    • InMemoryScheduleStore

      public InMemoryScheduleStore()
    • InMemoryScheduleStore

      public InMemoryScheduleStore(Duration messageExpiration)
  • Method Details

    • filterMessages

      protected Collection<io.fluxzero.common.api.SerializedMessage> filterMessages(Collection<io.fluxzero.common.api.SerializedMessage> messages)
      Overrides:
      filterMessages in class InMemoryMessageStore
    • append

      public CompletableFuture<Void> append(io.fluxzero.common.api.SerializedMessage... messages)
    • schedule

      public CompletableFuture<Void> schedule(io.fluxzero.common.Guarantee guarantee, io.fluxzero.common.api.scheduling.SerializedSchedule... schedules)
      Description copied from interface: SchedulingClient
      Schedule one or more serialized schedules with a specified Guarantee.
      Specified by:
      schedule in interface SchedulingClient
      Parameters:
      guarantee - Delivery guarantee to apply (e.g., none, sent, stored).
      schedules - One or more schedules to register.
      Returns:
      A future that completes when the scheduling is acknowledged.
    • cancelSchedule

      public CompletableFuture<Void> cancelSchedule(String scheduleId, io.fluxzero.common.Guarantee guarantee)
      Description copied from interface: SchedulingClient
      Cancel a scheduled message using the provided delivery guarantee.
      Specified by:
      cancelSchedule in interface SchedulingClient
      Parameters:
      scheduleId - The identifier of the schedule to cancel.
      guarantee - Delivery guarantee for the cancellation request.
      Returns:
      A future that completes when the cancellation is processed.
    • getSchedule

      public io.fluxzero.common.api.scheduling.SerializedSchedule getSchedule(String scheduleId)
      Description copied from interface: SchedulingClient
      Retrieves the serialized schedule associated with the given ID.
      Specified by:
      getSchedule in interface SchedulingClient
      Parameters:
      scheduleId - The ID of the schedule to retrieve.
      Returns:
      The matching SerializedSchedule, or null if none is found.
    • append

      public CompletableFuture<Void> append(List<io.fluxzero.common.api.SerializedMessage> messages)
      Overrides:
      append in class InMemoryMessageStore
    • setClock

      public void setClock(@NonNull @NonNull Clock clock)
    • getFutureSchedules

      public List<Schedule> getFutureSchedules(Serializer serializer)
    • removeExpiredSchedules

      public List<Schedule> removeExpiredSchedules(Serializer serializer)
    • asList

      protected List<Schedule> asList(Map<Long,String> scheduleIdsByIndex, Serializer serializer)
    • purgeExpiredMessages

      protected void purgeExpiredMessages(Duration messageExpiration)
      Overrides:
      purgeExpiredMessages in class InMemoryMessageStore
    • toString

      public String toString()
      Overrides:
      toString in class InMemoryMessageStore
    • getBatch

      default List<io.fluxzero.common.api.SerializedMessage> getBatch(Long arg0, int arg1)
    • setRetentionTime

      void setRetentionTime(Duration arg0)
    • unwrap

      default <T extends io.fluxzero.common.tracking.MessageStore> T unwrap(Class<T> arg0)
    • getMessageStore

      default io.fluxzero.common.tracking.MessageStore getMessageStore()