Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Refactor interface of AtLeastOnceStorage #57

Open
mattiamanzati opened this issue Apr 21, 2024 · 0 comments
Open

Refactor interface of AtLeastOnceStorage #57

mattiamanzati opened this issue Apr 21, 2024 · 0 comments

Comments

@mattiamanzati
Copy link
Contributor

Right now the interface is too specific and tight to the concept of a cluster,
we should maybe revisit that and make it so its more tight to the message instead.
We could align more to the api style of effect/platform's KeyValueStore. (and cluster-platform could provide a storage backed on that)
API would look like:

Need to experiment because I am not a fan of generics in services, but I could see that being nicer dx wise.

export interface AtLeastOnceStorage<Msg extends Message.Message.Any> {
  readonly [AtLeastOnceStorageTypeId]: AtLeastOnceStorageTypeId

  /**
   * Stores a message into the storage, eventually returning the already existing message state as result in the storage
   */
  upsert<Msg extends Message.Message.Any>(
    message: Msg
  ): Effect.Effect<void>

  /**
   * Marks the message as processed, so no more send attempt will occur
   */
  markAsProcessed<Msg extends Message.Message.Any>(
    message: Msg
  ): Effect.Effect<void>

  /**
   * Gets a set of messages that will be sent to the local Pod as second attempt
   */
  sweepPending: Stream.Stream<Msg>
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant