storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxStaples is 25.
	DefaultMaxStaples = 25
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStapleStorer

type InMemoryStapleStorer struct {
	Err error // can be set to simulate an error
	// contains filtered or unexported fields
}

InMemoryStapleStorer is a storer which uses a map as a storage backend.

func NewInMemoryStapleStorer

func NewInMemoryStapleStorer() InMemoryStapleStorer

NewInMemoryStapleStorer creates a new in memory storage medium.

func (InMemoryStapleStorer) Archive

func (p InMemoryStapleStorer) Archive(email string, stapleID int) error

Archive archives a staple.

func (InMemoryStapleStorer) Create

func (p InMemoryStapleStorer) Create(staple models.Staple, email string) error

Create will create a staple in the underlying in memory storage medium.

func (InMemoryStapleStorer) Delete

func (p InMemoryStapleStorer) Delete(email string, stapleID int) error

Delete removes a staple.

func (InMemoryStapleStorer) Get

func (p InMemoryStapleStorer) Get(email string, stapleID int) (*models.Staple, error)

Get retrieves a staple.

func (InMemoryStapleStorer) List

func (p InMemoryStapleStorer) List(email string) ([]models.Staple, error)

List gets all the not archived staples for a user. List will not retrieve the content since that can possibly be a large text. We only ever retrieve it when that specific staple is Get.

func (InMemoryStapleStorer) Oldest

func (p InMemoryStapleStorer) Oldest(email string) (*models.Staple, error)

Oldest will get the oldest staple that is not archived.

func (InMemoryStapleStorer) ShowArchive

func (p InMemoryStapleStorer) ShowArchive(email string) ([]models.Staple, error)

ShowArchive will return the users archived staples ordered by id.

type InMemoryUserStorer

type InMemoryUserStorer struct {
	Err error
	// contains filtered or unexported fields
}

InMemoryUserStorer is a storer which uses memory as a storage backend.

func NewInMemoryUserStorer

func NewInMemoryUserStorer() InMemoryUserStorer

NewInMemoryUserStorer creates a new in memory storage medium.

func (InMemoryUserStorer) Create

func (s InMemoryUserStorer) Create(email string, password []byte) error

Create saves a user in in memory.

func (InMemoryUserStorer) Delete

func (s InMemoryUserStorer) Delete(email string) error

Delete deletes a user from in memory.

func (InMemoryUserStorer) Get

func (s InMemoryUserStorer) Get(email string) (*models.User, error)

Get retrieves a user.

func (InMemoryUserStorer) Update

func (s InMemoryUserStorer) Update(email string, newUser models.User) error

Update updates a user with a given email address.

type PostgresStapleStorer

type PostgresStapleStorer struct{}

PostgresStapleStorer is a storer which uses Postgres as a storage backend.

func NewPostgresStapleStorer

func NewPostgresStapleStorer() PostgresStapleStorer

NewPostgresStapleStorer creates a new Postgres storage medium.

func (PostgresStapleStorer) Archive

func (p PostgresStapleStorer) Archive(email string, stapleID int) error

Archive archives a staple.

func (PostgresStapleStorer) Create

func (p PostgresStapleStorer) Create(staple models.Staple, email string) error

Create will create a staple in the underlying postgres storage medium.

func (PostgresStapleStorer) Delete

func (p PostgresStapleStorer) Delete(email string, stapleID int) error

Delete removes a staple.

func (PostgresStapleStorer) Get

func (p PostgresStapleStorer) Get(email string, stapleID int) (*models.Staple, error)

Get retrieves a staple.

func (PostgresStapleStorer) List

func (p PostgresStapleStorer) List(email string) ([]models.Staple, error)

List gets all the not archived staples for a user. List will not retrieve the content since that can possibly be a large text. We only ever retrieve it when that specific staple is Get.

func (PostgresStapleStorer) Oldest

func (p PostgresStapleStorer) Oldest(email string) (*models.Staple, error)

Oldest will get the oldest staple that is not archived.

func (PostgresStapleStorer) ShowArchive

func (p PostgresStapleStorer) ShowArchive(email string) ([]models.Staple, error)

ShowArchive will return the users archived staples ordered by id.

type PostgresUserStorer

type PostgresUserStorer struct{}

PostgresUserStorer is a storer which uses Postgres as a storage backend.

func NewPostgresUserStorer

func NewPostgresUserStorer() PostgresUserStorer

NewPostgresUserStorer creates a new Postgres storage medium.

func (PostgresUserStorer) Create

func (s PostgresUserStorer) Create(email string, password []byte) error

Create saves a user in the db.

func (PostgresUserStorer) Delete

func (s PostgresUserStorer) Delete(email string) error

Delete deletes a user from the db.

func (PostgresUserStorer) Get

func (s PostgresUserStorer) Get(email string) (*models.User, error)

Get retrieves a user.

func (PostgresUserStorer) Update

func (s PostgresUserStorer) Update(email string, newUser models.User) error

Update updates a user with a given email address.

type StapleStorer

type StapleStorer interface {
	Create(staple models.Staple, email string) error
	Delete(email string, stapleID int) error
	Get(email string, stapleID int) (*models.Staple, error)
	List(email string) ([]models.Staple, error)
	Archive(email string, stapleID int) error
	Oldest(email string) (*models.Staple, error)
	ShowArchive(email string) ([]models.Staple, error)
}

StapleStorer defines a set of functions for storing staples.

type UserStorer

type UserStorer interface {
	Create(email string, password []byte) error
	Delete(email string) error
	Get(email string) (*models.User, error)
	Update(email string, newUser models.User) error
}

UserStorer defines a set of functions for storing users.

Jump to

Keyboard shortcuts

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