mplugin

package
v0.5.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TriggerHook

func TriggerHook[A any](p *PluginController, name string, arg A) error

TODO: fix the bloody thing

Types

type HookEntries

type HookEntries[A any] struct {
	Mu   sync.RWMutex
	Data map[HookID]HookEntry[A]
}

func NewHookEntries

func NewHookEntries[A any]() *HookEntries[A]

func (*HookEntries[A]) Add

func (s *HookEntries[A]) Add(hook func(A) error, pluginID PluginID) HookID

func (*HookEntries[A]) Num

func (s *HookEntries[A]) Num() int

func (*HookEntries[A]) RemoveByHookID

func (s *HookEntries[A]) RemoveByHookID(hookID HookID) bool

func (*HookEntries[A]) RemoveByPluginID

func (s *HookEntries[A]) RemoveByPluginID(pluginID PluginID) bool

func (*HookEntries[A]) Run

func (s *HookEntries[A]) Run(arg A) error

type HookEntry

type HookEntry[A any] struct {
	// contains filtered or unexported fields
}

type HookID

type HookID umid.UMID

func PluginSubscribeHook

func PluginSubscribeHook[A any](p PluginInterface, name string, hook func(A) error) (HookID, error)

type NewInstanceFunction

type NewInstanceFunction func(pluginInterface PluginInterface) (PluginInstance, error)

type PluginController

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

func NewPluginController

func NewPluginController(parent umid.UMID) *PluginController

func (*PluginController) AddPlugin

func (p *PluginController) AddPlugin(pluginID umid.UMID, f NewInstanceFunction) (PluginInstance, error)

func (*PluginController) NewPluginInterface

func (p *PluginController) NewPluginInterface(id PluginID) PluginInterface

func (*PluginController) UnsubscribeAllHooks

func (p *PluginController) UnsubscribeAllHooks(plugin PluginInterface) error

func (*PluginController) UnsubscribeHookByHookId

func (p *PluginController) UnsubscribeHookByHookId(plugin PluginInterface, id HookID) error

func (*PluginController) UnsubscribeHooksByName

func (p *PluginController) UnsubscribeHooksByName(plugin PluginInterface, name string) error

func (*PluginController) ValidPlugin

func (p *PluginController) ValidPlugin(id PluginID, secret umid.UMID) bool

type PluginID

type PluginID umid.UMID

type PluginInstance

type PluginInstance any

type PluginInterface

type PluginInterface interface {
	GetId() PluginID
	GetWorld() umid.UMID
	GetSecret() umid.UMID

	//SubscribeHook(name string, hook any) (HookID, error)
	UnsubscribeAllHooks() error
	UnsubscribeHooksByName(name string) error
	UnsubscribeHookByHookId(id HookID) error
	// contains filtered or unexported methods
}

type PluginSubscriberInterface

type PluginSubscriberInterface[A any] interface {
	PluginSubscribeHook(PluginInterface, string, func(A) error) (HookID, error)
}

Jump to

Keyboard shortcuts

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