app

package
v0.0.0-...-d6e48e4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextSet

func ContextSet(ctx context.Context, key string, value interface{}) context.Context

func Setup

func Setup() error

func Start

func Start() error

func TickTock

func TickTock(tag string) func()

func WithTimeout

func WithTimeout(delegate func() interface{}, timeout time.Duration) (ret interface{}, ok bool)

WithTimeout runs a delegate function with a timeout,

Example: Wait for a channel

if value, ok := WithTimeout(func()interface{}{return <- inbox}, time.Second); ok {
    // returned
} else {
    // didn't return
}

Example: To send to a channel

_, ok := WithTimeout(func()interface{}{outbox <- myValue; return nil}, time.Second)
if !ok {
    // didn't send
}

Types

type Application

type Application struct {
	Config *Config
	Log    *zap.SugaredLogger

	//golem:template:app/app_partial_definitions
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Routes
	Engine  *echo.Echo
	Default *echo.Group
	Router  *echo.Group

	// Models
	DB *Connector

	// Workers
	Workers *minion.Minion

	Plex *plexgo.PlexAPI
}

func ContextApp

func ContextApp(ctx context.Context) *Application

func (*Application) FileCreate

func (a *Application) FileCreate(c echo.Context, subject *File) error

POST /file/

func (*Application) FileCreateHandler

func (a *Application) FileCreateHandler(c echo.Context) error

func (*Application) FileDelete

func (a *Application) FileDelete(c echo.Context, id string) error

DELETE /file/:id

func (*Application) FileDeleteHandler

func (a *Application) FileDeleteHandler(c echo.Context) error

func (*Application) FileIndex

func (a *Application) FileIndex(c echo.Context, page int, limit int) error

GET /file/

func (*Application) FileIndexHandler

func (a *Application) FileIndexHandler(c echo.Context) error

File (/file)

func (*Application) FileSettings

func (a *Application) FileSettings(c echo.Context, id string, setting *Setting) error

PATCH /file/:id

func (*Application) FileSettingsHandler

func (a *Application) FileSettingsHandler(c echo.Context) error

func (*Application) FileShow

func (a *Application) FileShow(c echo.Context, id string) error

GET /file/:id

func (*Application) FileShowHandler

func (a *Application) FileShowHandler(c echo.Context) error

func (*Application) FileUpdate

func (a *Application) FileUpdate(c echo.Context, id string, subject *File) error

PUT /file/:id

func (*Application) FileUpdateHandler

func (a *Application) FileUpdateHandler(c echo.Context) error

func (*Application) Health

func (a *Application) Health() (map[string]bool, error)

func (*Application) LibraryCreate

func (a *Application) LibraryCreate(c echo.Context, subject *Library) error

POST /library/

func (*Application) LibraryCreateHandler

func (a *Application) LibraryCreateHandler(c echo.Context) error

func (*Application) LibraryDelete

func (a *Application) LibraryDelete(c echo.Context, id string) error

DELETE /library/:id

func (*Application) LibraryDeleteHandler

func (a *Application) LibraryDeleteHandler(c echo.Context) error

func (*Application) LibraryIndex

func (a *Application) LibraryIndex(c echo.Context, page int, limit int) error

GET /library/

func (*Application) LibraryIndexHandler

func (a *Application) LibraryIndexHandler(c echo.Context) error

Library (/library)

func (*Application) LibrarySettings

func (a *Application) LibrarySettings(c echo.Context, id string, setting *Setting) error

PATCH /library/:id

func (*Application) LibrarySettingsHandler

func (a *Application) LibrarySettingsHandler(c echo.Context) error

func (*Application) LibraryShow

func (a *Application) LibraryShow(c echo.Context, id string) error

GET /library/:id

func (*Application) LibraryShowHandler

func (a *Application) LibraryShowHandler(c echo.Context) error

func (*Application) LibraryTemplateCreate

func (a *Application) LibraryTemplateCreate(c echo.Context, subject *LibraryTemplate) error

POST /library_template/

func (*Application) LibraryTemplateCreateHandler

func (a *Application) LibraryTemplateCreateHandler(c echo.Context) error

func (*Application) LibraryTemplateDelete

func (a *Application) LibraryTemplateDelete(c echo.Context, id string) error

DELETE /library_template/:id

func (*Application) LibraryTemplateDeleteHandler

func (a *Application) LibraryTemplateDeleteHandler(c echo.Context) error

func (*Application) LibraryTemplateIndex

func (a *Application) LibraryTemplateIndex(c echo.Context, page int, limit int) error

GET /library_template/

func (*Application) LibraryTemplateIndexHandler

func (a *Application) LibraryTemplateIndexHandler(c echo.Context) error

