storage

package
v0.0.0-...-4d67ef4 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicRedis

type BasicRedis interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Exists(ctx context.Context, key ...string) *redis.IntCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Del(ctx context.Context, key ...string) *redis.IntCmd
	Ping(ctx context.Context) *redis.StatusCmd
	Close() error
}

type RedisStore

type RedisStore[T BasicRedis] struct {
	Client BasicRedis
}

func (*RedisStore[T]) Close

func (r *RedisStore[T]) Close() error

Close closes of any open resources.

func (*RedisStore[T]) Delete

func (r *RedisStore[T]) Delete(ctx context.Context, key string) error

Delete remove the key.

func (*RedisStore[T]) Exists

func (r *RedisStore[T]) Exists(ctx context.Context, key string) (bool, error)

Checks if key exists in store.

func (*RedisStore[T]) Get

func (r *RedisStore[T]) Get(ctx context.Context, key string) (string, error)

Get retrieves a token from the store.

func (*RedisStore[T]) GetRefreshTokenFromStore

func (r *RedisStore[T]) GetRefreshTokenFromStore(
	ctx context.Context,
	token string,
) (string, error)

Get retrieves a token from the store, the key we are using here is the access token.

func (*RedisStore[T]) Set

func (r *RedisStore[T]) Set(ctx context.Context, key, value string, expiration time.Duration) error

Set adds a token to the store.

func (*RedisStore[T]) Test

func (r *RedisStore[T]) Test(ctx context.Context) error

Test connection to store.

type RedisStoreBuilder

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

func (*RedisStoreBuilder) Build

func (b *RedisStoreBuilder) Build() Storage

func (*RedisStoreBuilder) WithCACert

func (b *RedisStoreBuilder) WithCACert(caPool *x509.CertPool) *RedisStoreBuilder

func (*RedisStoreBuilder) WithClientCert

func (b *RedisStoreBuilder) WithClientCert(tlsCert *tls.Certificate) *RedisStoreBuilder

type Storage

type Storage interface {
	// Set the token to the store
	Set(ctx context.Context, key string, value string, expiration time.Duration) error
	// Get retrieves a token from the store
	Get(ctx context.Context, key string) (string, error)
	// Exists checks if key exists in store
	Exists(ctx context.Context, key string) (bool, error)
	// Delete removes a key from the store
	Delete(ctx context.Context, key string) error
	// Close is used to close off any resources
	Close() error
	GetRefreshTokenFromStore(ctx context.Context, token string) (string, error)
	Test(ctx context.Context) error
}

storage is used to hold the offline refresh token, assuming you don't want to use the default practice of a encrypted cookie.

func CreateStorage

func CreateStorage(location string, highAvail bool, caPool *x509.CertPool, keyPair *tls.Certificate) (Storage, error)

createStorage creates the store client for use.

Jump to

Keyboard shortcuts

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