app

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 31 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.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryBool

func QueryBool(c echo.Context, name string) bool

QueryBool retrieves a boolean param from the gin request querystring

func QueryDefaultInteger

func QueryDefaultInteger(c echo.Context, name string, def int) (int, error)

QueryDefaultInt retrieves an integer param from the gin request querystring defaults to def argument if not found

func QueryInt

func QueryInt(c echo.Context, name string) int

QueryInt retrieves an integer param from the gin request querystring

func QueryString

func QueryString(c echo.Context, name string) string

QueryString retrieves a string param from the gin request querystring

func Setup

func Setup() error

func Start

func Start() error

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
	Reader    *reader.Reader
	Rift      *rift.Client
	Processor *Processor

	//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

	// Events
	Events *Events

	// Workers
	Workers *minion.Minion
}

func (*Application) Health

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

func (*Application) IndexersCreate

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

func (*Application) IndexersCreateHandler

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

func (*Application) IndexersDelete

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

func (*Application) IndexersDeleteHandler

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

func (*Application) IndexersIndex

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

func (*Application) IndexersIndexHandler

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

Indexers (/indexers)

func (*Application) IndexersSettings

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

func (*Application) IndexersSettingsHandler

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

func (*Application) IndexersShow

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

func (*Application) IndexersShowHandler

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

func (*Application) IndexersUpdate

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

func (*Application) IndexersUpdateHandler

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

func (*Application) JobsCreate

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

POST /minion/

func (*Application) JobsCreateHandler

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

func (*Application) JobsDelete

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

DELETE /minion/:id

func (*Application) JobsDeleteHandler

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

func (*Application) JobsIndex

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

GET /minion/

func (*Application) JobsIndexHandler

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

Jobs (/jobs)

func (*Application) JobsSettings

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

PATCH /minion/:id

func (*Application) JobsSettingsHandler

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

func (*Application) JobsShow

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

GET /minion/:id

func (*Application) JobsShowHandler

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

func (*Application) JobsUpdate

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

PUT /minion/:id

func (*Application) JobsUpdateHandler

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

func (*Application) ReleasesCreate

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

POST /releases/

func (*Application) ReleasesCreateHandler

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

func (*Application) ReleasesDelete

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

DELETE /releases/:id

func (*Application) ReleasesDeleteHandler

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

func (*Application) ReleasesIndex

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

GET /releases/

func (*Application) ReleasesIndexHandler

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

Releases (/releases)

func (*Application) ReleasesSettings

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

PATCH /releases/:id

func (*Application) ReleasesSettingsHandler

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

func (*Application) ReleasesShow

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

GET /releases/:id

func (*Application) ReleasesShowHandler

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

func (*Application) ReleasesUpdate

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

PUT /releases/:id

func (*Application) ReleasesUpdateHandler

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

func (*Application) Routes

func (a *Application) Routes()

func (*Application) SourcesCreate

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

func (*Application) SourcesCreateHandler

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

func (*Application) SourcesDelete

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

func (*Application) SourcesDeleteHandler

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

func (*Application) SourcesIndex

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

func (*Application) SourcesIndexHandler

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

Sources (/sources)

func (*Application) SourcesParse

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

func (*Application) SourcesParseHandler

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

func (*Application) SourcesRead

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

func (*Application) SourcesReadHandler

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

func (*Application) SourcesSearch

func (a *Application) SourcesSearch(c echo.Context, id string, query string, searchType string) error

func (*Application) SourcesSearchHandler

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

func (*Application) SourcesSettings

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

func (*Application) SourcesSettingsHandler

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

func (*Application) SourcesShow

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

func (*Application) SourcesShowHandler

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

func (*Application) SourcesUpdate

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

func (*Application) SourcesUpdateHandler

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

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"`

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

	// Events
	NatsURL string `env:"NATS_URL"`

	// 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"`
	MinionDatabase    string `env:"MINION_DATABASE"`
	MinionCollection  string `env:"MINION_COLLECTION"`

	RiftURL string   `env:"RIFT_URL"`
	Words   []string `env:"WORDS"`
}

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
	Indexer *grimoire.Store[*Indexer]
	Minion  *grimoire.Store[*Minion]
	Release *grimoire.Store[*Release]
}

func NewConnector

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

func (*Connector) IndexerActive

func (c *Connector) IndexerActive() ([]*Indexer, error)

func (*Connector) IndexerGet

func (c *Connector) IndexerGet(id string) (*Indexer, error)

func (*Connector) IndexerList

func (c *Connector) IndexerList(page, limit int) ([]*Indexer, int64, error)

func (*Connector) MinionGet

func (c *Connector) MinionGet(id string) (*Minion, error)

func (*Connector) MinionList

func (c *Connector) MinionList(limit, skip int) ([]*Minion, error)

func (*Connector) ReleaseGet

func (c *Connector) ReleaseGet(id string) (*Release, error)

func (*Connector) ReleaseList

func (c *Connector) ReleaseList(page, limit int) ([]*Release, int64, error)

func (*Connector) ReleaseSetting

func (c *Connector) ReleaseSetting(id, setting string, value bool) error

func (*Connector) ReleasesAll

