Skip to content

Commit cea4073

Browse files
committed
1 parent 599494c commit cea4073

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

gatewayd_plugins.yaml

+12-14
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,19 @@ timeout: 30s
6363
# use when connecting to the database. The DEFAULT_DB_NAME environment variable is optional
6464
# and should only be used if one only has a single database in their PostgreSQL instance.
6565
plugins:
66-
- name: gatewayd-plugin-cache
66+
- name: plugin-template-python
67+
# whether to enable or disable the plugin on the next run
6768
enabled: True
68-
localPath: ../gatewayd-plugin-cache/gatewayd-plugin-cache
69-
args: ["--log-level", "debug"]
69+
# path to the plugin's binary file
70+
localPath: poetry
71+
args: ["-C", "../plugin-template-python", "run", "python", "../plugin-template-python/main.py"]
72+
# Pass environment variables to the plugin
73+
# System-wide environment variables are passed to the plugin normally
74+
# and they can be accessed via os.Environ().
75+
# Defining any environment variables below will override system-wide environment variables.
7076
env:
77+
# The below environment variables are used by the plugin loader to verify the plugin's identity.
7178
- MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN
7279
- MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872
73-
- REDIS_URL=redis://localhost:6379/0
74-
- EXPIRY=1h
75-
# - DEFAULT_DB_NAME=postgres
76-
- METRICS_ENABLED=True
77-
- METRICS_UNIX_DOMAIN_SOCKET=/tmp/gatewayd-plugin-cache.sock
78-
- METRICS_PATH=/metrics
79-
- PERIODIC_INVALIDATOR_ENABLED=True
80-
- PERIODIC_INVALIDATOR_INTERVAL=1m
81-
- PERIODIC_INVALIDATOR_START_DELAY=1m
82-
- API_ADDRESS=localhost:18080
83-
checksum: 28456728dd3427b91d2e22f38b909526355d1b2becc9379581e1b70bb9495aa9
80+
# Checksum hash to verify the binary before loading
81+
checksum: dee4aa014a722e1865d91744a4fd310772152467d9c6ab4ba17fd9dd40d3f724

plugin/plugin_registry.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package plugin
33
import (
44
"context"
55
"sort"
6+
"time"
67

78
semver "github.com/Masterminds/semver/v3"
89
sdkPlugin "github.com/gatewayd-io/gatewayd-plugin-sdk/plugin"
@@ -454,9 +455,9 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) {
454455

455456
plugin.Client = goplugin.NewClient(
456457
&goplugin.ClientConfig{
457-
HandshakeConfig: v1.Handshake,
458-
Plugins: v1.GetPluginMap(plugin.ID.Name),
459-
Cmd: NewCommand(plugin.LocalPath, plugin.Args, plugin.Env),
458+
// HandshakeConfig: v1.Handshake,
459+
Plugins: v1.GetPluginMap(plugin.ID.Name),
460+
Cmd: NewCommand(plugin.LocalPath, plugin.Args, plugin.Env),
460461
AllowedProtocols: []goplugin.Protocol{
461462
goplugin.ProtocolGRPC,
462463
},
@@ -465,7 +466,7 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) {
465466
Managed: true,
466467
MinPort: config.DefaultMinPort,
467468
MaxPort: config.DefaultMaxPort,
468-
AutoMTLS: true,
469+
AutoMTLS: false,
469470
},
470471
)
471472

@@ -490,6 +491,7 @@ func (reg *Registry) LoadPlugins(ctx context.Context, plugins []config.Plugin) {
490491
plugin.Client.Kill()
491492
continue
492493
}
494+
time.Sleep(2 * time.Second)
493495
meta, origErr := pluginV1.GetPluginConfig( //nolint:contextcheck
494496
context.Background(), &structpb.Struct{})
495497
if err != nil || meta == nil {

0 commit comments

Comments
 (0)