Some changes coming to Dispatch

44 views
Skip to first unread message

Matt Farmer

unread,
May 27, 2017, 3:39:36 PM5/27/17
to dispatc...@googlegroups.com
Hey all,

As you all know we've had a number of issues recently where folks get into resource leakage scenarios while using Dispatch. After thinking a bit on these issues I think I've got some solid suggestions for how to avoid this being a problem in the future.

The biggest are:
  • Doing away with the pattern of using the Http singleton directly. Instead, provide Http.default for the default Http executor.
  • Removing the ability to just invoke .configure on an Http executor. Instead providing a closeAndConfigure method that provides the same functionality (with the exception of explicitly shutting down the client) and a Http.withConfiguration method that can create an executor with a particular Builder=>Builder function.
  • Removing the default arguments from the Http case class to prevent folks from fat-fingering Http() and getting a bunch of new resources by surprise.
This in essence means that instead of...

Http(req OK as.String)

...folks would write...

Http.default(req OK as.String)

... to get the same behavior.

These changes so far are represented in the following PRs:

PR 156: Adds closeAndConfigure to 0.12.x, adds deprecation warnings for direct usage of Http.apply and for the configure method.
PR 157: Does the same for the 0.13.x series with the addition of making Http singleton no longer a subclass of the Http case class. The apply methods are still on the Http singleton to facilitate migrations, but no other methods are.

I wanted to call out these upcoming changes to start getting some input from the community on thoughts around them. I think clarifying the difference between "doing this will create more resources" and not is super important to the utility of the library, and I hope that you will all agree that these changes are a step in the right direction.

Cheers,

Matt
Reply all
Reply to author
Forward
0 new messages