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

Expose Http Client #22

Closed
jakesylvestre opened this issue Sep 20, 2020 · 7 comments
Closed

Expose Http Client #22

jakesylvestre opened this issue Sep 20, 2020 · 7 comments
Milestone

Comments

@jakesylvestre
Copy link

jakesylvestre commented Sep 20, 2020

Certain methods for exposing the registry client (namely service tokens require access to the http client to add auth headers. Would you be open to exposing the httpClient->HttpClient on SchemaRegsitryClient so we can add in interceptors and inject the headers we need. I'm open to other approaches as well and will be happy to submit a pull request however you want me to implement this

@riferrei
Copy link
Owner

I think exposing the httpClient object is risky because it breaks the encapsulation logic used in the code. Maybe a better approach could be creating an overloaded version of the function CreateSchemaRegistryClient where extra parameters could be provided?

I am open to suggestions along these lines :)

Thanks,

-- @riferrei

@jakesylvestre
Copy link
Author

Got it - will set this up now

@jakesylvestre
Copy link
Author

@riferrei
image

Will clean this up, but probably the cleanest I can do (w/o builder pattern since Golang doesn't support virtual method overriding.

Alternatively, we can add a SetClient method that can be called once the client is created

@maarek
Copy link
Collaborator

maarek commented Sep 21, 2020

I was thinking about this last week and had started to add something similar to the following and wasn't quite sure it was the way to go. I ended up backing out of the change and using httpTest in the test cases instead of injecting an httpClient.

type Config func(*SchemaRegistryClient)

func WithHttpClient(httpClient *http.Client) *SchemaRegistryClient {
    return func (client *SchemaRegistryClient) {
        client.httpClient = httpClient
    }
}

func CreateSchemaRegistryClient(schemaRegistryURL string,  options ...Config) *SchemaRegistryClient {
    schemaRegistryClient := ...
   for opt := range options {
       opt(schemaRegistryClient)
   }
   return schemaRegistryClient
}

@tomarrell
Copy link

tomarrell commented Oct 14, 2020

I think the functional option direction would be best here.

I would try steer clear of exposing the http client on the struct to avoid accidental mutation. It also would lead to a bit of a fragmented configuration API imo.

@AtakanColak
Copy link
Collaborator

AtakanColak commented Nov 13, 2020

I'd like to assign myself to this work, and I don't plant to expose the http client. Could you give me a list of what kind of changes user might want to do on the http client?

@AtakanColak AtakanColak added this to the v1.0 milestone Dec 12, 2020
@AtakanColak
Copy link
Collaborator

Closed as http client is now exposed with #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants