backend

package
v0.0.0-...-bbd37fe Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResource

func NewResource[T Resource]() T

Types

type BarSetLoader

type BarSetLoader struct {
	Symbol   string
	Location *time.Location
	Store    Store[*models.BarSet]
}

func NewBarSetLoader

func NewBarSetLoader(
	db *mongo.Database,
	symbol string,
	loc *time.Location,
) *BarSetLoader

func (*BarSetLoader) Load

func (l *BarSetLoader) Load(ctx context.Context, d date.Date) (models.Bars, 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]) GetAllKeys

func (s *MongoStore[T]) GetAllKeys(ctx context.Context) ([]string, 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)
	GetAllKeys(ctx context.Context) ([]string, Error)
	Update(ctx context.Context, val T) Error
}

func NewMongoStore

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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