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 ¶
- func ContextSet(ctx context.Context, key string, value interface{}) context.Context
- func ParseFulltitle(title string) (int, int)
- func ParseURL(url string) (int, int)
- func QueryBool(c echo.Context, name string) bool
- func QueryDefaultInteger(c echo.Context, name string, def int) (int, error)
- func QueryDefaultString(c echo.Context, name, def string) string
- func QueryInt(c echo.Context, name string) int
- func QueryParamBool(c echo.Context, name string) bool
- func QueryParamBoolDefault(c echo.Context, name string, def string) bool
- func QueryParamFloatDefault(c echo.Context, name string, def string) float64
- func QueryParamInt(c echo.Context, name string) int
- func QueryParamIntDefault(c echo.Context, name string, def string) int
- func QueryParamString(c echo.Context, name string) string
- func QueryParamStringDefault(c echo.Context, name string, def string) string
- func QueryString(c echo.Context, name string) string
- func Setup() error
- func Start() error
- func WithTimeout(delegate func() interface{}, timeout time.Duration) (ret interface{}, ok bool)
- type Application
- func (a *Application) Health() (map[string]bool, error)
- func (a *Application) PageCreate(c echo.Context, req *Page) error
- func (a *Application) PageCreateHandler(c echo.Context) error
- func (a *Application) PageDelete(c echo.Context, id string) error
- func (a *Application) PageDeleteHandler(c echo.Context) error
- func (a *Application) PageIndex(c echo.Context, page int, limit int) error
- func (a *Application) PageIndexHandler(c echo.Context) error
- func (a *Application) PageRefresh(c echo.Context, id string) error
- func (a *Application) PageRefreshHandler(c echo.Context) error
- func (a *Application) PageSettings(c echo.Context, id string, setting *Setting) error
- func (a *Application) PageSettingsHandler(c echo.Context) error
- func (a *Application) PageShow(c echo.Context, id string) error
- func (a *Application) PageShowHandler(c echo.Context) error
- func (a *Application) PageUpdate(c echo.Context, id string, req *Page) error
- func (a *Application) PageUpdateHandler(c echo.Context) error
- func (a *Application) PageVideos(c echo.Context, id string, page int, limit int) error
- func (a *Application) PageVideosHandler(c echo.Context) error
- func (a *Application) PageVisits(c echo.Context, id string, page int, limit int) error
- func (a *Application) PageVisitsHandler(c echo.Context) error
- func (a *Application) Routes()
- func (a *Application) VideoCreate(c echo.Context, video *Video) error
- func (a *Application) VideoCreateHandler(c echo.Context) error
- func (a *Application) VideoDelete(c echo.Context, id string) error
- func (a *Application) VideoDeleteHandler(c echo.Context) error
- func (a *Application) VideoIndex(c echo.Context, page int, limit int) error
- func (a *Application) VideoIndexHandler(c echo.Context) error
- func (a *Application) VideoSettings(c echo.Context, id string, setting *Setting) error
- func (a *Application) VideoSettingsHandler(c echo.Context) error
- func (a *Application) VideoShow(c echo.Context, id string) error
- func (a *Application) VideoShowHandler(c echo.Context) error
- func (a *Application) VideoUpdate(c echo.Context, id string, video *Video) error
- func (a *Application) VideoUpdateHandler(c echo.Context) error
- func (a *Application) VisitCreate(c echo.Context, visit *Visit) error
- func (a *Application) VisitCreateHandler(c echo.Context) error
- func (a *Application) VisitDelete(c echo.Context, id string) error
- func (a *Application) VisitDeleteHandler(c echo.Context) error
- func (a *Application) VisitIndex(c echo.Context, page int, limit int) error
- func (a *Application) VisitIndexHandler(c echo.Context) error
- func (a *Application) VisitSettings(c echo.Context, id string, setting *Setting) error
- func (a *Application) VisitSettingsHandler(c echo.Context) error
- func (a *Application) VisitShow(c echo.Context, id string) error
- func (a *Application) VisitShowHandler(c echo.Context) error
- func (a *Application) VisitUpdate(c echo.Context, id string, visit *Visit) error
- func (a *Application) VisitUpdateHandler(c echo.Context) error
- type Config
- type Connection
- type ConnectionSet
- type Connector
- func (c *Connector) IsVisited(page *Page, url string) (bool, error)
- func (c *Connector) PageExists(name string) bool
- func (c *Connector) PageGet(id string) (*Page, error)
- func (c *Connector) PageList() ([]*Page, error)
- func (c *Connector) VideoFindOrCreate(displayID string) (*Video, error)
- func (c *Connector) VideoGet(id string) (*Video, error)
- func (c *Connector) VideoList() ([]*Video, error)
- func (c *Connector) VisitError(page *Page, url string, failure *fae.Error) error
- func (c *Connector) VisitGet(id string) (*Visit, error)
- func (c *Connector) VisitList() ([]*Visit, error)
- type Events
- type EventsChannel
- type EventsTopic
- type H
- type Page
- type Response
- type ScrapeAll
- type ScrapePage
- type Setting
- type SettingsBatch
- type Video
- type Visit
- type YtdlpList
- type YtdlpParse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextSet ¶
func ParseFulltitle ¶
func QueryDefaultInteger ¶
QueryDefaultInt retrieves an integer param from the gin request querystring defaults to def argument if not found
func QueryParamBool ¶
QueryParamBool retrieves a boolean param from the gin request querystring
func QueryParamBoolDefault ¶
func QueryParamFloatDefault ¶
func QueryParamInt ¶
QueryParamInt retrieves an integer param from the gin request querystring
func QueryParamString ¶
QueryParamString retrieves a string param from the gin request querystring
func QueryParamStringDefault ¶
func QueryString ¶
QueryString retrieves a string param from the gin request querystring
func WithTimeout ¶
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) 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) 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 ¶
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 ¶
PUT /page/:id
func (*Application) PageUpdateHandler ¶
func (a *Application) PageUpdateHandler(c echo.Context) error
func (*Application) PageVideos ¶
GET /page/:id/videos
func (*Application) PageVideosHandler ¶
func (a *Application) PageVideosHandler(c echo.Context) error
func (*Application) PageVisits ¶
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 ¶
GET /video/
func (*Application) VideoIndexHandler ¶
func (a *Application) VideoIndexHandler(c echo.Context) error
Video (/video)
func (*Application) VideoSettings ¶
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 ¶
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 ¶
GET /visit/
func (*Application) VisitIndexHandler ¶
func (a *Application) VisitIndexHandler(c echo.Context) error
Visit (/visit)
func (*Application) VisitSettings ¶
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 ¶
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)
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) PageExists ¶
func (*Connector) VideoFindOrCreate ¶
func (*Connector) VisitError ¶
type Events ¶
type Events struct {
App *Application
Merc *mercury.Mercury
Log *zap.SugaredLogger
Video chan *Video
}
func NewEvents ¶
func NewEvents(app *Application) (*Events, error)
type EventsChannel ¶
type EventsChannel string
type EventsTopic ¶
type EventsTopic string
type H ¶
stolen from gin gonic H is a shortcut for map[string]any
func (H) MarshalXML ¶
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 ScrapeAll ¶
type ScrapeAll struct {
minion.WorkerDefaults[*ScrapeAll]
}
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 SettingsBatch ¶
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"`
}
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 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