Skip to content

Commit

Permalink
queue client should accept endpoint as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
shudshi committed Feb 26, 2024
1 parent badde64 commit e6daebf
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions queue/queue_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ func NewQueueClientWithConfigurationProvider(configProvider common.Configuration
return newQueueClientFromBaseClient(baseClient, provider)
}

// NewQueueClientWithConfigurationProviderWithEndpoint Creates a new default Queue client with the given configuration provider and the Queue endpoint.
// the configuration provider will be used for the default signer as well as reading the region
func NewQueueClientWithConfigurationProviderWithEndpoint(configProvider common.ConfigurationProvider, endpoint string) (client QueueClient, err error) {
client, err = NewQueueClientWithConfigurationProvider(configProvider)
if err != nil {
return client, err
}

client.SetEndpoint(endpoint)
return client, nil
}

// NewQueueClientWithOboToken Creates a new default Queue client with the given configuration provider.
// The obotoken will be added to default headers and signed; the configuration provider will be used for the signer
//
Expand All @@ -53,6 +65,20 @@ func NewQueueClientWithOboToken(configProvider common.ConfigurationProvider, obo
return newQueueClientFromBaseClient(baseClient, configProvider)
}

// NewQueueClientWithOboTokenWithEndpoint Creates a new default Queue client with the given configuration provider and endpoint.
// The obotoken will be added to default headers and signed; the configuration provider will be used for the signer
//
// as well as reading the region
func NewQueueClientWithOboTokenWithEndpoint(configProvider common.ConfigurationProvider, oboToken, endpoint string) (client QueueClient, err error) {
client, err = NewQueueClientWithOboToken(configProvider, oboToken)
if err != nil {
return client, err
}

client.SetEndpoint(endpoint)
return client, nil
}

func newQueueClientFromBaseClient(baseClient common.BaseClient, configProvider common.ConfigurationProvider) (client QueueClient, err error) {
// Queue service default circuit breaker is enabled
baseClient.Configuration.CircuitBreaker = common.NewCircuitBreaker(common.DefaultCircuitBreakerSettingWithServiceName("Queue"))
Expand All @@ -66,10 +92,16 @@ func newQueueClientFromBaseClient(baseClient common.BaseClient, configProvider c
}

// SetRegion overrides the region of this client.
// Deprecated: SetReion is deprecated because each Queue's endpoint is different
func (client *QueueClient) SetRegion(region string) {
client.Host = common.StringToRegion(region).EndpointForTemplate("queue", "https://messaging.{region}.oci.{secondLevelDomain}")
}

// SetEndpoint overrides the endpoint of this client.
func (client *QueueClient) SetEndpoint(endpoint string) {
client.Host = endpoint
}

// SetConfigurationProvider sets the configuration provider including the region, returns an error if is not valid
func (client *QueueClient) setConfigurationProvider(configProvider common.ConfigurationProvider) error {
if ok, err := common.IsConfigurationProviderValid(configProvider); !ok {
Expand Down

0 comments on commit e6daebf

Please sign in to comment.