Help us shape the future of Go! Take the 2026 Go Developer Survey

capability

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package capability probes runtime feature availability — both binary tools (ffmpeg, gs, libreoffice, vips) and external HTTP services (OnlyOffice, Drawio).

Results are cached so the /api/capabilities endpoint is cheap: 1h after a fully-successful probe round, but only 2 minutes when any external probe failed — a transient outage must not pin an "unreachable" banner in the UI for a whole hour.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSONForResponse

func MarshalJSONForResponse(c *model.Capabilities) ([]byte, error)

MarshalJSONForResponse serializes Capabilities for the public API.

Types

type Service

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

Service answers /api/capabilities and persists external_services state.

func New

func New(store db.Store) *Service

New constructs a Service.

func (*Service) AttachStorageResolver

func (s *Service) AttachStorageResolver(resolver func(int64) (storage.Driver, error))

AttachStorageResolver wires the resolver used for per-storage capability probes. Optional — when nil the response omits the per-storage map.

func (*Service) Get

func (s *Service) Get(ctx context.Context) (*model.Capabilities, error)

Get returns the current Capabilities snapshot, refreshing if the cache expired (okTTL after a clean probe round, failTTL when any external probe failed).

func (*Service) Invalidate

func (s *Service) Invalidate()

Invalidate forces the next Get to re-probe.

func (*Service) ProbeExternal

func (s *Service) ProbeExternal(ctx context.Context, name string) (*model.ExternalServiceState, error)

ProbeExternal probes a single named external service immediately and returns its fresh state. The capability cache is invalidated as a side effect so the next /api/capabilities call sees the updated row.

func (*Service) SetAppPlugins

func (s *Service) SetAppPlugins(v model.AppPluginsCapabilities)

SetAppPlugins records the app-plugin runtime state for the snapshot.

func (*Service) SetAuthDrivers

func (s *Service) SetAuthDrivers(names []string)

SetAuthDrivers records the sign-in methods the login page offers. The Identity providers page changes them without a restart (internal/authsetup), so this is set on every swap, not only at boot.

func (*Service) SetRecoveryLogin

func (s *Service) SetRecoveryLogin(on bool)

SetRecoveryLogin records whether recovery sign-in is active (see model.Capabilities.AuthRecoveryLogin).

func (*Service) SetStaticInventory

func (s *Service) SetStaticInventory(
	authDrivers, storageDrivers []string,
	dbDriver string,
	searchEnabled bool,
	version, build string,
	demoMode bool, demoUser, demoPass string,
	defaultLocale string,
	oidcAutoRedirect bool,
)

SetStaticInventory wires the boot-time-known fields into the Capabilities response. Safe to call once before the first Get().

Jump to

Keyboard shortcuts

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