diff --git a/buf.gen.yaml b/buf.gen.yaml index ca2eebb0..2e63aa56 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -3,12 +3,12 @@ version: v1 # enabled: true plugins: - name: go-grpc - out: gen/proto/go + out: . opt: paths=source_relative - name: go - out: gen/proto/go + out: . opt: paths=source_relative # - name: python_betterproto - # out: gen/proto/python_betterproto + # out: . # - name: java - # out: gen/proto/java + # out: . diff --git a/cmd/config_parser.go b/cmd/config_parser.go index 5651519a..2ae17e23 100644 --- a/cmd/config_parser.go +++ b/cmd/config_parser.go @@ -15,6 +15,9 @@ import ( // Global koanf instance. Using "." as the key path delimiter. var globalConfig = koanf.New(".") +// Plugin koanf instance. Using "." as the key path delimiter. +var pluginConfig = koanf.New(".") + func getPath(path string) string { ref := globalConfig.String(path) if globalConfig.Exists(path) && globalConfig.StringMap(ref) != nil { diff --git a/cmd/run.go b/cmd/run.go index 953ebe83..fe8a0f42 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -1,21 +1,25 @@ package cmd import ( + "context" "os" "os/signal" "syscall" "time" + gerr "github.com/gatewayd-io/gatewayd/errors" "github.com/gatewayd-io/gatewayd/logging" "github.com/gatewayd-io/gatewayd/network" "github.com/gatewayd-io/gatewayd/plugin" "github.com/gatewayd-io/gatewayd/pool" - "github.com/knadh/koanf" + goplugin "github.com/hashicorp/go-plugin" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/confmap" "github.com/knadh/koanf/providers/file" "github.com/panjf2000/gnet/v2" + "github.com/rs/zerolog" "github.com/spf13/cobra" + "google.golang.org/protobuf/types/known/structpb" ) const ( @@ -23,8 +27,14 @@ const ( ) var ( - configFile string - hooksConfig = plugin.NewHookConfig() + globalConfigFile string + pluginConfigFile string +) + +var ( + hooksConfig = plugin.NewHookConfig() + DefaultLogger = logging.NewLogger(logging.LoggerConfig{Level: zerolog.DebugLevel}) + pluginRegistry = plugin.NewRegistry(hooksConfig) ) // runCmd represents the run command. @@ -32,9 +42,25 @@ var runCmd = &cobra.Command{ Use: "run", Short: "Run a gatewayd instance", Run: func(cmd *cobra.Command, args []string) { + // The plugins are loaded and hooks registered + // before the configuration is loaded. + hooksConfig.Logger = DefaultLogger + + // Load the plugin configuration file + if f, err := cmd.Flags().GetString("plugin-config"); err == nil { + if err := pluginConfig.Load(file.Provider(f), yaml.Parser()); err != nil { + DefaultLogger.Fatal().Err(err).Msg("Failed to load plugin configuration") + os.Exit(gerr.FailedToLoadPluginConfig) + } + } + + // Load plugins and register their hooks + pluginRegistry.LoadPlugins(pluginConfig) + if f, err := cmd.Flags().GetString("config"); err == nil { if err := globalConfig.Load(file.Provider(f), yaml.Parser()); err != nil { - panic(err) + DefaultLogger.Fatal().Err(err).Msg("Failed to load configuration") + os.Exit(gerr.FailedToLoadGlobalConfig) } } @@ -43,39 +69,47 @@ var runCmd = &cobra.Command{ // The config will be passed to the hooks, and in turn to the plugins that // register to this hook. - result := hooksConfig.Run( - plugin.OnConfigLoaded, - plugin.Signature{"config": globalConfig.All()}, - hooksConfig.Verification) - if result != nil { - var config map[string]interface{} - if cfg, ok := result["config"].(map[string]interface{}); ok { - config = cfg - } - - if config != nil { - // Load the config from the map emitted by the hook - var hookEmittedConfig *koanf.Koanf - if err := hookEmittedConfig.Load(confmap.Provider(config, "."), nil); err != nil { - // Since the logger is not yet initialized, we can't log the error. - // So we panic. Same happens in the next if statement. - panic(err) - } + currentGlobalConfig, err := structpb.NewStruct(globalConfig.All()) + if err != nil { + DefaultLogger.Error().Err(err).Msg("Failed to convert configuration to structpb") + } else { + updatedGlobalConfig, _ := hooksConfig.Run( + context.Background(), + currentGlobalConfig, + plugin.OnConfigLoaded, + hooksConfig.Verification) + if updatedGlobalConfig != nil && plugin.Verify(updatedGlobalConfig, currentGlobalConfig) { // Merge the config with the one loaded from the file (in memory). // The changes won't be persisted to disk. - if err := globalConfig.Merge(hookEmittedConfig); err != nil { - panic(err) + if err := globalConfig.Load( + confmap.Provider(updatedGlobalConfig.AsMap(), "."), nil); err != nil { + DefaultLogger.Fatal().Err(err).Msg("Failed to merge configuration") } } } // Create a new logger from the config - logger := logging.NewLogger(loggerConfig()) - hooksConfig.Logger = logger + loggerCfg := loggerConfig() + logger := logging.NewLogger(loggerCfg) + // TODO: Use https://github.com/dcarbone/zadapters to adapt hclog to zerolog // This is a notification hook, so we don't care about the result. - hooksConfig.Run( - plugin.OnNewLogger, plugin.Signature{"logger": logger}, hooksConfig.Verification) + data, err := structpb.NewStruct(map[string]interface{}{ + "timeFormat": loggerCfg.TimeFormat, + "level": loggerCfg.Level, + "output": loggerCfg.Output, + "noColor": loggerCfg.NoColor, + }) + if err != nil { + logger.Error().Err(err).Msg("Failed to convert logger config to structpb") + } else { + // TODO: Use a context with a timeout + _, err := hooksConfig.Run( + context.Background(), data, plugin.OnNewLogger, hooksConfig.Verification) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnNewLogger hooks") + } + } // Create and initialize a pool of connections pool := pool.NewPool() @@ -90,15 +124,26 @@ var runCmd = &cobra.Command{ logger, ) - hooksConfig.Run( - plugin.OnNewClient, - plugin.Signature{ - "client": client, - }, - hooksConfig.Verification, - ) - if client != nil { + clientCfg, err := structpb.NewStruct(map[string]interface{}{ + "id": client.ID, + "network": clientConfig.Network, + "address": clientConfig.Address, + "receiveBufferSize": clientConfig.ReceiveBufferSize, + }) + if err != nil { + logger.Error().Err(err).Msg("Failed to convert client config to structpb") + } else { + _, err := hooksConfig.Run( + context.Background(), + clientCfg, + plugin.OnNewClient, + hooksConfig.Verification) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnNewClient hooks") + } + } + pool.Put(client.ID, client) } } @@ -113,15 +158,38 @@ var runCmd = &cobra.Command{ os.Exit(1) } - hooksConfig.Run( - plugin.OnNewPool, plugin.Signature{"pool": pool}, hooksConfig.Verification) + poolCfg, err := structpb.NewStruct(map[string]interface{}{ + "size": poolSize, + }) + if err != nil { + logger.Error().Err(err).Msg("Failed to convert pool config to structpb") + } else { + _, err := hooksConfig.Run( + context.Background(), poolCfg, plugin.OnNewPool, hooksConfig.Verification) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnNewPool hooks") + } + } // Create a prefork proxy with the pool of clients elastic, reuseElasticClients, elasticClientConfig := proxyConfig() proxy := network.NewProxy( pool, hooksConfig, elastic, reuseElasticClients, elasticClientConfig, logger) - hooksConfig.Run( - plugin.OnNewProxy, plugin.Signature{"proxy": proxy}, hooksConfig.Verification) + + proxyCfg, err := structpb.NewStruct(map[string]interface{}{ + "elastic": elastic, + "reuseElasticClients": reuseElasticClients, + "clientConfig": elasticClientConfig, + }) + if err != nil { + logger.Error().Err(err).Msg("Failed to convert proxy config to structpb") + } else { + _, err := hooksConfig.Run( + context.Background(), proxyCfg, plugin.OnNewProxy, hooksConfig.Verification) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnNewProxy hooks") + } + } // Create a server serverConfig := serverConfig() @@ -166,9 +234,35 @@ var runCmd = &cobra.Command{ logger, hooksConfig, ) - hooksConfig.Run( - plugin.OnNewServer, plugin.Signature{"server": server}, hooksConfig.Verification) + serverCfg, err := structpb.NewStruct(map[string]interface{}{ + "network": serverConfig.Network, + "address": serverConfig.Address, + "softLimit": serverConfig.SoftLimit, + "hardLimit": serverConfig.HardLimit, + "tickInterval": serverConfig.TickInterval, + "multiCore": serverConfig.MultiCore, + "lockOSThread": serverConfig.LockOSThread, + "enableTicker": serverConfig.EnableTicker, + "loadBalancer": serverConfig.LoadBalancer, + "readBufferCap": serverConfig.ReadBufferCap, + "writeBufferCap": serverConfig.WriteBufferCap, + "socketRecvBuffer": serverConfig.SocketRecvBuffer, + "socketSendBuffer": serverConfig.SocketSendBuffer, + "reuseAddress": serverConfig.ReuseAddress, + "reusePort": serverConfig.ReusePort, + "tcpKeepAlive": serverConfig.TCPKeepAlive, + "tcpNoDelay": serverConfig.TCPNoDelay, + }) + if err != nil { + logger.Error().Err(err).Msg("Failed to convert server config to structpb") + } else { + _, err := hooksConfig.Run( + context.Background(), serverCfg, plugin.OnNewServer, hooksConfig.Verification) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnNewServer hooks") + } + } // Shutdown the server gracefully var signals []os.Signal signals = append(signals, @@ -187,10 +281,25 @@ var runCmd = &cobra.Command{ for _, s := range signals { if sig != s { // Notify the hooks that the server is shutting down - hooksConfig.Run( - plugin.OnSignal, plugin.Signature{"signal": sig}, hooksConfig.Verification) + signalCfg, err := structpb.NewStruct(map[string]interface{}{"signal": sig}) + if err != nil { + logger.Error().Err(err).Msg( + "Failed to convert signal config to structpb") + } else { + _, err := hooksConfig.Run( + context.Background(), + signalCfg, + plugin.OnSignal, + hooksConfig.Verification, + ) + if err != nil { + logger.Error().Err(err).Msg("Failed to run OnSignal hooks") + } + } server.Shutdown() + pluginRegistry.Shutdown() + goplugin.CleanupClients() os.Exit(0) } } @@ -208,5 +317,11 @@ func init() { rootCmd.AddCommand(runCmd) runCmd.PersistentFlags().StringVarP( - &configFile, "config", "c", "./gatewayd.yaml", "config file (default is ./gatewayd.yaml)") + &globalConfigFile, + "config", "c", "./gatewayd.yaml", + "config file (default is ./gatewayd.yaml)") + runCmd.PersistentFlags().StringVarP( + &pluginConfigFile, + "plugin-config", "p", "./gatewayd_plugins.yaml", + "plugin config file (default is ./gatewayd_plugins.yaml)") } diff --git a/network/errors.go b/errors/errors.go similarity index 58% rename from network/errors.go rename to errors/errors.go index 78df2eb1..eb541e56 100644 --- a/network/errors.go +++ b/errors/errors.go @@ -1,4 +1,4 @@ -package network +package errors import "errors" @@ -7,4 +7,12 @@ var ( ErrNetworkNotSupported = errors.New("network is not supported") ErrClientNotConnected = errors.New("client is not connected") ErrPoolExhausted = errors.New("pool is exhausted") + + ErrPluginNotFound = errors.New("plugin not found") + ErrPluginNotReady = errors.New("plugin is not ready") +) + +const ( + FailedToLoadPluginConfig = 1 + FailedToLoadGlobalConfig = 2 ) diff --git a/gatewayd_plugins.yaml b/gatewayd_plugins.yaml new file mode 100644 index 00000000..170dceb2 --- /dev/null +++ b/gatewayd_plugins.yaml @@ -0,0 +1,4 @@ +gatewayd-plugin-test: + enabled: True + localPath: ../gatewayd-plugin-test/gatewayd-plugin-test + checksum: 9c12267332a609ed7c739098a0aa7614f580ba174f35f611fc1cc53de5647bff diff --git a/go.mod b/go.mod index cbf315aa..5b595925 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/gatewayd-io/gatewayd go 1.19 require ( - github.com/Masterminds/semver/v3 v3.2.0 github.com/fergusstrange/embedded-postgres v1.19.0 - github.com/gatewayd-io/gatewayd-plugin-test v0.0.0-00010101000000-000000000000 github.com/google/go-cmp v0.5.9 github.com/hashicorp/go-plugin v1.4.8 github.com/knadh/koanf v1.4.4 + github.com/mitchellh/mapstructure v1.5.0 github.com/panjf2000/gnet/v2 v2.2.0 github.com/rs/zerolog v1.28.0 github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.8.1 google.golang.org/grpc v1.51.0 + google.golang.org/protobuf v1.28.1 ) require ( @@ -29,7 +29,6 @@ require ( github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -42,7 +41,6 @@ require ( golang.org/x/sys v0.3.0 // indirect golang.org/x/text v0.5.0 // indirect google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect - google.golang.org/protobuf v1.28.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 36003eac..82fc94b0 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= -github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= diff --git a/logging/logger.go b/logging/logger.go index c828df53..ca94a720 100644 --- a/logging/logger.go +++ b/logging/logger.go @@ -24,7 +24,11 @@ type LoggerConfig struct { func NewLogger(cfg LoggerConfig) zerolog.Logger { // Create a new logger - consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: cfg.TimeFormat} + consoleWriter := zerolog.ConsoleWriter{ + Out: os.Stdout, + TimeFormat: cfg.TimeFormat, + NoColor: cfg.NoColor, + } if cfg.Output == nil { // Default to stdout diff --git a/network/proxy.go b/network/proxy.go index 144fa7d9..c30a4cb1 100644 --- a/network/proxy.go +++ b/network/proxy.go @@ -1,14 +1,17 @@ package network import ( + "context" "errors" "fmt" "io" + gerr "github.com/gatewayd-io/gatewayd/errors" "github.com/gatewayd-io/gatewayd/plugin" "github.com/gatewayd-io/gatewayd/pool" "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" + "google.golang.org/protobuf/types/known/structpb" ) type Proxy interface { @@ -74,7 +77,7 @@ func (pr *ProxyImpl) Connect(gconn gnet.Conn) error { ) pr.logger.Debug().Msgf("Reused the client %s by putting it back in the pool", client.ID) } else { - return ErrPoolExhausted + return gerr.ErrPoolExhausted } } else { // Get a client from the pool @@ -88,7 +91,7 @@ func (pr *ProxyImpl) Connect(gconn gnet.Conn) error { pr.busyConnections.Put(gconn, client) pr.logger.Debug().Msgf("Client %s has been assigned to %s", client.ID, gconn.RemoteAddr().String()) } else { - return ErrClientNotConnected + return gerr.ErrClientNotConnected } pr.logger.Debug().Msgf("[C] There are %d clients in the pool", pr.availableConnections.Size()) @@ -132,7 +135,7 @@ func (pr *ProxyImpl) PassThrough(gconn gnet.Conn) error { if cl, ok := pr.busyConnections.Get(gconn).(*Client); ok { client = cl } else { - return ErrClientNotFound + return gerr.ErrClientNotFound } // buf contains the data from the client (, length, query) @@ -141,23 +144,37 @@ func (pr *ProxyImpl) PassThrough(gconn gnet.Conn) error { pr.logger.Error().Err(err).Msgf("Error reading from client: %v", err) } - result := pr.hookConfig.Run( - plugin.OnIngressTraffic, - plugin.Signature{ - "gconn": gconn, - "client": client, - "buffer": buf, - "error": err, + //nolint:nestif + if ingressData, err := structpb.NewStruct(map[string]interface{}{ + "client": map[string]interface{}{ + "local": gconn.LocalAddr().String(), + "remote": gconn.RemoteAddr().String(), }, - pr.hookConfig.Verification) - if result != nil { - // TODO: Not sure if the gconn and client can be modified in the hook, - // so I'm not using the modified values here - if buffer, ok := result["buffer"].([]byte); ok { - buf = buffer + "server": map[string]interface{}{ + "local": client.Conn.LocalAddr().String(), + "remote": client.Conn.RemoteAddr().String(), + }, + "buffer": buf, // Will be converted to base64-encoded string + "error": err, + }); err != nil { + pr.logger.Error().Err(err).Msgf("Error creating ingress data: %v", err) + } else { + result, err := pr.hookConfig.Run( + context.Background(), + ingressData, + plugin.OnIngressTraffic, + pr.hookConfig.Verification) + if err != nil { + pr.logger.Error().Err(err).Msgf("Error running hook: %v", err) } - if err, ok := result["error"].(error); ok && err != nil { - pr.logger.Error().Err(err).Msg("Error in hook") + + if result != nil { + if buffer, ok := result.AsMap()["buffer"].([]byte); ok { + buf = buffer + } + if err, ok := result.AsMap()["error"].(error); ok && err != nil { + pr.logger.Error().Err(err).Msg("Error in hook") + } } } @@ -173,23 +190,38 @@ func (pr *ProxyImpl) PassThrough(gconn gnet.Conn) error { // Receive the response from the server size, response, err := client.Receive() - result = pr.hookConfig.Run( - plugin.OnEgressTraffic, - plugin.Signature{ - "gconn": gconn, - "client": client, - "response": response[:size], - "error": err, + + //nolint:nestif + if egressData, err := structpb.NewStruct(map[string]interface{}{ + "client": map[string]interface{}{ + "local": gconn.LocalAddr().String(), + "remote": gconn.RemoteAddr().String(), }, - pr.hookConfig.Verification) - if result != nil { - // TODO: Not sure if the gconn and client can be modified in the hook, - // so I'm not using the modified values here - if resp, ok := result["response"].([]byte); ok { - response = resp + "server": map[string]interface{}{ + "local": client.Conn.LocalAddr().String(), + "remote": client.Conn.RemoteAddr().String(), + }, + "response": response[:size], // Will be converted to base64-encoded string + "error": err, + }); err != nil { + pr.logger.Error().Err(err).Msgf("Error creating egress data: %v", err) + } else { + result, err := pr.hookConfig.Run( + context.Background(), + egressData, + plugin.OnEgressTraffic, + pr.hookConfig.Verification) + if err != nil { + pr.logger.Error().Err(err).Msgf("Error running hook: %v", err) } - if err, ok := result["error"].(error); ok && err != nil { - pr.logger.Error().Err(err).Msg("Error in hook") + + if result != nil { + if resp, ok := result.AsMap()["response"].([]byte); ok { + response = resp + } + if err, ok := result.AsMap()["error"].(error); ok && err != nil { + pr.logger.Error().Err(err).Msg("Error in hook") + } } } diff --git a/network/server.go b/network/server.go index a3175b4f..c3e71f55 100644 --- a/network/server.go +++ b/network/server.go @@ -1,6 +1,7 @@ package network import ( + "context" "fmt" "os" "time" @@ -8,6 +9,7 @@ import ( "github.com/gatewayd-io/gatewayd/plugin" "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" + "google.golang.org/protobuf/types/known/structpb" ) type Status string @@ -41,26 +43,38 @@ type Server struct { func (s *Server) OnBoot(engine gnet.Engine) gnet.Action { s.logger.Debug().Msg("GatewayD is booting...") - s.hooksConfig.Run( - plugin.OnBooting, - plugin.Signature{ - "server": s, - "engine": engine, - }, - s.hooksConfig.Verification) + onBootingData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "engine": engine, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onBootingData, plugin.OnBooting, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnBooting hook") + } + } s.engine = engine // Set the status to running s.Status = Running - s.hooksConfig.Run( - plugin.OnBooted, - plugin.Signature{ - "server": s, - "engine": engine, - }, - s.hooksConfig.Verification) + onBootedData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "engine": engine, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onBootedData, plugin.OnBooted, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnBooted hook") + } + } s.logger.Debug().Msg("GatewayD booted") @@ -70,13 +84,19 @@ func (s *Server) OnBoot(engine gnet.Engine) gnet.Action { func (s *Server) OnOpen(gconn gnet.Conn) ([]byte, gnet.Action) { s.logger.Debug().Msgf("GatewayD is opening a connection from %s", gconn.RemoteAddr().String()) - s.hooksConfig.Run( - plugin.OnOpening, - plugin.Signature{ - "server": s, - "gconn": gconn, - }, - s.hooksConfig.Verification) + onOpeningData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "gconn": gconn, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onOpeningData, plugin.OnOpening, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnOpening hook") + } + } if uint64(s.engine.CountConnections()) >= s.SoftLimit { s.logger.Warn().Msg("Soft limit reached") @@ -96,13 +116,19 @@ func (s *Server) OnOpen(gconn gnet.Conn) ([]byte, gnet.Action) { return nil, gnet.Close } - s.hooksConfig.Run( - plugin.OnOpened, - plugin.Signature{ - "server": s, - "gconn": gconn, - }, - s.hooksConfig.Verification) + onOpenedData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "gconn": gconn, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onOpenedData, plugin.OnOpened, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnOpened hook") + } + } return nil, gnet.None } @@ -110,14 +136,20 @@ func (s *Server) OnOpen(gconn gnet.Conn) ([]byte, gnet.Action) { func (s *Server) OnClose(gconn gnet.Conn, err error) gnet.Action { s.logger.Debug().Msgf("GatewayD is closing a connection from %s", gconn.RemoteAddr().String()) - s.hooksConfig.Run( - plugin.OnClosing, - plugin.Signature{ - "server": s, - "gconn": gconn, - "error": err, - }, - s.hooksConfig.Verification) + onClosingData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "gconn": gconn, + "error": err, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onClosingData, plugin.OnClosing, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnClosing hook") + } + } if err := s.proxy.Disconnect(gconn); err != nil { s.logger.Error().Err(err).Msg("Failed to disconnect from the client") @@ -127,26 +159,38 @@ func (s *Server) OnClose(gconn gnet.Conn, err error) gnet.Action { return gnet.Shutdown } - s.hooksConfig.Run( - plugin.OnClosed, - plugin.Signature{ - "server": s, - "gconn": gconn, - "error": err, - }, - s.hooksConfig.Verification) + onClosedData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "gconn": gconn, + "error": err, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onClosedData, plugin.OnClosed, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnClosed hook") + } + } return gnet.Close } func (s *Server) OnTraffic(gconn gnet.Conn) gnet.Action { - s.hooksConfig.Run( - plugin.OnTraffic, - plugin.Signature{ - "server": s, - "gconn": gconn, - }, - s.hooksConfig.Verification) + onTrafficData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "gconn": gconn, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onTrafficData, plugin.OnTraffic, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnTraffic hook") + } + } if err := s.proxy.PassThrough(gconn); err != nil { s.logger.Error().Err(err).Msg("Failed to pass through traffic") @@ -159,13 +203,21 @@ func (s *Server) OnTraffic(gconn gnet.Conn) gnet.Action { func (s *Server) OnShutdown(engine gnet.Engine) { s.logger.Debug().Msg("GatewayD is shutting down...") - s.hooksConfig.Run( - plugin.OnShutdown, - plugin.Signature{ - "server": s, - "engine": engine, - }, - s.hooksConfig.Verification) + + onShutdownData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "engine": engine, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onShutdownData, plugin.OnShutdown, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnShutdown hook") + } + } + s.proxy.Shutdown() s.Status = Stopped } @@ -173,12 +225,20 @@ func (s *Server) OnShutdown(engine gnet.Engine) { func (s *Server) OnTick() (time.Duration, gnet.Action) { s.logger.Debug().Msg("GatewayD is ticking...") s.logger.Info().Msgf("Active connections: %d", s.engine.CountConnections()) - s.hooksConfig.Run( - plugin.OnTick, - plugin.Signature{ - "server": s, - }, - s.hooksConfig.Verification) + + onTickData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + }) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + _, err := s.hooksConfig.Run( + context.Background(), onTickData, plugin.OnTick, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run OnTick hook") + } + } + return s.TickInterval, gnet.None } @@ -192,22 +252,28 @@ func (s *Server) Run() error { } // Since gnet.Run is blocking, we need to run OnRun before it - result := s.hooksConfig.Run( - plugin.OnRun, - plugin.Signature{ - "server": s, - "address": addr, - "error": err, - }, - s.hooksConfig.Verification) - - if result != nil { - if err, ok := result["error"].(error); ok && err != nil { - s.logger.Err(err).Msg("The hook returned an error") + //nolint:nestif + if onRunData, err := structpb.NewStruct(map[string]interface{}{ + "server": s, + "address": addr, + "error": err, + }); err != nil { + s.logger.Error().Err(err).Msg("Failed to create structpb") + } else { + result, err := s.hooksConfig.Run( + context.Background(), onRunData, plugin.OnRun, s.hooksConfig.Verification) + if err != nil { + s.logger.Error().Err(err).Msg("Failed to run the hook") } - if address, ok := result["address"].(string); ok { - addr = address + if result != nil { + if err, ok := result.AsMap()["error"].(error); ok && err != nil { + s.logger.Err(err).Msg("The hook returned an error") + } + + if address, ok := result.AsMap()["address"].(string); ok { + addr = address + } } } diff --git a/network/server_test.go b/network/server_test.go index 602c1d31..920a1757 100644 --- a/network/server_test.go +++ b/network/server_test.go @@ -1,6 +1,8 @@ package network import ( + "context" + "encoding/base64" "sync" "testing" @@ -11,6 +13,8 @@ import ( "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/structpb" ) //nolint:funlen @@ -32,36 +36,56 @@ func TestRunServer(t *testing.T) { hooksConfig := plugin.NewHookConfig() - onIngressTraffic := func(params plugin.Signature) plugin.Signature { - if params["buffer"] == nil { + onIngressTraffic := func( + ctx context.Context, + params *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + paramsMap := params.AsMap() + if paramsMap["buffer"] == nil { t.Fatal("buffer is nil") } logger.Info().Msg("Ingress traffic") - if buf, ok := params["buffer"].([]byte); ok { - assert.Equal(t, CreatePgStartupPacket(), buf) + // Decode the buffer + // The buffer is []byte, but it is base64-encoded as a string + // via using the structpb.NewStruct function + if buf, ok := paramsMap["buffer"].(string); ok { + if buffer, err := base64.StdEncoding.DecodeString(buf); err == nil { + assert.Equal(t, CreatePgStartupPacket(), buffer) + } else { + t.Fatal(err) + } } else { t.Fatal("buffer is not a []byte") } - assert.Nil(t, params["error"]) - return nil + assert.Nil(t, paramsMap["error"]) + return params, nil } hooksConfig.Add(plugin.OnIngressTraffic, 1, onIngressTraffic) - onEgressTraffic := func(params plugin.Signature) plugin.Signature { - if params["response"] == nil { + onEgressTraffic := func( + ctx context.Context, + params *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + paramsMap := params.AsMap() + if paramsMap["response"] == nil { t.Fatal("response is nil") } logger.Info().Msg("Egress traffic") - if buf, ok := params["response"].([]byte); ok { - assert.Equal( - t, CreatePostgreSQLPacket('R', []byte{0x0, 0x0, 0x0, 0x3}), buf) + if buf, ok := paramsMap["response"].(string); ok { + if buffer, err := base64.StdEncoding.DecodeString(buf); err == nil { + assert.Equal(t, CreatePostgreSQLPacket('R', []byte{0x0, 0x0, 0x0, 0x3}), buffer) + } else { + t.Fatal(err) + } } else { t.Fatal("response is not a []byte") } - assert.Nil(t, params["error"]) - return nil + assert.Nil(t, paramsMap["error"]) + return params, nil } hooksConfig.Add(plugin.OnEgressTraffic, 1, onEgressTraffic) diff --git a/network/utils.go b/network/utils.go index 30af5440..d2ccfb1f 100644 --- a/network/utils.go +++ b/network/utils.go @@ -7,6 +7,7 @@ import ( "net" "syscall" + gerr "github.com/gatewayd-io/gatewayd/errors" "github.com/rs/zerolog" ) @@ -42,6 +43,6 @@ func Resolve(network, address string, logger zerolog.Logger) (string, error) { return addr.String(), err default: logger.Error().Msgf("Network %s is not supported", network) - return "", ErrNetworkNotSupported + return "", gerr.ErrNetworkNotSupported } } diff --git a/plugin/hooks.go b/plugin/hooks.go index 5c670900..079ace8d 100644 --- a/plugin/hooks.go +++ b/plugin/hooks.go @@ -1,22 +1,23 @@ package plugin import ( + "context" "fmt" "sort" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/rs/zerolog" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/structpb" ) type ( - // Prio is the priority of a hook. + // Priority is the priority of a hook. // Smaller values are executed first (higher priority). - Prio uint - HookType string - Signature map[string]interface{} - HookDef func(Signature) Signature - Policy int + Priority uint + HookType string + HookDef func( + context.Context, *structpb.Struct, ...grpc.CallOption) (*structpb.Struct, error) + Policy int ) const ( @@ -51,29 +52,27 @@ const ( OnTick HookType = "onTick" // Pool hooks (network/pool.go). OnNewClient HookType = "onNewClient" - // Plugin hooks (plugin/plugin.go). - OnNewPlugin HookType = "onNewPlugin" ) type HookConfig struct { - hooks map[HookType]map[Prio]HookDef + hooks map[HookType]map[Priority]HookDef Logger zerolog.Logger Verification Policy } func NewHookConfig() *HookConfig { return &HookConfig{ - hooks: map[HookType]map[Prio]HookDef{}, + hooks: map[HookType]map[Priority]HookDef{}, } } -func (h *HookConfig) Hooks() map[HookType]map[Prio]HookDef { +func (h *HookConfig) Hooks() map[HookType]map[Priority]HookDef { return h.hooks } -func (h *HookConfig) Add(hookType HookType, prio Prio, hook HookDef) { +func (h *HookConfig) Add(hookType HookType, prio Priority, hook HookDef) { if len(h.hooks[hookType]) == 0 { - h.hooks[hookType] = map[Prio]HookDef{prio: hook} + h.hooks[hookType] = map[Priority]HookDef{prio: hook} } else { if _, ok := h.hooks[hookType][prio]; ok { h.Logger.Warn().Msgf("Hook %s replaced with priority %d.", hookType, prio) @@ -82,25 +81,24 @@ func (h *HookConfig) Add(hookType HookType, prio Prio, hook HookDef) { } } -func (h *HookConfig) Get(hookType HookType) map[Prio]HookDef { +func (h *HookConfig) Get(hookType HookType) map[Priority]HookDef { return h.hooks[hookType] } -func Verify(params, returnVal Signature) bool { - return cmp.Equal(params, returnVal, cmp.Options{ - cmpopts.SortMaps(func(a, b string) bool { - return a < b - }), - cmpopts.EquateEmpty(), - }) -} - -//nolint:funlen +//nolint:funlen,contextcheck func (h *HookConfig) Run( - hookType HookType, args Signature, verification Policy, -) Signature { + ctx context.Context, + args *structpb.Struct, + hookType HookType, + verification Policy, + opts ...grpc.CallOption, +) (*structpb.Struct, error) { + if ctx == nil { + ctx = context.Background() + } + // Sort hooks by priority - priorities := make([]Prio, 0, len(h.hooks[hookType])) + priorities := make([]Priority, 0, len(h.hooks[hookType])) for prio := range h.hooks[hookType] { priorities = append(priorities, prio) } @@ -109,17 +107,18 @@ func (h *HookConfig) Run( }) // Run hooks, passing the result of the previous hook to the next one - returnVal := make(Signature) - var removeList []Prio + returnVal := &structpb.Struct{} + var removeList []Priority // The signature of parameters and args MUST be the same for this to work for idx, prio := range priorities { - var result Signature + var result *structpb.Struct + var err error if idx == 0 { // TODO: Run hooks from the registry - result = h.hooks[hookType][prio](args) + result, err = h.hooks[hookType][prio](ctx, args, opts...) } else { // TODO: Run hooks from the registry - result = h.hooks[hookType][prio](returnVal) + result, err = h.hooks[hookType][prio](ctx, returnVal, opts...) } // This is done to ensure that the return value of the hook is always valid, @@ -158,9 +157,9 @@ func (h *HookConfig) Run( panic(errMsg) } if idx == 0 { - return args + return args, err } - return returnVal + return returnVal, err // Remove the hook from the registry, log the error and execute the next hook. case Remove: errMsg := fmt.Sprintf( @@ -185,5 +184,5 @@ func (h *HookConfig) Run( delete(h.hooks[hookType], prio) } - return returnVal + return returnVal, nil } diff --git a/plugin/hooks_test.go b/plugin/hooks_test.go index 4d44ab74..14fe6b12 100644 --- a/plugin/hooks_test.go +++ b/plugin/hooks_test.go @@ -1,9 +1,12 @@ package plugin import ( + "context" "testing" "github.com/stretchr/testify/assert" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/structpb" ) func Test_NewHookConfig(t *testing.T) { @@ -13,8 +16,12 @@ func Test_NewHookConfig(t *testing.T) { func Test_HookConfig_Add(t *testing.T) { hooks := NewHookConfig() - testFunc := func(s Signature) Signature { - return s + testFunc := func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return args, nil } hooks.Add(OnNewLogger, 0, testFunc) assert.NotNil(t, hooks.Hooks()[OnNewLogger][0]) @@ -23,11 +30,19 @@ func Test_HookConfig_Add(t *testing.T) { func Test_HookConfig_Add_Multiple_Hooks(t *testing.T) { hooks := NewHookConfig() - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return s + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return args, nil }) - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return s + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return args, nil }) assert.NotNil(t, hooks.Hooks()[OnNewLogger][0]) assert.NotNil(t, hooks.Hooks()[OnNewLogger][1]) @@ -35,10 +50,14 @@ func Test_HookConfig_Add_Multiple_Hooks(t *testing.T) { func Test_HookConfig_Get(t *testing.T) { hooks := NewHookConfig() - testFunc := func(s Signature) Signature { - return s + testFunc := func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return args, nil } - prio := Prio(0) + prio := Priority(0) hooks.Add(OnNewLogger, prio, testFunc) assert.NotNil(t, hooks.Get(OnNewLogger)) assert.ObjectsAreEqual(testFunc, hooks.Get(OnNewLogger)[prio]) @@ -46,24 +65,38 @@ func Test_HookConfig_Get(t *testing.T) { func Test_HookConfig_Run(t *testing.T) { hooks := NewHookConfig() - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return s + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return args, nil }) - assert.NotNil(t, hooks.Run(OnNewLogger, Signature{}, Ignore)) + result, err := hooks.Run(context.Background(), &structpb.Struct{}, OnNewLogger, Ignore) + assert.NotNil(t, result) + assert.Nil(t, err) } -func Test_verify(t *testing.T) { - params := Signature{ - "test": "test", - } - returnVal := Signature{ - "test": "test", - } +func Test_Verify(t *testing.T) { + params, err := structpb.NewStruct( + map[string]interface{}{ + "test": "test", + }, + ) + assert.Nil(t, err) + + returnVal, err := structpb.NewStruct( + map[string]interface{}{ + "test": "test", + }, + ) + assert.Nil(t, err) + assert.True(t, Verify(params, returnVal)) } -func Test_verify_fail(t *testing.T) { - data := [][]Signature{ +func Test_Verify_fail(t *testing.T) { + data := [][]map[string]interface{}{ { { "test": "test", @@ -95,102 +128,185 @@ func Test_verify_fail(t *testing.T) { } for _, d := range data { - assert.False(t, Verify(d[0], d[1])) + params, err := structpb.NewStruct(d[0]) + assert.Nil(t, err) + returnVal, err := structpb.NewStruct(d[1]) + assert.Nil(t, err) + assert.False(t, Verify(params, returnVal)) } } func Test_HookConfig_Run_PassDown(t *testing.T) { hooks := NewHookConfig() // The result of the hook will be nil and will be passed down to the next hook. - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return nil + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return nil, nil //nolint:nilnil }) - // The consolidated result should be Signature{"test": "test"}. - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return Signature{ + // The consolidated result should be {"test": "test"}. + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + output, err := structpb.NewStruct(map[string]interface{}{ "test": "test", - } + }) + assert.Nil(t, err) + return output, nil }) - // Although the first hook returns nil, and its Signature doesn't match the params, + + data, err := structpb.NewStruct( + map[string]interface{}{ + "test": "test", + }, + ) + assert.Nil(t, err) + // Although the first hook returns nil, and its signature doesn't match the params, // so its result (nil) is passed down to the next hook in chain (prio 2). - // Then the second hook runs and returns a Signature with a "test" key and value. - assert.NotNil( - t, hooks.Run(OnNewLogger, Signature{"test": "test"}, PassDown)) + // Then the second hook runs and returns a signature with a "test" key and value. + result, err := hooks.Run(context.Background(), data, OnNewLogger, PassDown) + assert.Nil(t, err) + assert.NotNil(t, result) } func Test_HookConfig_Run_PassDown_2(t *testing.T) { hooks := NewHookConfig() // The result of the hook will be nil and will be passed down to the next hook. - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return Signature{ - "test1": "test1", + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + args.Fields["test1"] = &structpb.Value{ + Kind: &structpb.Value_StringValue{ //nolint:nosnakecase + StringValue: "test1", + }, } + return args, nil }) - // The consolidated result should be Signature{"test1": "test1", "test2": "test2"}. - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return Signature{ - "test2": "test2", + // The consolidated result should be {"test1": "test1", "test2": "test2"}. + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + args.Fields["test2"] = &structpb.Value{ + Kind: &structpb.Value_StringValue{ //nolint:nosnakecase + StringValue: "test2", + }, } + return args, nil }) - // Although the first hook returns nil, and its Signature doesn't match the params, + // Although the first hook returns nil, and its signature doesn't match the params, // so its result (nil) is passed down to the next hook in chain (prio 2). - // Then the second hook runs and returns a Signature with a "test1" and "test2" key and value. - assert.NotNil( - t, hooks.Run( - OnNewLogger, - Signature{"test1": "test1", "test2": "test2"}, - PassDown)) + // Then the second hook runs and returns a signature with a "test1" and "test2" key and value. + data, err := structpb.NewStruct( + map[string]interface{}{ + "test": "test", + }, + ) + assert.Nil(t, err) + result, err := hooks.Run(context.Background(), data, OnNewLogger, PassDown) + assert.Nil(t, err) + assert.NotNil(t, result) } func Test_HookConfig_Run_Ignore(t *testing.T) { hooks := NewHookConfig() // This should not run, because the return value is not the same as the params - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return nil + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return nil, nil //nolint:nilnil }) // This should run, because the return value is the same as the params - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return Signature{ - "test": "test", + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + args.Fields["test"] = &structpb.Value{ + Kind: &structpb.Value_StringValue{ //nolint:nosnakecase + StringValue: "test", + }, } + return args, nil }) - // The first hook returns nil, and its Signature doesn't match the params, + // The first hook returns nil, and its signature doesn't match the params, // so its result is ignored. - // Then the second hook runs and returns a Signature with a "test" key and value. - assert.NotNil(t, hooks.Run(OnNewLogger, Signature{"test": "test"}, Ignore)) + // Then the second hook runs and returns a signature with a "test" key and value. + data, err := structpb.NewStruct( + map[string]interface{}{ + "test": "test", + }, + ) + assert.Nil(t, err) + result, err := hooks.Run(context.Background(), data, OnNewLogger, Ignore) + assert.Nil(t, err) + assert.NotNil(t, result) } func Test_HookConfig_Run_Abort(t *testing.T) { hooks := NewHookConfig() // This should not run, because the return value is not the same as the params - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return nil + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return nil, nil //nolint:nilnil }) // This should not run, because the first hook returns nil, and its result is ignored. - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return Signature{ + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + output, err := structpb.NewStruct(map[string]interface{}{ "test": "test", - } + }) + assert.Nil(t, err) + return output, nil }) // The first hook returns nil, and it aborts the execution of the rest of the hook. - assert.Nil(t, hooks.Run(OnNewLogger, nil, Abort)) + result, err := hooks.Run(context.Background(), &structpb.Struct{}, OnNewLogger, Abort) + assert.Nil(t, err) + assert.Nil(t, result) } func Test_HookConfig_Run_Remove(t *testing.T) { hooks := NewHookConfig() // This should not run, because the return value is not the same as the params - hooks.Add(OnNewLogger, 0, func(s Signature) Signature { - return nil + hooks.Add(OnNewLogger, 0, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + return nil, nil //nolint:nilnil }) // This should not run, because the first hook returns nil, and its result is ignored. - hooks.Add(OnNewLogger, 1, func(s Signature) Signature { - return Signature{ + hooks.Add(OnNewLogger, 1, func( + ctx context.Context, + args *structpb.Struct, + opts ...grpc.CallOption, + ) (*structpb.Struct, error) { + output, err := structpb.NewStruct(map[string]interface{}{ "test": "test", - } + }) + assert.Nil(t, err) + return output, nil }) - // The first hook returns nil, and its Signature doesn't match the params, + // The first hook returns nil, and its signature doesn't match the params, // so its result is ignored. The failing hook is removed from the list and // the execution continues with the next hook in the list. - assert.Nil(t, hooks.Run(OnNewLogger, nil, Remove)) + result, err := hooks.Run(context.Background(), &structpb.Struct{}, OnNewLogger, Remove) + assert.Nil(t, err) + assert.Nil(t, result) assert.Equal(t, 1, len(hooks.Hooks()[OnNewLogger])) } diff --git a/plugin/plugin.go b/plugin/plugin.go index ff7e1aa3..eb50ab9e 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -1,50 +1,80 @@ package plugin import ( - "os/exec" + "net" + gerr "github.com/gatewayd-io/gatewayd/errors" + pluginV1 "github.com/gatewayd-io/gatewayd/plugin/v1" goplugin "github.com/hashicorp/go-plugin" ) -const ( - minPort uint = 50000 - maxPort uint = 50002 -) +type Plugin interface { + Start() (net.Addr, error) + Stop() + Dispense() (pluginV1.GatewayDPluginServiceClient, error) +} + +type Identifier struct { + Name string + Version string + RemoteURL string + Checksum string +} -type Clients struct { - Clients []*goplugin.Client +type Impl struct { + goplugin.NetRPCUnsupportedPlugin + pluginV1.GatewayDPluginServiceServer + + client *goplugin.Client + + ID Identifier + Description string + Authors []string + License string + ProjectURL string + LocalPath string + Enabled bool + // internal and external config options + Config map[string]string + // hooks it attaches to + Hooks []HookType + Priority Priority + // required plugins to be loaded before this one + // Built-in plugins are always loaded first + Requires []Identifier + Tags []string + Categories []string } -func NewPluginClient() *Clients { - return &Clients{ - Clients: make([]*goplugin.Client, 0, 1), +var _ Plugin = &Impl{} + +func (p *Impl) Start() (net.Addr, error) { + var addr net.Addr + var err error + if addr, err = p.client.Start(); err != nil { + return nil, err //nolint:wrapcheck } + return addr, nil } -func (p *Clients) Load() error { - client := goplugin.NewClient(&goplugin.ClientConfig{ - HandshakeConfig: goplugin.HandshakeConfig{ - ProtocolVersion: 1, - // MagicCookieKey: "BASIC_PLUGIN", - // MagicCookieValue: "hello", - }, - Managed: true, - Plugins: map[string]goplugin.Plugin{}, - Cmd: exec.Command("python", "pluginA/pluginA_server.py"), - AllowedProtocols: []goplugin.Protocol{goplugin.ProtocolGRPC, goplugin.ProtocolNetRPC}, - // VersionedPlugins: nil, - // Logger: nil, - // TLSConfig: nil, - // Reattach: nil, - // SecureConfig: nil, - MinPort: minPort, - MaxPort: maxPort, - // StartTimeout: 10, - // AutoMTLS: false, - // GRPCDialOptions: nil, - }) - // defer client.Kill() - p.Clients = append(p.Clients, client) - - return nil +func (p *Impl) Stop() { + p.client.Kill() +} + +func (p *Impl) Dispense() (pluginV1.GatewayDPluginServiceClient, error) { + rpcClient, err := p.client.Client() + if err != nil { + return nil, err //nolint:wrapcheck + } + + raw, err := rpcClient.Dispense(p.ID.Name) + if err != nil { + return nil, err //nolint:wrapcheck + } + + if gatewaydPlugin, ok := raw.(pluginV1.GatewayDPluginServiceClient); ok { + return gatewaydPlugin, nil + } + + return nil, gerr.ErrPluginNotReady } diff --git a/plugin/registry.go b/plugin/registry.go new file mode 100644 index 00000000..fb967b2c --- /dev/null +++ b/plugin/registry.go @@ -0,0 +1,263 @@ +package plugin + +import ( + "context" + "os/exec" + + pluginV1 "github.com/gatewayd-io/gatewayd/plugin/v1" + "github.com/gatewayd-io/gatewayd/pool" + goplugin "github.com/hashicorp/go-plugin" + "github.com/knadh/koanf" + "github.com/mitchellh/mapstructure" + "google.golang.org/protobuf/types/known/structpb" +) + +const ( + DefaultMinPort uint = 50000 + DefaultMaxPort uint = 60000 + PluginPriorityStart uint = 1000 +) + +var handshakeConfig = goplugin.HandshakeConfig{ + ProtocolVersion: 1, + MagicCookieKey: "GATEWAYD_PLUGIN", + MagicCookieValue: "5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872", +} + +type Registry interface { + Add(plugin *Impl) bool + Get(id Identifier) *Impl + List() []Identifier + Remove(id Identifier) + Shutdown() + LoadPlugins(pluginConfig *koanf.Koanf) + RegisterHooks(id Identifier) +} + +type RegistryImpl struct { + plugins pool.Pool + hooksConfig *HookConfig +} + +var _ Registry = &RegistryImpl{} + +func NewRegistry(hooksConfig *HookConfig) *RegistryImpl { + return &RegistryImpl{plugins: pool.NewPool(), hooksConfig: hooksConfig} +} + +func (reg *RegistryImpl) Add(plugin *Impl) bool { + _, loaded := reg.plugins.GetOrPut(plugin.ID, plugin) + return loaded +} + +func (reg *RegistryImpl) Get(id Identifier) *Impl { + if plugin, ok := reg.plugins.Get(id).(*Impl); ok { + return plugin + } + + return nil +} + +func (reg *RegistryImpl) List() []Identifier { + var plugins []Identifier + reg.plugins.ForEach(func(key, _ interface{}) bool { + if id, ok := key.(Identifier); ok { + plugins = append(plugins, id) + } + return true + }) + return plugins +} + +func (reg *RegistryImpl) Remove(id Identifier) { + reg.plugins.Remove(id) +} + +func (reg *RegistryImpl) Shutdown() { + reg.plugins.ForEach(func(key, value interface{}) bool { + if id, ok := key.(Identifier); ok { + if plugin, ok := value.(*Impl); ok { + plugin.Stop() + reg.Remove(id) + } + } + return true + }) +} + +//nolint:funlen +func (reg *RegistryImpl) LoadPlugins(pluginConfig *koanf.Koanf) { + // Get top-level list of plugins + plugins := pluginConfig.MapKeys("") + + // TODO: Append built-in plugins to the list of plugins + // Built-in plugins are plugins that are compiled and shipped with the gatewayd binary + + // Add each plugin to the registry + for priority, name := range plugins { + reg.hooksConfig.Logger.Debug().Msgf("Loading plugin: %s", name) + plugin := &Impl{ + ID: Identifier{ + Name: name, + }, + } + + if enabled, ok := pluginConfig.Get(name + ".enabled").(bool); !ok || !enabled { + reg.hooksConfig.Logger.Debug().Msgf("Plugin is disabled or is not set: %s", name) + continue + } else { + plugin.Enabled = enabled + } + + if localPath, ok := pluginConfig.Get( + name + ".localPath").(string); !ok || localPath == "" { + reg.hooksConfig.Logger.Debug().Msgf("Local file of plugin doesn't exist or is not set: %s", name) + continue + } else { + plugin.LocalPath = localPath + } + + if checksum, ok := pluginConfig.Get(name + ".checksum").(string); !ok || checksum == "" { + reg.hooksConfig.Logger.Debug().Msgf("Checksum of plugin doesn't exist or is not set: %s", name) + continue + } else { + plugin.ID.Checksum = checksum + } + + // Verify the checksum + // TODO: Load the plugin from a remote location if the checksum doesn't match + if sum, err := sha256sum(plugin.LocalPath); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to calculate checksum") + continue + } else if sum != plugin.ID.Checksum { + reg.hooksConfig.Logger.Debug().Msgf( + "Checksum mismatch: %s != %s", sum, plugin.ID.Checksum) + continue + } + + // Plugin priority is determined by the order in which it is listed in the config file + // Built-in plugins are loaded first, followed by user-defined plugins. Built-in plugins + // have a priority of 0 to 999, and user-defined plugins have a priority of 1000 or greater. + plugin.Priority = Priority(PluginPriorityStart + uint(priority)) + + plugin.client = goplugin.NewClient( + &goplugin.ClientConfig{ + HandshakeConfig: handshakeConfig, + Plugins: pluginV1.GetPluginMap(plugin.ID.Name), + Cmd: exec.Command(plugin.LocalPath), //nolint:gosec + AllowedProtocols: []goplugin.Protocol{ + goplugin.ProtocolGRPC, + }, + // SecureConfig: nil, + Managed: true, + MinPort: DefaultMinPort, + MaxPort: DefaultMaxPort, + // GRPCDialOptions: []grpc.DialOption{ + // grpc.WithInsecure(), + // }, + AutoMTLS: true, + }, + ) + + reg.hooksConfig.Logger.Debug().Msgf("Plugin loaded: %s", plugin.ID.Name) + if _, err := plugin.Start(); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to start plugin") + } + + // Load metadata from the plugin + var metadata *structpb.Struct + if pluginV1, err := plugin.Dispense(); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to dispense plugin") + continue + } else { + if metadata, err = pluginV1.GetPluginConfig(context.Background(), &structpb.Struct{}); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to get plugin metadata") + continue + } + } + + plugin.ID.RemoteURL = metadata.Fields["id"].GetStructValue().Fields["remoteUrl"].GetStringValue() + plugin.ID.Version = metadata.Fields["id"].GetStructValue().Fields["version"].GetStringValue() + plugin.Description = metadata.Fields["description"].GetStringValue() + plugin.License = metadata.Fields["license"].GetStringValue() + plugin.ProjectURL = metadata.Fields["projectUrl"].GetStringValue() + if err := mapstructure.Decode(metadata.Fields["authors"].GetListValue().AsSlice(), + &plugin.Authors); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to decode plugin authors") + } + if err := mapstructure.Decode(metadata.Fields["hooks"].GetListValue().AsSlice(), + &plugin.Hooks); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to decode plugin hooks") + } + if err := mapstructure.Decode(metadata.Fields["config"].GetListValue().AsSlice(), + &plugin.Config); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to decode plugin config") + } + + reg.Add(plugin) + + reg.RegisterHooks(plugin.ID) + reg.hooksConfig.Logger.Debug().Msgf("Plugin metadata loaded: %s", plugin.ID.Name) + } +} + +//nolint:funlen +func (reg *RegistryImpl) RegisterHooks(id Identifier) { + pluginImpl := reg.Get(id) + reg.hooksConfig.Logger.Debug().Msgf("Registering hooks for plugin: %s", pluginImpl.ID.Name) + var pluginV1 pluginV1.GatewayDPluginServiceClient + var err error + if pluginV1, err = pluginImpl.Dispense(); err != nil { + reg.hooksConfig.Logger.Debug().Err(err).Msg("Failed to dispense plugin") + return + } + + for _, hook := range pluginImpl.Hooks { + var hookFunc HookDef + switch hook { + case OnConfigLoaded: + hookFunc = pluginV1.OnConfigLoaded + case OnNewLogger: + hookFunc = pluginV1.OnNewLogger + case OnNewPool: + hookFunc = pluginV1.OnNewPool + case OnNewProxy: + hookFunc = pluginV1.OnNewProxy + case OnNewServer: + hookFunc = pluginV1.OnNewServer + case OnSignal: + hookFunc = pluginV1.OnSignal + case OnRun: + hookFunc = pluginV1.OnRun + case OnBooting: + hookFunc = pluginV1.OnBooting + case OnBooted: + hookFunc = pluginV1.OnBooted + case OnOpening: + hookFunc = pluginV1.OnOpening + case OnOpened: + hookFunc = pluginV1.OnOpened + case OnClosing: + hookFunc = pluginV1.OnClosing + case OnClosed: + hookFunc = pluginV1.OnClosed + case OnTraffic: + hookFunc = pluginV1.OnTraffic + case OnIngressTraffic: + hookFunc = pluginV1.OnIngressTraffic + case OnEgressTraffic: + hookFunc = pluginV1.OnEgressTraffic + case OnShutdown: + hookFunc = pluginV1.OnShutdown + case OnTick: + hookFunc = pluginV1.OnTick + case OnNewClient: + hookFunc = pluginV1.OnNewClient + default: + reg.hooksConfig.Logger.Warn().Msgf("Unknown hook type: %s", hook) + continue + } + reg.hooksConfig.Logger.Debug().Msgf("Registering hook: %s", hook) + reg.hooksConfig.Add(hook, pluginImpl.Priority, hookFunc) + } +} diff --git a/plugin/utils.go b/plugin/utils.go new file mode 100644 index 00000000..53a31b77 --- /dev/null +++ b/plugin/utils.go @@ -0,0 +1,52 @@ +package plugin + +import ( + "bufio" + "crypto/sha256" + "errors" + "fmt" + "io" + "os" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "google.golang.org/protobuf/types/known/structpb" +) + +const bufferSize = 65536 + +func sha256sum(filename string) (string, error) { + if info, err := os.Stat(filename); err != nil || info.IsDir() { + return "", err //nolint:wrapcheck + } + + file, err := os.Open(filename) + if err != nil { + return "", err //nolint:wrapcheck + } + defer func() { _ = file.Close() }() + + hashAlgorithm := sha256.New() + + buf := make([]byte, bufferSize) + for { + n, err := bufio.NewReader(file).Read(buf) + //nolint:gocritic + if err == nil { + hashAlgorithm.Write(buf[:n]) + } else if errors.Is(err, io.EOF) { + return fmt.Sprintf("%x", hashAlgorithm.Sum(nil)), nil + } else { + return "", err //nolint:wrapcheck + } + } +} + +func Verify(params, returnVal *structpb.Struct) bool { + return cmp.Equal(params.AsMap(), returnVal.AsMap(), cmp.Options{ + cmpopts.SortMaps(func(a, b string) bool { + return a < b + }), + cmpopts.EquateEmpty(), + }) +} diff --git a/plugin/v1/interface.go b/plugin/v1/interface.go new file mode 100644 index 00000000..5b747a2d --- /dev/null +++ b/plugin/v1/interface.go @@ -0,0 +1,44 @@ +package v1 + +import ( + "context" + + goplugin "github.com/hashicorp/go-plugin" + "google.golang.org/grpc" +) + +// Handshake must be used by all plugins to ensure that the plugin +// and host are compatible. +var Handshake = goplugin.HandshakeConfig{ + ProtocolVersion: 1, + MagicCookieKey: "GATEWAYD_PLUGIN", + MagicCookieValue: "5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872", +} + +func GetPluginMap(pluginName string) map[string]goplugin.Plugin { + return map[string]goplugin.Plugin{ + pluginName: &Plugin{}, + } +} + +var PluginMap = map[string]goplugin.Plugin{ + "gatewayd-plugin-test": &Plugin{}, +} + +// Plugin is the interface that all plugins must implement. +type Plugin struct { + goplugin.GRPCPlugin + goplugin.NetRPCUnsupportedPlugin + Impl struct { + GatewayDPluginServiceServer + } +} + +func (p *Plugin) GRPCServer(b *goplugin.GRPCBroker, s *grpc.Server) error { + RegisterGatewayDPluginServiceServer(s, &p.Impl) + return nil +} + +func (p *Plugin) GRPCClient(ctx context.Context, b *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { + return NewGatewayDPluginServiceClient(c), nil +} diff --git a/plugin/v1/plugin.pb.go b/plugin/v1/plugin.pb.go new file mode 100644 index 00000000..83999d16 --- /dev/null +++ b/plugin/v1/plugin.pb.go @@ -0,0 +1,580 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: plugin/v1/plugin.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Version struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Major uint64 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"` + Minor uint64 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"` + Patch uint64 `protobuf:"varint,3,opt,name=patch,proto3" json:"patch,omitempty"` + Pre string `protobuf:"bytes,4,opt,name=pre,proto3" json:"pre,omitempty"` + Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` + Original string `protobuf:"bytes,6,opt,name=original,proto3" json:"original,omitempty"` +} + +func (x *Version) Reset() { + *x = Version{} + if protoimpl.UnsafeEnabled { + mi := &file_plugin_v1_plugin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Version) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Version) ProtoMessage() {} + +func (x *Version) ProtoReflect() protoreflect.Message { + mi := &file_plugin_v1_plugin_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Version.ProtoReflect.Descriptor instead. +func (*Version) Descriptor() ([]byte, []int) { + return file_plugin_v1_plugin_proto_rawDescGZIP(), []int{0} +} + +func (x *Version) GetMajor() uint64 { + if x != nil { + return x.Major + } + return 0 +} + +func (x *Version) GetMinor() uint64 { + if x != nil { + return x.Minor + } + return 0 +} + +func (x *Version) GetPatch() uint64 { + if x != nil { + return x.Patch + } + return 0 +} + +func (x *Version) GetPre() string { + if x != nil { + return x.Pre + } + return "" +} + +func (x *Version) GetMetadata() string { + if x != nil { + return x.Metadata + } + return "" +} + +func (x *Version) GetOriginal() string { + if x != nil { + return x.Original + } + return "" +} + +type PluginID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + RemoteUrl string `protobuf:"bytes,3,opt,name=remote_url,json=remoteUrl,proto3" json:"remote_url,omitempty"` + Checksum string `protobuf:"bytes,4,opt,name=checksum,proto3" json:"checksum,omitempty"` +} + +func (x *PluginID) Reset() { + *x = PluginID{} + if protoimpl.UnsafeEnabled { + mi := &file_plugin_v1_plugin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PluginID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PluginID) ProtoMessage() {} + +func (x *PluginID) ProtoReflect() protoreflect.Message { + mi := &file_plugin_v1_plugin_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PluginID.ProtoReflect.Descriptor instead. +func (*PluginID) Descriptor() ([]byte, []int) { + return file_plugin_v1_plugin_proto_rawDescGZIP(), []int{1} +} + +func (x *PluginID) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *PluginID) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *PluginID) GetRemoteUrl() string { + if x != nil { + return x.RemoteUrl + } + return "" +} + +func (x *PluginID) GetChecksum() string { + if x != nil { + return x.Checksum + } + return "" +} + +type PluginConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *PluginID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + License string `protobuf:"bytes,4,opt,name=license,proto3" json:"license,omitempty"` + ProjectUrl string `protobuf:"bytes,5,opt,name=project_url,json=projectUrl,proto3" json:"project_url,omitempty"` + Authors []string `protobuf:"bytes,3,rep,name=authors,proto3" json:"authors,omitempty"` + // internal and external config options + Config map[string]string `protobuf:"bytes,6,rep,name=config,proto3" json:"config,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // hooks it attaches to + Hooks []string `protobuf:"bytes,7,rep,name=hooks,proto3" json:"hooks,omitempty"` + // required plugins + Requires map[string]string `protobuf:"bytes,8,rep,name=requires,proto3" json:"requires,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Tags []string `protobuf:"bytes,9,rep,name=tags,proto3" json:"tags,omitempty"` + Categories []string `protobuf:"bytes,10,rep,name=categories,proto3" json:"categories,omitempty"` +} + +func (x *PluginConfig) Reset() { + *x = PluginConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_plugin_v1_plugin_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PluginConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PluginConfig) ProtoMessage() {} + +func (x *PluginConfig) ProtoReflect() protoreflect.Message { + mi := &file_plugin_v1_plugin_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PluginConfig.ProtoReflect.Descriptor instead. +func (*PluginConfig) Descriptor() ([]byte, []int) { + return file_plugin_v1_plugin_proto_rawDescGZIP(), []int{2} +} + +func (x *PluginConfig) GetId() *PluginID { + if x != nil { + return x.Id + } + return nil +} + +func (x *PluginConfig) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *PluginConfig) GetLicense() string { + if x != nil { + return x.License + } + return "" +} + +func (x *PluginConfig) GetProjectUrl() string { + if x != nil { + return x.ProjectUrl + } + return "" +} + +func (x *PluginConfig) GetAuthors() []string { + if x != nil { + return x.Authors + } + return nil +} + +func (x *PluginConfig) GetConfig() map[string]string { + if x != nil { + return x.Config + } + return nil +} + +func (x *PluginConfig) GetHooks() []string { + if x != nil { + return x.Hooks + } + return nil +} + +func (x *PluginConfig) GetRequires() map[string]string { + if x != nil { + return x.Requires + } + return nil +} + +func (x *PluginConfig) GetTags() []string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *PluginConfig) GetCategories() []string { + if x != nil { + return x.Categories + } + return nil +} + +var File_plugin_v1_plugin_proto protoreflect.FileDescriptor + +var file_plugin_v1_plugin_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x95, 0x01, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6d, 0x61, + 0x6a, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, + 0x10, 0x0a, 0x03, 0x70, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x72, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, + 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x22, 0x73, 0x0a, 0x08, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x55, + 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x22, 0xec, + 0x03, 0x0a, 0x0c, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x23, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x44, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x72, + 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x07, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x73, 0x12, 0x3b, 0x0a, 0x06, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x68, 0x6f, 0x6f, 0x6b, + 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x41, + 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x69, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x1a, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x98, 0x0a, + 0x0a, 0x15, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x44, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x42, 0x0a, 0x0e, + 0x4f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x12, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x12, 0x3f, 0x0a, 0x0b, 0x4f, 0x6e, 0x4e, 0x65, 0x77, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, + 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x12, 0x3d, 0x0a, 0x09, 0x4f, 0x6e, 0x4e, 0x65, 0x77, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x12, 0x3e, 0x0a, 0x0a, 0x4f, 0x6e, 0x4e, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x12, 0x3f, 0x0a, 0x0b, 0x4f, 0x6e, 0x4e, 0x65, 0x77, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, + 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x4f, 0x6e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x17, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, + 0x39, 0x0a, 0x05, 0x4f, 0x6e, 0x52, 0x75, 0x6e, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3d, 0x0a, 0x09, 0x4f, 0x6e, + 0x42, 0x6f, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x4f, 0x6e, 0x42, + 0x6f, 0x6f, 0x74, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3d, 0x0a, 0x09, 0x4f, 0x6e, 0x4f, 0x70, 0x65, + 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x4f, 0x6e, 0x4f, 0x70, 0x65, 0x6e, + 0x65, 0x64, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x75, 0x63, 0x74, 0x12, 0x3d, 0x0a, 0x09, 0x4f, 0x6e, 0x43, 0x6c, 0x6f, 0x73, 0x69, 0x6e, + 0x67, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x4f, 0x6e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x12, + 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x12, 0x3d, 0x0a, 0x09, 0x4f, 0x6e, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x12, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x12, 0x44, 0x0a, 0x10, 0x4f, 0x6e, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x54, 0x72, 0x61, + 0x66, 0x66, 0x69, 0x63, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x43, 0x0a, 0x0f, 0x4f, 0x6e, 0x45, 0x67, 0x72, 0x65, + 0x73, 0x73, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, + 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3e, 0x0a, 0x0a, 0x4f, + 0x6e, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, + 0x63, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3a, 0x0a, 0x06, 0x4f, + 0x6e, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x17, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3f, 0x0a, 0x0b, 0x4f, 0x6e, 0x4e, 0x65, 0x77, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, + 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x64, 0x2d, + 0x69, 0x6f, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x64, 0x2f, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_plugin_v1_plugin_proto_rawDescOnce sync.Once + file_plugin_v1_plugin_proto_rawDescData = file_plugin_v1_plugin_proto_rawDesc +) + +func file_plugin_v1_plugin_proto_rawDescGZIP() []byte { + file_plugin_v1_plugin_proto_rawDescOnce.Do(func() { + file_plugin_v1_plugin_proto_rawDescData = protoimpl.X.CompressGZIP(file_plugin_v1_plugin_proto_rawDescData) + }) + return file_plugin_v1_plugin_proto_rawDescData +} + +var file_plugin_v1_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_plugin_v1_plugin_proto_goTypes = []interface{}{ + (*Version)(nil), // 0: plugin.v1.Version + (*PluginID)(nil), // 1: plugin.v1.PluginID + (*PluginConfig)(nil), // 2: plugin.v1.PluginConfig + nil, // 3: plugin.v1.PluginConfig.ConfigEntry + nil, // 4: plugin.v1.PluginConfig.RequiresEntry + (*structpb.Struct)(nil), // 5: google.protobuf.Struct +} +var file_plugin_v1_plugin_proto_depIdxs = []int32{ + 1, // 0: plugin.v1.PluginConfig.id:type_name -> plugin.v1.PluginID + 3, // 1: plugin.v1.PluginConfig.config:type_name -> plugin.v1.PluginConfig.ConfigEntry + 4, // 2: plugin.v1.PluginConfig.requires:type_name -> plugin.v1.PluginConfig.RequiresEntry + 5, // 3: plugin.v1.GatewayDPluginService.GetPluginConfig:input_type -> google.protobuf.Struct + 5, // 4: plugin.v1.GatewayDPluginService.OnConfigLoaded:input_type -> google.protobuf.Struct + 5, // 5: plugin.v1.GatewayDPluginService.OnNewLogger:input_type -> google.protobuf.Struct + 5, // 6: plugin.v1.GatewayDPluginService.OnNewPool:input_type -> google.protobuf.Struct + 5, // 7: plugin.v1.GatewayDPluginService.OnNewProxy:input_type -> google.protobuf.Struct + 5, // 8: plugin.v1.GatewayDPluginService.OnNewServer:input_type -> google.protobuf.Struct + 5, // 9: plugin.v1.GatewayDPluginService.OnSignal:input_type -> google.protobuf.Struct + 5, // 10: plugin.v1.GatewayDPluginService.OnRun:input_type -> google.protobuf.Struct + 5, // 11: plugin.v1.GatewayDPluginService.OnBooting:input_type -> google.protobuf.Struct + 5, // 12: plugin.v1.GatewayDPluginService.OnBooted:input_type -> google.protobuf.Struct + 5, // 13: plugin.v1.GatewayDPluginService.OnOpening:input_type -> google.protobuf.Struct + 5, // 14: plugin.v1.GatewayDPluginService.OnOpened:input_type -> google.protobuf.Struct + 5, // 15: plugin.v1.GatewayDPluginService.OnClosing:input_type -> google.protobuf.Struct + 5, // 16: plugin.v1.GatewayDPluginService.OnClosed:input_type -> google.protobuf.Struct + 5, // 17: plugin.v1.GatewayDPluginService.OnTraffic:input_type -> google.protobuf.Struct + 5, // 18: plugin.v1.GatewayDPluginService.OnIngressTraffic:input_type -> google.protobuf.Struct + 5, // 19: plugin.v1.GatewayDPluginService.OnEgressTraffic:input_type -> google.protobuf.Struct + 5, // 20: plugin.v1.GatewayDPluginService.OnShutdown:input_type -> google.protobuf.Struct + 5, // 21: plugin.v1.GatewayDPluginService.OnTick:input_type -> google.protobuf.Struct + 5, // 22: plugin.v1.GatewayDPluginService.OnNewClient:input_type -> google.protobuf.Struct + 5, // 23: plugin.v1.GatewayDPluginService.GetPluginConfig:output_type -> google.protobuf.Struct + 5, // 24: plugin.v1.GatewayDPluginService.OnConfigLoaded:output_type -> google.protobuf.Struct + 5, // 25: plugin.v1.GatewayDPluginService.OnNewLogger:output_type -> google.protobuf.Struct + 5, // 26: plugin.v1.GatewayDPluginService.OnNewPool:output_type -> google.protobuf.Struct + 5, // 27: plugin.v1.GatewayDPluginService.OnNewProxy:output_type -> google.protobuf.Struct + 5, // 28: plugin.v1.GatewayDPluginService.OnNewServer:output_type -> google.protobuf.Struct + 5, // 29: plugin.v1.GatewayDPluginService.OnSignal:output_type -> google.protobuf.Struct + 5, // 30: plugin.v1.GatewayDPluginService.OnRun:output_type -> google.protobuf.Struct + 5, // 31: plugin.v1.GatewayDPluginService.OnBooting:output_type -> google.protobuf.Struct + 5, // 32: plugin.v1.GatewayDPluginService.OnBooted:output_type -> google.protobuf.Struct + 5, // 33: plugin.v1.GatewayDPluginService.OnOpening:output_type -> google.protobuf.Struct + 5, // 34: plugin.v1.GatewayDPluginService.OnOpened:output_type -> google.protobuf.Struct + 5, // 35: plugin.v1.GatewayDPluginService.OnClosing:output_type -> google.protobuf.Struct + 5, // 36: plugin.v1.GatewayDPluginService.OnClosed:output_type -> google.protobuf.Struct + 5, // 37: plugin.v1.GatewayDPluginService.OnTraffic:output_type -> google.protobuf.Struct + 5, // 38: plugin.v1.GatewayDPluginService.OnIngressTraffic:output_type -> google.protobuf.Struct + 5, // 39: plugin.v1.GatewayDPluginService.OnEgressTraffic:output_type -> google.protobuf.Struct + 5, // 40: plugin.v1.GatewayDPluginService.OnShutdown:output_type -> google.protobuf.Struct + 5, // 41: plugin.v1.GatewayDPluginService.OnTick:output_type -> google.protobuf.Struct + 5, // 42: plugin.v1.GatewayDPluginService.OnNewClient:output_type -> google.protobuf.Struct + 23, // [23:43] is the sub-list for method output_type + 3, // [3:23] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_plugin_v1_plugin_proto_init() } +func file_plugin_v1_plugin_proto_init() { + if File_plugin_v1_plugin_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_plugin_v1_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Version); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_plugin_v1_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PluginID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_plugin_v1_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PluginConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_plugin_v1_plugin_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_plugin_v1_plugin_proto_goTypes, + DependencyIndexes: file_plugin_v1_plugin_proto_depIdxs, + MessageInfos: file_plugin_v1_plugin_proto_msgTypes, + }.Build() + File_plugin_v1_plugin_proto = out.File + file_plugin_v1_plugin_proto_rawDesc = nil + file_plugin_v1_plugin_proto_goTypes = nil + file_plugin_v1_plugin_proto_depIdxs = nil +} diff --git a/plugin/v1/plugin.proto b/plugin/v1/plugin.proto index 6c8eb053..cda0ef7a 100644 --- a/plugin/v1/plugin.proto +++ b/plugin/v1/plugin.proto @@ -2,247 +2,64 @@ syntax = "proto3"; package plugin.v1; -import "google/protobuf/empty.proto"; -import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; -option go_package = "github.com/gatewayd-io/gatewayd/plugin/v1"; +option go_package = "github.com/gatewayd-io/gatewayd/plugin/shared/plugin/v1"; -enum Action { - ACTION_UNSPECIFIED = 0; - ACTION_KILL = 1; - ACTION_RESTART = 2; - ACTION_RELOAD = 3; -} +service GatewayDPluginService { + // GetPluginConfig returns the plugin config upon registration + rpc GetPluginConfig (google.protobuf.Struct) returns (google.protobuf.Struct); -message SemVer { - uint32 major = 1; - uint32 minor = 2; - uint32 patch = 3; + // OnConfigLoaded is called when the config is loaded from any config provider + rpc OnConfigLoaded (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnNewLogger (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnNewPool (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnNewProxy (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnNewServer (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnSignal (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnRun (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnBooting (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnBooted (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnOpening (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnOpened (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnClosing (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnClosed (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnTraffic (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnIngressTraffic (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnEgressTraffic (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnShutdown (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnTick (google.protobuf.Struct) returns (google.protobuf.Struct); + rpc OnNewClient (google.protobuf.Struct) returns (google.protobuf.Struct); +} + +message Version { + uint64 major = 1; + uint64 minor = 2; + uint64 patch = 3; + string pre = 4; + string metadata = 5; + string original = 6; +} + +message PluginID { + string name = 1; + string version = 2; + string remote_url = 3; + string checksum = 4; } message PluginConfig { - string name = 1; - SemVer version = 2; - string description = 3; - string author = 4; - string license = 5; - string remote_url = 6; - string url = 7; + PluginID id = 1; + string description = 2; + string license = 4; + string project_url = 5; + repeated string authors = 3; // internal and external config options - map config = 8; + map config = 6; // hooks it attaches to - repeated string hooks = 9; + repeated string hooks = 7; // required plugins - map requires = 10; - repeated string tags = 11; - repeated string categories = 12; -} - -message PluginConfigRequest { - google.protobuf.Empty empty = 1; -} - -message PluginConfigResponse { - PluginConfig config = 1; -} - -// const ( -// OnConfigLoaded HookType = "onConfigLoaded" -// OnNewLogger HookType = "onNewLogger" -// OnNewPool HookType = "onNewPool" -// OnNewProxy HookType = "onNewProxy" -// OnNewServer HookType = "onNewServer" -// OnSignal HookType = "onSignal" -// OnRun HookType = "onRun" -// OnBooting HookType = "onBooting" -// OnBooted HookType = "onBooted" -// OnOpening HookType = "onOpening" -// OnOpened HookType = "onOpened" -// OnClosing HookType = "onClosing" -// OnClosed HookType = "onClosed" -// OnTraffic HookType = "onTraffic" -// OnIngressTraffic HookType = "onIngressTraffic" -// OnEgressTraffic HookType = "onEgressTraffic" -// OnShutdown HookType = "onShutdown" -// OnTick HookType = "onTick" -// OnNewClient HookType = "onNewClient" -// ) - -message OnConfigLoadedRequest { - map config = 1; -} - -message OnConfigLoadedResponse { - map config = 1; -} - -// Logger request/response -message OnNewLoggerRequest { - google.protobuf.Any logger = 1; -} - -message OnNewLoggerResponse { - google.protobuf.Empty empty = 1; -} - -message OnNewPoolRequest { - google.protobuf.Any pool = 1; -} - -message OnNewPoolResponse { - google.protobuf.Empty empty = 1; -} - -message OnNewProxyRequest { - google.protobuf.Any proxy = 1; -} - -message OnNewProxyResponse { - google.protobuf.Empty empty = 1; -} - -message OnNewServerRequest { - google.protobuf.Any server = 1; -} - -message OnNewServerResponse { - google.protobuf.Empty empty = 1; -} - -message OnSignalRequest { - string signal = 1; -} - -message OnSignalResponse { - Action action = 1; -} - -message OnRunRequest { - google.protobuf.Empty empty = 1; -} - -message OnRunResponse { - google.protobuf.Empty empty = 1; -} - -message OnBootingRequest { - google.protobuf.Empty empty = 1; -} - -message OnBootingResponse { - google.protobuf.Empty empty = 1; -} - -message OnBootedRequest { - google.protobuf.Empty empty = 1; -} - -message OnBootedResponse { - google.protobuf.Empty empty = 1; -} - -message OnOpeningRequest { - google.protobuf.Empty empty = 1; -} - -message OnOpeningResponse { - google.protobuf.Empty empty = 1; -} - -message OnOpenedRequest { - google.protobuf.Empty empty = 1; -} - -message OnOpenedResponse { - google.protobuf.Empty empty = 1; -} - -message OnClosingRequest { - google.protobuf.Empty empty = 1; -} - -message OnClosingResponse { - google.protobuf.Empty empty = 1; -} - -message OnClosedRequest { - google.protobuf.Empty empty = 1; -} - -message OnClosedResponse { - google.protobuf.Empty empty = 1; -} - -message OnTrafficRequest { - google.protobuf.Any traffic = 1; -} - -message OnTrafficResponse { - google.protobuf.Empty empty = 1; -} - -message OnIngressTrafficRequest { - google.protobuf.Any traffic = 1; -} - -message OnIngressTrafficResponse { - google.protobuf.Empty empty = 1; -} - -message OnEgressTrafficRequest { - google.protobuf.Any traffic = 1; -} - -message OnEgressTrafficResponse { - google.protobuf.Empty empty = 1; -} - -message OnShutdownRequest { - google.protobuf.Empty empty = 1; -} - -message OnShutdownResponse { - google.protobuf.Empty empty = 1; -} - -message OnTickRequest { - google.protobuf.Empty empty = 1; -} - -message OnTickResponse { - google.protobuf.Empty empty = 1; -} - -message OnNewClientRequest { - google.protobuf.Any client = 1; -} - -message OnNewClientResponse { - google.protobuf.Empty empty = 1; -} - -service GDPService { - // PluginConfig returns the plugin config for registration - rpc PluginConfig (PluginConfigRequest) returns (PluginConfigResponse); - - // OnConfigLoaded is called when the config is loaded from any config provider - rpc OnConfigLoaded (OnConfigLoadedRequest) returns (OnConfigLoadedResponse); - rpc OnNewLogger (OnNewLoggerRequest) returns (OnNewLoggerResponse); - rpc OnNewPool (OnNewPoolRequest) returns (OnNewPoolResponse); - rpc OnNewProxy (OnNewProxyRequest) returns (OnNewProxyResponse); - rpc OnNewServer (OnNewServerRequest) returns (OnNewServerResponse); - rpc OnSignal (OnSignalRequest) returns (OnSignalResponse); - rpc OnRun (OnRunRequest) returns (OnRunResponse); - rpc OnBooting (OnBootingRequest) returns (OnBootingResponse); - rpc OnBooted (OnBootedRequest) returns (OnBootedResponse); - rpc OnOpening (OnOpeningRequest) returns (OnOpeningResponse); - rpc OnOpened (OnOpenedRequest) returns (OnOpenedResponse); - rpc OnClosing (OnClosingRequest) returns (OnClosingResponse); - rpc OnClosed (OnClosedRequest) returns (OnClosedResponse); - rpc OnTraffic (OnTrafficRequest) returns (OnTrafficResponse); - rpc OnIngressTraffic (OnIngressTrafficRequest) returns (OnIngressTrafficResponse); - rpc OnEgressTraffic (OnEgressTrafficRequest) returns (OnEgressTrafficResponse); - rpc OnShutdown (OnShutdownRequest) returns (OnShutdownResponse); - rpc OnTick (OnTickRequest) returns (OnTickResponse); - rpc OnNewClient (OnNewClientRequest) returns (OnNewClientResponse); + map requires = 8; + repeated string tags = 9; + repeated string categories = 10; } diff --git a/plugin/v1/plugin_grpc.pb.go b/plugin/v1/plugin_grpc.pb.go new file mode 100644 index 00000000..3c1487ed --- /dev/null +++ b/plugin/v1/plugin_grpc.pb.go @@ -0,0 +1,794 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: plugin/v1/plugin.proto + +package v1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + structpb "google.golang.org/protobuf/types/known/structpb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// GatewayDPluginServiceClient is the client API for GatewayDPluginService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GatewayDPluginServiceClient interface { + // GetPluginConfig returns the plugin config upon registration + GetPluginConfig(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + // OnConfigLoaded is called when the config is loaded from any config provider + OnConfigLoaded(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnNewLogger(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnNewPool(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnNewProxy(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnNewServer(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnSignal(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnRun(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnBooting(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnBooted(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnOpening(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnOpened(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnClosing(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnClosed(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnIngressTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnEgressTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnShutdown(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnTick(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) + OnNewClient(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) +} + +type gatewayDPluginServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewGatewayDPluginServiceClient(cc grpc.ClientConnInterface) GatewayDPluginServiceClient { + return &gatewayDPluginServiceClient{cc} +} + +func (c *gatewayDPluginServiceClient) GetPluginConfig(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/GetPluginConfig", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnConfigLoaded(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnConfigLoaded", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnNewLogger(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnNewLogger", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnNewPool(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnNewPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnNewProxy(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnNewProxy", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnNewServer(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnNewServer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnSignal(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnSignal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnRun(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnRun", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnBooting(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnBooting", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnBooted(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnBooted", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnOpening(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnOpening", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnOpened(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnOpened", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnClosing(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnClosing", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnClosed(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnClosed", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnTraffic", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnIngressTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnIngressTraffic", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnEgressTraffic(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnEgressTraffic", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnShutdown(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnShutdown", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnTick(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnTick", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayDPluginServiceClient) OnNewClient(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) { + out := new(structpb.Struct) + err := c.cc.Invoke(ctx, "/plugin.v1.GatewayDPluginService/OnNewClient", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GatewayDPluginServiceServer is the server API for GatewayDPluginService service. +// All implementations must embed UnimplementedGatewayDPluginServiceServer +// for forward compatibility +type GatewayDPluginServiceServer interface { + // GetPluginConfig returns the plugin config upon registration + GetPluginConfig(context.Context, *structpb.Struct) (*structpb.Struct, error) + // OnConfigLoaded is called when the config is loaded from any config provider + OnConfigLoaded(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnNewLogger(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnNewPool(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnNewProxy(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnNewServer(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnSignal(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnRun(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnBooting(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnBooted(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnOpening(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnOpened(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnClosing(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnClosed(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnIngressTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnEgressTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnShutdown(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnTick(context.Context, *structpb.Struct) (*structpb.Struct, error) + OnNewClient(context.Context, *structpb.Struct) (*structpb.Struct, error) + mustEmbedUnimplementedGatewayDPluginServiceServer() +} + +// UnimplementedGatewayDPluginServiceServer must be embedded to have forward compatible implementations. +type UnimplementedGatewayDPluginServiceServer struct { +} + +func (UnimplementedGatewayDPluginServiceServer) GetPluginConfig(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPluginConfig not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnConfigLoaded(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnConfigLoaded not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnNewLogger(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnNewLogger not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnNewPool(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnNewPool not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnNewProxy(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnNewProxy not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnNewServer(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnNewServer not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnSignal(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnSignal not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnRun(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnRun not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnBooting(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnBooting not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnBooted(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnBooted not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnOpening(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnOpening not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnOpened(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnOpened not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnClosing(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnClosing not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnClosed(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnClosed not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnTraffic not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnIngressTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnIngressTraffic not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnEgressTraffic(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnEgressTraffic not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnShutdown(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnShutdown not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnTick(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnTick not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) OnNewClient(context.Context, *structpb.Struct) (*structpb.Struct, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnNewClient not implemented") +} +func (UnimplementedGatewayDPluginServiceServer) mustEmbedUnimplementedGatewayDPluginServiceServer() {} + +// UnsafeGatewayDPluginServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GatewayDPluginServiceServer will +// result in compilation errors. +type UnsafeGatewayDPluginServiceServer interface { + mustEmbedUnimplementedGatewayDPluginServiceServer() +} + +func RegisterGatewayDPluginServiceServer(s grpc.ServiceRegistrar, srv GatewayDPluginServiceServer) { + s.RegisterService(&GatewayDPluginService_ServiceDesc, srv) +} + +func _GatewayDPluginService_GetPluginConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).GetPluginConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/GetPluginConfig", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).GetPluginConfig(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnConfigLoaded_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnConfigLoaded(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnConfigLoaded", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnConfigLoaded(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnNewLogger_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnNewLogger(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnNewLogger", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnNewLogger(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnNewPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnNewPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnNewPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnNewPool(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnNewProxy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnNewProxy(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnNewProxy", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnNewProxy(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnNewServer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnNewServer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnNewServer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnNewServer(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnSignal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnSignal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnSignal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnSignal(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnRun_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnRun(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnRun", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnRun(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnBooting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnBooting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnBooting", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnBooting(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnBooted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnBooted(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnBooted", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnBooted(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnOpening_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnOpening(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnOpening", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnOpening(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnOpened_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnOpened(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnOpened", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnOpened(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnClosing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnClosing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnClosing", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnClosing(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnClosed_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnClosed(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnClosed", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnClosed(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnTraffic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnTraffic(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnTraffic", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnTraffic(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnIngressTraffic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnIngressTraffic(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnIngressTraffic", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnIngressTraffic(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnEgressTraffic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnEgressTraffic(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnEgressTraffic", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnEgressTraffic(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnShutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnShutdown(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnShutdown", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnShutdown(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnTick_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnTick(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnTick", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnTick(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayDPluginService_OnNewClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(structpb.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayDPluginServiceServer).OnNewClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.v1.GatewayDPluginService/OnNewClient", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayDPluginServiceServer).OnNewClient(ctx, req.(*structpb.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +// GatewayDPluginService_ServiceDesc is the grpc.ServiceDesc for GatewayDPluginService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var GatewayDPluginService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.v1.GatewayDPluginService", + HandlerType: (*GatewayDPluginServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPluginConfig", + Handler: _GatewayDPluginService_GetPluginConfig_Handler, + }, + { + MethodName: "OnConfigLoaded", + Handler: _GatewayDPluginService_OnConfigLoaded_Handler, + }, + { + MethodName: "OnNewLogger", + Handler: _GatewayDPluginService_OnNewLogger_Handler, + }, + { + MethodName: "OnNewPool", + Handler: _GatewayDPluginService_OnNewPool_Handler, + }, + { + MethodName: "OnNewProxy", + Handler: _GatewayDPluginService_OnNewProxy_Handler, + }, + { + MethodName: "OnNewServer", + Handler: _GatewayDPluginService_OnNewServer_Handler, + }, + { + MethodName: "OnSignal", + Handler: _GatewayDPluginService_OnSignal_Handler, + }, + { + MethodName: "OnRun", + Handler: _GatewayDPluginService_OnRun_Handler, + }, + { + MethodName: "OnBooting", + Handler: _GatewayDPluginService_OnBooting_Handler, + }, + { + MethodName: "OnBooted", + Handler: _GatewayDPluginService_OnBooted_Handler, + }, + { + MethodName: "OnOpening", + Handler: _GatewayDPluginService_OnOpening_Handler, + }, + { + MethodName: "OnOpened", + Handler: _GatewayDPluginService_OnOpened_Handler, + }, + { + MethodName: "OnClosing", + Handler: _GatewayDPluginService_OnClosing_Handler, + }, + { + MethodName: "OnClosed", + Handler: _GatewayDPluginService_OnClosed_Handler, + }, + { + MethodName: "OnTraffic", + Handler: _GatewayDPluginService_OnTraffic_Handler, + }, + { + MethodName: "OnIngressTraffic", + Handler: _GatewayDPluginService_OnIngressTraffic_Handler, + }, + { + MethodName: "OnEgressTraffic", + Handler: _GatewayDPluginService_OnEgressTraffic_Handler, + }, + { + MethodName: "OnShutdown", + Handler: _GatewayDPluginService_OnShutdown_Handler, + }, + { + MethodName: "OnTick", + Handler: _GatewayDPluginService_OnTick_Handler, + }, + { + MethodName: "OnNewClient", + Handler: _GatewayDPluginService_OnNewClient_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "plugin/v1/plugin.proto", +}