service

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service ties long-lived Go values ("services") to the lifecycle of a tango.App: they start in registration order once the app is ready and shut down in reverse order when it terminates.

A service is any value. If it implements Starter, Startup runs on the main thread when the app is ready (or soon after Register, if it already is); if it implements Stopper, Shutdown runs on the main thread when the app terminates. Both block the main thread, so start long work on a goroutine and stop it with the context Startup receives, which is canceled before any Shutdown runs.

If a Startup fails, the services already started are shut down, the remaining ones are not started, and the app quits; Err reports why.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(app *tango.App, router *ipc.Router, name string, svc Service) error

Bind registers svc's exported methods on router as "name.Method" (see package bind) and adds svc to app as Register does. Startup and Shutdown are lifecycle hooks, not API: calls to them from the page answer not_found.

func Err

func Err(app *tango.App) error

Err reports the Startup error that made app quit, if any, joined with the errors Shutdown methods returned.

func Register

func Register(app *tango.App, svcs ...Service)

Register adds svcs to app. They start, in order, once the app is ready; services from earlier Register calls start first. Nil entries are ignored.

func Shutdown

func Shutdown(app *tango.App) error

Shutdown shuts down app's services now if the app has not already done so, and returns Err. Use it when Run can return without the app emitting Terminating, e.g. defer service.Shutdown(app) after Run.

Types

type Service

type Service interface{}

Service is any value managed by this package.

type Starter

type Starter interface {
	Startup(ctx context.Context) error
}

Starter is implemented by services that need to start with the app.

type Stopper

type Stopper interface {
	Shutdown() error
}

Stopper is implemented by services that need to release resources when the app terminates.

Directories

Path Synopsis
Package fileserver serves a local directory over HTTP, for showing user files (downloads, generated images, a documents folder) in a page.
Package fileserver serves a local directory over HTTP, for showing user files (downloads, generated images, a documents folder) in a page.
Package kv is a small thread-safe key-value store for app settings and state: kept in memory and, optionally, persisted to a JSON file.
Package kv is a small thread-safe key-value store for app settings and state: kept in memory and, optionally, persisted to a JSON file.
Package log sets up application logging on log/slog: records go to stderr and to a log file that rotates by size, and the page can log through ipc (Handler).
Package log sets up application logging on log/slog: records go to stderr and to a log file that rotates by size, and the page can log through ipc (Handler).
Package paths returns the per-user directories an application keeps its files in, on every platform Tango runs on.
Package paths returns the per-user directories an application keeps its files in, on every platform Tango runs on.
Package updater keeps a Tango desktop app up to date: it fetches a signed update manifest, refuses anything older than what it runs (or has seen), downloads a binary patch or the full release, verifies it, installs it once the app quits, and rolls back if the new version does not confirm that it starts.
Package updater keeps a Tango desktop app up to date: it fetches a signed update manifest, refuses anything older than what it runs (or has seen), downloads a binary patch or the full release, verifies it, installs it once the app quits, and rolls back if the new version does not confirm that it starts.
internal/e2e/drillapp command
Command drillapp is the app of the macOS update drill (see ../drill_test.go): a headless Tango app whose version is set at link time.
Command drillapp is the app of the macOS update drill (see ../drill_test.go): a headless Tango app whose version is set at link time.
updateui
Package updateui is a ready-made update window for apps that use service/updater: it checks for updates in the background, shows what a new release contains, downloads it with progress, and restarts into it when the user agrees.
Package updateui is a ready-made update window for apps that use service/updater: it checks for updates in the background, shows what a new release contains, downloads it with progress, and restarts into it when the user agrees.

Jump to

Keyboard shortcuts

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