55 lines
660 B
Go
55 lines
660 B
Go
|
package natsio
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// Config ...
|
||
|
type Config struct {
|
||
|
// Connect url
|
||
|
URL string
|
||
|
|
||
|
// Auth user
|
||
|
User string
|
||
|
|
||
|
// Auth password
|
||
|
Password string
|
||
|
|
||
|
// TLS config
|
||
|
TLS *TLSConfig
|
||
|
|
||
|
// RequestTimeout
|
||
|
RequestTimeout time.Duration
|
||
|
|
||
|
// Stream name
|
||
|
StreamName string
|
||
|
|
||
|
// Debug
|
||
|
Debug bool
|
||
|
}
|
||
|
|
||
|
func (c Config) validate() error {
|
||
|
if c.URL == "" {
|
||
|
return errors.New("connect URL is required")
|
||
|
}
|
||
|
|
||
|
if c.StreamName == "" {
|
||
|
return errors.New("stream name is required")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// TLSConfig ...
|
||
|
type TLSConfig struct {
|
||
|
// Cert file
|
||
|
CertFilePath string
|
||
|
|
||
|
// Key file
|
||
|
KeyFilePath string
|
||
|
|
||
|
// Root CA
|
||
|
RootCAFilePath string
|
||
|
}
|