bus

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	ResultChannel   *Channel[*ResultMsg]
	RequestChannel  *Channel[*RequestMsg]
	JobChannel      *Channel[*JobMsg]
	DatabaseChannel *Channel[*DatabaseUpdateMsg]
}

func New

func New() *Bus

type Channel added in v0.10.0

type Channel[T any] struct {
	Subscriber []func(T)
}

func (*Channel[T]) Publish added in v0.10.0

func (c *Channel[T]) Publish(msg T)

func (*Channel[T]) Subscribe added in v0.10.0

func (c *Channel[T]) Subscribe(handler func(T))

type DatabaseUpdateMsg

type DatabaseUpdateMsg struct {
	IDs  []driver.DocumentID `json:"ids"`
	Type DatabaseUpdateType  `json:"type"`
}

type DatabaseUpdateType

type DatabaseUpdateType string
const (
	DatabaseEntryRead    DatabaseUpdateType = "read"
	DatabaseEntryCreated DatabaseUpdateType = "created"
	DatabaseEntryUpdated DatabaseUpdateType = "updated"
)

type JobMsg

type JobMsg struct {
	ID         string         `json:"id"`
	Automation string         `json:"automation"`
	Origin     *model.Origin  `json:"origin"`
	Message    *model.Message `json:"message"`
}

type RequestMsg

type RequestMsg struct {
	IDs      []driver.DocumentID `json:"ids"`
	Function string              `json:"function"`
	User     string              `json:"user"`
}

type ResultMsg

type ResultMsg struct {
	Automation string         `json:"automation"`
	Data       map[string]any `json:"data,omitempty"`
	Target     *model.Origin  `json:"target"`
}

Jump to

Keyboard shortcuts

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