app

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 30 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 FileCopy added in v0.9.0

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 added in v0.9.0

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 added in v0.9.0

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

QueryBool retrieves a boolean param from the gin request querystring

func QueryDefaultInteger added in v0.9.0

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 added in v0.9.0

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

func QueryInt added in v0.9.0

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

QueryInt retrieves an integer param from the gin request querystring

func QueryString added in v0.9.0

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

QueryString retrieves a string param from the gin request querystring

func Setup added in v0.9.0

func Setup() error

func Start added in v0.9.0

func Start() error

func Updates added in v0.9.0

func Updates() error

func WithTimeout added in v0.9.0

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

	// Events
	Events *Events

	// Workers
	Workers *minion.Minion

	//Cache
	Cache *Cache
}

func (*Application) Health added in v0.9.0

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

func (*Application) MetubeAdd added in v0.9.0

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

GET /metube/add

func (*Application) MetubeAddHandler added in v0.9.0

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

func (*Application) MetubeIndex added in v0.9.0

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

GET /metube/

func (*Application) MetubeIndexHandler added in v0.9.0

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

Metube (/metube)

func (*Application) MetubeRemove added in v0.9.0

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

GET /metube/remove

func (*Application) MetubeRemoveHandler added in v0.9.0

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

func (*Application) NzbsAdd added in v0.9.0

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

func (*Application) NzbsAddHandler added in v0.9.0

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

func (*Application) NzbsDestroy added in v0.9.0

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

func (*Application) NzbsDestroyHandler added in v0.9.0

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

func (*Application) NzbsHistory added in v0.9.0

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

func (*Application) NzbsHistoryHandler added in v0.9.0

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

func (*Application) NzbsIndex added in v0.9.0

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

func (*Application) NzbsIndexHandler added in v0.9.0

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

Nzbs (/nzbs)

func (*Application) NzbsPause added in v0.9.0

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

func (*Application) NzbsPauseAll added in v0.9.0

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

func (*Application) NzbsPauseHandler added in v0.9.0

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

func (*Application) NzbsRemove added in v0.9.0

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

func (*Application) NzbsRemoveHandler added in v0.9.0

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

func (*Application) NzbsResume added in v0.9.0

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

func (*Application) NzbsResumeAll added in v0.9.0

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

func (*Application) NzbsResumeHandler added in v0.9.0

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

func (*Application) QbittorrentsAdd added in v0.9.0

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

func (*Application) QbittorrentsAddHandler added in v0.9.0

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

func (*Application) QbittorrentsIndex added in v0.9.0

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

func (*Application) QbittorrentsIndexHandler added in v0.9.0

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

Qbittorrents (/qbittorrents)

func (*Application) QbittorrentsLabel added in v0.9.0

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

func (*Application) QbittorrentsLabelHandler added in v0.9.0

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

func (*Application) QbittorrentsPause added in v0.9.0

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

func (*Application) QbittorrentsPauseAll added in v0.9.0

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

func (*Application) QbittorrentsPauseHandler added in v0.9.0

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

func (*Application) QbittorrentsRemove added in v0.9.0

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

func (*Application) QbittorrentsRemoveHandler added in v0.9.0

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

func (*Application) QbittorrentsResume added in v0.9.0

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

func (*Application) QbittorrentsResumeAll added in v0.9.0

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

func (*Application) QbittorrentsResumeHandler added in v0.9.0

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

func (*Application) QbittorrentsWant added in v0.9.0

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

func (*Application) QbittorrentsWantHandler added in v0.9.0

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

func (*Application) QbittorrentsWantNone added in v0.9.0

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

func (*Application) QbittorrentsWanted added in v0.9.0

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

func (*Application) QbittorrentsWantedHandler added in v0.9.0

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

func (*Application) Routes added in v0.9.0

func (a *Application) Routes()

type Cache added in v0.9.0

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

func NewCache added in v0.9.0

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

func (*Cache) Close added in v0.9.0

func (c *Cache) Close() error

func (*Cache) Delete added in v0.9.0

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

func (*Cache) Fetch added in v0.9.0

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

func (*Cache) Get added in v0.9.0

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

func (*Cache) Set added in v0.9.0

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

type Combined added in v0.8.0

type Combined struct {
	Torrents  []*qbt.Torrent
	Nzbs      []nzbget.Group
	NzbStatus nzbget.Status
	Metrics   *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.
	// Cache
	RedisAddress string `env:"REDIS_ADDRESS"`

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

func (*Config) Validate

func (c *Config) Validate() error

type Events added in v0.9.0

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 added in v0.9.0

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

func (*Events) Send added in v0.9.0

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

func (*Events) Start added in v0.9.0

func (e *Events) Start() error

type EventsChannel added in v0.9.0

type EventsChannel string

type EventsTopic added in v0.9.0

type EventsTopic string

type H added in v0.9.0

type H map[string]any

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

func (H) MarshalXML added in v0.9.0

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

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

type Metrics added in v0.8.0

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

Jump to

Keyboard shortcuts

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