Skip to content

Commit 005cf8b

Browse files
committed
Define env var in the PluginConfig
1 parent 9a8ab02 commit 005cf8b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ package main
33
import (
44
"context"
55
"flag"
6-
"log"
7-
"os"
8-
"strconv"
9-
106
"github.com/gatewayd-io/gatewayd-plugin-cache/plugin"
117
sdkConfig "github.com/gatewayd-io/gatewayd-plugin-sdk/config"
128
"github.com/gatewayd-io/gatewayd-plugin-sdk/logging"
@@ -17,6 +13,8 @@ import (
1713
"github.com/hashicorp/go-hclog"
1814
goplugin "github.com/hashicorp/go-plugin"
1915
"github.com/spf13/cast"
16+
"log"
17+
"os"
2018
)
2119

2220
func main() {
@@ -53,9 +51,8 @@ func main() {
5351
go metrics.ExposeMetrics(metricsConfig, logger)
5452
}
5553

56-
cacheBufferSizeStr := sdkConfig.GetEnv("CACHE_CHANNEL_BUFFER_SIZE", "100")
57-
cacheBufferSize, err := strconv.Atoi(cacheBufferSizeStr)
58-
if err != nil || cacheBufferSize <= 0 {
54+
cacheBufferSize := cast.ToUint(cfg["cacheBufferSize"])
55+
if cacheBufferSize <= 0 {
5956
cacheBufferSize = 100 // default value
6057
}
6158

plugin/module.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var (
4545
"PERIODIC_INVALIDATOR_INTERVAL", "1m"),
4646
"apiAddress": sdkConfig.GetEnv("API_ADDRESS", "localhost:8080"),
4747
"exitOnStartupError": sdkConfig.GetEnv("EXIT_ON_STARTUP_ERROR", "false"),
48+
"cacheBufferSize": sdkConfig.GetEnv("CACHE_CHANNEL_BUFFER_SIZE", "100"),
4849
},
4950
"hooks": []interface{}{
5051
int32(v1.HookName_HOOK_NAME_ON_CLOSED),

0 commit comments

Comments
 (0)