natsio/config.go

55 lines
660 B
Go
Raw Normal View History

2021-10-08 04:23:59 +00:00
package natsio
2022-12-04 15:21:30 +00:00
import (
"errors"
"time"
)
2021-10-08 04:23:59 +00:00
// Config ...
type Config struct {
// Connect url
URL string
// Auth user
User string
// Auth password
Password string
// TLS config
TLS *TLSConfig
// RequestTimeout
RequestTimeout time.Duration
2022-12-04 15:10:05 +00:00
// Stream name
StreamName string
2022-12-15 10:34:47 +00:00
// Debug
Debug bool
2022-12-04 15:21:30 +00:00
}
func (c Config) validate() error {
if c.URL == "" {
return errors.New("connect URL is required")
}
2022-12-15 10:34:47 +00:00
if c.StreamName == "" {
return errors.New("stream name is required")
}
2022-12-04 15:21:30 +00:00
return nil
2021-10-08 04:23:59 +00:00
}
// TLSConfig ...
type TLSConfig struct {
// Cert file
CertFilePath string
// Key file
KeyFilePath string
// Root CA
RootCAFilePath string
}