runtime

package
v4.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyDiscovery    = "discovery"
	KeyRegistry     = "registry"
	KeyBroker       = "broker"
	KeyConfig       = "config"
	KeyVault        = "vault"
	KeyKeyring      = "keyring"
	KeyCertsStore   = "certs_store"
	KeyCache        = "cache"
	KeyShortCache   = "shortcache"
	KeyQueue        = "queue"
	KeyPersistQueue = "persistqueue"
	KeyFork         = "fork"
	KeyForkLegacy   = "is_fork"
	KeyArgTags      = "tags"
	KeyArgExclude   = "exclude"
	KeyNodeCapacity = "cap"

	KeyAdvertiseAddress  = "advertise_address"
	KeyBindHost          = "bind_address"
	KeyGrpcDiscoveryPort = "grpc_discovery_port"
	KeyGrpcPort          = "grpc_port"
	KeyHttpPort          = "http_port"
	KeyGrpcExternal      = "grpc_external"

	KeySiteBind               = "site_bind"
	KeySiteExternal           = "site_external"
	KeySiteNoTLS              = "site_no_tls"
	KeySiteTlsCertFile        = "site_tls_cert_file"
	KeySiteTlsKeyFile         = "site_tls_key_file"
	KeySiteLetsEncryptEmail   = "site_le_email"
	KeySiteLetsEncryptAgree   = "site_le_agree"
	KeySiteLetsEncryptStaging = "site_le_staging"

	// Legacy versions without "site_" prefix
	KeySiteBindL               = "bind"
	KeySiteExternalL           = "external"
	KeySiteNoTLSL              = "no_tls"
	KeySiteTlsCertFileL        = "tls_cert_file"
	KeySiteTlsKeyFileL         = "tls_key_file"
	KeySiteLetsEncryptEmailL   = "le_email"
	KeySiteLetsEncryptAgreeL   = "le_agree"
	KeySiteLetsEncryptStagingL = "le_staging"

	KeyInstallCli       = "install_cli"
	KeyInstallYaml      = "install_yaml"
	KeyInstallJson      = "install_json"
	KeyInstallExitAfter = "exit_after_install"

	KeyInstallCliLegacy  = "cli"
	KeyInstallYamlLegacy = "yaml"
	KeyInstallJsonLegacy = "json"

	KeyLog       = "log"
	KeyLogJson   = "log_json"
	KeyLogToFile = "log_to_file"

	KeyEnableMetrics    = "enable_metrics"
	KeyMetricsBasicAuth = "metrics_basic_auth"
	KeyEnablePprof      = "enable_pprof"

	KeyHttpServer    = "http"
	HttpServerCaddy  = "caddy"
	HttpServerNative = "http"

	DefaultDiscoveryPort   = "8030"
	DefaultGrpcPort        = "8031"
	DefaultBindingSitePort = "8080"
	DefaultHttpPort        = "0"

	DefaultConfigFileName  = "pydio.json"
	DefaultVaultFileName   = "pydio-vault.json"
	DefaultKeyringFileName = "cells-vault-key"
	DefaultCertStorePath   = "certs"

	DefaultConfigSuffix     = "/config"
	DefaultVaultSuffix      = "/vault"
	DefaultRegistrySuffix   = "/registry"
	DefaultBrokerSuffix     = "/broker"
	DefaultCacheSuffix      = "/cache"
	DefaultShortCacheSuffix = "/shortcache"
	DefaultQueueSuffix      = "/queue"
)
View Source
const (
	NodeMetaPID          = "PID"
	NodeMetaParentPID    = "parentPID"
	NodeMetaMetrics      = "metrics"
	NodeMetaStartTag     = "start"
	NodeMetaForkStartTag = "forkStartTag"
	NodeMetaHostName     = "hostname"
	NodeMetaCapacities   = "capacities"
	NodeRootID           = "rootID"
)

Variables