LibraryTemplate (/library_template)

func (*Application) LibraryTemplateSettings

func (a *Application) LibraryTemplateSettings(c echo.Context, id string, setting *Setting) error

PATCH /library_template/:id

func (*Application) LibraryTemplateSettingsHandler

func (a *Application) LibraryTemplateSettingsHandler(c echo.Context) error

func (*Application) LibraryTemplateShow

func (a *Application) LibraryTemplateShow(c echo.Context, id string) error

GET /library_template/:id

func (*Application) LibraryTemplateShowHandler

func (a *Application) LibraryTemplateShowHandler(c echo.Context) error

func (*Application) LibraryTemplateUpdate

func (a *Application) LibraryTemplateUpdate(c echo.Context, id string, subject *LibraryTemplate) error

PUT /library_template/:id

func (*Application) LibraryTemplateUpdateHandler

func (a *Application) LibraryTemplateUpdateHandler(c echo.Context) error

func (*Application) LibraryTypeCreate

func (a *Application) LibraryTypeCreate(c echo.Context, subject *LibraryType) error

POST /library_type/

func (*Application) LibraryTypeCreateHandler

func (a *Application) LibraryTypeCreateHandler(c echo.Context) error

func (*Application) LibraryTypeDelete

func (a *Application) LibraryTypeDelete(c echo.Context, id string) error

DELETE /library_type/:id

func (*Application) LibraryTypeDeleteHandler

func (a *Application) LibraryTypeDeleteHandler(c echo.Context) error

func (*Application) LibraryTypeIndex

func (a *Application) LibraryTypeIndex(c echo.Context, page int, limit int) error

GET /library_type/

func (*Application) LibraryTypeIndexHandler

func (a *Application) LibraryTypeIndexHandler(c echo.Context) error

LibraryType (/library_type)

func (*Application) LibraryTypeSettings

func (a *Application) LibraryTypeSettings(c echo.Context, id string, setting *Setting) error

PATCH /library_type/:id

func (*Application) LibraryTypeSettingsHandler

func (a *Application) LibraryTypeSettingsHandler(c echo.Context) error

func (*Application) LibraryTypeShow

func (a *Application) LibraryTypeShow(c echo.Context, id string) error

GET /library_type/:id

func (*Application) LibraryTypeShowHandler

func (a *Application) LibraryTypeShowHandler(c echo.Context) error

func (*Application) LibraryTypeUpdate

func (a *Application) LibraryTypeUpdate(c echo.Context, id string, subject *LibraryType) error

PUT /library_type/:id

func (*Application) LibraryTypeUpdateHandler

func (a *Application) LibraryTypeUpdateHandler(c echo.Context) error

func (*Application) LibraryUpdate

func (a *Application) LibraryUpdate(c echo.Context, id string, subject *Library) error

PUT /library/:id

func (*Application) LibraryUpdateHandler

func (a *Application) LibraryUpdateHandler(c echo.Context) error

func (*Application) Routes

func (a *Application) Routes()

type Config

type Config struct {
	Mode   string `env:"MODE" envDefault:"dev"`
	Logger string `env:"LOGGER" envDefault:"dev"`
	Port   int    `env:"PORT" envDefault:"10080"`
	//golem:template:app/config_partial_struct
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Models (Database)
	Connections ConnectionSet `env:"CONNECTIONS,required"`

	// Router Auth
	Auth           bool   `env:"AUTH" envDefault:"false"`
	ClerkSecretKey string `env:"CLERK_SECRET_KEY"`
	ClerkToken     string `env:"CLERK_TOKEN"`

	// Workers
	MinionConcurrency int    `env:"MINION_CONCURRENCY" envDefault:"10"`
	MinionDebug       bool   `env:"MINION_DEBUG" envDefault:"false"`
	MinionBufferSize  int    `env:"MINION_BUFFER_SIZE" envDefault:"100"`
	MinionURI         string `env:"MINION_URI,required"`
	MinionDatabase    string `env:"MINION_DATABASE,required"`
	MinionCollection  string `env:"MINION_COLLECTION,required"`

	PlexToken          string   `env:"PLEX_TOKEN"`
	PlexURL            string   `env:"PLEX_URL"`
	PlexIdentifier     string   `env:"PLEX_IDENTIFIER"`
	WatcherDirectories []string `env:"WATCHER_DIRECTORIES" envSeparator:","`
}

func (*Config) ConnectionFor

func (c *Config) ConnectionFor(name string) (*Connection, error)

func (*Config) Validate

func (c *Config) Validate() error

type Connection

