From cea40739022489bb6c7a1275e1857c330dedd2f6 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Fri, 7 Apr 2023 19:24:05 +0200 Subject: [PATCH] WIP (https://github.com/gatewayd-io/plugin-template-python/issues/1) --- gatewayd_plugins.yaml | 26 ++++++++++++-------------- plugin/plugin_registry.go | 10 ++++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gatewayd_plugins.yaml b/gatewayd_plugins.yaml index f8c30d88..b57d0225 100644 --- a/gatewayd_plugins.yaml +++ b/gatewayd_plugins.yaml @@ -63,21 +63,19 @@ timeout: 30s # use when connecting to the database. The DEFAULT_DB_NAME environment variable is optional # and should only be used if one only has a single database in their PostgreSQL instance. plugins: - - name: gatewayd-plugin-cache + - name: plugin-template-python + # whether to enable or disable the plugin on the next run enabled: True - localPath: ../gatewayd-plugin-cache/gatewayd-plugin-cache - args: ["--log-level", "debug"] + # path to the plugin's binary file + localPath: poetry + args: ["-C", "../plugin-template-python", "run", "python", "../plugin-template-python/main.py"] + # Pass environment variables to the plugin + # System-wide environment variables are passed to the plugin normally + # and they can be accessed via os.Environ(). + # Defining any environment variables below will override system-wide environment variables. env: + # The below environment variables are used by the plugin loader to verify the plugin's identity. - MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN - MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872 - - REDIS_URL=redis://localhost:6379/0 - - EXPIRY=1h - # - DEFAULT_DB_NAME=postgres - - METRICS_ENABLED=True - - METRICS_UNIX_DOMAIN_SOCKET=/tmp/gatewayd-plugin-cache.sock - - METRICS_PATH=/metrics - - PERIODIC_INVALIDATOR_ENABLED=True - - PERIODIC_INVALIDATOR_INTERVAL=1m - - PERIODIC_INVALIDATOR_START_DELAY=1m - - API_ADDRESS=localhost:18080 - checksum: 28456728dd3427b91d2e22f38b909526355d1b2becc9379581e1b70bb9495aa9 + # Checksum hash to verify the binary before loading + checksum: dee4aa014a722e1865d91744a4fd310772152467d9c6ab4ba17fd9dd40d3f724 diff --git a/plugin/plugin_registry.go b/plugin/plugin_registry.go index e5747aed..8e5e5693 100644 --- a/plugin/plugin_registry.go +++ b/plugin/plugin_registry.go @@ -3,6 +3,7 @@ package plugin import ( "context" "sort" + "time" semver "github.com/Masterminds/semver/v3" sdkPlugin "github.com/gatewayd-io/gatewayd-plugin-sdk/plugin" @@ -454,9 +455,9 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) { plugin.Client = goplugin.NewClient( &goplugin.ClientConfig{ - HandshakeConfig: v1.Handshake, - Plugins: v1.GetPluginMap(plugin.ID.Name), - Cmd: NewCommand(plugin.LocalPath, plugin.Args, plugin.Env), + // HandshakeConfig: v1.Handshake, + Plugins: v1.GetPluginMap(plugin.ID.Name), + Cmd: NewCommand(plugin.LocalPath, plugin.Args, plugin.Env), AllowedProtocols: []goplugin.Protocol{ goplugin.ProtocolGRPC, }, @@ -465,7 +466,7 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) { Managed: true, MinPort: config.DefaultMinPort, MaxPort: config.DefaultMaxPort, - AutoMTLS: true, + AutoMTLS: false, }, ) @@ -490,6 +491,7 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) { plugin.Client.Kill() continue } + time.Sleep(2 * time.Second) meta, origErr := pluginV1.GetPluginConfig( //nolint:contextcheck context.Background(), &structpb.Struct{}) if err != nil || meta == nil { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy