app

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileCopy

func FileCopy(srcpath, dstpath string) (err error)

https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file Copy copies the contents of the file at srcpath to a regular file at dstpath. If dstpath already exists and is not a directory, the function truncates it. The function does not copy file modes or file attributes.

func FileDir

func FileDir(file string) error
func FileLink(srcpath, dstpath string, force bool) error

FileLink creates hard link, if destination exists and force is true, it will remove the destination before linking

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 QueryDefaultString

func QueryDefaultString(c echo.Context, name, def string) string

func QueryInt

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

QueryInt retrieves an integer param from the gin request querystring

func QueryParamBool

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

QueryParamBool retrieves a boolean param from the gin request querystring

func QueryParamBoolDefault

func QueryParamBoolDefault(c echo.Context, name string, def string) bool

func QueryParamFloatDefault

func QueryParamFloatDefault(c echo.Context, name string, def string) float64

func QueryParamInt

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

QueryParamInt retrieves an integer param from the gin request querystring

func QueryParamIntDefault

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

func QueryParamString

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

QueryParamString retrieves a string param from the gin request querystring

func QueryParamStringDefault

func QueryParamStringDefault(c echo.Context, name string, def string) string

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 Updates

func Updates() 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

	Nzb    *nzbget.Client
	Qbt    *qbt.Api
	Metube *metube.Client

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

	//Cache
	Cache *Cache
}

func (*Application) Health

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

func (*Application) MetubeAdd

func (a *Application) MetubeAdd(c echo.Context, url string, name string, autoStart bool) error

GET /metube/add

func (*Application) MetubeAddHandler

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

func (*Application) MetubeIndex

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

GET /metube/

func (*Application) MetubeIndexHandler

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

Metube (/metube)

func (*Application) MetubeRemove

func (a *Application) MetubeRemove(c echo.Context, name string, where string) error

GET /metube/remove

func (*Application) MetubeRemoveHandler

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

func (*Application) NzbsAdd

func (a *Application) NzbsAdd(c echo.Context, URL, cat, name string) error

func (*Application) NzbsAddHandler

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

func (*Application) NzbsDestroy

func (a *Application) NzbsDestroy(c echo.Context, id int) error

func (*Application) NzbsDestroyHandler

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

func (*Application) NzbsHistory

func (a *Application) NzbsHistory(c echo.Context, hidden bool) error

func (*Application) NzbsHistoryHandler

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

func (*Application) NzbsIndex

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

func (*Application) NzbsIndexHandler

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

Nzbs (/nzbs)

func (*Application) NzbsPause

func (a *Application) NzbsPause(c echo.Context, id int) error

func (*Application) NzbsPauseAll

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

func (*Application) NzbsPauseHandler

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

func (*Application) NzbsRemove

func (a *Application) NzbsRemove(c echo.Context, id int) error

func (*Application) NzbsRemoveHandler

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

func (*Application) NzbsResume

func (a *Application) NzbsResume(c echo.Context, id int) error

func (*Application) NzbsResumeAll

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

func (*Application) NzbsResumeHandler

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

func (*Application) QbittorrentsAdd

func (a *Application) QbittorrentsAdd(c echo.Context, URL string) error

func (*Application) QbittorrentsAddHandler

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

func (*Application) QbittorrentsIndex

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

func (*Application) QbittorrentsIndexHandler

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

Qbittorrents (/qbittorrents)

func (*Application) QbittorrentsLabel

func (a *Application) QbittorrentsLabel(c echo.Context, infohash, label string) error

func (*Application) QbittorrentsLabelHandler

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

func (*Application) QbittorrentsPause

func (a *Application) QbittorrentsPause(c echo.Context, infohash string) error

func (*Application) QbittorrentsPauseAll

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

func (*Application) QbittorrentsPauseHandler

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

func (*Application) QbittorrentsRemove

func (a *Application) QbittorrentsRemove(c echo.Context, infohash string, del bool) error

func (*Application) QbittorrentsRemoveHandler

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

func (*Application) QbittorrentsResume

func (a *Application) QbittorrentsResume(c echo.Context, infohash string) error

func (*Application) QbittorrentsResumeAll

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

func (*Application) QbittorrentsResumeHandler

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

func (*Application) QbittorrentsWant

func (a *Application) QbittorrentsWant(c echo.Context, infohash, files string) error

func (*Application) QbittorrentsWantHandler

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

func (*Application) QbittorrentsWantNone

func (a *Application) QbittorrentsWantNone(c echo.Context, infohash string) error

func (*Application) QbittorrentsWanted

func (a *Application) QbittorrentsWanted(c echo.Context, infohash string) error

func (*Application) QbittorrentsWantedHandler

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

func (*Application) Routes

func (a *Application) Routes()

type Cache

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

func NewCache

func NewCache(log *zap.SugaredLogger, options kv.Options) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Delete

func (c *Cache) Delete(k string) error

func (*Cache) Fetch

func (c *Cache) Fetch(k string, v interface{}, f func() (interface{}, error)) (bool, error)

func (*Cache) Get

func (c *Cache) Get(k string, v interface{}) (bool, error)

func (*Cache) Set

func (c *Cache) Set(k string, v interface{}) error

type Combined

type Combined struct {
	Torrents  []*qbt.Torrent `bson:"torrents" json:"torrents"`
	Nzbs      []nzbget.Group `bson:"nzbs" json:"nzbs"`
	NzbStatus *nzbget.Status `bson:"nzb_status" json:"nzb_status"`
	Metrics   *Metrics       `bson:"metrics" json:"metrics"`
}

type Config

type Config struct {
	Mode                string `env:"MODE" envDefault:"dev"`
	Logger              string `env:"LOGGER" envDefault:"dev"`
	Port                int    `env:"PORT" envDefault:"10080"`
	QbittorrentURL      string `env:"QBITTORRENT_URL"`
	QbittorrentUsername string `env:"QBITTORRENT_USERNAME"`
	QbittorrentPassword string `env:"QBITTORRENT_PASSWORD"`
	MetubeURL           string `env:"METUBE_URL"`
	NzbgetURL           string `env:"NZBGET_URL"`
	RedisHost           string `env:"REDIS_HOST"`
	RedisPort           string `env:"REDIS_PORT"`
	RedisDatabase       int    `env:"REDIS_DATABASE"`

	//golem:template:app/config_partial_struct
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Models (Database)
	Connections ConnectionSet `env:"CONNECTIONS"`

	// Cache
	RedisAddress string `env:"REDIS_ADDRESS"`

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

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

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
}

func NewConnector

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

type Events

type Events struct {
	App          *Application
	Merc         *mercury.Mercury
	Log          *zap.SugaredLogger
	Combined     chan *Combined
	Metrics      chan *Metrics
	Nzbs         chan *nzbget.GroupResponse
	Qbittorrents chan *qbt.Response
}

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 Metrics

type Metrics struct {
	Diskspace string `bson:"diskspace" json:"diskspace"`
	Torrents  struct {
		DownloadRate string `json:"download_rate"`
		UploadRate   string `json:"upload_rate"`
	} `bson:"torrents" json:"torrents"`
	Nzbs struct {
		DownloadRate string `json:"download_rate"`
	} `bson:"nzbs" json:"nzbs"`
}

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