pluggable

package module
v0.0.0-...-8b59b89 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 14 Imported by: 4

README

go-module

Modular Library for GoLang

Installation

go get -u github.com/moisespsena/go-module

Documentation

Index

Constants

View Source
const (
	E_REGISTER     = "register"
	E_INIT         = "init"
	E_INIT_PLUGINS = "initPlugins"
	E_INIT_DONE    = "initDone"
	E_POST_INIT    = "postInit"
)

Variables

View Source
var (
	EAll     = edis.EAll
	NewEvent = edis.NewEvent
)
View Source
var (
	SortedError = errors.New("Sorted")
	Initialized = errors.New("Initialized")
)
View Source
var E_FS = PKG + ".FS"
View Source
var E_LOCALE_FS = PKG + ".localeFS"

Functions

func DefaultFSPathRegister

func DefaultFSPathRegister(fs assetfsapi.PathRegistrator, pth string) error

func InitPluginFS

func InitPluginFS(pls PluginFSInterface)

func InitPluginI18nFS

func InitPluginI18nFS(pls I18nPluginsInterface)

func IsInitializador

func IsInitializador(v interface{}) bool

func IsOptionsProvider

func IsOptionsProvider(v interface{}) bool

func OnFS

func OnFS(p EventDispatcherInterface, cb func(e *FSEvent))

func OnInit

func OnInit(dis EventDispatcherInterface, callbacks ...interface{}) error

func OnLocaleFS

func OnLocaleFS(p EventDispatcherInterface, cb func(e *LocaleFSEvent))

func OnPostInit

func OnPostInit(dis EventDispatcherInterface, callbacks ...interface{}) error

func UID

func UID(v interface{}) string

func UIDs

func UIDs(vs ...interface{}) []string

Types

type Accessible

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

func (*Accessible) Plugin

func (a *Accessible) Plugin() *Plugin

func (*Accessible) SetPlugin

func (a *Accessible) SetPlugin(plugin *Plugin)

type CallbackFunc

type CallbackFunc = edis.CallbackFunc

type CallbackFuncE

type CallbackFuncE = edis.CallbackFuncE

type Event

type Event = edis.Event

type EventDispatcher

type EventDispatcher struct {
	edis.EventDispatcher
}

func (*EventDispatcher) On

func (ed *EventDispatcher) On(eventName string, callbacks ...interface{})

func (*EventDispatcher) OnE

func (ed *EventDispatcher) OnE(eventName string, callbacks ...interface{}) error

type EventDispatcherInterface

type EventDispatcherInterface = edis.EventDispatcherInterface

type EventInterface

type EventInterface = edis.EventInterface

type Extension

type Extension interface {
	Init(plugins *Plugins) error
}

type FSEvent

type FSEvent struct {
	PluginEventInterface
	AssetFS       assetfsapi.Interface
	AssetRegister func(fs assetfsapi.PathRegistrator, pth string) error
	PrivateFS     assetfsapi.Interface
}

func (FSEvent) PathOf

func (FSEvent) PathOf(value interface{}) (pth string)

func (*FSEvent) RegisterAssetPath

func (a *FSEvent) RegisterAssetPath(basePath string)

type FSSetter

type FSSetter interface {
	SetFS(fs assetfsapi.Interface)
}

type GlobalOptions

type GlobalOptions struct {
	GlobalOptions *Options
}

func (GlobalOptions) GetGlobalOptions

func (b GlobalOptions) GetGlobalOptions() *Options

func (*GlobalOptions) SetGlobalOptions

func (b *GlobalOptions) SetGlobalOptions(options *Options)

type GlobalOptionsInterface

type GlobalOptionsInterface interface {
	SetGlobalOptions(options *Options)
	GetGlobalOptions() *Options
}

type I18nPlugins

type I18nPlugins struct {
	PluginsFS
	// contains filtered or unexported fields
}

func NewI18nPlugins

func NewI18nPlugins(fs assetfsapi.Interface, nameSpace string) *I18nPlugins

