common

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAddress for a server
	DefaultAddress string = "localhost"
	// DefaultPort for a server
	DefaultPort uint64 = 9650
)
View Source
const DefaultBlockSize = 1024

DefaultBlockSize is the minimal block that is transferred to the server

Variables

This section is empty.

Functions

func AddLogger

func AddLogger(logger io.Writer, shortLog bool)

AddLogger adds a new logger to the application and logs to all active loggers ConfigureLogging must be called prior to this call

func CleanPath

func CleanPath(path string) (absolutePath string, err error)

CleanPath takes a directory path and evaluates symlinks, takes the absolute path, and adds path separators based on the OS

func ConfigureLogging

func ConfigureLogging(loggingLevel zerolog.Level, shortLog bool, loggersIn ...io.Writer)

ConfigureLogging configures all the log related settings for the application

func IsSubdir

func IsSubdir(rootDir, subdir string) bool

IsSubdir returns true if subDir is a sub directory of rootdir

func LogError

func LogError(err error, message string)

LogError wrapper around logging regular error

func LogErrorStack

func LogErrorStack(err error, message string)

LogErrorStack wrapper around logging an error with the current stack

Types

type ClientConfig

type ClientConfig struct {
	Servers            []ServerConnectionConfig `json:"Servers"`
	WatchedDirectories []WatchedDirectory       `json:"WatchedDirectories"`
	DeleteOnComplete   bool                     `json:"DeleteFileOnComplete"`
}

ClientConfig json representation

type DirectoryDecoder

type DirectoryDecoder struct {
	FsInfo   fs.FileInfo
	Filepath string
}

DirectoryDecoder decodes a directory from json

func (*DirectoryDecoder) Decode

func (d *DirectoryDecoder) Decode(value string) error

Decode take a file name and uses it as the filepath

type LogFileDecoder

type LogFileDecoder struct {
	Writer io.Writer
}

LogFileDecoder wraps a writer and writes to it

func (*LogFileDecoder) Decode

func (d *LogFileDecoder) Decode(value string) error

Decode takes a file name and opens it as the log file

type ServerConfig

type ServerConfig struct {
	Debug   bool             `envconfig:"DEBUG" default:"true"`
	Address string           `envconfig:"ADDRESS" default:"localhost" json:"Address"`
	Port    uint32           `envconfig:"PORT" default:"9650" json:"Port"`
	Logfile LogFileDecoder   `envconfig:"LOGFILE" default:""`
	SaveDir DirectoryDecoder `envconfig:"MEDIADIR" default:"."`
	DbDir   string           `envconfig:"DBDIR" default:""`
}

ServerConfig describes all the environment specific details for running the server

type ServerConnectionConfig

type ServerConnectionConfig struct {
	Address   string `json:"Address"`
	Port      uint32 `json:"Port"`
	UseTLS    bool   `json:"Secure"`
	CertFile  string `json:"CertFile"`
	OAuthFile string `json:"OAuthFile"`
}

ServerConnectionConfig json representation

type WatchedDirectory

type WatchedDirectory struct {
	Directory string `json:"Directory"`
	MediaRoot string `json:"MediaRoot"`
}

WatchedDirectory json representation

Jump to

Keyboard shortcuts

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