kernel

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: EUPL-1.2 Imports: 9 Imported by: 0

Documentation

Overview

Package kernel provides the main kernel service.

Index

Constants

View Source
const (
	ProfileCPU  = "CPU"
	ProfileHead = "heap"
)

Constants for profile names.

View Source
const (
	CoreDebug     = "debug"
	CoreGoArch    = "go-arch"
	CoreGoOS      = "go-os"
	CoreGoVersion = "go-version"
	CoreHostname  = "hostname"
	CorePort      = "port"
	CoreProgname  = "progname"
	CoreStarted   = "started"
	CoreVerbose   = "verbose"
	CoreVersion   = "version"
	CoreVTime     = "vtime"
)

Constants for core service system keys.

View Source
const (
	ConfigSimpleMode   = "simple-mode"
	ConfigInsecureHTML = "insecure-html"
)

Constants for config service keys.

View Source
const (
	AuthOwner    = "owner"
	AuthReadonly = "readonly"
)

Constants for authentication service keys.

View Source
const (
	BoxDefaultDirType = "defdirtype"
	BoxURIs           = "box-uri-"
)

Constants for box service keys.

View Source
const (
	BoxDirTypeNotify = "notify"
	BoxDirTypeSimple = "simple"
)

Allowed values for BoxDefaultDirType

View Source
const (
	ConfigSecureHTML   = "secure"
	ConfigSyntaxHTML   = "html"
	ConfigMarkdownHTML = "markdown"
	ConfigZmkHTML      = "zettelmarkup"
)

Constants for config service keys.

View Source
const (
	WebAssetDir          = "asset-dir"
	WebBaseURL           = "base-url"
	WebListenAddress     = "listen"
	WebPersistentCookie  = "persistent"
	WebMaxRequestSize    = "max-request-size"
	WebSecureCookie      = "secure"
	WebTokenLifetimeAPI  = "api-lifetime"
	WebTokenLifetimeHTML = "html-lifetime"
	WebURLPrefix         = "prefix"
)

Constants for web service keys.

View Source
const (
	CoreDefaultVersion = "unknown"
)

Defined values for core service.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAuthManagerFunc

type CreateAuthManagerFunc func(readonly bool, owner id.Zid) (auth.Manager, error)

CreateAuthManagerFunc is called to create a new auth manager.

type CreateBoxManagerFunc

type CreateBoxManagerFunc func(
	boxURIs []*url.URL,
	authManager auth.Manager,
	rtConfig config.Config,
) (box.Manager, error)

CreateBoxManagerFunc is called to create a new box manager.

type Kernel

type Kernel interface {
	// Setup sets the most basic data of a software: its name, its version,
	// and when the version was created.
	Setup(progname, version string, versionTime time.Time)

	// Start the service.
	Start(headline bool, lineServer bool, configFile string)

	// WaitForShutdown blocks the call until Shutdown is called.
	WaitForShutdown()

	// Shutdown the service. Waits for all concurrent activities to stop.
	Shutdown(silent bool)

	// GetKernelLogger returns the kernel logger.
	GetKernelLogger() *logger.Logger

	// SetLogLevel sets the logging level for logger maintained by the kernel.
	//
	// Its syntax is: (SERVICE ":")? LEVEL (";" (SERICE ":")? LEVEL)*.
	SetLogLevel(string)

	// LogRecover outputs some information about the previous panic.
	LogRecover(name string, recoverInfo interface{}) bool

	// StartProfiling starts profiling the software according to a profile.
	// It is an error to start more than one profile.
	//
	// profileName is a valid profile (see runtime/pprof/Lookup()), or the
	// value "cpu" for profiling the CPI.
	// fileName is the name of the file where the results are written to.
	StartProfiling(profileName, fileName string) error

	// StopProfiling stops the current profiling and writes the result to
	// the file, which was named during StartProfiling().
	// It will always be called before the software stops its operations.
	StopProfiling() error

	// SetConfig stores a configuration value.
	SetConfig(srv Service, key, value string) error

	// GetConfig returns a configuration value.
	GetConfig(srv Service, key string) interface{}

	// GetConfigList returns a sorted list of configuration data.
	GetConfigList(Service) []KeyDescrValue

	// GetLogger returns a logger for the given service.
	GetLogger(Service) *logger.Logger

	// SetLevel sets the logging level for the given service.
	SetLevel(Service, logger.Level)

	// RetrieveLogEntries returns all buffered log entries.
	RetrieveLogEntries() []LogEntry

	// GetLastLogTime returns the time when the last logging with level > DEBUG happened.
	GetLastLogTime() time.Time

	// StartService start the given service.
	StartService(Service) error

	// RestartService stops and restarts the given service, while maintaining service dependencies.
	RestartService(Service) error

	// StopService stop the given service.
	StopService(Service) error

	// GetServiceStatistics returns a key/value list with statistical data.
	GetServiceStatistics(Service) []KeyValue

	// DumpIndex writes some data about the internal index into a writer.
	DumpIndex(io.Writer)

	// SetCreators store functions to be called when a service has to be created.
	SetCreators(CreateAuthManagerFunc, CreateBoxManagerFunc, SetupWebServerFunc)
}

Kernel is the main internal service.

var Main Kernel

Main references the main kernel.

type KeyDescrValue

type KeyDescrValue struct{ Key, Descr, Value string }

KeyDescrValue is a triple of config data.

type KeyValue

type KeyValue struct{ Key, Value string }

KeyValue is a pair of key and value.

type LogEntry added in v0.2.1

type LogEntry struct {
	Level   logger.Level
	TS      time.Time
	Prefix  string
	Message string
}

LogEntry stores values of one log line written by a logger.Logger

type Service

type Service uint8

Service specifies a service, e.g. web, ...

const (
	KernelService Service // The Kernel itself is also a sevice
	CoreService           // Manages startup specific functionality
	ConfigService         // Provides access to runtime configuration
	AuthService           // Manages authentication
	BoxService            // Boxes provide zettel
	WebService            // Access to Zettelstore through Web-based API and WebUI
)

Constants for type Service.

type SetupWebServerFunc

type SetupWebServerFunc func(
	webServer server.Server,
	boxManager box.Manager,
	authManager auth.Manager,
	rtConfig config.Config,
) error

SetupWebServerFunc is called to create a new web service handler.

type ShutdownChan

type ShutdownChan <-chan Unit

ShutdownChan is a channel used to signal a system shutdown.

type Unit

type Unit struct{}

Unit is a type with just one value.

Directories

Path Synopsis
Package impl provides the kernel implementation.
Package impl provides the kernel implementation.

Jump to

Keyboard shortcuts

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