Giter Club home page Giter Club logo

restexpress / restexpress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tfredrich/restexpress

938.0 938.0 288.0 157.39 MB

Minimalist Java framework for rapidly creating scalable, containerless, RESTful microservices. Ship a production-quality, headless, RESTful API in the shortest time possible. Uses Netty for HTTP, Jackson for JSON, Metrics for metrics, properties files for configuration. Sub-projects and plugins enable, NoSQL, Swagger, Auth0, HAL integration, etc.

Home Page: https://groups.google.com/d/forum/restexpress

License: Apache License 2.0

Java 99.64% Shell 0.36%

restexpress's People

Contributors

actolap avatar albahrani avatar chamaln avatar kevwil avatar mathewl avatar mooralee avatar mrinteresting avatar reaperunreal avatar sinisterminister avatar tfredrich avatar tommaco avatar vkondratiuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restexpress's Issues

Create Thread Pool for Long-Running Requests

Since Netty uses non-blocking I/O, using its worker threads to perform long-running activities, such as database and file I/O, etc. is not optimal. Instead, for long-running activities like this, utilize a thread pool to execute the service controller outside Netty's I/O worker thread(s).

Preliminary thoughts on design:

  1. Netty pipeline simply creates RESTExpress Request.
  2. Put Request on request queue.
  3. Worker is freed to handle next request.
  4. Service thread(s) read Request from request queue.
  5. Handle request.
  6. Place Response on response queue.
  7. Netty pipeline monitors response queue and sends them back to client.

See also issue #25

Change to use JodaTime libraries

DateAdapterJ works fine. However, JodaTime is very popular and seems to accomplish the same task. Speed-wise is it equivalent or better? If so, perhaps we can just roll it in.

Marshal Exceptions into a Response When Appropriate

Currently, all exceptions return text/plain and an HTTP status response code. This does not work well for some Javascript implementations. Marshal ALL responses into the requested mime type, including exceptions.

Support Caching Best Practices

Utilize a plugin? to support caching best practices (e.g. RESTful Web Services Cookbook, Chapter 9).

Headers to set, according to the above reference:

  • Cache-Control
  • max-age
  • Expires
  • Pragma: no-cache
  • Date

Chunking

Support chunking by default. Allow configuration to turn it off via DSL/fluent interface.

Testing Console

Implement a testing console to support the testing of routes determined by introspection of /routes/metadata plugin.

Parse Format and Query String Separately

The format and query string influence the inbound and outbound serialization. Currently, if the URL refers to a non-existant resource, the error always gets marshaled to the default format. It should get marshaled to the requested format, if specified.

Support HTTPS

RestExpress is built to be the simplest thing that could possibly work--and only supports HTTP. Current thought is to utilize SSL off-loading and caching layers in front of RestExpress for maximum performance and scalability. However, HTTPS may make sense in some cases.

Produce Error on No Routes Defined

If no routes are defined for a given server, the startup should either display the number of routes defined or throw an exception. Otherwise, produce some indication of how many routes are defined within the RestExpress server.

how to retrieve query parameter value in the controller

When I create a rest api in the query parameter format, is the only way to get the query parameters is

request.getQueryStringMap();

or there exists another way which URLDecode the parameter values and return the string data?

HashDos Mitigation

Netty limits the number of headers that can be processed in the header decoder. Netty also limits the number of query-string parameters allowed in the QueryStringDecoder.

Ensure the RestExpress utilizes both in the pipeline to mitigate the known HashDOS possibility.

DSL Modifications

Revamp/enhance DSL/fluent interface to be more elegant and pass things through from RestExpress to each Route to support the concept of 'inheritance' but allow each route to be tweaked individually.

Add URI Parameters to Metadata Output

The URL pattern returned by the metadata service (e.g. '/console/routes') needs to include the parsed-out parameter names in the pattern to facilitate more easily creating a page that populates those values.

For example, if the URL pattern is /products/{orderId}.{format} the output should include the parameters, 'orderId' and 'format'.

Named Executor Pools Assignable by Route

Be able to assign routes to a given executor pool so extremely-long-running requests don't interfere with the lesser-long-running requests. Routes default to a 'default' pool.

Possible route DSL:
route.executorPool("pool.foo"); // for all methods
route.executorPool("pool.long", HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE);
route.executorPool("pool.short", HttpMethod.GET);

Possible server DSL:
server.executorPool("pool.foo", 15); // pool name, thread count
server.executorPool(25); // 'default' pool, thread count

Support Multi-part (file) upload

Netty does not yet support multi-part file uploads. Even when it does, RestExpress might need to be tweaked to support it. Supporting it early would be helpful.

Support File Streaming

Currently, all responses are passed in entirety. Support streaming of large files such as video, images, static files, etc.

Support Static Files

Enable RestExpress to return/stream static files (e.g. HTML, Javascript, etc.).

Script to create kickstart application

Create a kickstart application via script or command line much like Rails. For example:

$> restexpress FancyApp

