compressor

package
v1.0.1-0...-32d7d0a Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultShortpixelConfig = ShortpixelConfig{
		Url:             "",
		Url2:            "",
		ApiKey:          "",
		RetryTimes:      0,
		RetryPause:      0,
		Timeout:         0,
		Wait:            "",
		UploadTimeout:   250 * time.Millisecond,
		DownloadTimeout: 250 * time.Millisecond,
		RepeatIn:        0,
		RestartIn:       0,
	}
	DefaultImaginaryConfig = ImaginaryConfig{
		Host:       "localhost",
		Port:       "9001",
		RetryTimes: 4,
		RetryPause: 5 * time.Second,
		Timeout:    30 * time.Second,
	}
)

Functions

func WithHeartbeatRestart

func WithHeartbeatRestart(ch chan<- any) options

Types

type CompressorConfig

type CompressorConfig struct {
	Compressor string           `mapstructure:"APP_COMPRESSOR" validate:"required"`
	Shortpixel ShortpixelConfig `mapstructure:",squash"`
	Imaginary  ImaginaryConfig  `mapstructure:",squash"`
}

func (CompressorConfig) IsMock

func (c CompressorConfig) IsMock() bool

type Imaginary

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

func NewImaginary

func NewImaginary(ctx context.Context, conf ImaginaryConfig) (*Imaginary, error)

func (*Imaginary) Compress

func (im *Imaginary) Compress(ctx context.Context, f model.File) (model.File, error)

func (*Imaginary) Health

func (im *Imaginary) Health(ctx context.Context) (bool, error)

type ImaginaryConfig

type ImaginaryConfig struct {
	Host       string        `mapstructure:"COMPRESSOR_IMAGINARY_HOST"        validate:"required"`
	Port       string        `mapstructure:"COMPRESSOR_IMAGINARY_PORT"        validate:"required"`
	RetryTimes int           `mapstructure:"COMPRESSOR_IMAGINARY_RETRY_TIMES" validate:"required"`
	RetryPause time.Duration `mapstructure:"COMPRESSOR_IMAGINARY_RETRY_PAUSE" validate:"required"`
	Timeout    time.Duration `mapstructure:"COMPRESSOR_IMAGINARY_TIMEOUT"     validate:"required"`
}

type Mock

type Mock struct {
}

func NewMock

func NewMock() *Mock

func (*Mock) Compress

func (m *Mock) Compress(_ context.Context, f model.File) (model.File, error)

func (*Mock) Health

func (m *Mock) Health(_ context.Context) (bool, error)

type Shortpixel

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

func NewShortpixel

func NewShortpixel(conf ShortpixelConfig, opts ...options) *Shortpixel

func (*Shortpixel) Compress

func (sp *Shortpixel) Compress(ctx context.Context, f model.File) (model.File, error)

func (*Shortpixel) Health

func (sp *Shortpixel) Health(ctx context.Context) (bool, error)

func (*Shortpixel) Monitor

func (sp *Shortpixel) Monitor(ctx context.Context)

func (*Shortpixel) Ping

func (sp *Shortpixel) Ping(ctx context.Context) error

type ShortpixelConfig

type ShortpixelConfig struct {
	Url             string        `mapstructure:"COMPRESSOR_SHORTPIXEL_URL"              validate:"required"`
	Url2            string        `mapstructure:"COMPRESSOR_SHORTPIXEL_URL2"             validate:"required"`
	ApiKey          string        `mapstructure:"COMPRESSOR_SHORTPIXEL_API_KEY"          validate:"required"`
	RetryTimes      int           `mapstructure:"COMPRESSOR_SHORTPIXEL_RETRY_TIMES"      validate:"required"`
	RetryPause      time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_RETRY_PAUSE"      validate:"required"`
	Timeout         time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_TIMEOUT"          validate:"required"`
	Wait            string        `mapstructure:"COMPRESSOR_SHORTPIXEL_WAIT"             validate:"required"`
	UploadTimeout   time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_UPLOAD_TIMEOUT"   validate:"required"`
	DownloadTimeout time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_DOWNLOAD_TIMEOUT" validate:"required"`
	RepeatIn        time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_REPEAT_IN"        validate:"required"`
	RestartIn       time.Duration `mapstructure:"COMPRESSOR_SHORTPIXEL_RESTART_IN"       validate:"required"`
}

Jump to

Keyboard shortcuts

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