modutil

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 11 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
}

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

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 Service added in v0.0.19

type Service interface {
	Handle(msg *bus.BusMessage) *bus.BusMessage
}

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