app

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 28 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 ContextSet

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

func ParseFulltitle

func ParseFulltitle(title string) (int, int)

func ParseURL

func ParseURL(url string) (int, int)

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

	// Events
	Events *Events

	// Workers
	Workers *minion.Minion
}

func ContextApp

func ContextApp(ctx context.Context) *Application

func (*Application) Health

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

func (*Application) PageCreate

func (a *Application) PageCreate(c echo.Context, req *Page) error

POST /page/

func (*Application) PageCreateHandler

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

func (*Application) PageDelete

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

DELETE /page/:id

func (*Application) PageDeleteHandler

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

func (*Application) PageIndex

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

GET /page/

func (*Application) PageIndexHandler

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

Page (/page)

func (*Application) PageRefresh

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

func (*Application) PageRefreshHandler

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

func (*Application) PageSettings

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

PATCH /page/:id

func (*Application) PageSettingsHandler

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

func (*Application) PageShow

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

GET /page/:id

func (*Application) PageShowHandler

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

func (*Application) PageUpdate

func (a *Application) PageUpdate(c echo.Context, id string, req *Page) error

PUT /page/:id

func (*Application) PageUpdateHandler

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

func (*Application) PageVideos

func (a *Application) PageVideos(c echo.Context, id string, page int, limit int) error

GET /page/:id/videos

func (*Application) PageVideosHandler

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

func (*Application) PageVisits

func (a *Application) PageVisits(c echo.Context, id string, page int, limit int) error

GET /page/:id/visits

func (*Application) PageVisitsHandler

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

func (*Application) Routes

func (a *Application) Routes()

func (*Application) VideoCreate

func (a *Application) VideoCreate(c echo.Context, video *Video) error

POST /video/

func (*Application) VideoCreateHandler

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

func (*Application) VideoDelete

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

DELETE /video/:id

func (*Application) VideoDeleteHandler

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

func (*Application) VideoIndex

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

GET /video/

func (*Application) VideoIndexHandler

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

Video (/video)

func (*Application) VideoSettings

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

PATCH /video/:id

func (*Application) VideoSettingsHandler

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

func (*Application) VideoShow

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

GET /video/:id

func (*Application) VideoShowHandler

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

func (*Application) VideoUpdate

func (a *Application) VideoUpdate(c echo.Context, id string, video *Video) error

PUT /video/:id

func (*Application) VideoUpdateHandler

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

func (*Application) VisitCreate

func (a *Application) VisitCreate(c echo.Context, visit *Visit) error

POST /visit/

func (*Application) VisitCreateHandler

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

func (*Application) VisitDelete

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

DELETE /visit/:id

func (*Application) VisitDeleteHandler

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

func (*Application) VisitIndex

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

GET /visit/

func (*Application) VisitIndexHandler

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

Visit (/visit)

func (*Application) VisitSettings

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

PATCH /visit/:id

func (*Application) VisitSettingsHandler

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

func (*Application) VisitShow

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

GET /visit/:id

func (*Application) VisitShowHandler

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

func (*Application) VisitUpdate

func (a *Application) VisitUpdate(c echo.Context, id string, visit *Visit) error

PUT /visit/:id

func (*Application) VisitUpdateHandler

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

type Config

type Config struct {
	Production bool   `env:"PRODUCTION" envDefault:"false"`
	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"`

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

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

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
	Page  *grimoire.Store[*Page]
	Video *grimoire.Store[*Video]
	Visit *grimoire.Store[*Visit]
}

func NewConnector

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

func (*Connector) IsVisited

func (c *Connector) IsVisited(page *Page, url string) (bool, error)

func (*Connector) PageExists

func (c *Connector) PageExists(name string) bool

func (*Connector) PageGet

func (c *Connector) PageGet(id string) (*Page, error)

func (*Connector) PageList

func (c *Connector) PageList() ([]*Page, error)

func (*Connector) VideoFindOrCreate

func (c *Connector) VideoFindOrCreate(displayID string) (*Video, error)

func (*Connector) VideoGet

func (c *Connector) VideoGet(id string) (*Video, error)

func (*Connector) VideoList

func (c *Connector) VideoList() ([]*Video, error)

func (*Connector) VisitError

func (c *Connector) VisitError(page *Page, url string, failure *fae.Error) error

func (*Connector) VisitGet

func (c *Connector) VisitGet(id string) (*Visit, error)

func (*Connector) VisitList

func (c *Connector) VisitList() ([]*Visit, error)

type Events

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

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(ctx context.Context) 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 Page

type Page 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"`
	URL         string    `bson:"url" json:"url"`
	Scraper     string    `bson:"scraper" json:"scraper" grimoire:"index"`
	Downloader  string    `bson:"downloader" json:"downloader" grimoire:"index"`
	Enabled     bool      `bson:"enabled" json:"enabled"`
	ProcessedAt time.Time `bson:"processed_at" json:"processed_at"`
}

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 ScrapeAll

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

func (*ScrapeAll) Kind

func (j *ScrapeAll) Kind() string

func (*ScrapeAll) Work

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

type ScrapePage

type ScrapePage struct {
	minion.WorkerDefaults[*ScrapePage]
	Title string `json:"title"`
	Page  *Page  `json:"page"`
}

func (*ScrapePage) Kind

func (j *ScrapePage) Kind() string

func (*ScrapePage) Work

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

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

type Video

type Video 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"`
	PageID     primitive.ObjectID `bson:"page_id" json:"page_id" grimoire:"index"`
	Title      string             `bson:"title" json:"title" grimoire:"index"`
	Season     int                `bson:"season" json:"season"`
	Episode    int                `bson:"episode" json:"episode"`
	Raw        string             `bson:"raw" json:"raw"`
	DisplayID  string             `bson:"display_id" json:"display_id"`
	Extension  string             `bson:"extension" json:"extension"`
	Resolution int                `bson:"resolution" json:"resolution"`
	Size       int64              `bson:"size" json:"size"`
	Download   string             `bson:"download" json:"download"`
	View       string             `bson:"view" json:"view"`
	Source     string             `bson:"source" json:"source" grimoire:"index"`
}

func (*Video) Created

func (v *Video) Created(ctx context.Context) error

func (*Video) Updated

func (v *Video) Updated(ctx context.Context, result *mongo.UpdateResult) error

type Visit

type Visit 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"`
	PageID     primitive.ObjectID `bson:"page_id" json:"page_id" grimoire:"index"`
	URL        string             `bson:"url" json:"url"`
	Error      string             `bson:"error" json:"error"`
	Stacktrace []string           `bson:"stacktrace" json:"stacktrace"`
}

type YtdlpList

type YtdlpList struct {
	minion.WorkerDefaults[*YtdlpList]
	PageID  primitive.ObjectID
	Name    string
	Season  int
	Episode int
	URL     string
}

func (*YtdlpList) Kind

func (j *YtdlpList) Kind() string

func (*YtdlpList) Work

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

type YtdlpParse

type YtdlpParse struct {
	minion.WorkerDefaults[*YtdlpParse]
	PageID  primitive.ObjectID
	Source  string
	URL     string
	Info    *ytdlp.Info
	Name    string
	Season  int
	Episode int
}

func (*YtdlpParse) Kind

func (j *YtdlpParse) Kind() string

func (*YtdlpParse) Work

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

Jump to

Keyboard shortcuts

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