func (*I18nPlugins) LocaleFS

func (pls *I18nPlugins) LocaleFS() assetfsapi.Interface

type I18nPluginsInterface

type I18nPluginsInterface interface {
	PluginFSInterface
	LocaleFS() assetfsapi.Interface
}

type LocaleFSEvent

type LocaleFSEvent struct {
	PluginEventInterface
	LocaleFS assetfsapi.Interface
}

func (*LocaleFSEvent) RegisterWithNameSpace

func (e *LocaleFSEvent) RegisterWithNameSpace(nameSpace, basePath string) error

type LogSetter

type LogSetter interface {
	SetLog(log logging.Logger)
}

type Logged

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

func (*Logged) Log

func (l *Logged) Log() logging.Logger

func (*Logged) SetLog

func (l *Logged) SetLog(log logging.Logger)

type LoggedInterface

type LoggedInterface interface {
	LoggerSetter
	Log() logging.Logger
}

type LoggerSetter

type LoggerSetter interface {
	SetLogger(Log logging.Logger)
}

type NamedPlugin

type NamedPlugin interface {
	Name() string
}

type OptionProvider

type OptionProvider interface {
	ProvidesOptions(options *Options)
}

type OptionProviderE

type OptionProviderE interface {
	ProvidesOptions(options *Options) (err error)
}

type Options

type Options struct {
	options.Options
}

func NewOptions

func NewOptions(data ...map[string]interface{}) *Options

type Parent

type Parent struct {
	Value EventInterface
}

type Plugin

type Plugin struct {
	Index                 int
	Path                  string
	AbsPath               string
	Value                 interface{}
	ReflectedValue        reflect.Value
	AssetsRoot, NameSpace string
	// contains filtered or unexported fields
}

func Filter

func Filter(f func(p *Plugin) bool, plugin ...*Plugin) (result []*Plugin)

func (*Plugin) Logger

func (p *Plugin) Logger() logging.Logger

func (*Plugin) SetLoggerLevel

func (p *Plugin) SetLoggerLevel(level logging.Level)

func (*Plugin) String

func (p *Plugin) String() string

func (*Plugin) UID

func (p *Plugin) UID() string

type PluginAccess

type PluginAccess interface {
	PluginSetter
	Plugin() *Plugin
}

type PluginAfterI

type PluginAfterI interface {
	After() []interface{}
}

type PluginAfterUID

type PluginAfterUID interface {
	After() []string
}

type PluginAssetFSSetter

type PluginAssetFSSetter interface {
	SetPrivateFS(fs assetfsapi.Interface)
}

type PluginAssetsRootPath

type PluginAssetsRootPath interface {
	AssetsRootPath() string
}

type PluginBeforeI

type PluginBeforeI interface {
	Before() []interface{}
}

type PluginBeforeUID

type PluginBeforeUID interface {
	Before() []string
}

type PluginCallbackFunc

type PluginCallbackFunc func(pe PluginEventInterface)

func (PluginCallbackFunc) Call

type PluginCallbackFuncE

type PluginCallbackFuncE func(pe PluginEventInterface) error

func (PluginCallbackFuncE) Call

type PluginEvent

type PluginEvent struct {
	EventInterface
	// contains filtered or unexported fields
}

func NewPluginEvent

func NewPluginEvent(e interface{}, data ...interface{}) (pe *PluginEvent)

func (*PluginEvent) Options

func (pe *PluginEvent) Options() *Options

func (*PluginEvent) Plugin

func (pe *PluginEvent) Plugin() *Plugin

func (*PluginEvent) PluginDispatcher

func (pe *PluginEvent) PluginDispatcher() PluginEventDispatcherInterface

func (*PluginEvent) SetOptions

func (pe *PluginEvent) SetOptions(o *Options)

func (*PluginEvent) SetPlugin

func (pe *PluginEvent) SetPlugin(p *Plugin)

func (*PluginEvent) WithPluginDispatcher

