Skip to content

Commit

Permalink
use fully qualified namespace (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik authored Sep 24, 2023
1 parent e7748b9 commit f1ce7c9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flow/connectors/eventhub/hubmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package conneventhub
import (
"context"
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs"
Expand Down Expand Up @@ -33,9 +34,16 @@ func NewEventHubManager(
func (m *EventHubManager) GetOrCreateHub(name string) (*azeventhubs.ProducerClient, error) {
hub, ok := m.hubs.Get(name)

namespace := m.namespace
// if the namespace isn't fully qualified, add the `.servicebus.windows.net`
// check by counting the number of '.' in the namespace
if strings.Count(namespace, ".") < 2 {
namespace = fmt.Sprintf("%s.servicebus.windows.net", namespace)
}

if !ok {
opts := &azeventhubs.ProducerClientOptions{}
hub, err := azeventhubs.NewProducerClient(m.namespace, name, m.creds, opts)
hub, err := azeventhubs.NewProducerClient(namespace, name, m.creds, opts)
if err != nil {
return nil, fmt.Errorf("failed to create eventhub client: %v", err)
}
Expand Down

0 comments on commit f1ce7c9

Please sign in to comment.