abcupdater

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAppVersion

func CheckAppVersion(ctx context.Context, params *CheckVersionParams, out func(string)) func()

CheckAppVersion calls CheckAppVersionSync in a go routine. It returns a closure to be run after program logic which will block until a response is returned or provided context is canceled. If no provided deadline in context, defaults to 2 seconds. If there is an update, out() will be called during the returned closure.

If no update is available: out() will not be called. If there is an error: out() will not be called, message will be logged as WARN. If the context is canceled: out() is not called. Example out(): `func(s string) {fmt.Fprintln(os.Stderr, s)}`.

func CheckAppVersionSync added in v0.1.0

func CheckAppVersionSync(ctx context.Context, params *CheckVersionParams) (string, error)

CheckAppVersionSync checks if a newer version of an app is available. Any relevant update info will be returned as a string. Accepts a context for cancellation.

Types

type AppResponse

type AppResponse struct {
	AppID          string `json:"appId"`
	AppName        string `json:"appName"`
	AppRepoURL     string `json:"appRepoUrl"`
	CurrentVersion string `json:"currentVersion"`
}

AppResponse is the response object for an app version request. It contains information about the most recent version for a given app.

type CheckVersionParams

type CheckVersionParams struct {
	// The ID of the application to check.
	AppID string

	// The version of the app to check for updates.
	// Should be of form vMAJOR[.MINOR[.PATCH[-PRERELEASE][+BUILD]]] (e.g., v1.0.1)
	Version string

	// An optional Lookuper to load envconfig structs. Will default to os environment variables.
	Lookuper envconfig.Lookuper

	// Optional override for cached file location. Mostly intended for testing.
	// If empty uses default location.
	CacheFileOverride string
}

CheckVersionParams are the parameters for checking for application updates.

type LocalVersionData

type LocalVersionData struct {
	// Last time version information was checked, in UTC epoch seconds.
	LastCheckTimestamp int64 `json:"lastCheckTimestamp"`
	// Currently unused
	AppResponse
}

LocalVersionData defines the json file that caches version lookup data. Future versions may alert users of cached version info with every invocation.

Directories

Path Synopsis
Package localstore is a helper for persistent JSON storage on the users machine.
Package localstore is a helper for persistent JSON storage on the users machine.

Jump to

Keyboard shortcuts

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