Skip to content

feat(SessionStore)!: make record IDs generic#253

Draft
dustypomerleau wants to merge 1 commit intomaxcountryman:mainfrom
dustypomerleau:id
Draft

feat(SessionStore)!: make record IDs generic#253
dustypomerleau wants to merge 1 commit intomaxcountryman:mainfrom
dustypomerleau:id

Conversation

@dustypomerleau
Copy link
Copy Markdown

Thanks for all the time you've put into tower-sessions!

I have been looking at ways to make the built-in Record type more flexible, so that it could hold any suitable value, like Uuids. My goal is to allow the Id type in the Record to be whatever the backing DB/store is already using for IDs.

To show my use case, I copied the counter example, using a newtyped v7 UUID (see examples/uuid.rs).

The current test suite passes, but I haven't yet added any tests or completed docs. I just wanted to get a sense of whether there is interest in the PR.

My approach so far:

  • add an associated type to SessionStore that specifies the type of the ID
  • add a GenId trait, to allow SessionStore::Id types to choose how they generate new values
  • add a generic on Session, Record, and MemoryStore, to represent the ID type
  • make the existing implementation of SessionStore for MemoryStore generic
  • rename the existing Id to SesId, to avoid confusing it with the associated type

Happy for any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant