lantunes / fixd

An HTTP Server Fixture for Testing HTTP Clients and mocking web services, and a Java Micro Web Framework
http://bigtesting.org/fixd
Apache License 2.0
41 stars 6 forks source link

Long-running custom handlers #29

Open lantunes opened 10 years ago

lantunes commented 10 years ago

Right now, there are 3 request-response scenarios:

  1. The user defines a request to be handled by returning an interpolated string. This kind of request can be handled by performing the interpolation logic on the Container's calling thread (one of Simple's 8 servicing threads), as it is not long-running or potentially blocking.
  2. The user defines a request to be handled by an asynchronous response. This includes broadcast-subscribe and every() and after(). These requests are blocking or long-running, and need to be handled using a separate new thread, or some other process that offloads the processing from the Container's calling thread.
  3. The user defines a custom handler to handle the request. The user could do anything in this handler.

Currently, scenario 3 is treated as though it were like scenario 1. But it's not. The user could perform potentially long-running, or blocking, tasks in the handler. The handler logic should not be performed on the Container's calling thread.