func (pe *PluginEvent) WithPluginDispatcher(dis PluginEventDispatcherInterface) func()

type PluginEventCallback

type PluginEventCallback func(e PluginEventInterface)

func (PluginEventCallback) Call

type PluginEventCallbackE

type PluginEventCallbackE func(e PluginEventInterface) error

func (PluginEventCallbackE) Call

type PluginEventCallbackInterface

type PluginEventCallbackInterface interface {
	Call(pe PluginEventInterface) error
}

type PluginEventDispatcher

type PluginEventDispatcher struct {
	EventDispatcher

	PluginsGetter func() []*Plugin
	// contains filtered or unexported fields
}

func (*PluginEventDispatcher) EachPlugins

func (ped *PluginEventDispatcher) EachPlugins(items []*Plugin, cb func(plugin *Plugin) (err error)) (err error)

func (*PluginEventDispatcher) EachPluginsCallback

func (ped *PluginEventDispatcher) EachPluginsCallback(items []*Plugin, callbacks ...func(plugin *Plugin) error) (err error)

func (*PluginEventDispatcher) GetPlugins

func (ped *PluginEventDispatcher) GetPlugins() []*Plugin

func (*PluginEventDispatcher) OnPlugin

func (ped *PluginEventDispatcher) OnPlugin(eventName string, callbacks ...interface{})

func (*PluginEventDispatcher) OnPluginE

func (ped *PluginEventDispatcher) OnPluginE(eventName string, callbacks ...interface{}) (err error)

func (*PluginEventDispatcher) Options

func (ped *PluginEventDispatcher) Options() *Options

func (*PluginEventDispatcher) PluginDispatcher

func (ped *PluginEventDispatcher) PluginDispatcher() PluginEventDispatcherInterface

func (*PluginEventDispatcher) SetDispatcher

func (ped *PluginEventDispatcher) SetDispatcher(dis EventDispatcherInterface)

func (*PluginEventDispatcher) SetOptions

func (ped *PluginEventDispatcher) SetOptions(options *Options)

func (*PluginEventDispatcher) TriggerPlugins

func (ped *PluginEventDispatcher) TriggerPlugins(e EventInterface, plugins ...*Plugin) (err error)

type PluginEventDispatcherInterface

type PluginEventDispatcherInterface interface {
	EventDispatcherInterface
	OnPluginE(eventName string, callbacks ...interface{}) error
	OnPlugin(eventName string, callbacks ...interface{})
	TriggerPlugins(e EventInterface, plugins ...*Plugin) (err error)
	EachPlugins(items []*Plugin, cb func(plugin *Plugin) (err error)) (err error)
	EachPluginsCallback(items []*Plugin, callbacks ...func(plugin *Plugin) error) (err error)
	Options() *Options
	GetPlugins() []*Plugin
}

func Dispatcher

func Dispatcher(options *Options) PluginEventDispatcherInterface

type PluginEventInterface

type PluginEventInterface interface {
	EventInterface
	PluginDispatcher() PluginEventDispatcherInterface
	Plugin() *Plugin
	SetPlugin(*Plugin)
	Options() *Options
	SetOptions(*Options)
	WithPluginDispatcher(dis PluginEventDispatcherInterface) func()
}

type PluginFSInterface

type PluginFSInterface interface {
	PluginEventDispatcherInterface
	SetAssetFSPathRegister(regiser func(fs assetfsapi.PathRegistrator, pth string) error)
	AssetFSPathRegister() func(fs assetfsapi.PathRegistrator, pth string) error
	FS() assetfsapi.Interface
	PrivateFS() assetfsapi.Interface
	PluginPrivateFS(pluginID string) assetfsapi.Interface
}

type PluginFSNameSpace

type PluginFSNameSpace interface {
	NameSpace() string
}

type PluginInit

type PluginInit interface {
	Init()
}

type PluginInitE

type PluginInitE interface {
	Init() error
}

type PluginInitOptions

