store

package
v0.0.0-...-8e081cf Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyExistsError

func IsAlreadyExistsError(err error) bool

Types

type AlreadyExistsError

type AlreadyExistsError struct {
	Err error
}

func NewAlreadyExistsError

func NewAlreadyExistsError(err error) *AlreadyExistsError

func (*AlreadyExistsError) Error

func (e *AlreadyExistsError) Error() string

type Config

type Config struct {
	Log *zap.Logger
	DB  *bun.DB
	// contains filtered or unexported fields
}

type IdentityUpdate

type IdentityUpdate struct {
	Kind               IdentityUpdateKind
	InstallationKey    []byte
	CredentialIdentity []byte
	TimestampNs        uint64
}

type IdentityUpdateKind

type IdentityUpdateKind int
const (
	Create IdentityUpdateKind = iota
	Revoke
)

type IdentityUpdateList

type IdentityUpdateList []IdentityUpdate

Add the required methods to make a valid sort.Sort interface

func (IdentityUpdateList) Len

func (a IdentityUpdateList) Len() int

func (IdentityUpdateList) Less

func (a IdentityUpdateList) Less(i, j int) bool

func (IdentityUpdateList) Swap

func (a IdentityUpdateList) Swap(i, j int)

type MlsStore

type MlsStore interface {
	IdentityStore

	CreateOrUpdateInstallation(ctx context.Context, installationId []byte, keyPackage []byte) error
	FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error)
	InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*queries.GroupMessage, error)
	InsertWelcomeMessage(ctx context.Context, installationId []byte, data []byte, hpkePublicKey []byte) (*queries.WelcomeMessage, error)
	QueryGroupMessagesV1(ctx context.Context, query *mlsv1.QueryGroupMessagesRequest) (*mlsv1.QueryGroupMessagesResponse, error)
	QueryWelcomeMessagesV1(ctx context.Context, query *mlsv1.QueryWelcomeMessagesRequest) (*mlsv1.QueryWelcomeMessagesResponse, error)
}

type Store

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

func New

func New(ctx context.Context, config Config) (*Store, error)

func (*Store) CreateOrUpdateInstallation

func (s *Store) CreateOrUpdateInstallation(ctx context.Context, installationId []byte, keyPackage []byte) error

Creates the installation and last resort key package

func (*Store) FetchKeyPackages

func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error)

func (*Store) GetInboxIds

func (*Store) GetInboxLogs

func (*Store) InsertGroupMessage

func (s *Store) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*queries.GroupMessage, error)

func (*Store) InsertWelcomeMessage

func (s *Store) InsertWelcomeMessage(ctx context.Context, installationId []byte, data []byte, hpkePublicKey []byte) (*queries.WelcomeMessage, error)

func (*Store) RunInRepeatableReadTx

func (s *Store) RunInRepeatableReadTx(ctx context.Context, numRetries int, fn func(ctx context.Context, txQueries *queries.Queries) error) error

func (*Store) RunInTx

func (s *Store) RunInTx(
	ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, txQueries *queries.Queries) error,
) error

type StoreOptions

type StoreOptions struct {
	DbConnectionString string        `long:"db-connection-string" description:"Connection string for MLS DB"`
	ReadTimeout        time.Duration `long:"read-timeout" description:"Timeout for reading from the database" default:"10s"`
	WriteTimeout       time.Duration `long:"write-timeout" description:"Timeout for writing to the database" default:"10s"`
	MaxOpenConns       int           `long:"max-open-conns" description:"Maximum number of open connections" default:"80"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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