Documentation
¶
Overview ¶
Package sessionstore is the single Gorilla session store for all three database providers (GH #5733). It replaces antonlindstrom/pgstore, the 2017 cf-stratos/mysqlstore fork and the vendored sqlitestore with one implementation over the shared *sql.DB, using the same ModifySQLStatement dialect handling as the rest of jetstream.
The sessions table is created by migration 20260808120000, not here, and is named "sessions" on every provider. The primary key stays an integer: api.SessionDataStore.IsValidSession takes an int, session_data joins via CAST(id AS varchar), and the Kubernetes terminal round-trips the id through a pod annotation with strconv.Atoi. A future move to a non-sequential session id replaces lastInsertedID/session.ID handling here plus those three call sites, and nothing else.
Index ¶
- type Store
- func (s *Store) Cleanup(interval time.Duration) (chan<- struct{}, <-chan struct{})
- func (s *Store) Close()
- func (s *Store) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *Store) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *Store) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *Store) StopCleanup(quit chan<- struct{}, done <-chan struct{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
Codecs []securecookie.Codec
Options *sessions.Options
// contains filtered or unexported fields
}
Store implements gorilla/sessions.Store plus the Cleanup lifecycle the jetstream HttpSessionStore interface expects.
func New ¶
func New(db *sql.DB, databaseProvider string, path string, maxAge int, keyPairs ...[]byte) (*Store, error)
New creates a session store on the already-open connection pool. The pool stays owned by the caller — Close on the store does not close it.
func (*Store) Cleanup ¶
Cleanup runs a background goroutine that deletes expired sessions from the database every interval. Returns the channels StopCleanup needs.
func (*Store) Close ¶
func (s *Store) Close()
Close satisfies HttpSessionStore. The connection pool is shared and owned by main, which closes it itself — unlike the old stores, there is nothing of ours to release here.
func (*Store) New ¶
New returns a session for the request: the stored one when the cookie decodes and the row is live, a fresh one otherwise.
func (*Store) Save ¶
Save persists the session and writes the cookie. A negative MaxAge destroys the session: row deleted, cookie expired — the pgstore contract clearSession (logout) relies on; the old MySQL and SQLite stores left the row valid until natural expiry.
func (*Store) StopCleanup ¶
func (s *Store) StopCleanup(quit chan<- struct{}, done <-chan struct{})
StopCleanup stops the background cleanup goroutine.