Skip to content

v3.0.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@connorslade connorslade released this 21 Aug 05:13
· 98 commits to v3.0.0-alpha since this release
76d7c71

Changelog

  • The thread pool can now be resized at runtime.
  • Server::start_threaded has been replaced with Server::workers to set the number of worker threads and the normal Server::start.
  • Supply a context to all route handlers.
    The context contains a reference to the server, request, and acts as a response builder.
    Note: This also allows access to the thread_pool for both executing tasks and resizing it.
  • Remove the stateful_route method, use normal routes with ctx.app() instead.
  • You can now send responses before the route handler ends.
    This allows you to easily send a response and then do some work after the response is sent as to not block the client.
  • Responses can be sent from other threads.
    You will have to notify the handler that you will be sending a response after the handler function returns with ctx.guarantee_will_send().
  • Allow returning any error type from route handlers.
    This is done with a return type of Result<(), Box<dyn Error>>.
  • Allow attaching extra context to an error with anyhow like functions: context, with_context, status, with_status, header, with_header.
  • Remove StartupError::NoState error.
  • Make ForceLockMutex, ForceLockRwLock, and SingleBarrier public through the internal::sync module.
    • The force lock traits are used to lock a Mutex or RwLock even if it is poisoned.
    • The SingleBarrier is used to have a thread wait until another thread unlocks the barrier.
      The difference from a normal Barrier is that it does not block on both sides, only the waiting side.
  • Replace the TcpStream in Request with Socket, a wrapper struct.
    Its used to allow automatically the barrier with a response is sent.
    In the future it might also be used for optional TLS support.
  • Move path parameters into Context and use a HashMap instead of a Vec.
  • Parse the HTTP version into an enum instead of a string.
  • Properly determine weather to use keep-alive or not.
    In HTTP/1.1 keep-alive is opt-out, but previous versions of afire assumed it was opt-in.
    Fixing this produced a 2x performance increase in the benchmarks I ran.
    Now, this is still only a ~500us improvement but hey.
  • Filter CLRF characters from headers. This prevents a potential response splitting attack.
  • Properly disallow HTTP/1.1 requests with no Host header.
  • Added a new ResponseBody type of Empty.
  • Added a current_thread function to the threadpool.
  • Catch panics at the thread-pool level, not the route handler level.
    This will ensure that a worker will not die, even if internal afire code panics.

What's Changed

Full Changelog: v2.1.0...v3.0.0-alpha.1