would create a new kickstart application in the FancyApp directory with all classes and strings appropriately renamed.

20 second shutdown of RestExpress

I'm writing some integration tests against RestExpress, and the shutdown time seems to be taking 20 seconds. I'm not sure what I should be setting to get the server to forcibly release everything for a test.

I've stepped into the code and as far in as I can go, it seems to be bouncing around inside ExecutorUtil.java (lines 84 -115) waiting for worker threads to be cleaned up.

Should I be setting something somewhere in my tests to speed the shutdown?

I'm using JDK 1.7

This is my server launch script

public class Serve {
private static RestExpress server;

public static void main(String[] args) throws Exception {
    go();
    server.awaitShutdown();
}

public static void go() {
    server = new RestExpress()
            .setName("commerce")
            .setDefaultFormat(Format.JSON)
            .putResponseProcessor(Format.JSON, ResponseProcessors.json())
            .putResponseProcessor(Format.WRAPPED_JSON,
                    ResponseProcessors.wrappedJson())
            .addMessageObserver(new SimpleConsoleLogMessageObserver());
    defineRoutes(server);
    server.bind(9050);
}

public static void defineRoutes(RestExpress server) {
    server.uri("/search", new Controller())
            .method(HttpMethod.POST, HttpMethod.GET)
            .flag(Flags.Cache.DONT_CACHE); // Expressly deny cache-ability.
}

public static void stop() {
    server.shutdown();
}
}

Refactor KickStart to utilize Rails-style environment configuration

Utilize a config directory structure named after the environment with environment properties contained therein.

For example:
config/dev/environment.properties
config/testing/environment.properties
config/prod/environment.properties

Pass the runtime environment to the RestExpress main() method to use the desired configuration.

Create a Benchmark Sample Application

  1. Create a sample application that can be used for benchmarking RestExpress functionality.
  2. Publish benchmark statistics and charts.

Perhaps against other frameworks? For example: Tomcat/Jersey, Restlet

Generated files have license header

Two of the stub files generated by RestExpress contain licensing information. Is that your intent?

The two files are:

  1. ResponseProcessors.java
  2. Constants.java

Both have an Apache 2.0 license, meaning users will have to carry the StrategicGains copyright statement in the code they generate.

Asynchronous long-running requests

Hi,

I need to use a remote service which can be called asynchronously. This means that I can use the worker thread without blocking the thread, but I don't know how to do it within the controller. We only have access to the request and the response so I don't know how to use some kind of future to make the external service call.

I would appreciate your suggestions.

Regards,
Miguel

.xml .json .jsend, etc. format types

Currently .xml and .json format types are supported. However, jsend-style responses are dictated by the service implementation. Implementing a .jsend format type would allow for the client to decide what style of response they wanted.

Use Callback-style Actions

Support asynchronous handling of services by not blocking for controllers. In other words, initiate the controller action and return the thread to the pool, waiting for a response from the controller asynchronously--to boost performance.

Conditional GET

Implement functionality at least as an example of how to implement conditional GET logic.

Need to handle 15,000+ HTTP POST restful requests per second

Hi,

We need to implement restful service accepting JSON string of approx 165 to 200 byte and submitting to RabbitMQ for further processing. In your post (http://toddfredrich.com/introducing-restexpress-instant-restful-services-in-java.html) you have mentioned that you have seen 15,000+ requests per second.

Can you please elaborate that does it mean that server was able to handle those many request per second and was able to reply. Can you share some more technical details like what would be required to achieve such performance?

I have tried executing Apache benchmark with your “kick start” example and was able to see performance around 1K.

I would appreciate your thoughts/suggestions.

regards,
Jaymin

Replace GSON with Jackson for JSON

Update RestExpress to use Jackson for both JSON and XML processing, reducing the number of external dependencies (e.g. GSON and XStream).

Error Retrieving Routes Testing Console

curl -i localhost:8081/routes/console.html

now returns a 400 Bad Request, presumably due to the enforcement of the .format specifier and not globally supporting HTML as a format.

This error occurs in branch v0.8.0

Plugin Management

Create a plugin manager to update/manage plugins for your RESTExpress projects

Plugin Auto-Registration

Create a Plugins directory (or some-such), where if plugin jars are dropped in that directory, those plugins are automatically registered with the RESTExpress server on startup.

Group/Forum Needed

Whilst not technically a problem with the code, this project should have a group or forum to discuss how to get the most from it.

Unless I just haven't found it?

Route Metadata/Testing Console

Provide a RestExpress Dynamic Test Console where:

  1. get /_routes/_metadata provides a response that lists metadata about the routes available, their url, methods, etc.
  2. get /_routes/_console returns a text/html response that, when loaded in a browser, provides an interface for testing the routes.

Refactor to FilterComponent

The FilterCallback.filterOn() method currently takes a String name and String value. Refactor it to accept a FilterComponent, to correspond with OrderCallback.orderBy() which takes an OrderComponent.

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.