storage

package
v0.0.0-...-69e1925 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMembers

func AddMembers[T Set](ctx context.Context, obj T, members ...string) error

func AddScoredMember

func AddScoredMember[T SortedSet](ctx context.Context, obj T, score float64, member string) error

func BOMAwareCSVReader

func BOMAwareCSVReader(reader io.Reader) *csv.Reader

BOMAwareCSVReader will detect a UTF BOM (Byte Order Mark) at the start of the data and transform to UTF8 accordingly. If there is no BOM, it will read the data without any transformation.

This code taken from [this StackOverflow answer](https://stackoverflow.com/a/76023436/558006).

func DeleteStorage

func DeleteStorage[T Storable](ctx context.Context, obj T) error

func DumpObjectsToPath

func DumpObjectsToPath(what ObjectMap, where string) error

DumpObjectsToPath serializes the entire map to the given filepath

func DumpObjectsToStream

func DumpObjectsToStream(stream io.Writer, what ObjectMap)

DumpObjectsToStream marshals the objects as JSON to the given stream

func FetchMembers

func FetchMembers[T Set](ctx context.Context, obj T) ([]string, error)

func FetchOneBlocking

func FetchOneBlocking[T List](ctx context.Context, obj T, timeout time.Duration) (string, error)

func FetchRange

func FetchRange[T List](ctx context.Context, obj T, start int64, end int64) ([]string, error)

func FetchRangeInterval

func FetchRangeInterval[T SortedSet](ctx context.Context, obj T, start, end int64) ([]string, error)

func FetchRangeScoreInterval

func FetchRangeScoreInterval[T SortedSet](ctx context.Context, obj T, min, max float64) ([]string, error)

func FetchString

func FetchString[T String](ctx context.Context, obj T) (string, error)

func FindEnvFile

func FindEnvFile(name string, fallback bool) (string, error)

func GetDb

func GetDb() (*redis.Client, string)

func LoadFields

func LoadFields[T StructPointer](ctx context.Context, obj T) error

func MapFields

func MapFields[T StructPointer](ctx context.Context, f func(), obj T) error

func PopConfig

func PopConfig()

func PushAlteredConfig

func PushAlteredConfig(env Environment)

func PushConfig

func PushConfig(name string) error

func PushRange

func PushRange[T List](ctx context.Context, obj T, onLeft bool, members ...string) error

func RemoveElement

func RemoveElement[T List](ctx context.Context, obj T, count int64, element string) error

func RemoveMember

func RemoveMember[T SortedSet](ctx context.Context, obj T, member string) error

func RemoveMembers

func RemoveMembers[T Set](ctx context.Context, obj T, members ...string) error

func S3GetBlob

func S3GetBlob(ctx context.Context, blobname string, blobfile *os.File) error

func S3PutBlob

func S3PutBlob(ctx context.Context, blobname string, blobfile *os.File) error

func SaveFields

func SaveFields[T StructPointer](ctx context.Context, obj T) error

func StoreString

func StoreString[T String](ctx context.Context, obj T, val string) error

Types

type Environment

type Environment struct {
	Name                 string
	AgePublicKey         string
	AgeSecretKey         string
	AwsAccessKey         string
	AwsSecretKey         string
	AwsRegion            string
	AwsBucket            string
	AwsDialpadFolder     string
	DbUrl                string
	DbKeyPrefix          string
	DialpadApiKey        string
	DialpadWebhookSecret string
	HerokuHostUrl        string
	MasterAdminId        string
	MasterAdminEmail     string
}

func GetConfig

func GetConfig() Environment

type List

type List interface {
	Storable
	~string
}

type ObjectMap

type ObjectMap map[string][]any

type Set

type Set interface {
	~string
	Storable
}

type SortedSet

type SortedSet interface {
	~string
	Storable
}

type Storable

type Storable interface {
	StoragePrefix() string
	StorageId() string
}

type String

type String interface {
	~string
	Storable
}

type StructPointer

type StructPointer interface {
	Storable
	SetStorageId(id string) error
	Copy() StructPointer
	Downgrade(any) (StructPointer, error)
}

Jump to

Keyboard shortcuts

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