marvin

package module
v0.0.0-...-16b2e41 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 13 Imported by: 0

README

marvin

It's Marvin; it's a synergy clone, but this time with slighly more go knowledge behind it.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShuttingDown = errors.New("shutting down")

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Name() BusName
	Run(context.Context, BusBundle) error
	SendMessage(ctx context.Context, address any, text string)
}

type BusAssembler

type BusAssembler func(BusName, arbitraryConfig) (Bus, error)

type BusBundle

type BusBundle struct {
	Events  chan<- Event
	Replies <-chan Reply
	Errors  chan<- error
}

type BusName

type BusName string

type Config

type Config struct {
	Name     string
	LogLevel slog.Level `toml:"log_level"`
	Bus      map[string]arbitraryConfig
	Reactor  map[string]arbitraryConfig
	// contains filtered or unexported fields
}

func (*Config) Assemble

func (cfg *Config) Assemble(registry Registry) (*Hub, error)

type Event

type Event struct {
	Text      string
	SourceBus BusName
	Address   any
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent(source Bus) Event

func (*Event) Done

func (e *Event) Done() <-chan struct{}

func (*Event) ID

func (e *Event) ID() uint64

func (*Event) MarkHandled

func (e *Event) MarkHandled()

func (*Event) Reply

func (e *Event) Reply(format string, args ...any) Reply

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func FromFile

func FromFile(path string, registry Registry) (*Hub, error)

func New

func New() *Hub

func (*Hub) Run

func (h *Hub) Run() error

type Reactor

type Reactor interface {
	Run(context.Context, ReactorBundle) error
}

type ReactorAssembler

type ReactorAssembler func(ReactorName, arbitraryConfig) (Reactor, error)

type ReactorBundle

type ReactorBundle struct {
	Events  <-chan Event
	Replies chan<- Reply
	Errors  chan<- error
}

type ReactorName

type ReactorName string

type Registry

type Registry interface {
	BusFor(string) BusAssembler
	ReactorFor(string) ReactorAssembler
}

type Reply

type Reply struct {
	Bus     BusName
	Address any
	Text    string
}

Directories

Path Synopsis
buses
cmd
reactors

Jump to

Keyboard shortcuts

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