58 lines
720 B
Go
58 lines
720 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
|
|
|
|
// Server
|
|
Server string
|
|
|
|
// Service
|
|
Service string
|
|
}
|
|
|
|
func (c Config) validate() error {
|
|
if c.URL == "" {
|
|
return errors.New("connect URL is required")
|
|
}
|
|
|
|
if c.Server == "" || c.Service == "" {
|
|
return errors.New("server and service name is required")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// TLSConfig ...
|
|
type TLSConfig struct {
|
|
// Cert file
|
|
CertFilePath string
|
|
|
|
// Key file
|
|
KeyFilePath string
|
|
|
|
// Root CA
|
|
RootCAFilePath string
|
|
}
|