Skip to content

Commit e6daebf

Browse files
committed
queue client should accept endpoint as a parameter
1 parent badde64 commit e6daebf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

queue/queue_client.go

+32
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ func NewQueueClientWithConfigurationProvider(configProvider common.Configuration
4040
return newQueueClientFromBaseClient(baseClient, provider)
4141
}
4242

43+
// NewQueueClientWithConfigurationProviderWithEndpoint Creates a new default Queue client with the given configuration provider and the Queue endpoint.
44+
// the configuration provider will be used for the default signer as well as reading the region
45+
func NewQueueClientWithConfigurationProviderWithEndpoint(configProvider common.ConfigurationProvider, endpoint string) (client QueueClient, err error) {
46+
client, err = NewQueueClientWithConfigurationProvider(configProvider)
47+
if err != nil {
48+
return client, err
49+
}
50+
51+
client.SetEndpoint(endpoint)
52+
return client, nil
53+
}
54+
4355
// NewQueueClientWithOboToken Creates a new default Queue client with the given configuration provider.
4456
// The obotoken will be added to default headers and signed; the configuration provider will be used for the signer
4557
//
@@ -53,6 +65,20 @@ func NewQueueClientWithOboToken(configProvider common.ConfigurationProvider, obo
5365
return newQueueClientFromBaseClient(baseClient, configProvider)
5466
}
5567

68+
// NewQueueClientWithOboTokenWithEndpoint Creates a new default Queue client with the given configuration provider and endpoint.
69+
// The obotoken will be added to default headers and signed; the configuration provider will be used for the signer
70+
//
71+
// as well as reading the region
72+
func NewQueueClientWithOboTokenWithEndpoint(configProvider common.ConfigurationProvider, oboToken, endpoint string) (client QueueClient, err error) {
73+
client, err = NewQueueClientWithOboToken(configProvider, oboToken)
74+
if err != nil {
75+
return client, err
76+
}
77+
78+
client.SetEndpoint(endpoint)
79+
return client, nil
80+
}
81+
5682
func newQueueClientFromBaseClient(baseClient common.BaseClient, configProvider common.ConfigurationProvider) (client QueueClient, err error) {
5783
// Queue service default circuit breaker is enabled
5884
baseClient.Configuration.CircuitBreaker = common.NewCircuitBreaker(common.DefaultCircuitBreakerSettingWithServiceName("Queue"))
@@ -66,10 +92,16 @@ func newQueueClientFromBaseClient(baseClient common.BaseClient, configProvider c
6692
}
6793

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

100+
// SetEndpoint overrides the endpoint of this client.
101+
func (client *QueueClient) SetEndpoint(endpoint string) {
102+
client.Host = endpoint
103+
}
104+
73105
// SetConfigurationProvider sets the configuration provider including the region, returns an error if is not valid
74106
func (client *QueueClient) setConfigurationProvider(configProvider common.ConfigurationProvider) error {
75107
if ok, err := common.IsConfigurationProviderValid(configProvider); !ok {

0 commit comments

Comments
 (0)