View Source
var (
	DefaultKeyDiscovery    = "mem://"
	DefaultKeyRegistry     = "mem://?cache=shared"
	DefaultKeyBroker       = "mem://"
	DefaultKeyConfig       = "file://" + filepath.ToSlash(filepath.Join(ApplicationWorkingDir(), DefaultConfigFileName))
	DefaultKeyKeyring      = "file://" + filepath.ToSlash(filepath.Join(ApplicationWorkingDir(), DefaultKeyringFileName)+"?keyring=true")
	DefaultKeyCertsStore   = "file://" + filepath.ToSlash(filepath.Join(ApplicationWorkingDir(), DefaultCertStorePath))
	DefaultKeyVault        = "detect"
	DefaultKeyCache        = "bigcache://"
	DefaultKeyShortCache   = "pm://"
	DefaultKeyQueue        = "mem://"
	DefaultKeyPersistQueue = "file://"
)

Functions

func ApplicationWorkingDir

func ApplicationWorkingDir(dirType ...ApplicationDirType) string

ApplicationWorkingDir creates a local file to store pydio system data

func BrokerURL

func BrokerURL() string

BrokerURL returns the scheme://address url for Broker

func BuildForkParams

func BuildForkParams(cmd string) []string

BuildForkParams creates --key=value arguments from runtime parameters

func CacheURL

func CacheURL(prefix string, queryPairs ...string) string

CacheURL creates URL to open a long-living, shared cache, containing queryPairs as query parameters

func CertsStoreLocalLocation

func CertsStoreLocalLocation() string

func CertsStoreURL

func CertsStoreURL() string

func ConfigIsLocalFile

func ConfigIsLocalFile() bool

ConfigIsLocalFile checks if ConfigURL scheme is file

func ConfigURL

func ConfigURL() string

ConfigURL returns the scheme://address url for Config

func DefaultAdvertiseAddress

func DefaultAdvertiseAddress() string

DefaultAdvertiseAddress reads or compute the address advertised to clients

func DiscoveryURL

func DiscoveryURL() string

DiscoveryURL returns the scheme://address url for Registry

func DocRegisteredEnvVariables added in v4.3.2

func DocRegisteredEnvVariables(excludes ...string) string

func ForkContext

func ForkContext(ctx, parent context.Context) context.Context

ForkContext copies all necessary dependencies using the internal ContextInjector registry

func GetBool

func GetBool(key string) bool

GetBool gets a key as boolean from global runtime

func GetHostname

func GetHostname() string

GetHostname wraps os.Hostname, could be overwritten by env or parameter.

func GetPID added in v4.0.6

func GetPID() string

GetPID wraps os.Getpid.

func GetPPID added in v4.0.6

func GetPPID() string

GetPPID wraps os.Getppid.

func GetString

func GetString(key string) string

GetString gets a key from global runtime

func GetStringSlice

func GetStringSlice(key string) []string

GetStringSlice gets a slice from global runtime.

func GrpcBindAddress

func GrpcBindAddress() string

GrpcBindAddress returns the KeyBindHost:KeyGrpcPort URL

func GrpcDiscoveryBindAddress

func GrpcDiscoveryBindAddress() string

GrpcDiscoveryBindAddress returns the KeyBindHost:KeyGrpcDiscoveryPort URL

func GrpcExternalPort

func GrpcExternalPort() string

GrpcExternalPort returns optional GRPC port to be used for external binding

func HasCapacity

func HasCapacity(c string) bool

HasCapacity checks if a specific capacity is registered for the current process

func HttpBindAddress

func HttpBindAddress() string

HttpBindAddress returns the KeyBindHost:KeyHttpPort URL

func HttpServerType

func HttpServerType() string

HttpServerType returns one of HttpServerCaddy or HttpServerCore

func Init

func Init(ctx context.Context, typ string)

func InitGlobalConnConsumers

func InitGlobalConnConsumers(ctx context.Context, typ string)

func IsFork

func IsFork() bool

IsFork checks if the runtime is originally a fork of a different process

func IsGrpcScheme

func IsGrpcScheme(u string) bool

func IsRequired

func IsRequired(name string, tags ...string) bool

IsRequired checks arguments, --tags and --exclude against a service name

func IsSet

func IsSet(key string) bool

IsSet check existence of a key in runtime

func KeyringURL

func KeyringURL() string

func LastInitType

func LastInitType() string

func LogJSON

func LogJSON() bool

LogJSON returns the --log_json value

