1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-04-25 12:24:41 +02:00
oauth2-proxy/pkg/apis/sessions/interfaces.go
Kobi Meirson f753ec1ca5
feat: readiness check (#1839)
* feat: readiness check

* fix: no need for query param

* docs: add a note

* chore: move the readyness check to its own endpoint

* docs(cr): add godoc

Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
2022-12-23 09:08:12 +00:00

38 lines
1.2 KiB
Go

package sessions
import (
"context"
"errors"
"net/http"
"time"
)
// SessionStore is an interface to storing user sessions in the proxy
type SessionStore interface {
Save(rw http.ResponseWriter, req *http.Request, s *SessionState) error
Load(req *http.Request) (*SessionState, error)
Clear(rw http.ResponseWriter, req *http.Request) error
VerifyConnection(ctx context.Context) error
}
var ErrLockNotObtained = errors.New("lock: not obtained")
var ErrNotLocked = errors.New("tried to release not existing lock")
// Lock is an interface for controlling session locks
type Lock interface {
// Obtain obtains the lock on the distributed
// lock resource if no lock exists yet.
// Otherwise it will return ErrLockNotObtained
Obtain(ctx context.Context, expiration time.Duration) error
// Peek returns true if the lock currently exists
// Otherwise it returns false.
Peek(ctx context.Context) (bool, error)
// Refresh refreshes the expiration time of the lock,
// if is still applied.
// Otherwise it will return ErrNotLocked
Refresh(ctx context.Context, expiration time.Duration) error
// Release removes the existing lock,
// Otherwise it will return ErrNotLocked
Release(ctx context.Context) error
}