datastore

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package datastore implements session storage over Cloud Datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	Namespace string // the datastore namespace to use or "" for default
}

Store uses Cloud Datastore for sessions.

func (*Store) FetchSession

func (s *Store) FetchSession(ctx context.Context, id session.ID) (*sessionpb.Session, error)

FetchSession fetches an existing session with the given ID.

Returns (nil, nil) if there's no such session. All errors are transient.

func (*Store) UpdateSession

func (s *Store) UpdateSession(ctx context.Context, id session.ID, cb func(*sessionpb.Session) error) 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.

Jump to

Keyboard shortcuts

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