Code Monkey home page Code Monkey logo

reactive-streams-servlet's Introduction

Servlet 3.1 Reactive Streams implementation

This is a reactive streams implementation based on the Servlet 3.1 asynchronous IO API. It has zero dependencies, other than the JDK. It is TCK verified.

Usage

To create a publisher for a request (which can be subscribed to to consume the request body):

HttpServletRequest request = ...
AsyncContext context = request.startAsync();
Publisher<ByteBuffer> publisher = new RequestPublisher(context, 8192);

The second parameter to RequestPubisher is the maximum amount of data to read on each attempt to read.

To create a subscriber for a response (which can be passed to a publisher to publish the response body):

HttpServletRequest request = ...
AsyncContext context = request.startAsync();
Subscriber<ByteBuffer> subscriber = new ResponseSubscriber(context);

Status

Currently, the response subscriber only requests one element at a time, and never buffers. This could be improved, for example, using a low and high watermark based buffer, to keep a few elements in flight for maximising throughput.

Legal

This project has been produced by Lightbend. The code is offered to the Public Domain in order to allow free use by interested parties who want to create compatible implementations. For details see COPYING.

CC0
To the extent possible under law, Reactive Streams Special Interest Group has waived all copyright and related or neighboring rights to Reactive Streams JVM. This work is published from: United States.

reactive-streams-servlet's People

Contributors

jroper avatar viktorklang avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.