kernel

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: EUPL-1.2 Imports: 32 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"
	WebLoopbackIdent     = "loopback-ident"
	WebLoopbackZid       = "loopback-zid"
	WebPersistentCookie  = "persistent"
	WebProfiling         = "profiling"
	WebMaxRequestSize    = "max-request-size"
	WebSecureCookie      = "secure"
	WebSxMaxNesting      = "sx-max-nesting"
	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 struct {
	// contains filtered or unexported fields
}

Kernel is the main internal kernel.

var Main *Kernel

Main references the main kernel.

func (*Kernel) GetConfig

func (kern *Kernel) GetConfig(srvnum Service, key string) any

GetConfig returns a configuration value.

func (*Kernel) GetKernelLogLevel added in v0.22.0

func (kern *Kernel) GetKernelLogLevel() slog.Level

GetKernelLogLevel return the logging level of the kernel logger.

func (*Kernel) GetKernelLogger

func (kern *Kernel) GetKernelLogger() *slog.Logger

GetKernelLogger returns the kernel logger.

func (*Kernel) GetLastLogTime

func (kern *Kernel) GetLastLogTime() time.Time

GetLastLogTime returns the time when the last logging with level > DEBUG happened.

func (*Kernel) GetLogger

func (kern *Kernel) GetLogger(srvnum Service) *slog.Logger

GetLogger returns a logger for the given service.

func (*Kernel) GetServiceStatistics

func (kern *Kernel) GetServiceStatistics(srvnum Service) []KeyValue

GetServiceStatistics returns a key/value list with statistical data.

func (*Kernel) LogRecover

func (kern *Kernel) LogRecover(name string, recoverInfo any)

LogRecover outputs some information about the previous panic.

func (*Kernel) RetrieveLogEntries

func (kern *Kernel) RetrieveLogEntries() []LogEntry

RetrieveLogEntries returns all buffered log entries.

func (*Kernel) SetConfig

func (kern *Kernel) SetConfig(srvnum Service, key, value string) error

SetConfig stores a configuration value.

func (*Kernel) SetCreators

func (kern *Kernel) SetCreators(
	createAuthManager CreateAuthManagerFunc,
	createBoxManager CreateBoxManagerFunc,
	setupWebServer SetupWebServerFunc,
)

SetCreators store functions to be called when a service has to be created.

func (*Kernel) SetLogLevel

func (kern *Kernel) SetLogLevel(logLevel string)

SetLogLevel sets the logging level for logger maintained by the kernel.

Its syntax is: (SERVICE ":")? LEVEL (";" (SERVICE ":")? LEVEL)*.

func (*Kernel) Setup

func (kern *Kernel) Setup(progname, version string, versionTime time.Time)

Setup sets the most basic data of a software: its name, its version, and when the version was created.

func (*Kernel) Shutdown

func (kern *Kernel) Shutdown(silent bool)

Shutdown the service. Waits for all concurrent activities to stop.

func (*Kernel) Start

func (kern *Kernel) Start(headline, lineServer bool, configFilename string)

Start the service.

func (*Kernel) StartProfiling

func (kern *Kernel) StartProfiling(profileName, fileName string) error

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.

func (*Kernel) StartService

func (kern *Kernel) StartService(srvnum Service) error

StartService start the given service.

func (*Kernel) StopProfiling

func (kern *Kernel) StopProfiling() 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.

func (*Kernel) WaitForShutdown

func (kern *Kernel) WaitForShutdown()

WaitForShutdown blocks the call until Shutdown is called.

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

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

LogEntry stores values of one log line written by a 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.

Jump to

Keyboard shortcuts

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