Skip to content

Scope clients to new hosts #42

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

Merged
merged 1 commit into from
Dec 7, 2024
Merged
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
16 changes: 16 additions & 0 deletions rpadmin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,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
Loading