repo

package
v1.0.1-0...-7ff242b Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound      = errors.New("mongo: task not found")
	ErrMongoNoConnection = errors.New("mongo: no connection")
	ErrRedisNoConnection = errors.New("redis: no connection")
	ErrErrorRequired     = errors.New("error message required")
	ErrDurationRequired  = errors.New("task duration required")
)

List of repo related errors

Functions

This section is empty.

Types

type TaskRepository

type TaskRepository struct {
	RedisConn *infra.RedisClient
	MongoConn *infra.MongoClient
	// contains filtered or unexported fields
}

TaskRepository contain necessary fields

func NewTaskRepo

func NewTaskRepo(redisCon *infra.RedisClient, mgoCon *infra.MongoClient) *TaskRepository

NewTaskRepo return a new TaskRepository instance

func (*TaskRepository) CloseClients

func (s *TaskRepository) CloseClients()

CloseClients close connection

func (*TaskRepository) CreateTask

func (s *TaskRepository) CreateTask(task *util.Task) error

CreateTask create a task object both in redis and mongo

func (*TaskRepository) DropIndices

func (s *TaskRepository) DropIndices() error

DropIndices drop all the listed indices

func (*TaskRepository) EnsureIndices

func (s *TaskRepository) EnsureIndices() error

EnsureIndices ensure listed indices

func (*TaskRepository) GetTask

func (s *TaskRepository) GetTask(id string) (*util.Task, error)

GetTask return a id from redis

func (*TaskRepository) Indices

func (s *TaskRepository) Indices() []infra.Index

Indices are indices

func (*TaskRepository) List

func (s *TaskRepository) List(v map[string]interface{}, startTime, endTime *time.Time, skip, limit int) ([]*util.Task, error)

List send a task list

func (*TaskRepository) ListByStatusBefore

func (s *TaskRepository) ListByStatusBefore(status util.Status, t time.Time, skip, limit int) ([]*util.Task, error)

ListByStatusBefore fetch a task list before time t

func (*TaskRepository) ListCountDateRangeInterval

func (s *TaskRepository) ListCountDateRangeInterval(startTime, endTime time.Time, interval int) ([]util.TaskDateRangeCount, error)

ListCountDateRangeInterval send a bucket list

func (*TaskRepository) UpdateRetryCount

func (s *TaskRepository) UpdateRetryCount(id string, count int)

UpdateRetryCount update task retry count field

func (*TaskRepository) UpdateTaskStatus

func (s *TaskRepository) UpdateTaskStatus(ctx context.Context, id string, status util.Status, args ...interface{})

UpdateTaskStatus update the task status

Jump to

Keyboard shortcuts

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