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

queue client should accept endpoint as a parameter #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
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