plugin

package
v0.0.0-...-b02c517 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[P Plugin[O], O any](name string, opts ...Option[O]) (P, error)

Get gets a plugin and initialize it using the given options. If the plugin does not exist, its builder if registered will be used with the options to instantiate the plugin. If the builder is not registered, an error will be returned.

func Register

func Register[P Plugin[O], O any](name string, builder Buidler[P, O])

Register registers a provider builder.

Types

type Buidler

type Buidler[P, O any] func(...Option[O]) P

Builder is a provider builder.

func GetBuilder

func GetBuilder[P Plugin[O], O any](name string) (Buidler[P, O], bool)

type Option

type Option[O any] func(*O)

Option is functional wrapper for an option.

type Plugin

type Plugin[O any] interface {
	// Init initializes the provider using some options.
	Init(...Option[O])
	// String returns the implementation name.
	String() string
}

Plugin represents a dependency to be auto-wired.

Jump to

Keyboard shortcuts

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