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.

Source Files