dnclient

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Title            = "DiscordNotifier Client"
	DefaultName      = "discordnotifier-client"
	DefaultLogFileMb = 100
	DefaultLogFiles  = 0 // delete none
	DefaultTimeout   = time.Minute
	DefaultBindAddr  = "0.0.0.0:5454"
	DefaultEnvPrefix = "DN"
)

Application Defaults.

Variables

View Source
var (
	ErrNilAPIKey = fmt.Errorf("API key may not be empty")
	ErrNoApps    = fmt.Errorf("0 applications configured")
)

Errors returned by this package.

View Source
var (
	ErrNoTMDB    = fmt.Errorf("TMDB ID must not be empty")
	ErrNoGRID    = fmt.Errorf("GRID ID must not be empty")
	ErrNoTVDB    = fmt.Errorf("TVDB ID must not be empty")
	ErrNoMBID    = fmt.Errorf("MBID ID must not be empty")
	ErrNoRadarr  = fmt.Errorf("configured radarr ID not found")
	ErrNoSonarr  = fmt.Errorf("configured sonarr ID not found")
	ErrNoLidarr  = fmt.Errorf("configured lidarr ID not found")
	ErrNoReadarr = fmt.Errorf("configured readarr ID not found")
	ErrExists    = fmt.Errorf("the requested item already exists")
)

Errors sent to client web requests.

Functions

func Start

func Start() error

Start runs the app.

Types

type App

type App string

App allows safely storing context values.

const (
	Sonarr  App = "sonarr"
	Readarr App = "readarr"
	Radarr  App = "radarr"
	Lidarr  App = "lidarr"
)

Constant for each app to unique identify itself. These strings are also used as a suffix to the /api/ web path.

type Client

type Client struct {
	*Logger
	Flags  *Flags
	Config *Config
	// contains filtered or unexported fields
}

Client stores all the running data.

func NewDefaults

func NewDefaults() *Client

NewDefaults returns a new Client pointer with default settings.

func (*Client) Exit

func (c *Client) Exit() error

Exit stops the web server and logs our exit messages. Start() calls this.

func (*Client) InitStartup

func (c *Client) InitStartup()

InitStartup fixes config problems and prints info about our startup config. This runs once on startup.

func (*Client) RestartWebServer added in v0.0.2

func (c *Client) RestartWebServer(run func())

RestartWebServer stop and starts the web server. Panics if that causes an error or timeout.

func (*Client) SetupLogging

func (c *Client) SetupLogging()

SetupLogging splits log write into a file and/or stdout.

func (*Client) StartWebServer added in v0.0.2

func (c *Client) StartWebServer()

StartWebServer starts the web server.

func (*Client) StopWebServer added in v0.0.2

func (c *Client) StopWebServer()

StopWebServer stops the web servers. Panics if that causes an error or timeout.

type Config

type Config struct {
	APIKey     string           `json:"api_key" toml:"api_key" xml:"api_key" yaml:"api_key"`
	BindAddr   string           `json:"bind_addr" toml:"bind_addr" xml:"bind_addr" yaml:"bind_addr"`
	SSLCrtFile string           `json:"ssl_cert_file" toml:"ssl_cert_file" xml:"ssl_cert_file" yaml:"ssl_cert_file"`
	SSLKeyFile string           `json:"ssl_key_file" toml:"ssl_key_file" xml:"ssl_key_file" yaml:"ssl_key_file"`
	Quiet      bool             `json:"quiet" toml:"quiet" xml:"quiet" yaml:"quiet"`
	LogFile    string           `json:"log_file" toml:"log_file" xml:"log_file" yaml:"log_file"`
	HTTPLog    string           `json:"http_log" toml:"http_log" xml:"http_log" yaml:"http_log"`
	LogFiles   int              `json:"log_files" toml:"log_files" xml:"log_files" yaml:"log_files"`
	LogFileMb  int              `json:"log_file_mb" toml:"log_file_mb" xml:"log_file_mb" yaml:"log_file_mb"`
	URLBase    string           `json:"urlbase" toml:"urlbase" xml:"urlbase" yaml:"urlbase"`
	Upstreams  []string         `json:"upstreams" toml:"upstreams" xml:"upstreams" yaml:"upstreams"`
	Timeout    cnfg.Duration    `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"`
	Sonarr     []*SonarrConfig  `json:"sonarr,omitempty" toml:"sonarr" xml:"sonarr" yaml:"sonarr,omitempty"`
	Radarr     []*RadarrConfig  `json:"radarr,omitempty" toml:"radarr" xml:"radarr" yaml:"radarr,omitempty"`
	Lidarr     []*LidarrConfig  `json:"lidarr,omitempty" toml:"lidarr" xml:"lidarr" yaml:"lidarr,omitempty"`
	Readarr    []*ReadarrConfig `json:"readarr,omitempty" toml:"readarr" xml:"readarr" yaml:"readarr,omitempty"`
}

Config represents the data in our config file.

type Flags

type Flags struct {
	*flag.FlagSet

	ConfigFile string
	EnvPrefix  string
	// contains filtered or unexported fields
}

Flags are our CLI input flags.

func (*Flags) ParseArgs

func (f *Flags) ParseArgs(args []string)

ParseArgs stores the cli flag data into the Flags pointer.

type LidarrConfig

type LidarrConfig struct {
	*starr.Config
	*lidarr.Lidarr
	sync.RWMutex `json:"-" toml:"-" xml:"-" yaml:"-"`
}

LidarrConfig represents the input data for a Lidarr server.

type Logger

type Logger struct {
	Errors   *log.Logger // Shares a Writer with Logger.
	Logger   *log.Logger
	Requests *log.Logger
	// contains filtered or unexported fields
}

Logger provides a struct we can pass into other packages.

func (*Logger) Errorf added in v0.0.2

func (l *Logger) Errorf(msg string, v ...interface{})

Errorf writes log lines... to stdout and/or a file.

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

Print writes log lines... to stdout and/or a file.

func (*Logger) Printf

func (l *Logger) Printf(msg string, v ...interface{})

Printf writes log lines... to stdout and/or a file.

type RadarrConfig

type RadarrConfig struct {
	*starr.Config
	*radarr.Radarr
	sync.RWMutex `json:"-" toml:"-" xml:"-" yaml:"-"`
}

RadarrConfig represents the input data for a Radarr server.

type ReadarrConfig

type ReadarrConfig struct {
	*starr.Config
	*readarr.Readarr
	sync.RWMutex `json:"-" toml:"-" xml:"-" yaml:"-"`
}

ReadarrConfig represents the input data for a Readarr server.

type SonarrConfig

type SonarrConfig struct {
	*starr.Config
	*sonarr.Sonarr
	sync.RWMutex `json:"-" toml:"-" xml:"-" yaml:"-"`
}

SonarrConfig represents the input data for a Sonarr server.

Jump to

Keyboard shortcuts

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