postgres

package
v4.0.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// connection string for our local development. see docker-compose.yaml at root
	DefaultDSN = `host=localhost port=5432 user=clair dbname=clair sslmode=disable`
)

Variables

This section is empty.

Functions

func TestStore

func TestStore(ctx context.Context, t testing.TB) (*sqlx.DB, *Store, *KeyStore, func())

Types

type KeyStore

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

KeyStore implements the notifier.KeyStore interface. Stored public keys are RSA encoded in PKIX ASN.1 DER form.

func NewKeyStore

func NewKeyStore(pool *pgxpool.Pool) *KeyStore

func (*KeyStore) BumpExpiration

func (k *KeyStore) BumpExpiration(ctx context.Context, ID uuid.UUID, n time.Duration) error

func (*KeyStore) DeleteKey

func (k *KeyStore) DeleteKey(ctx context.Context, ID uuid.UUID) error

func (*KeyStore) GC

func (k *KeyStore) GC(ctx context.Context) (int64, error)

func (*KeyStore) KeyByID

func (k *KeyStore) KeyByID(ctx context.Context, ID uuid.UUID) (notifier.Key, error)

func (*KeyStore) Keys

func (k *KeyStore) Keys(ctx context.Context) ([]notifier.Key, error)

func (*KeyStore) PutKey

func (k *KeyStore) PutKey(ctx context.Context, ID uuid.UUID, key *rsa.PublicKey, n time.Duration) error

type Store

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

Store implements the notifier.Store interface

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

func (*Store) Created

func (s *Store) Created(ctx context.Context) ([]uuid.UUID, error)

Created returns a slice of notification ids in created status

func (*Store) DeleteNotifications

func (s *Store) DeleteNotifications(ctx context.Context, id uuid.UUID) error

DeleteNotifications garbage collects all notifications associated with a notification id.

Normally Receipter.SetDeleted will be issues first, however application logic may decide to gc notifications which have not been set deleted after some period of time, thus this condition should not be checked.

func (*Store) Deleted

func (s *Store) Deleted(ctx context.Context) ([]uuid.UUID, error)

Deleted returns a slice of notification ids in deleted status

func (*Store) Failed

func (s *Store) Failed(ctx context.Context) ([]uuid.UUID, error)

Failed returns a slice of notification ids in failed status

func (*Store) Notifications

func (s *Store) Notifications(ctx context.Context, id uuid.UUID, page *notifier.Page) ([]notifier.Notification, notifier.Page, error)

Notifications retrieves the list of notifications associated with a notification id

func (*Store) PutNotifications

func (s *Store) PutNotifications(ctx context.Context, opts notifier.PutOpts) error

PutNotifications persists the provided notifications and associates them with the provided notification id

PutNotifications must update the latest update operation for the provided updater in such a way that UpdateOperation returns the the provided update operation id when queried with the updater name

PutNotifications must create a Receipt with status created status on successful persistence of notifications in such a way that Receipter.Created() returns the persisted notification id.

func (*Store) Receipt

func (s *Store) Receipt(ctx context.Context, id uuid.UUID) (notifier.Receipt, error)

Receipt returns the Receipt for a given notification id

func (*Store) ReceiptByUOID

func (s *Store) ReceiptByUOID(ctx context.Context, id uuid.UUID) (notifier.Receipt, error)

ReceiptByUOID returns the Receipt for a given notification UOID

func (*Store) SetDeleted

func (s *Store) SetDeleted(ctx context.Context, id uuid.UUID) error

SetDeleted marks the provided notification id as deleted

func (*Store) SetDelivered

func (s *Store) SetDelivered(ctx context.Context, id uuid.UUID) error

SetDelivered marks the provided notification id as delivered

func (*Store) SetDeliveryFailed

func (s *Store) SetDeliveryFailed(ctx context.Context, id uuid.UUID) error

SetDeliveryFailed marks the provided notification id failed to be delivere

Jump to

Keyboard shortcuts

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