type PluginInitOptions interface {
	Init(options *Options)
}

type PluginInitOptionsE

type PluginInitOptionsE interface {
	Init(options *Options) error
}

type PluginPrivateFSSetter

type PluginPrivateFSSetter interface {
	SetPrivateFS(fs assetfsapi.Interface)
}

type PluginProvideOptions

type PluginProvideOptions interface {
	ProvideOptions() []string
}

type PluginRegister

type PluginRegister interface {
	OnRegister()
}

type PluginRegisterArg

type PluginRegisterArg interface {
	OnRegister(p *Plugin)
}

type PluginRegisterOptionsArg

type PluginRegisterOptionsArg interface {
	OnRegister(options *Options)
}

type PluginRequireOptions

type PluginRequireOptions interface {
	RequireOptions() []string
}

type PluginSetter

type PluginSetter interface {
	SetPlugin(p *Plugin)
}

type Plugins

type Plugins struct {
	Logged
	PluginEventDispatcher
	ByUID      PluginsMap
	Extensions []Extension
	// contains filtered or unexported fields
}

func NewPlugins

func NewPlugins() *Plugins

func (*Plugins) Add

func (pls *Plugins) Add(plugin ...interface{}) (err error)

func (*Plugins) AddTo

func (pls *Plugins) AddTo(to *[]*Plugin, plugin ...interface{}) (err error)

func (*Plugins) After

func (pls *Plugins) After(self, other interface{})

func (*Plugins) Before

func (pls *Plugins) Before(self, other interface{})

func (*Plugins) Each

func (pls *Plugins) Each(cb func(plugin *Plugin) (err error)) (err error)

func (*Plugins) Extension

func (pls *Plugins) Extension(extensions ...Extension) (err error)

func (*Plugins) Init

func (pls *Plugins) Init() (err error)

func (*Plugins) ProvideOptions

func (pls *Plugins) ProvideOptions() (err error)

func (*Plugins) TriggerPlugins

func (pls *Plugins) TriggerPlugins(e edis.EventInterface, plugins ...*Plugin) (err error)

type PluginsFS

type PluginsFS struct {
	*Plugins
	// contains filtered or unexported fields
}

func NewPluginsFS

func NewPluginsFS(fs assetfsapi.Interface) *PluginsFS

func (*PluginsFS) AssetFSPathRegister

func (p *PluginsFS) AssetFSPathRegister() func(fs assetfsapi.PathRegistrator, pth string) error

func (*PluginsFS) FS

func (p *PluginsFS) FS() assetfsapi.Interface

func (*PluginsFS) PluginPrivateFS

func (p *PluginsFS) PluginPrivateFS(pluginUID string) assetfsapi.Interface

func (*PluginsFS) PrivateFS

func (p *PluginsFS) PrivateFS() assetfsapi.Interface

func (*PluginsFS) SetAssetFSPathRegister

func (p *PluginsFS) SetAssetFSPathRegister(register func(fs assetfsapi.PathRegistrator, pth string) error)

type PluginsMap

type PluginsMap map[string]*Plugin

func (*PluginsMap) Add

func (this *PluginsMap) Add(plugin ...*Plugin)

func (*PluginsMap) Get

func (this *PluginsMap) Get(uid string) *Plugin

func (*PluginsMap) Has

func (this *PluginsMap) Has(uid string) bool

type Sorter

type Sorter struct {
	PluginsMap
	Plugins         []*Plugin
	Befores, Afters map[string][]string
	Pre, Post       func(state *SorterState) error
}

func (Sorter) Sort

func (this Sorter) Sort(do func(state *SorterState, p *Plugin) (err error)) (result []*Plugin, err error)

type SorterState

type SorterState struct {
	Plugins []*Plugin
	Graph   *topsort.Graph

	Befors, Afters map[string][]string
	// contains filtered or unexported fields
}

func (SorterState) UidOrPanic

func (this SorterState) UidOrPanic(v interface{}) string

Jump to

Keyboard shortcuts

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