Skip to content

Commit

Permalink
feat(http-client)!: add new internal service url for namespace client
Browse files Browse the repository at this point in the history
  • Loading branch information
aris1009 committed Jun 6, 2024
1 parent 7a66a7f commit 28f7ee3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ import (
"github.com/rudderlabs/rudder-go-kit/logger"
)

const defaultBaseUrl = "https://api.rudderstack.com"
const (
defaultBaseUrl = "https://api.rudderstack.com"
defaultBaseUrlV2 = "https://dp.api.rudderstack.com"
)

type ControlPlane struct {
baseUrl *url.URL
baseUrlV2 *url.URL
workspaceIdentity *identity.Workspace
namespaceIdentity *identity.Namespace
adminCredentials *identity.AdminCredentials
Expand Down Expand Up @@ -53,8 +57,10 @@ type RequestDoer interface {

func New(options ...Option) (*ControlPlane, error) {
url, _ := url.Parse(defaultBaseUrl)
urlV2, _ := url.Parse(defaultBaseUrlV2)
cp := &ControlPlane{
baseUrl: url,
baseUrlV2: urlV2,
log: logger.NOP,
pollingInterval: 1 * time.Second,
configsCache: &cache.WorkspaceConfigCache{},
Expand Down Expand Up @@ -83,6 +89,7 @@ func (cp *ControlPlane) setupClients() error {
}

baseClient := &base.Client{HTTPClient: cp.httpClient, BaseURL: cp.baseUrl}
baseClientV2 := &base.Client{HTTPClient: cp.httpClient, BaseURL: cp.baseUrlV2}

// set admin client
if cp.adminCredentials != nil {
Expand All @@ -101,7 +108,7 @@ func (cp *ControlPlane) setupClients() error {
}
} else if cp.namespaceIdentity != nil {
cp.Client = &namespace.Client{
Client: baseClient,
Client: baseClientV2,
Identity: cp.namespaceIdentity,
}
} else {
Expand Down

0 comments on commit 28f7ee3

Please sign in to comment.