type Connection struct {
	URI        string `yaml:"uri,omitempty"`
	Database   string `yaml:"database,omitempty"`
	Collection string `yaml:"collection,omitempty"`
}

func (*Connection) UnmarshalText

func (c *Connection) UnmarshalText(text []byte) error

type ConnectionSet

type ConnectionSet map[string]*Connection

func (*ConnectionSet) UnmarshalText

func (c *ConnectionSet) UnmarshalText(text []byte) error

type Connector

type Connector struct {
	Log             *zap.SugaredLogger
	File            *grimoire.Store[*File]
	Library         *grimoire.Store[*Library]
	LibraryTemplate *grimoire.Store[*LibraryTemplate]
	LibraryType     *grimoire.Store[*LibraryType]
}

func NewConnector

func NewConnector(app *Application) (*Connector, error)

func (*Connector) FileCreateOrUpdate

func (c *Connector) FileCreateOrUpdate(path string) (*File, error)

func (*Connector) FileGet

func (c *Connector) FileGet(id string) (*File, error)

func (*Connector) FileList

func (c *Connector) FileList(page, limit int) ([]*File, error)

func (*Connector) LibraryGet

func (c *Connector) LibraryGet(id string) (*Library, error)

func (*Connector) LibraryGetByKind

func (c *Connector) LibraryGetByKind(kind string) (*Library, error)

func (*Connector) LibraryList

func (c *Connector) LibraryList(page, limit int) ([]*Library, error)

func (*Connector) LibraryTemplateGet

func (c *Connector) LibraryTemplateGet(id string) (*LibraryTemplate, error)

func (*Connector) LibraryTemplateList

func (c *Connector) LibraryTemplateList(page, limit int) ([]*LibraryTemplate, error)

func (*Connector) LibraryTypeGet

func (c *Connector) LibraryTypeGet(id string) (*LibraryType, error)

func (*Connector) LibraryTypeList

func (c *Connector) LibraryTypeList(page, limit int) ([]*LibraryType, error)

type File

type File struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Type       string             `bson:"type" json:"type" grimoire:"index"`
	Path       string             `bson:"path" json:"path" grimoire:"index"`
	Size       int64              `bson:"size" json:"size"`
	ModifiedAt int64              `bson:"modified_at" json:"modified_at"`
	MediumID   primitive.ObjectID `bson:"medium_id" json:"medium_id" grimoire:"index"`
}

type Library

type Library struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Name              string             `bson:"name" json:"name" grimoire:"index"`
	Path              string             `bson:"path" json:"path" grimoire:"index"`
	LibraryTypeID     primitive.ObjectID `bson:"library_type_id" json:"library_type_id"`
	LibraryTemplateID primitive.ObjectID `bson:"library_template_id" json:"library_template_id"`
	LibraryType       *LibraryType       `bson:"-" json:"library_type"`
	LibraryTemplate   *LibraryTemplate   `bson:"-" json:"library_template"`
}

type LibraryFiles

type LibraryFiles struct {
	minion.WorkerDefaults[*LibraryFiles]
	ID string `bson:"id" json:"id"`
}

func (*LibraryFiles) Kind

func (j *LibraryFiles) Kind() string

func (*LibraryFiles) Work

func (j *LibraryFiles) Work(ctx context.Context, job *minion.Job[*LibraryFiles]) error

type LibraryFilesAll

type LibraryFilesAll struct {
	minion.WorkerDefaults[*LibraryFilesAll]
}

func (*LibraryFilesAll) Kind

func (j *LibraryFilesAll) Kind() string

func (*LibraryFilesAll) Work

type LibraryTemplate

type LibraryTemplate struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Name     string `bson:"name" json:"name"`
	Template string `bson:"template" json:"template"`
}

type LibraryType

type LibraryType struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Name string `bson:"name" json:"name"`
}

type PlexFiles

type PlexFiles struct {
	minion.WorkerDefaults[*PlexFiles]
	ID string `bson:"id" json:"id"`
}

func (*PlexFiles) Kind

func (j *PlexFiles) Kind() string

func (*PlexFiles) Work

func (j *PlexFiles) Work(ctx context.Context, job *minion.Job[*PlexFiles]) error

type Response

type Response struct {
	Error   bool        `json:"error"`
	Message string      `json:"message,omitempty"`
	Result  interface{} `json:"result,omitempty"`
	Total   int64       `json:"total,omitempty"`
}

type Setting

type Setting struct {
	Name  string `json:"name"`
	Value bool   `json:"value"`
}

type SettingsBatch

type SettingsBatch struct {
	IDs   []string `json:"ids"`
	Name  string   `json:"name"`
	Value bool     `json:"value"`
}

Jump to

Keyboard shortcuts

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