postgres

package
v0.0.0-...-430e8a6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyTasksModified

func AnyTasksModified(as map[int64]schedule.RecurringTask, bs []schedule.RecurringTask) bool

AnyTasksModified returns whether the map of recurring tasks contains all entries in the slice of recurring tasks

Types

type DBConn

type DBConn struct {
	Host              string
	Port              int
	User              string
	Password          string
	Name              string
	MaxRetryAttempts  int
	RetrySleepSeconds int
	DB                *sql.DB

	AppName string
	// contains filtered or unexported fields
}

DBConn contains DB connection data

func NewDBConn

func NewDBConn(l Logger, appName string) DBConn

NewDBConn creates struct with default DB connection info, and overrides with environment variables if set

func (*DBConn) Close

func (conn *DBConn) Close() error

Close closes the wrapped DB connection

func (*DBConn) Connect

func (conn *DBConn) Connect() (err error)

Connect opens and ping-checks a DB connection

func (*DBConn) Setup

func (conn *DBConn) Setup() (setup bool, err error)

Setup sets up initial DB schema

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Logger interface needed for postgres log messages

type ScheduleRepo

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

ScheduleRepo persists schedule data in a PostgreSQL DB

func NewScheduleRepo

func NewScheduleRepo(conn DBConn) (repo *ScheduleRepo, err error)

NewScheduleRepo instantiates a new ScheduleRepo

func (*ScheduleRepo) Add

Add adds a schedule to the persisence layer

func (*ScheduleRepo) Get

Get retrieves a schedule aggregate, given its persistent ID

func (*ScheduleRepo) GetAll

GetAll retrieves all schedules

func (*ScheduleRepo) GetAllForUser

func (r *ScheduleRepo) GetAllForUser(uid user.ID) (map[usecase.ScheduleID]*schedule.Schedule, usecase.Error)

GetAllForUser retrieves all schedules created by the given user

func (*ScheduleRepo) GetAllScheduled

func (r *ScheduleRepo) GetAllScheduled() (map[usecase.ScheduleID]*schedule.Schedule, usecase.Error)

GetAllScheduled retrieves all unpaused schedules that haven't been removed

func (*ScheduleRepo) GetForUser

func (r *ScheduleRepo) GetForUser(id usecase.ScheduleID, uid user.ID) (*schedule.Schedule, usecase.Error)

GetForUser retrieves a schedule entity for a user, given its persistent ID

func (*ScheduleRepo) Update

Update updates a schedule's persistent data to the given aggregate values

type TaskRepo

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

TaskRepo handles persisting task data and maintaining an in-memory cache

func NewTaskRepo

func NewTaskRepo(conn DBConn) (repo *TaskRepo, err error)

NewTaskRepo instantiates a new TaskRepo

func (*TaskRepo) Add

func (r *TaskRepo) Add(t *task.Task) (usecase.TaskID, usecase.Error)

Add adds a task to the persisence layer

func (*TaskRepo) Get

func (r *TaskRepo) Get(id usecase.TaskID) (*task.Task, usecase.Error)

Get retrieves a task entity, given its persistent ID

func (*TaskRepo) GetAll

func (r *TaskRepo) GetAll() (map[usecase.TaskID]*task.Task, usecase.Error)

GetAll retrieves all tasks

func (*TaskRepo) GetAllForUser

func (r *TaskRepo) GetAllForUser(uid user.ID) (map[usecase.TaskID]*task.Task, usecase.Error)

GetAllForUser retrieves all tasks for a user

func (*TaskRepo) GetForUser

func (r *TaskRepo) GetForUser(id usecase.TaskID, uid user.ID) (*task.Task, usecase.Error)

GetForUser retrieves a task entity, given its persistent ID and user ID

func (*TaskRepo) Update

func (r *TaskRepo) Update(id usecase.TaskID, t *task.Task) usecase.Error

Update updates a task's persistent data to the given entity values

type UserRepo

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

UserRepo handles persisting user data

func NewUserRepo

func NewUserRepo(conn DBConn) (repo *UserRepo, err error)

NewUserRepo instantiates a new UserRepo

func (*UserRepo) AddExternal

func (r *UserRepo) AddExternal(u *user.User, providerID string, externalID string) usecase.Error

AddExternal adds a user and associates it to a provider and external ID

func (*UserRepo) GetExternal

func (r *UserRepo) GetExternal(providerID string, externalID string) (*user.User, usecase.Error)

GetExternal gets a user given its provider and external ID

func (*UserRepo) Update

func (r *UserRepo) Update(u *user.User) usecase.Error

Update updates a user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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