Code Monkey home page Code Monkey logo

async-mongodb-session's People

Contributors

aaronerhardt avatar jbr avatar lrlna avatar no9 avatar pepoviola avatar tilopapke avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

async-mongodb-session's Issues

Discussion: Handle Session Expiry

Hey Folks
As mentioned in the code https://github.com/yoshuawuyts/async-mongodb-session/blob/master/src/lib.rs#L49
Sessions do not expire at the moment.

Looking at the mongo docs it seems expiry can be enforced using an index
https://docs.mongodb.com/manual/tutorial/expire-data/#expire-documents-after-a-specified-number-of-seconds

It should be simple enough to code (famous last words when talking about cache expiry :) ), but wanted to clarify a some points before i started.

The approach I am considering is to add an additional parameter called expireAfterSeconds to connect and from_client
Is that ok?

Currently the session object in async-session only has an expiry field https://github.com/http-rs/async-session/blob/main/src/session.rs#L59 .
Using the inbuilt TTL in mongo means that the property in this scenario is not an expiry time but the creation time that will be offset with the expireAfterSeconds value to calculate the expiry time.
I can proceed using the expiry field but would suggest that we change the name of the of the session object to expiry-marker.
If that makes sense I can PR that as part of this.

As the TTL is an index it will have to be redefined on restart in the case where the user changes the value following restarts.
This will be done using collMod https://docs.mongodb.com/manual/reference/command/collMod/#dbcmd.collMod

It would be great if we can finalise #7 as expiry will will need tests and I wouldn't want to do too much using an approach that hasn't landed.

Thanks for your time.

Compilation error with mongodb

error[E0428]: the name `RUNTIME_NAME` is defined multiple times
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/mongodb-2.3.1/src/cmap/establish/handshake/mod.rs:25:1
   |
22 | const RUNTIME_NAME: &str = "tokio";
   | ----------------------------------- previous definition of the value `RUNTIME_NAME` here
...
25 | const RUNTIME_NAME: &str = "async-std";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `RUNTIME_NAME` redefined here
   |
   = note: `RUNTIME_NAME` must be defined only once in the value namespace of this module

error[E0252]: the name `Interval` is defined multiple times
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/mongodb-2.3.1/src/runtime/mod.rs:34:5
   |
28 | use interval::Interval;
   |     ------------------ previous import of the type `Interval` here
...
34 | use tokio::time::Interval;
   |     ^^^^^^^^^^^^^^^^^^^^^ `Interval` reimported here
   |
   = note: `Interval` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
34 | use tokio::time::Interval as OtherInterval;
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: `tokio-runtime` and `async-std-runtime` can't both be enabled; either disable `async-std-runtime` or set `default-features = false` in your Cargo.toml
   --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/mongodb-2.3.1/src/lib.rs:357:1
    |
357 | / compile_error!(
358 | |     "`tokio-runtime` and `async-std-runtime` can't both be enabled; either disable \
359 | |      `async-std-runtime` or set `default-features = false` in your Cargo.toml"
360 | | );
    | |_^

error[E0124]: field `resolver` is already declared
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/mongodb-2.3.1/src/runtime/resolver.rs:16:5
   |
13 |     resolver: trust_dns_resolver::TokioAsyncResolver,
   |     ------------------------------------------------ `resolver` first declared here
...
16 |     resolver: async_std_resolver::AsyncStdResolver,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field already declared
[dependencies]
axum = "0.5.16"
axum-extra = { version = "0.3.7", features = ["cookie-private", "cookie-signed"] }
axum-sessions = "0.3.1"
async-session = "3.0.0"
# async-redis-session = "0.2.2"
mongodb = { version = "2.3.1", features = ["tokio-runtime"] }
async-mongodb-session = { version = "3.0.0", features = ["tokio-runtime"] }
tokio = { version = "1.21.2", features = ["full"] }

For some reason this app crashes when trying to use MongodbSessionStore::from_client

I tried deleting the .cargo cache, but the problem still persists. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.