db

package
v0.0.0-...-4ecb97e Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = fmt.Errorf("not found")
	ErrTooManyHits = fmt.Errorf("found too many hits")
)

Functions

func Bootstrap

func Bootstrap(ctx context.Context, dbal Dbal) error

Types

type Dbal

type Dbal interface {
	// newConnection create a connection and store it
	NewConnection(address string) error
	// Ping try to get info from the nodes and return an error if it failed
	Ping() error
	// CreateIndexes initialize needed indexes
	CreateIndexes(ctx context.Context) error

	// User index methods:
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByID(ctx context.Context, id string) (User, error)
	CreateUser(ctx context.Context, user User) error
	DeleteUser(ctx context.Context, id string) error

	// Task index methods:
	GetNextTask(ctx context.Context) (*Task, error)
	GetTasksByUserID(ctx context.Context, id string) ([]Task, error)
	UpdateTaskLogs(ctx context.Context, taskID string, logs string) error
	UpdateTaskStatus(ctx context.Context, taskID string, status Status) error
	DeleteTaskByID(ctx context.Context, id string) error
	DeleteTasksBysUserID(ctx context.Context, userId string) error
	CreateTask(ctx context.Context, task Task) error
}

Dbal for DataBase Abstracted Layer

func NewDatabaseAbstractedLayerImplemented

func NewDatabaseAbstractedLayerImplemented(log logger.Logger, cf conf.Configuration) (Dbal, error)

type ErrAlreadyExist

type ErrAlreadyExist string

func (ErrAlreadyExist) Error

func (e ErrAlreadyExist) Error() string

func (ErrAlreadyExist) Ptr

type Itr

type Itr func(*elastic.SearchHit) error

type Job

type Job struct {
	DockerImage string   `json:"docker_image"`
	Dataset     string   `json:"dataset"`
	Env         []string `json:"env"`
}

func (Job) Ptr

func (j Job) Ptr() *Job

type Status

type Status string
const (
	StatusStatusless Status = "STATUSLESS"
	StatusFailed     Status = "FAILED"
	StatusNotStarted Status = "NOT_STARTED"
	StatusRunning    Status = "RUNNING"
	StatusEnded      Status = "ENDED"
	StatusCanceled   Status = "CANCELED"
)

func (Status) IsValid

func (e Status) IsValid() bool

func (Status) MarshalGQL

func (e Status) MarshalGQL(w io.Writer)

func (Status) String

func (e Status) String() string

func (*Status) UnmarshalGQL

func (e *Status) UnmarshalGQL(v interface{}) error

type Task

type Task struct {
	ID        string    `json:"id"`
	UserId    string    `json:"user_id"`
	CreatedAt time.Time `json:"created_at"`
	StartedAt time.Time `json:"started_at"`
	EndedAt   time.Time `json:"ended_at"`
	Status    Status    `json:"status"`
	Job       Job       `json:"job"`
}

func (Task) Ptr

func (t Task) Ptr() *Task

type User

type User struct {
	ID        string    `json:"id"`
	Admin     bool      `json:"admin"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
}

func (User) Ptr

func (u User) Ptr() *User

Directories

Path Synopsis
Package mock_db is a generated GoMock package.
Package mock_db is a generated GoMock package.

Jump to

Keyboard shortcuts

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