sql

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option is a type which configures a *Store

func WithIDGeneratorFunc

func WithIDGeneratorFunc(fn func() string) Option

WithIDGeneratorFunc overrides the stores ID generator function used to generate new random ID strings, when creating new instances of Authentications. The default is a string containing a valid UUID (V4).

func WithNowFunc

func WithNowFunc(fn func() *timestamppb.Timestamp) Option

WithNowFunc overrides the stores now() function used to obtain a protobuf timestamp representative of the current time of evaluation.

func WithTokenGeneratorFunc

func WithTokenGeneratorFunc(fn func() string) Option

WithTokenGeneratorFunc overrides the stores token generator function used to generate new random token strings as client tokens, when creating new instances of Authentication. The default is a pseudo-random string of bytes base64 encoded.

type Store

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

Store is the persistent storage layer for Authentications backed by SQL based relational database systems.

func NewStore

func NewStore(driver storagesql.Driver, builder sq.StatementBuilderType, logger *zap.Logger, opts ...Option) *Store

NewStore constructs and configures a new instance of *Store. Queries are issued to the database via the provided statement builder.

func (*Store) CreateAuthentication

CreateAuthentication creates and persists an instance of an Authentication.

func (*Store) DeleteAuthentications

func (s *Store) DeleteAuthentications(ctx context.Context, req *storageauth.DeleteAuthenticationsRequest) (err error)

DeleteAuthentications attempts to delete one or more Authentication instances from the backing store. Use auth.DeleteByID to construct a request to delete a single Authentication by ID string. Use auth.DeleteByMethod to construct a request to delete 0 or more Authentications by Method and optional expired before constraint.

func (*Store) ExpireAuthenticationByID

func (s *Store) ExpireAuthenticationByID(ctx context.Context, id string, expireAt *timestamppb.Timestamp) (err error)

ExpireAuthenticationByID attempts to expire an Authentication by ID string and the provided expiry time.

func (*Store) GetAuthenticationByClientToken

func (s *Store) GetAuthenticationByClientToken(ctx context.Context, clientToken string) (*rpcauth.Authentication, error)

GetAuthenticationByClientToken fetches the associated Authentication for the provided clientToken string.

Given a row is present for the hash of the clientToken then materialize into an Authentication. Else, given it cannot be located, a storage.ErrNotFound error is wrapped and returned instead.

func (*Store) GetAuthenticationByID

func (s *Store) GetAuthenticationByID(ctx context.Context, id string) (*rpcauth.Authentication, error)

GetAuthenticationByID retrieves an instance of Authentication from the backing store using the provided id string.

func (*Store) ListAuthentications

ListAuthentications lists a page of Authentications from the backing store.

Jump to

Keyboard shortcuts

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