nats-exec: make JS domain configurable
This commit is contained in:
@@ -28,6 +28,7 @@ func main() {
|
||||
natsURL := getEnv("NATS_URL", "nats://localhost:4222")
|
||||
bucketName := getEnv("NATS_BUCKET", "binaries")
|
||||
cacheDir := getEnv("NATS_CACHE_DIR", filepath.Join(os.TempDir(), "nats-exec-cache"))
|
||||
natsDomain := getEnv("NATS_JS_DOMAIN", "")
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -37,7 +38,7 @@ func main() {
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
js, err := jetstream.New(nc)
|
||||
js, err := createJetStream(nc, natsDomain)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create JetStream context: %v", err)
|
||||
}
|
||||
@@ -144,3 +145,11 @@ func getEnv(key, defaultValue string) string {
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func createJetStream(nc *nats.Conn, domain string) (jetstream.JetStream, error) {
|
||||
if domain != "" {
|
||||
return jetstream.NewWithDomain(nc, domain)
|
||||
}
|
||||
|
||||
return jetstream.New(nc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user