modutil

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 12 Imported by: 8

Documentation

Index

Constants

View Source
const AKLogoType = "image/svg+xml"

Variables

View Source

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Bus         *bus.Bus
	KV          kv.KV
	Log         *log.MasterLogger
	Web         Web
	StoragePath string
	CachePath   string
	HttpClient  *http.Client
	Config      *svc.Config
	// contains filtered or unexported fields
}

Deps carries the deps of the modules system itself, not deps for a specific module

func (*Deps) UpdateConfig added in v0.1.8

func (d *Deps) UpdateConfig(cfg *svc.Config)

func (*Deps) WatchConfig added in v0.1.8

func (d *Deps) WatchConfig(fn func(*svc.Config))

type Module

type Module interface {
	Start(context.Context, *ModuleDeps) error
	Icon() ([]byte, string, error)
}

A Module can be started with context and deps

type ModuleBase

type ModuleBase struct {
	Log log.Logger
	// contains filtered or unexported fields
}

ModuleBase provides some common module functionality

func (*ModuleBase) Go

func (mb *ModuleBase) Go(fn func() error)

Go launches a goroutine with the provided function using the internal errgroup

func (*ModuleBase) Icon added in v0.0.16

func (mb *ModuleBase) Icon() ([]byte, string, error)

Icon returns a default icon and MIME type

func (*ModuleBase) MarshalMessage

func (mb *ModuleBase) MarshalMessage(msg *bus.BusMessage, v proto.Message)

MarshalMessage marshals a payload and sets it on the provided BusMessage. If marshalling fails, an error is logged and msg.Error is set

func (*ModuleBase) UnmarshalMessage

func (mb *ModuleBase) UnmarshalMessage(msg *bus.BusMessage, v protoreflect.ProtoMessage) *bus.Error

UnmarshalMessage unmarshals a payload from a BusMessage. If unmarshalling fails, an error is logged and a *bus.Error is returned. A useful idiom is:

if reply.Error = m.UnmarshallMessage(msg, target); reply.Error != nil {
    return reply
}

func (*ModuleBase) Wait

func (mb *ModuleBase) Wait() error

Wait for the internal errgroup to finish.

type ModuleDeps

type ModuleDeps struct {
	Bus         *bus.Bus
	KV          kv.KVPrefix
	Log         log.Logger
	StoragePath string
	CachePath   string
	Svc         Service
}

ModuleDeps carries the deps specific to a module.

type PluginContext added in v0.1.8

type PluginContext struct {
	RWDataPath string
}

type Service added in v0.0.19

type Service interface {
	Handle(ctx *PluginContext, msg *bus.BusMessage) *bus.BusMessage
	CloseModule(moduleID string)
}

type Web

type Web interface {
	Handle(path string, handler http.Handler)
}

Web things can handle HTTP requests

Jump to

Keyboard shortcuts

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