func (c *Connector) ReleasesAll() ([]*Release, error)

type Count added in v0.3.0

type Count struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Count) Inc added in v0.3.0

func (c *Count) Inc()

type Events

type Events struct {
	App      *Application
	Merc     *mercury.Mercury
	Log      *zap.SugaredLogger
	Releases chan *Release
}

func NewEvents

func NewEvents(app *Application) (*Events, error)

func (*Events) Send

func (e *Events) Send(topic EventsTopic, data any) error

func (*Events) Start

func (e *Events) Start() error

type EventsChannel

type EventsChannel string

type EventsTopic

type EventsTopic string

type H

type H map[string]any

stolen from gin gonic H is a shortcut for map[string]any

func (H) MarshalXML

func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML allows type H to be used with xml.Marshal.

type Indexer

type Indexer 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"`
	Url         string    `bson:"url" json:"url"`
	Active      bool      `bson:"active" json:"active"`
	Categories  []int     `bson:"categories" json:"categories"`
	ProcessedAt time.Time `bson:"processed_at" json:"processed_at"`
}

type Minion

type Minion 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"`
	Kind     string           `bson:"kind" json:"kind"`
	Args     string           `bson:"args" json:"args"`
	Status   string           `bson:"status" json:"status"`
	Queue    string           `bson:"queue" json:"queue"`
	Attempts []*MinionAttempt `bson:"attempts" json:"attempts"`
}

type MinionAttempt

type MinionAttempt struct {
	StartedAt  time.Time `bson:"started_at" json:"started_at"`
	Duration   float64   `bson:"duration" json:"duration"`
	Status     string    `bson:"status" json:"status"`
	Error      string    `bson:"error" json:"error"`
	Stacktrace []string  `bson:"stacktrace" json:"stacktrace"`
}

type ParseActive

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

func (*ParseActive) Kind

func (j *ParseActive) Kind() string

func (*ParseActive) Work

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

type ParseIndexer

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

func (*ParseIndexer) Kind

func (j *ParseIndexer) Kind() string

func (*ParseIndexer) Work

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

type ParseRift

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

func (*ParseRift) Kind

func (j *ParseRift) Kind() string

func (*ParseRift) Work

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

type ParseRiftAll added in v0.3.0

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

func (*ParseRiftAll) Kind added in v0.3.0

func (j *ParseRiftAll) Kind() string

func (*ParseRiftAll) Work added in v0.3.0

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

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

func (*Processor) Parse

func (p *Processor) Parse(source string, categories []int) ([]*Release, error)

func (*Processor) Process

func (p *Processor) Process(source string, list []*newznab.NZB) ([]*Release, error)

type Release

type Release 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"`
	Source      string              `bson:"source" json:"source"`
	Title       string              `bson:"title" json:"title"`
	Year        int                 `bson:"year" json:"year"`
	Description string              `bson:"description" json:"description"`
	Size        int64               `bson:"size" json:"size"`
	View        string              `bson:"view" json:"view"`
	Download    string              `bson:"download" json:"download"`
	Infohash    string              `bson:"infohash" json:"infohash"`
	Season      int                 `bson:"season" json:"season"`
	Episode     int                 `bson:"episode" json:"episode"`
	Volume      int                 `bson:"volume" json:"volume"`
	Group       string              `bson:"group" json:"group"`
	Website     string              `bson:"website" json:"website"`
	Verified    bool                `bson:"verified" json:"verified"`
	Widescreen  bool                `bson:"widescreen" json:"widescreen"`
	Unrated     bool                `bson:"unrated" json:"unrated"`
	Uncensored  bool                `bson:"uncensored" json:"uncensored"`
	Bluray      bool                `bson:"bluray" json:"bluray"`
	ThreeD      bool                `bson:"threeD" json:"threeD"`
	Resolution  string              `bson:"resolution" json:"resolution"`
	Encodings   []string            `bson:"encodings" json:"encodings"`
	Quality     string              `bson:"quality" json:"quality"`
	Raw         *newznab.NZB        `bson:"raw" json:"raw"`
	Info        *parser.TorrentInfo `bson:"info" json:"info"`
	Downloader  string              `bson:"downloader" json:"downloader"`
	Checksum    string              `bson:"checksum" json:"checksum"`
	PublishedAt time.Time           `bson:"published_at" json:"published_at"`
}

func (*Release) Created

func (r *Release) Created(ctx context.Context) error

func (*Release) Updated

func (r *Release) Updated(ctx context.Context, result *mongo.UpdateResult) error

type RunicSourceSimple

type RunicSourceSimple struct {
	Name string `json:"name"`
	Type string `json:"type"`
	URL  string `json:"url"`
}

type Setting

type Setting struct {
	Key   string `json:"setting"`
	Value bool   `json:"value"`
}

type UpdateIndexes added in v0.3.0

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

func (*UpdateIndexes) Kind added in v0.3.0

func (j *UpdateIndexes) Kind() string

func (*UpdateIndexes) Timeout added in v0.3.0

func (j *UpdateIndexes) Timeout(job *minion.Job[*UpdateIndexes]) time.Duration

func (*UpdateIndexes) Work added in v0.3.0

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

Jump to

Keyboard shortcuts

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