func LogLevel

func LogLevel() string

LogLevel returns the --log value

func LogToFile

func LogToFile() bool

LogToFile returns the --log_to_file value

func MatchDependencies

func MatchDependencies(ctx context.Context, rr map[string]string) error

MatchDependencies checks a list of known keys for specific runtime parameters. It is typically used to detect current-process aspects

func MetricsEnabled

func MetricsEnabled() bool

MetricsEnabled returns if the metrics should be published or not

func MetricsRemoteEnabled added in v4.0.5

func MetricsRemoteEnabled() (bool, string, string)

MetricsRemoteEnabled returns if the metrics should be published on a Service Discovery endpoint

func MustServiceDataDir

func MustServiceDataDir(serviceName string) string

MustServiceDataDir returns the applicationdir/services/serviceName and ignore error it if it does not exists

func NeedsGrpcDiscoveryConn

func NeedsGrpcDiscoveryConn() (bool, string)

func PersistingQueueURL added in v4.2.4

func PersistingQueueURL(queryPairs ...string) string

PersistingQueueURL creates URL to open a FIFO queue that persists to restart, containing queryPairs as query parameters

func PprofEnabled

func PprofEnabled() bool

PprofEnabled returns if a http endpoint should be published for debug/pprof

func ProcessRootID added in v4.0.6

func ProcessRootID() string

ProcessRootID retrieves a unique identifier for the current process

func ProcessStartTags

func ProcessStartTags() []string

ProcessStartTags returns a list of tags to be used for identifying processes

func QueueURL added in v4.2.4

func QueueURL(queryPairs ...string) string

QueueURL creates URL to open a FIFO queue, containing queryPairs as query parameters

func Register

func Register(typ string, y ...func(ctx context.Context))

func RegisterContextInjector

func RegisterContextInjector(injector ContextInjector)

RegisterContextInjector appends a ContextInjector to the internal registry

func RegisterDependencyMatcher

func RegisterDependencyMatcher(key string, f func(context.Context, string) error)

RegisterDependencyMatcher adds a key-based dependency matcher to internal registry.

func RegisterEnvVariable added in v4.3.2

func RegisterEnvVariable(key, def, description string, isBool ...bool)

RegisterEnvVariable can be called by any contributor to declare environment variables for documentation purpose

func RegisterGlobalConnConsumer

func RegisterGlobalConnConsumer(typ string, y ...func(ctx context.Context))

func RegisterPreRun

func RegisterPreRun(preRun func(runtime Runtime))

func RegistryURL

func RegistryURL() string

RegistryURL returns the scheme://address url for Registry

func ServiceDataDir

func ServiceDataDir(serviceName string) (string, error)

ServiceDataDir returns the applicationdir/services/serviceName and creates it if it does not exists

func SetArgs

func SetArgs(aa []string)

SetArgs copies command arguments to internal value

func SetDefault

func SetDefault(key string, value interface{})

SetDefault updates global runtime

func SetProcessRootID added in v4.0.6

func SetProcessRootID(id string)

SetProcessRootID passes a UUID for the current process

func SetRuntime

func SetRuntime(runtime Runtime)

SetRuntime sets internal global Runtime

func SetVaultMasterKey

func SetVaultMasterKey(masterKey string)

func ShortCacheURL

func ShortCacheURL(queryPairs ...string) string

ShortCacheURL creates URL to open a short, local cache, containing queryPairs as query parameters

func VaultURL

func VaultURL() string

Types

type ApplicationDirType

type ApplicationDirType int
const (
	ApplicationDirData ApplicationDirType = iota
	ApplicationDirLogs
	ApplicationDirServices
)

type ContextInjector

type ContextInjector func(ctx, parent context.Context) context.Context

type InfoGroup

type InfoGroup struct {
	Name  string
	Pairs []InfoPair
}

func Describe

func Describe() (out []InfoGroup)

Describe echoes the current runtime status

type InfoPair

type InfoPair struct {
	Key   string
	Value string
}

type Runtime

type Runtime interface {
	GetBool(key string) bool
	GetString(key string) string
	GetStringSlice(key string) []string
	IsSet(key string) bool
	SetDefault(key string, value interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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