cdevents

package
v0.0.0-...-6d6c6c5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{

	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Handshake is a common handshake that is shared by plugins and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	"translator_grpc": &TranslatorGRPCPlugin{},
	"translator":      &TranslatorPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

func Download

func Download(pluginURL string, pluginPath string) error

func SendCDEvent

func SendCDEvent(event string, messageBrokerURL string) error

func ValidateURL

func ValidateURL(URL string) (string, error)

Types

type EventTranslator

type EventTranslator interface {
	TranslateEvent(event string, headers http.Header) (string, error)
}

EventTranslator is the interface that we're exposing as a plugins.

type GRPCClient

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

func (*GRPCClient) TranslateEvent

func (m *GRPCClient) TranslateEvent(event string, header http.Header) (string, error)

type GRPCServer

type GRPCServer struct {
	Impl EventTranslator
}

func (*GRPCServer) TranslateEvent

type Plugin

type Plugin struct {
	Name          string `yaml:"name"`
	PluginURL     string `yaml:"pluginURL"`
	MessageBroker string `yaml:"messageBroker"`
}

type RPCClient

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

RPCClient is an implementation of EventTranslator that talks over RPC.

func (*RPCClient) TranslateEvent

func (m *RPCClient) TranslateEvent(event string, headers http.Header) (string, error)

type RPCServer

type RPCServer struct {
	// This is the real implementation
	Impl EventTranslator
}

Here is the RPC server that RPCClient talks to, conforming to the requirements of net/rpc

func (*RPCServer) TranslateEvent

func (m *RPCServer) TranslateEvent(event string, headers http.Header, resp *string) error

type Translator

type Translator struct {
	Path    string   `yaml:"path"`
	Plugins []Plugin `yaml:"plugins"`
}

type TranslatorGRPCPlugin

type TranslatorGRPCPlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl EventTranslator
}

TranslatorGRPCPlugin is the implementation of plugin.GRPCPlugin so we can serve/consume this.

func (*TranslatorGRPCPlugin) GRPCClient

func (p *TranslatorGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*TranslatorGRPCPlugin) GRPCServer

func (p *TranslatorGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type TranslatorPlugin

type TranslatorPlugin struct {
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl EventTranslator
}

TranslatorPlugin is the implementation of plugins.Plugin so we can serve/consume this.

func (*TranslatorPlugin) Client

func (*TranslatorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*TranslatorPlugin) Server

func (p *TranslatorPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type TranslatorPlugins

type TranslatorPlugins struct {
	Translator Translator `yaml:"translator"`
}

func LoadConfig

func LoadConfig(fileName string) (*TranslatorPlugins, error)

Jump to

Keyboard shortcuts

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