module

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "SAGOO_PLUGIN",
	MagicCookieValue: "sagoo_plugin",
}

HandshakeConfig 握手配置,插件进程和宿主机进程,都需要保持一致

Functions

func OutJsonRes

func OutJsonRes(code int, message string, data interface{}) string

OutJsonRes 输出json字符串结果

Types

type Notice

type Notice interface {
	Info() model.PluginInfo
	Send(data []byte) model.JsonRes
}

Notice 通知服务插件接口

type NoticePlugin

type NoticePlugin struct{}

NoticePlugin 插件的虚拟实现。用于PluginMap的插件接口。在运行时,来自插件实现的实际实现会覆盖

func (NoticePlugin) Client

func (NoticePlugin) Client(b *gplugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client 此方法由宿主进程调用

func (NoticePlugin) Server

func (NoticePlugin) Server(*gplugin.MuxBroker) (interface{}, error)

Server 此方法由插件进程延迟的调用

type NoticeRPC

type NoticeRPC struct {
	Client *rpc.Client
}

NoticeRPC 基于RPC实现

func (*NoticeRPC) Info

func (g *NoticeRPC) Info() model.PluginInfo

func (*NoticeRPC) Send

func (g *NoticeRPC) Send(data []byte) model.JsonRes

type NoticeRPCServer

type NoticeRPCServer struct {
	Impl Notice
}

NoticeRPCServer GreeterRPC的RPC服务器,符合 net/rpc的要求

func (*NoticeRPCServer) Info

func (s *NoticeRPCServer) Info(args interface{}, resp *model.PluginInfo) error

func (*NoticeRPCServer) Send

func (s *NoticeRPCServer) Send(data []byte, resp *model.JsonRes) error

type Protocol

type Protocol interface {
	Info() model.PluginInfo
	Encode(args interface{}) model.JsonRes
	Decode(data model.DataReq) model.JsonRes
}

Protocol 协议解析插件接口

type ProtocolPlugin

type ProtocolPlugin struct{}

ProtocolPlugin 插件的虚拟实现。用于PluginMap的插件接口。在运行时,来自插件实现的实际实现会覆盖

func (*ProtocolPlugin) Client

func (p *ProtocolPlugin) Client(b *gplugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client 此方法由宿主进程调用

func (*ProtocolPlugin) Server

func (p *ProtocolPlugin) Server(*gplugin.MuxBroker) (interface{}, error)

Server 此方法由插件进程延迟的调用

type ProtocolRPC

type ProtocolRPC struct {
	Client *rpc.Client
}

ProtocolRPC 基于RPC实现

func (*ProtocolRPC) Decode added in v1.0.3

func (p *ProtocolRPC) Decode(data model.DataReq) model.JsonRes

func (*ProtocolRPC) Encode added in v1.0.3

func (p *ProtocolRPC) Encode(args interface{}) model.JsonRes

func (*ProtocolRPC) Info

func (p *ProtocolRPC) Info() model.PluginInfo

type ProtocolRPCServer

type ProtocolRPCServer struct {
	// 内嵌业务接口
	// 插件进程会将实现业务接口的对象赋值给Impl
	Impl Protocol
}

ProtocolRPCServer GreeterRPC的RPC服务器,符合 net/rpc的要求

func (*ProtocolRPCServer) Decode added in v1.0.3

func (s *ProtocolRPCServer) Decode(args model.DataReq, resp *model.JsonRes) error

func (*ProtocolRPCServer) Encode added in v1.0.3

func (s *ProtocolRPCServer) Encode(args interface{}, resp *model.JsonRes) error

func (*ProtocolRPCServer) Info

func (s *ProtocolRPCServer) Info(args interface{}, resp *model.PluginInfo) error

Jump to

Keyboard shortcuts

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