Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Simplify multiple calls to the same service #11

Open
d3x7r0 opened this issue Jul 27, 2017 · 0 comments
Open

Simplify multiple calls to the same service #11

d3x7r0 opened this issue Jul 27, 2017 · 0 comments

Comments

@d3x7r0
Copy link
Contributor

d3x7r0 commented Jul 27, 2017

Currently if you want to do multiple calls to the same service you can, at most, save the request builder and start from there every time.

RequestBuilder<API> builder = Fetchyfetchy.createRequest("serviceId", API.class)
    .timeout(10);


Object result = builder
    .callable(client -> client.method())
    .execute();

builder
    .runnable(client -> client.method())
    .execute();

My suggestion is have something that allows you to set defaults for a given service and then use the normal fetchy calls on it:

FetchyProxy proxy = fetchy.buildProxy("serviceId", API.class)
    .withTimeout(10)
    .build();


Object result = proxy.call(client -> client.method());

proxy.run(client -> client.method());

proxy.createRequest()
         .runnable(client -> client.method())
         .timeout(10)
         .execute();

I believe, after ending up with similar code abstractions in my own fetchy usage, this may simplify things but would like to hear the opinion of other people.

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

No branches or pull requests

1 participant