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

javax.ws.rs.client configuration? #29

Closed
binakot opened this issue Jun 7, 2018 · 3 comments
Closed

javax.ws.rs.client configuration? #29

binakot opened this issue Jun 7, 2018 · 3 comments

Comments

@binakot
Copy link

binakot commented Jun 7, 2018

I need to change default configuration of rest client, at least timeouts.
How can I change client configuration using your mailgun library?

I found this part of code:

    void configureClient(Client client) {
        //defaults to no-op
    }

    private Invocation.Builder request() {
        Client client = JerseyClientBuilder.newClient();
        configureClient(client);
        return client
                .register(configuration.httpAuthenticationFeature())
                .target(configuration.apiUrl())
                .path(configuration.domain())
                .path("messages")
                .request();
    }

JerseyClientBuilder.newClient() can take javax.ws.rs.core.Configuration as argument, but method is private and I cannot override it. Method configureClient is package-private like its class itself and I cannot extend MailForm or MailMultipart.

I need to do smth like this:

    ClientConfig configuration = new ClientConfig();
    configuration.property(ClientProperties.CONNECT_TIMEOUT, 10000);
    configuration.property(ClientProperties.READ_TIMEOUT, 30000);
    Client client = ClientBuilder.newClient(configuration);
@sargue
Copy link
Owner

sargue commented Jun 7, 2018

Hi!

Yep, I didn't want to leak the client library (jax-rs, jersey) as much as possible. So adjusting the client directly is not currently possible.

I'm planning a 2.x version which won't depend on a single library but allow to use any (Jersey, Resteasy, Unirest) and, of course, would allow to customize it. But that's planning phase yet.

But those two timeouts could be general enough to be added to the configuration and still keep it on future versions.

Would that be enough? Are any other parameters worth adding?

@binakot
Copy link
Author

binakot commented Jun 7, 2018

@sargue Thanks for the quick feedback ☕️
Yep, timeouts are enough. That's because sometimes I received timeout exception on sending my emails. And large timeout helps as well.

@sargue
Copy link
Owner

sargue commented Jun 7, 2018

Ok, that shouln't be hard to implement. Expect it in the next few days.

@sargue sargue closed this as completed in 42aad6c Jun 9, 2018
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

2 participants