app

package
v0.0.0-...-5d55e2f Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDayBarsLoader

func NewDayBarsLoader(
	db *mongo.Database,
	symbol string,
	loc *time.Location,
) models.DayBarsLoader

func NewResource

func NewResource[T Resource]() T

Types

type DayBarsLoader

type DayBarsLoader struct {
	Symbol   string
	Location *time.Location
	Store    Store[*models.DayBars]
}

func (*DayBarsLoader) Load

func (l *DayBarsLoader) Load(ctx context.Context, d date.Date) (*models.DayBars, error)

type Error

type Error interface {
	error

	GetType() ErrorType
	GetMessage() string
	GetDetails() []string
}

func NewErrActionFailed

func NewErrActionFailed(action string, reason string) Error

func NewErrInvalidInput

func NewErrInvalidInput(name string, reasons ...string) Error

func NewErrNotFound

func NewErrNotFound(what string) Error

type ErrorType

type ErrorType int
const (
	ActionFailed ErrorType = iota
	InvalidInput
	NotFound
)

func (ErrorType) String

func (t ErrorType) String() string

type MongoStore

type MongoStore[T Resource] struct {
	// contains filtered or unexported fields
}

func (*MongoStore[T]) Create

func (s *MongoStore[T]) Create(ctx context.Context, val T) Error

func (*MongoStore[T]) Delete

func (s *MongoStore[T]) Delete(ctx context.Context, key string) Error

func (*MongoStore[T]) Get

func (s *MongoStore[T]) Get(ctx context.Context, key string) (T, Error)

func (*MongoStore[T]) GetAll

func (s *MongoStore[T]) GetAll(ctx context.Context) ([]T, Error)

func (*MongoStore[T]) GetInfo

func (s *MongoStore[T]) GetInfo() *ResourceInfo

func (*MongoStore[T]) Reset

func (s *MongoStore[T]) Reset(ctx context.Context) Error

func (*MongoStore[T]) Update

func (s *MongoStore[T]) Update(ctx context.Context, val T) Error

type Resource

type Resource interface {
	Validate() []error
	GetKey() string
}

type ResourceInfo

type ResourceInfo struct {
	KeyName    string
	Name       string
	NamePlural string
}

func (*ResourceInfo) NewErrNotFound

func (rdef *ResourceInfo) NewErrNotFound(key string) Error

type Store

type Store[T Resource] interface {
	GetInfo() *ResourceInfo

	Reset(ctx context.Context) Error
	Create(ctx context.Context, val T) Error
	Delete(ctx context.Context, key string) Error
	Get(ctx context.Context, key string) (T, Error)
	GetAll(ctx context.Context) ([]T, Error)
	Update(ctx context.Context, val T) Error
}

func NewMongoStore

func NewMongoStore[T Resource](
	info *ResourceInfo,
	col *mongo.Collection,
) Store[T]

Directories

Path Synopsis
backend
api
env

Jump to

Keyboard shortcuts

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