From 7e352a1629e328a1ff30b1c834bd7c07726dafe3 Mon Sep 17 00:00:00 2001 From: Max Hill Date: Fri, 13 Sep 2024 08:40:49 +0200 Subject: [PATCH] docs: adds postgres_store link out and cleanup description --- README.md | 34 +++++++++++++++++++++++++++++----- gleam.toml | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 632fb1a..0945a1c 100644 --- a/README.md +++ b/README.md @@ -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 . diff --git a/gleam.toml b/gleam.toml index 98bfa79..c77b2cc 100644 --- a/gleam.toml +++ b/gleam.toml @@ -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 = "" }]