Galeria-Kaufhof / jsonhomeclient

Scala client to consume JSON home documents
Apache License 2.0
14 stars 9 forks source link

Add builder api #3

Open magro opened 9 years ago

magro commented 9 years ago

It would be nice to have a builder like this:

JsonHomeClient.Builder()
  .addHost("host", DirectLinkRelation("rel"), TemplateLinkRelation("rel"))
  .addHost(...)
  .withWSClient(WS.client)
  .withCaching(1 minute, Akka.system)
  .build()
lichtsprung commented 9 years ago

What would be the return value of build()?

The example suggests that the Builder should be part of the JsonHomeClient object. So my guess for the type of the return value would be JsonHomeClient. But JsonHomeClient handles just one host and and is not concerned with caching the json home document. That is why I would expect this kind of Builder in JsonHomeService where build() returns a new JsonHomeService instance.

magro commented 9 years ago

According to issue #1 I'd rename JsonHomeService to JsonHomeClient, and perhaps just get rid of what's right now JsonHomeClient. The result of build() would be AsyncJsonHomeClient (if withCaching is not used) or JsonHomeClient if withCaching is used - withCaching would change the interface to a sync/blocking one. Perhaps then the Builder should be an AsyncJsonHomeClient.Builder...