Skip to content

Commit

Permalink
docs: adds postgres_store link out and cleanup description
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Hill committed Sep 13, 2024
1 parent 72cc253 commit 7e352a1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,43 @@ just watch-test # Run test and reload on file changes

A SessionStore driver is a function that produces a SessionStore instance. These drivers allow for custom session storage solutions by applying methods to the SessionStore object, potentially using external resources like databases.

For an example implementation, see ./src/actor_store.gleam.
For an example implementation, see `./src/wisp_kv_sessions/actor_store.gleam`.

## Existing Drivers

### actor_store (Included by Default)
The actor_store driver is suitable for development and testing purposes, but not recommended for production due to its non-concurrent nature. Internally, it uses an [Actor](https://hexdocs.pm/gleam_otp/gleam/otp/actor.html), which may become a bottleneck under heavy loads.
The actor_store driver is suitable for development and testing purposes,
but not recommended for production due to its non-concurrent nature.
Internally, it uses an [Actor](https://hexdocs.pm/gleam_otp/gleam/otp/actor.html),
which may become a bottleneck under heavy loads.

*Usage Example:*

```gleam
use actor_store <- result.map(actor_store.try_create_session_store())
use session_store <- result.map(actor_store.try_create_session_store())
// ...
```
See `./example/src/app.gleam` for full example

### postgress_store (In Development)
### postgress_store
The postgres_store uses a [gleam/pgo](https://hexdocs.pm/gleam_pgo/gleam/pgo.html)
connection to store the session information in postgres.

A SessionStore driver for PostgreSQL is currently under development.
```sh
gleam add wisp_kv_sessions_postgres_store
```

```gleam
import wisp_kv_sessions/postgres_store
let db = pgo.connect(pgo.default_config())
// Migrate
use _ <- result.try(postgres_store.migrate_up(conn))
// Setup session_store
use session_store <- result.map(postgres_store.try_create_session_store(conn))
//...
```
Further documentation can be found at <https://hexdocs.pm/wisp_kv_sessions_postgres_store>.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.2"
# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
description = "wisp_kv_sessions is a key-value session management library for [Wisp](https://gleam-wisp.github.io/wisp/), inspired by the Rust crate [tower sessions](https://docs.rs/tower-sessions/latest/tower_sessions/#). This library allows you to manage user sessions with ease, storing session data in a simple key-value store."
description = "Session management library for Wisp. Manage user sessions in a simple key-value store."
licences = ["Apache-2.0"]
repository = { type = "github", user = "MaxHill", repo = "wisp_kv_sessions" }
# links = [{ title = "Website", href = "" }]
Expand Down

0 comments on commit 7e352a1

Please sign in to comment.