goplugin

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

quadroops/goplugin

PkgGoDev

Introduction

This package is a library to implement modular and pluggable architecture for application using Golang's language.

Documentation

Please refer to our Wiki

Examples

Please refer to our examples


LICENSE

Please refer to our LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProtocol

func BuildProtocol(opt *ProtocolOption) caller.Builder

BuildProtocol a helper to check and also generate a default protocol should be used like a REST or GRPC

Types

type GoPlugin

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

GoPlugin used as main struct to store goplugin's state

func New

func New(hostName string, opts ...Option) *GoPlugin

New used to create new instance of GoPlugin, you can provide customization here by giving goplugin.Option

func (*GoPlugin) Build

func (g *GoPlugin) Build() (*host.Builder, error)

Build used to compile current host instance into consumed state of host.Builder

func (*GoPlugin) GetPluginConf

func (g *GoPlugin) GetPluginConf(pluginName string) (*PluginConf, error)

GetPluginConf used to get plugin's config

func (*GoPlugin) GetProcessInstance

func (g *GoPlugin) GetProcessInstance() *process.Instance

GetProcessInstance .

func (*GoPlugin) SetupPlugin

func (g *GoPlugin) SetupPlugin(plugins ...PluginMapper) *GoPlugin

SetupPlugin used to store host plugin's configurations

type HostPlugins

type HostPlugins struct {
	Host    string
	Plugins host.Plugins
}

HostPlugins used to store all plugins from some host

type InstallationOptions

type InstallationOptions struct {
	RetryTimeoutCaller int
}

InstallationOptions used to store any options on install

type Option

type Option func(*GoPlugin)

Option used to customize default objects

func WithCustomConfigChecker

func WithCustomConfigChecker(adapters ...discover.Checker) Option

WithCustomConfigChecker used to customize config checker, the parameter must be implement discover.Checker

func WithCustomConfigParser

func WithCustomConfigParser(parserAdapter discover.Parser, sourceAdapter discover.SourceReader) Option

WithCustomConfigParser used to customize config reader & parser, given adapters must be implement discover.Parser and discover.SourceReader interfaces

func WithCustomIdentityChecker

func WithCustomIdentityChecker(adapter host.IdentityChecker) Option

WithCustomIdentityChecker used to customize plugin's identity checker, given adapter must implement host.IdentityChecker

func WithCustomProcess

func WithCustomProcess(runner process.Runner, processes process.ProcessesBuilder) Option

WithCustomProcess used to customize process runner and process data builder (including registry)

type PluginConf

type PluginConf struct {
	Protocol *ProtocolOption
}

PluginConf used to store plugin's configurations

type PluginMapper

type PluginMapper map[string]*PluginConf

PluginMapper used as registry to store plugin's config

func Map

func Map(pluginName string, conf *PluginConf) PluginMapper

Map used to put a plugin and assign it with their spesific configurations

type PluginSupervisor

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

PluginSupervisor is main struct used to store supervisor's configurations

func Supervisor

func Supervisor(pluggable *Registry, options ...PluginSupervisorOption) *PluginSupervisor

Supervisor used to supervisor all available plugins from all hosts

func (*PluginSupervisor) AutoRestart

func (s *PluginSupervisor) AutoRestart(payload *supervisor.Payload)

AutoRestart used to restart plugin's process if cannot be reached or something went wrong

func (*PluginSupervisor) Handle

func (s *PluginSupervisor) Handle()

Handle used start error handling

func (*PluginSupervisor) OnError

func (s *PluginSupervisor) OnError(event *supervisor.Payload, handlers ...supervisor.OnErrorHandler)

OnError implement supervisor.Driver interface

func (*PluginSupervisor) Setup

func (s *PluginSupervisor) Setup(handlers ...supervisor.OnErrorHandler) error

Setup build a registry for host and their plugin and their plugin's caller and creating new supervisor's instance

func (*PluginSupervisor) Shutdown

func (s *PluginSupervisor) Shutdown()

Shutdown should be used on defer's way, it will should be automatically shutting down main supervisor's ticker

func (*PluginSupervisor) Start

func (s *PluginSupervisor) Start() *PluginSupervisor

Start used to start main supervisor process

func (*PluginSupervisor) Watch

func (s *PluginSupervisor) Watch() <-chan *supervisor.Payload

Watch implement supervisor.Driver interface

type PluginSupervisorOption

type PluginSupervisorOption func(*PluginSupervisor)

PluginSupervisorOption used to customize supervisor values

func SupervisorOptionCustomDriver

func SupervisorOptionCustomDriver(drv supervisor.Driver) PluginSupervisorOption

SupervisorOptionCustomDriver used to setup custom driver, by default will use current PluginSupervisor as driver

func SupervisorOptionInterval

func SupervisorOptionInterval(interval int) PluginSupervisorOption

SupervisorOptionInterval setup interval

type ProtocolOption

type ProtocolOption struct {
	RESTOpts *driver.RESTOptions
	GRPCOpts *driver.GrpcOptions
}

ProtocolOption used to configure rest or grpc options You have to choose between rest or grpc, if your plugin using rest, than ignore grpc option, and vice versa, but you can't ignore them both

type Registry

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

Registry used as wrapper of executor object

func Register

func Register(hostPlugins ...*GoPlugin) *Registry

Register used to collect available hosts and run executor behind it

func (*Registry) GetAllPlugins

func (r *Registry) GetAllPlugins() ([]*HostPlugins, error)

GetAllPlugins used to get all plugins from all hosts

func (*Registry) GetCaller

func (r *Registry) GetCaller(host, plugin string) (*caller.Plugin, error)

GetCaller plugin's caller instance. If plugin not started yet, this step will also run the plugin via os subprocess, before using this method you have to make sure that all hosts has been installed

func (*Registry) GetContainer

func (r *Registry) GetContainer(host string) (*executor.Container, error)

GetContainer used to get container from executor instance based on hosts

func (*Registry) GetHostPluginInstance

func (r *Registry) GetHostPluginInstance(host string) (*GoPlugin, error)

GetHostPluginInstance get GoPlugin instance based on host

func (*Registry) GetPID

func (r *Registry) GetPID(hostName, pluginName string) (process.ID, error)

GetPID used to get plugin's process id

func (*Registry) Install

func (r *Registry) Install(options *InstallationOptions) (*Registry, error)

Install used to install available hostPlugins by calling Build

func (*Registry) KillPlugins

func (r *Registry) KillPlugins()

KillPlugins used to kill all plugins from all installed hosts

Jump to

Keyboard shortcuts

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