Skip to content

Commit

Permalink
Merge pull request #42 from redpanda-data/scoped-clients
Browse files Browse the repository at this point in the history
Scope clients to new hosts
  • Loading branch information
bojand authored Dec 7, 2024
2 parents 7c14761 + 4e13468 commit dd5f6c3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rpadmin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,22 @@ func (a *AdminAPI) SetAuth(auth Auth) {
a.auth = auth
}

// ForBroker returns a new admin client with the same configuration as the initial
// client, but that talks to a single broker with the given id.
func (a *AdminAPI) ForBroker(ctx context.Context, id int) (*AdminAPI, error) {
url, err := a.BrokerIDToURL(ctx, id)
if err != nil {
return nil, err
}
return a.newAdminForSingleHost(url)
}

// ForHost returns a new admin client with the same configuration as the initial
// client, but that talks to a single broker at the given url.
func (a *AdminAPI) ForHost(url string) (*AdminAPI, error) {
return a.newAdminForSingleHost(url)
}

func (a *AdminAPI) newAdminForSingleHost(host string) (*AdminAPI, error) {
return newAdminAPI([]string{host}, a.auth, a.tlsConfig, nil, a.forCloud)
}
Expand Down

0 comments on commit dd5f6c3

Please sign in to comment.