Documentation ¶
Index ¶
- Constants
- func IsPluginTemplateEmbedded() bool
- func NewCommand(cmd string, args []string, env []string) *exec.Cmd
- func Scaffold(inputFile string, outputDir string) ([]string, error)
- type IHook
- type IPlugin
- type IRegistry
- type Plugin
- type Registry
- func (reg *Registry) Add(plugin *Plugin) bool
- func (reg *Registry) AddHook(hookName v1.HookName, priority sdkPlugin.Priority, hookMethod sdkPlugin.Method)
- func (reg *Registry) Apply(hook sdkAct.Hook) ([]*sdkAct.Output, bool)
- func (reg *Registry) Exists(name, version, remoteURL string) bool
- func (reg *Registry) ForEach(function func(sdkPlugin.Identifier, *Plugin))
- func (reg *Registry) Get(pluginID sdkPlugin.Identifier) *Plugin
- func (reg *Registry) Hooks() map[v1.HookName]map[sdkPlugin.Priority]sdkPlugin.Method
- func (reg *Registry) List() []sdkPlugin.Identifier
- func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin, startTimeout time.Duration)
- func (reg *Registry) RegisterHooks(ctx context.Context, pluginID sdkPlugin.Identifier)
- func (reg *Registry) Remove(pluginID sdkPlugin.Identifier)
- func (reg *Registry) Run(ctx context.Context, args map[string]any, hookName v1.HookName, ...) (map[string]any, *gerr.GatewayDError)
- func (reg *Registry) Shutdown()
- func (reg *Registry) Size() int
Constants ¶
const ( FolderPermissions os.FileMode = 0o755 FilePermissions os.FileMode = 0o644 )
Variables ¶
This section is empty.
Functions ¶
func IsPluginTemplateEmbedded ¶ added in v0.9.5
func IsPluginTemplateEmbedded() bool
func NewCommand ¶ added in v0.2.0
NewCommand returns a command with the given arguments and environment variables.
func Scaffold ¶ added in v0.9.5
Scaffold generates a gatewayd plugin based on the provided input file and stores the generated files in the specified output directory. The expected input file should be a YAML file containing the following fields:
```yaml remote_url: https://github.com/gatewayd-io/test-gatewayd-plugin version: 0.1 description: This is test plugin license: MIT authors:
- GatewayD Team
Types ¶
type IHook ¶ added in v0.2.5
type IHook interface { AddHook(hookName v1.HookName, priority sdkPlugin.Priority, hookMethod sdkPlugin.Method) Hooks() map[v1.HookName]map[sdkPlugin.Priority]sdkPlugin.Method Run( ctx context.Context, args map[string]any, hookName v1.HookName, opts ...grpc.CallOption, ) (map[string]any, *gerr.GatewayDError) }
type IPlugin ¶ added in v0.2.2
type IPlugin interface { Start() (net.Addr, error) Stop() Dispense() (v1.GatewayDPluginServiceClient, *gerr.GatewayDError) Ping() *gerr.GatewayDError }
type IRegistry ¶ added in v0.2.4
type IRegistry interface { // Plugin management Add(plugin *Plugin) bool Get(pluginID sdkPlugin.Identifier) *Plugin List() []sdkPlugin.Identifier Size() int Exists(name, version, remoteURL string) bool ForEach(f func(sdkPlugin.Identifier, *Plugin)) Remove(pluginID sdkPlugin.Identifier) Shutdown() LoadPlugins(ctx context.Context, plugins []config.Plugin, startTimeout time.Duration) RegisterHooks(ctx context.Context, pluginID sdkPlugin.Identifier) Apply(hook sdkAct.Hook) ([]*sdkAct.Output, bool) // Hook management IHook }
type Plugin ¶ added in v0.0.8
func (*Plugin) Dispense ¶ added in v0.0.8
func (p *Plugin) Dispense() (v1.GatewayDPluginServiceClient, *gerr.GatewayDError)
Dispense returns the plugin client.
func (*Plugin) Ping ¶ added in v0.4.1
func (p *Plugin) Ping() *gerr.GatewayDError
Ping pings the plugin.
type Registry ¶ added in v0.0.8
type Registry struct { ActRegistry *act.Registry DevMode bool Logger zerolog.Logger Compatibility config.CompatibilityPolicy StartTimeout time.Duration // contains filtered or unexported fields }
func NewRegistry ¶ added in v0.0.8
NewRegistry creates a new plugin registry.
func (*Registry) AddHook ¶ added in v0.2.4
func (reg *Registry) AddHook(hookName v1.HookName, priority sdkPlugin.Priority, hookMethod sdkPlugin.Method)
AddHook adds a hook with a priority to the hooks map.
func (*Registry) ForEach ¶ added in v0.3.0
func (reg *Registry) ForEach(function func(sdkPlugin.Identifier, *Plugin))
ForEach iterates over all plugins in the registry.
func (*Registry) Get ¶ added in v0.0.8
func (reg *Registry) Get(pluginID sdkPlugin.Identifier) *Plugin
Get returns a plugin from the registry.
func (*Registry) List ¶ added in v0.0.8
func (reg *Registry) List() []sdkPlugin.Identifier
List returns a list of all plugins in the registry.
func (*Registry) LoadPlugins ¶ added in v0.0.8
func (reg *Registry) LoadPlugins( ctx context.Context, plugins []config.Plugin, startTimeout time.Duration, )
LoadPlugins loads plugins from the config file.
func (*Registry) RegisterHooks ¶ added in v0.0.8
func (reg *Registry) RegisterHooks(ctx context.Context, pluginID sdkPlugin.Identifier)
RegisterHooks registers the hooks for the given plugin.
func (*Registry) Remove ¶ added in v0.0.8
func (reg *Registry) Remove(pluginID sdkPlugin.Identifier)
Remove removes plugin hooks and then removes the plugin from the registry.
func (*Registry) Run ¶ added in v0.2.4
func (reg *Registry) Run( ctx context.Context, args map[string]any, hookName v1.HookName, opts ...grpc.CallOption, ) (map[string]any, *gerr.GatewayDError)
Run runs the hooks of a specific type. The result of the previous hook is passed to the next hook as the argument, aka. chained. The context is passed to the hooks as well to allow them to cancel the execution. The args are passed to the first hook as the argument. The result of the first hook is passed to the second hook, and so on. The result of the last hook is eventually returned. The opts are passed to the hooks as well to allow them to use the grpc.CallOption.