spanner

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

spanner provides our data storage API backed by Google Cloud Spanner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(client *spanner.Client) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) DestroySession

func (c *Client) DestroySession(ctx context.Context, sessionID ccc.UUID) error

DestroySession marks the session as expired

func (*Client) DestroySessionOIDC

func (c *Client) DestroySessionOIDC(ctx context.Context, oidcSID string) error

DestroySessionOIDC marks the session as expired

func (*Client) InsertSession

func (c *Client) InsertSession(ctx context.Context, insertSession *InsertSession) (ccc.UUID, error)

InsertSession inserts a Session into database

func (*Client) Session

func (c *Client) Session(ctx context.Context, sessionID ccc.UUID) (*Session, error)

Session returns the session information from the database for given sessionID

func (*Client) UpdateSessionActivity

func (c *Client) UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

UpdateSessionActivity updates the session activity column with the current time

type ConnectionSettings

type ConnectionSettings struct {
	// ProjectID is the project the Spanner database is in
	ProjectID string

	// InstanceID is the Spanner Instance ID
	InstanceID string

	// DatabaseName is the Spanner Database Name
	DatabaseName string
}

ConnectionSettings is used to configure the spanner package

func (*ConnectionSettings) DBName

func (c *ConnectionSettings) DBName() string

type DB

type DB interface {
	// Session returns the session information from the database for given sessionID.
	Session(ctx context.Context, sessionID ccc.UUID) (*Session, error)

	// InsertSession creates a new session in the database and returns its session ID.
	InsertSession(ctx context.Context, session *InsertSession) (ccc.UUID, error)

	// UpdateSessionActivity updates the session activity column with the current time.
	UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

	// DestroySession marks the session as expired.
	DestroySession(ctx context.Context, sessionID ccc.UUID) error

	// DestroySessionOIDC marks the session as expired
	DestroySessionOIDC(ctx context.Context, oidcSID string) error
}

DB is the interface for the database methods

type InsertSession

type InsertSession struct {
	OidcSID   string    `spanner:"OidcSid"`
	Username  string    `spanner:"Username"`
	CreatedAt time.Time `spanner:"CreatedAt"`
	UpdatedAt time.Time `spanner:"UpdatedAt"`
	Expired   bool      `spanner:"Expired"`
}

type Session

type Session struct {
	ID        ccc.UUID  `spanner:"Id"`
	OidcSID   string    `spanner:"OidcSid"`
	Username  string    `spanner:"Username"`
	CreatedAt time.Time `spanner:"CreatedAt"`
	UpdatedAt time.Time `spanner:"UpdatedAt"`
	Expired   bool      `spanner:"Expired"`
}

Jump to

Keyboard shortcuts

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