1
Interfaces
Virgil edited this page 2026-02-19 17:30:02 +00:00
Table of Contents
Interfaces
Core defines several interfaces for service contracts. Services register implementations; consumers retrieve via ServiceFor[T]().
Lifecycle
type Startable interface {
OnStartup(ctx context.Context) error
}
type Stoppable interface {
OnShutdown(ctx context.Context) error
}
Config
type Config interface {
Get(key string, out any) error
Set(key string, v any) error
}
Display
type Display interface {
OpenWindow(opts ...WindowOption) error
}
Workspace
type Workspace interface {
CreateWorkspace(identifier, password string) (string, error)
SwitchWorkspace(name string) error
WorkspaceFileGet(filename string) (string, error)
WorkspaceFileSet(filename, content string) error
}
Crypt
type Crypt interface {
CreateKeyPair(name, passphrase string) (string, error)
EncryptPGP(writer io.Writer, recipientPath, data string, opts ...any) (string, error)
DecryptPGP(recipientPath, message, passphrase string, opts ...any) (string, error)
}
TaskWithID
For tasks that need progress reporting:
type TaskWithID interface {
Task
SetTaskID(id string)
GetTaskID() string
}
Abstract Storage (pkg/io)
type Medium interface {
Read(path string) (string, error)
Write(path, content string) error
List(path string) ([]fs.DirEntry, error)
Delete(path string) error
}
Implementations: local filesystem, S3, SFTP, WebDAV.
See Service-Lifecycle for how services implement these interfaces and Message-Bus for the message type interfaces.