plugins

package
v1.1.130 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](r *Registry, id PluginID) T

Get retrieves a registered implementation for the ID. If one doesn't exist, it returns the default implementation. If the id isn't found, it returns nil.

Types

type AtomicRegistry

type AtomicRegistry struct {
	atomic.Value
}

func NewAtomicRegistry

func NewAtomicRegistry(initialValue *Registry) AtomicRegistry

NewAtomicRegistry creates a new envelope to hold a Registry object.

func (*AtomicRegistry) Load

func (a *AtomicRegistry) Load() *Registry

Load loads the stored Registry or nil if non exists

func (*AtomicRegistry) Store

func (a *AtomicRegistry) Store(r *Registry)

Store stores the Registry to be retrieved later.

type PluginID

type PluginID = string
const (
	PluginIDWorkflowExecutor       PluginID = "WorkflowExecutor"
	PluginIDDataProxy              PluginID = "DataProxy"
	PluginIDUnaryServiceMiddleware PluginID = "UnaryServiceMiddleware"
	PluginIDPreRedirectHook        PluginID = "PreRedirectHook"
	PluginIDLogoutHook             PluginID = "LogoutHook"
)

type Registry

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

Registry is a generic plugin registrar for dependency injection.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry

func (*Registry) Get

func (r *Registry) Get(id PluginID) interface{}

Get retrieves a registered implementation for the ID. If one doesn't exist, it returns the default implementation. If the id isn't found, it returns nil.

func (*Registry) Register

func (r *Registry) Register(id PluginID, impl interface{}) error

Register registers a new implementation for the pluginID. Only one plugin is allowed to be registered for a given ID.

func (*Registry) RegisterDefault

func (r *Registry) RegisterDefault(id PluginID, impl interface{})

RegisterDefault registers a new implementation for the pluginID. This is the implementation that will be used if no other plugin is registered for the ID.

Jump to

Keyboard shortcuts

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