plugin

package
v0.0.0-...-1fb74ee Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SocketPath = "plugin.sock"

Functions

func Run

func Run()

Run is used for plugin server.

Types

type Plugin

type Plugin struct {
	IO  uint64
	CPU float64

	Counter atomic.Uint64
	// contains filtered or unexported fields
}

Plugin contains the process, socket, metadata and other information of a plugin

func NewPlugin

func NewPlugin(name, version, checksum, runPath string) (*Plugin, error)

NewPlugin func creates a new plugin instance

func (*Plugin) Checksum

func (p *Plugin) Checksum() string

Checksum func returns the checksum of the plugin

func (*Plugin) Close

func (p *Plugin) Close(timeout bool)

Close func is used to close this plugin, when closing it will kill all processes under the same process group

func (*Plugin) Connect

func (p *Plugin) Connect(req procotol.RegistRequest, conn net.Conn) error

Connect func is used to verify the connection request, if the pgid is inconsistent, an error will be returned Note that it is necessary to call Server's Delete func to clean up after this func returns error

func (*Plugin) Connected

func (p *Plugin) Connected() bool

func (*Plugin) Name

func (p *Plugin) Name() string

Name func returns the name of the plugin

func (*Plugin) PID

func (p *Plugin) PID() int

PID func returns the real run pid of the plugin

func (*Plugin) Receive

func (p *Plugin) Receive() (*spec.Data, error)

Receive func is used to read data from the socket connection of plugin

func (*Plugin) Run

func (p *Plugin) Run() error

func (*Plugin) Send

func (p *Plugin) Send(t spec.Task) error

Send func is used to send tasks to this plugin

func (*Plugin) Version

func (p *Plugin) Version() string

Version func returns the version of the plugin

type Server

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

Server is the unix doamin socket listener of the plugin, and it maintains a plugin map

func GetServer

func GetServer() (*Server, error)

GetServer func is used to obtain the server instance, please note: this function is not concurrently safe

func (*Server) Close

func (s *Server) Close()

Close func closes the unix domain socket listener in the server and deletes all plugin instances

func (*Server) Delete

func (s *Server) Delete(k string)

Delete func deletes a plugin instance from the server, the Close() method of the plugin will be called before deleting from the map

func (*Server) ForEach

func (s *Server) ForEach(f func(string, *Plugin))

ForEach is used to traverse all plugin instances with specified operations, for efficiency reasons, do not perform longer operations

func (*Server) Get

func (s *Server) Get(k string) (*Plugin, bool)

Get func gets the plugin instance with the corresponding name from the Server

func (*Server) Insert

func (s *Server) Insert(k string, p *Plugin)

Insert a new plugin, note: if there is a plugin with the same name before, please close it first

func (*Server) PluginList

func (s *Server) PluginList() []string

PluginList func traverses the server map and returns all plugin names

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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