Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing natsOpts from service observations and js advisories #203

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion surveyor/conn_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type natsContext struct {
TLSCA string `json:"tls_ca"`
TLSCert string `json:"tls_cert"`
TLSKey string `json:"tls_key"`

// only passed programmatically
NatsOpts []nats.Option `json:"-"`
}

func (c *natsContext) copy() *natsContext {
Expand Down Expand Up @@ -199,7 +202,7 @@ func (cp *natsConnPool) getPooledConn(key string, cfg *natsContext) (*pooledNats
}
cp.Unlock()

opts := cp.natsOpts
opts := append(cp.natsOpts, cfg.NatsOpts...)
opts = append(opts, func(options *nats.Options) error {
if cfg.Name != "" {
options.Name = cfg.Name
Expand Down
13 changes: 9 additions & 4 deletions surveyor/jetstream_advisories.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ type JSAdvisoryConfig struct {
// account name
AccountName string `json:"name"`

// optional configuration for importing JS metrics and advisories from other accounts
// it can only be set via JSAdvisoryConfig directly (not from config file)
ExternalAccountConfig *JSAdvisoriesExternalAccountConfig `json:"-"`

// connection options
JWT string `json:"jwt"`
Seed string `json:"seed"`
Expand All @@ -250,6 +246,14 @@ type JSAdvisoryConfig struct {
TLSCA string `json:"tls_ca"`
TLSCert string `json:"tls_cert"`
TLSKey string `json:"tls_key"`

// additional opts available via JSAdvisoryConfig directly (not from config file)

// optional configuration for importing JS metrics and advisories from other accounts
ExternalAccountConfig *JSAdvisoriesExternalAccountConfig `json:"-"`

// nats options appended to base surveyor options
NatsOpts []nats.Option `json:"-"`
}

// JSAdvisoriesExternalAccountConfig is used to configure external accounts from which
Expand Down Expand Up @@ -387,6 +391,7 @@ func (o *jsAdvisoryListener) natsContext() *natsContext {
TLSCA: o.config.TLSCA,
TLSCert: o.config.TLSCert,
TLSKey: o.config.TLSKey,
NatsOpts: o.config.NatsOpts,
}

return natsCtx
Expand Down
13 changes: 9 additions & 4 deletions surveyor/observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ type ServiceObsConfig struct {
ServiceName string `json:"name"`
Topic string `json:"topic"`

// optional configuration for importing observations from other accounts
// it can only be set via ServiceObsConfig directly (not from config file)
ExternalAccountConfig *ServiceObservationExternalAccountConfig `json:"-"`

// connection options
JWT string `json:"jwt"`
Seed string `json:"seed"`
Expand All @@ -140,6 +136,14 @@ type ServiceObsConfig struct {
TLSCA string `json:"tls_ca"`
TLSCert string `json:"tls_cert"`
TLSKey string `json:"tls_key"`

// additional opts available via ServiceObsConfig directly (not from config file)

// optional configuration for importing observations from other accounts
ExternalAccountConfig *ServiceObservationExternalAccountConfig `json:"-"`

// nats options appended to base surveyor options
NatsOpts []nats.Option `json:"-"`
}

type ServiceObservationExternalAccountConfig struct {
Expand Down Expand Up @@ -262,6 +266,7 @@ func (o *serviceObsListener) natsContext() *natsContext {
TLSCA: o.config.TLSCA,
TLSCert: o.config.TLSCert,
TLSKey: o.config.TLSKey,
NatsOpts: o.config.NatsOpts,
}

// legacy Credentials field
Expand Down
Loading