session

package
v0.0.0-...-128afb8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package session defines API for the session storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID []byte

ID identifies a session.

func GenerateID

func GenerateID() ID

GenerateID generates a new random session ID or panics if there's not enough entropy.

func (ID) String

func (id ID) String() string

String is used to format the ID for logging.

type Store

type Store interface {
	// FetchSession fetches an existing session with the given ID.
	//
	// Returns (nil, nil) if there's no such session. All errors are transient.
	FetchSession(ctx context.Context, id ID) (*sessionpb.Session, error)

	// UpdateSession transactionally updates or creates a session.
	//
	// If fetches the session, calls the callback to mutate it, and stores the
	// result. If it is a new session, the callback receives an empty proto.
	//
	// The callback may be called multiple times in case the transaction is
	// retried. Errors from callbacks are returned as is. All other errors are
	// transient.
	UpdateSession(ctx context.Context, id ID, cb func(*sessionpb.Session) error) error
}

Store is a persistent transactional-capable storage of user sessions.

Session IDs are assumed to be generated by GenerateID, i.e. be high-entropy random blobs.

Directories

Path Synopsis
Package datastore implements session storage over Cloud Datastore.
Package datastore implements session storage over Cloud Datastore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL