Skip to content

Commit

Permalink
update broker config
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Nov 15, 2024
1 parent c406f44 commit 6282827
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions receiver/solacereceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To get started with the Solace receiver, a telemetry queue and authentication de
```yaml
receivers:
solace:
broker: [localhost:5671]
broker: localhost:5671
auth:
sasl_plain:
username: otel
Expand Down Expand Up @@ -63,7 +63,7 @@ Simple single node configuration with SASL plain authentication (TLS enabled by
```yaml
receivers:
solace:
broker: [localhost:5671]
broker: localhost:5671
auth:
sasl_plain:
username: otel
Expand All @@ -80,15 +80,15 @@ High availability setup with SASL plain authentication (TLS enabled by default)
```yaml
receivers:
solace/primary:
broker: [myHost-primary:5671]
broker: myHost-primary:5671
auth:
sasl_plain:
username: otel
password: otel01$
queue: queue://#telemetry-profile123
solace/backup:
broker: [myHost-backup:5671]
broker: myHost-backup:5671
auth:
sasl_plain:
username: otel
Expand Down
4 changes: 2 additions & 2 deletions receiver/solacereceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (

// Config defines configuration for Solace receiver.
type Config struct {
// The list of solace brokers (default localhost:5671)
Broker []string `mapstructure:"broker"`
// The solace broker (default localhost:5671)
Broker string `mapstructure:"broker"`

// The name of the solace queue to consume from, it is required parameter
Queue string `mapstructure:"queue"`
Expand Down
2 changes: 1 addition & 1 deletion receiver/solacereceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestLoadConfig(t *testing.T) {
{
id: component.NewIDWithName(metadata.Type, "primary"),
expected: &Config{
Broker: []string{"myHost:5671"},
Broker: "myHost:5671",
Auth: Authentication{
PlainText: &SaslPlainTextConfig{
Username: "otel",
Expand Down
2 changes: 1 addition & 1 deletion receiver/solacereceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewFactory() receiver.Factory {
// createDefaultConfig creates the default configuration for receiver.
func createDefaultConfig() component.Config {
return &Config{
Broker: []string{defaultHost},
Broker: defaultHost,
MaxUnacked: defaultMaxUnaked,
Auth: Authentication{},
TLS: configtls.ClientConfig{
Expand Down
3 changes: 1 addition & 2 deletions receiver/solacereceiver/messaging_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ func newAMQPMessagingServiceFactory(cfg *Config, logger *zap.Logger) (messagingS
return nil, err
}

broker := cfg.Broker[0]
// If the TLS config is nil, insecure is true and we should use amqp rather than amqps
scheme := "amqp"
if loadedTLSConfig != nil {
scheme = "amqps"
}
amqpHostAddress := fmt.Sprintf("%s://%s", scheme, broker)
amqpHostAddress := fmt.Sprintf("%s://%s", scheme, cfg.Broker)

connectConfig := &amqpConnectConfig{
addr: amqpHostAddress,
Expand Down
8 changes: 4 additions & 4 deletions receiver/solacereceiver/messaging_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) {
cfg: &Config{ // no password
Auth: Authentication{PlainText: &SaslPlainTextConfig{Username: "set"}},
TLS: configtls.ClientConfig{Insecure: false, InsecureSkipVerify: false},
Broker: []string{broker},
Broker: broker,
Queue: queue,
MaxUnacked: maxUnacked,
},
Expand All @@ -98,7 +98,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) {
cfg: &Config{ // invalid to only provide a key file
Auth: Authentication{PlainText: &SaslPlainTextConfig{Username: "user", Password: "password"}},
TLS: configtls.ClientConfig{Config: configtls.Config{KeyFile: "someKeyFile"}, Insecure: false},
Broker: []string{broker},
Broker: broker,
Queue: queue,
MaxUnacked: maxUnacked,
},
Expand All @@ -110,7 +110,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) {
cfg: &Config{ // invalid to only provide a key file
Auth: Authentication{PlainText: &SaslPlainTextConfig{Username: "user", Password: "password"}},
TLS: configtls.ClientConfig{Insecure: false},
Broker: []string{broker},
Broker: broker,
Queue: queue,
MaxUnacked: maxUnacked,
},
Expand All @@ -134,7 +134,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) {
cfg: &Config{ // invalid to only provide a key file
Auth: Authentication{PlainText: &SaslPlainTextConfig{Username: "user", Password: "password"}},
TLS: configtls.ClientConfig{Insecure: true},
Broker: []string{broker},
Broker: broker,
Queue: queue,
MaxUnacked: maxUnacked,
},
Expand Down
6 changes: 3 additions & 3 deletions receiver/solacereceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
solace/primary:
broker: [ myHost:5671 ]
broker: myHost:5671
auth:
sasl_plain:
username: otel
Expand All @@ -20,12 +20,12 @@ solace/backup:
insecure: true

solace/noqueue:
broker: [ myHost:5671 ]
broker: myHost:5671
auth:
sasl_plain:
username: otel
password: otel01

solace/noauth:
broker: [ myHost:5671 ]
broker: myHost:5671
queue: queue://#trace-profile123

0 comments on commit 6282827

Please sign in to comment.