Skip to content

Commit

Permalink
Merge pull request #829 from andrewstucki/sr-client-opts
Browse files Browse the repository at this point in the history
Add Opts method for sr.Client
  • Loading branch information
twmb authored Oct 15, 2024
2 parents 3a0f09a + cfe0ae4 commit 019799a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/sr/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Client struct {
httpcl *http.Client
ua string
defParams Param
opts []ClientOpt

basicAuth *struct {
user string
Expand All @@ -69,6 +70,7 @@ func NewClient(opts ...ClientOpt) (*Client, error) {
urls: []string{"http://localhost:8081"},
httpcl: &http.Client{Timeout: 5 * time.Second},
ua: "franz-go",
opts: opts,
}

for _, opt := range opts {
Expand All @@ -82,6 +84,13 @@ func NewClient(opts ...ClientOpt) (*Client, error) {
return cl, nil
}

// Opts returns the options that were used to create this client. This can be
// as a base to generate a new client, where you can add override options to
// the end of the original input list.
func (cl *Client) Opts() []ClientOpt {
return cl.opts
}

func (cl *Client) get(ctx context.Context, path string, into any) error {
return cl.do(ctx, http.MethodGet, path, nil, into)
}
Expand Down

0 comments on commit 019799a

Please sign in to comment.