app

package
v0.29.4-dev-56e4e32 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package app provides the main application logic for immich-go, including client management for connecting to Immich servers.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Functions

func Banner() string

String generate a string with new lines and place the given text on the latest line

func DefaultLogFile added in v0.29.0

func DefaultLogFile() string

DefaultLogFile returns the default log file path

func GetVersion

func GetVersion() string

func NewFilteredHandler added in v0.28.0

func NewFilteredHandler(handler slog.Handler) slog.Handler

Types

type Application

type Application struct {
	// CLI flags
	DryRun         bool
	OnErrors       cliflags.OnErrorsFlag
	SaveConfig     bool
	ConcurrentTask int
	CfgFile        string

	Config *config.ConfigurationManager
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cmd *cobra.Command) *Application

func (*Application) GetSupportedMedia added in v0.29.0

func (app *Application) GetSupportedMedia() filetypes.SupportedMedia

func (*Application) GetTZ

func (app *Application) GetTZ() *time.Location

func (*Application) Jnl

func (app *Application) Jnl() *fileevent.Recorder

func (*Application) Log

func (app *Application) Log() *Log

func (*Application) ProcessError added in v0.29.0

func (app *Application) ProcessError(err error) error

func (*Application) RegisterFlags added in v0.29.0

func (app *Application) RegisterFlags(flags *pflag.FlagSet)

func (*Application) SetJnl

func (app *Application) SetJnl(jnl *fileevent.Recorder)

func (*Application) SetLog

func (app *Application) SetLog(log *Log)

func (*Application) SetSupportedMedia added in v0.29.0

func (app *Application) SetSupportedMedia(sm filetypes.SupportedMedia)

func (*Application) SetTZ

func (app *Application) SetTZ(tz *time.Location)

type Client

type Client struct {
	Server                    string         `mapstructure:"server" json:"server" toml:"server" yaml:"server"`                                                             // Immich server address (http://<your-ip>:2283/api or https://<your-domain>/api)
	APIKey                    string         `mapstructure:"api_key" json:"api_key" toml:"api_key" yaml:"api_key"`                                                         // API Key
	AdminAPIKey               string         `mapstructure:"admin_api_key" json:"admin_api_key" toml:"admin_api_key" yaml:"admin_api_key"`                                 // API Key for admin
	APITrace                  bool           `mapstructure:"api_trace" json:"api_trace" toml:"api_trace" yaml:"api_trace"`                                                 // Enable API call traces
	SkipSSL                   bool           `mapstructure:"skip_ssl" json:"skip_ssl" toml:"skip_ssl" yaml:"skip_ssl"`                                                     // Skip SSL Verification
	ClientTimeout             time.Duration  `mapstructure:"client_timeout" json:"client_timeout" toml:"client_timeout" yaml:"client_timeout"`                             // Set the client request timeout
	DeviceUUID                string         `mapstructure:"device_uuid" json:"device_uuid" toml:"device_uuid" yaml:"device_uuid"`                                         // Set a device UUID
	TimeZone                  string         `mapstructure:"time_zone" json:"time_zone" toml:"time_zone" yaml:"time_zone"`                                                 // Override default TZ
	APITraceWriter            io.WriteCloser `mapstructure:"api_trace_writer" json:"api_trace_writer" toml:"api_trace_writer" yaml:"api_trace_writer"`                     // API tracer
	APITraceWriterName        string         `mapstructure:"api_trace_writer_name" json:"api_trace_writer_name" toml:"api_trace_writer_name" yaml:"api_trace_writer_name"` // API trace log name
	User                      immich.User    `mapstructure:"user" json:"user" toml:"user" yaml:"user"`                                                                     // User info corresponding to the API key
	PauseImmichBackgroundJobs bool           ``                                                                                                                            // Pause Immich background jobs
	/* 151-byte string literal not displayed */

	TZ          *time.Location         // Time zone to use
	Immich      immich.ImmichInterface // Immich client
	AdminImmich immich.ImmichInterface // Immich client for admin
	ClientLog   *slog.Logger           // Logger

	DryRun bool // Protect the server from changes
	// contains filtered or unexported fields
}

Client represents an Immich server client with configuration and connection management. It handles authentication, API communication, and various client-side settings.

func (*Client) Close

func (client *Client) Close() error

Close cleans up the client connection. It logs dry-run status and performs any necessary cleanup operations.

func (*Client) Open

func (client *Client) Open(ctx context.Context, app *Application) error

Open establishes a connection to the Immich server. It validates configuration, sets up logging, creates client instances, and performs initial server validation including ping and authentication.

func (*Client) RegisterFlags added in v0.29.0

func (client *Client) RegisterFlags(flags *pflag.FlagSet, prefix string)

RegisterFlags adds client-related command-line flags to the provided flag set. These flags control server connection, authentication, and client behavior.

type FilteredHandler added in v0.28.0

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

FilteredHandler filterslog messages and filters out context canceled errors if err, ok := a.Value.Any().(error); ok { if errors.Is(err, context.Canceled) {

func (*FilteredHandler) Enabled added in v0.28.0

func (h *FilteredHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*FilteredHandler) Handle added in v0.28.0

func (h *FilteredHandler) Handle(ctx context.Context, r slog.Record) error

func (*FilteredHandler) WithAttrs added in v0.28.0

func (h *FilteredHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*FilteredHandler) WithGroup added in v0.28.0

func (h *FilteredHandler) WithGroup(name string) slog.Handler

type Log

type Log struct {
	Type  string `mapstructure:"type" json:"type" toml:"type" yaml:"type"`     // Log format : text|json
	File  string `mapstructure:"file" json:"file" toml:"file" yaml:"file"`     // Log file name
	Level string `mapstructure:"level" json:"level" toml:"level" yaml:"level"` // Indicate the log level (string)

	*slog.Logger // Logger
	// contains filtered or unexported fields
}

func (*Log) APITracer added in v0.29.0

func (log *Log) APITracer() *httptrace.Tracer

func (*Log) Close

func (log *Log) Close(ctx context.Context, cmd *cobra.Command, app *Application) error

func (*Log) GetSLog

func (log *Log) GetSLog() *slog.Logger

func (*Log) Message

func (log *Log) Message(msg string, values ...any)

func (*Log) Open

func (log *Log) Open(ctx context.Context, cmd *cobra.Command, app *Application) error

func (*Log) OpenAPITrace added in v0.29.0

func (log *Log) OpenAPITrace() error

func (*Log) OpenLogFile

func (log *Log) OpenLogFile() error

func (*Log) RegisterFlags added in v0.29.0

func (log *Log) RegisterFlags(flags *pflag.FlagSet)

func (*Log) SetLogWriter

func (log *Log) SetLogWriter(w io.Writer) *slog.Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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