Support for NATS Creds

This commit is contained in:
Aditya Ujeniya
2024-10-26 22:38:03 +02:00
parent 2f3f70aa9f
commit 2d510b2890
4 changed files with 27 additions and 5 deletions

View File

@@ -92,6 +92,10 @@ func ReceiveNats(conf *config.NatsConfig,
opts = append(opts, nats.UserInfo(conf.Username, conf.Password))
}
if conf.Credsfilepath != "" {
opts = append(opts, nats.UserCredentials(conf.Credsfilepath))
}
nc, err := nats.Connect(conf.Address, opts...)
if err != nil {
return err

View File

@@ -65,6 +65,9 @@ type NatsConfig struct {
Username string `json:"username"`
Password string `json:"password"`
//Creds file path
Credsfilepath string `json:"creds-file-path"`
Subscriptions []struct {
// Channel name
SubscribeTo string `json:"subscribe-to"`