Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp the examples #127

Closed
NiteshKant opened this issue May 23, 2014 · 1 comment
Closed

Revamp the examples #127

NiteshKant opened this issue May 23, 2014 · 1 comment
Milestone

Comments

@NiteshKant
Copy link
Member

There are the following issues with the examples:

  • There is little documentation on what they do.
  • They are not categorized so anyone looking at them is overwhelmed of which one to see.
    -They do not demonstrate the best way in which things can be done and are mostly complex. eg:
RxNetty.createHttpServer(port, new RequestHandler<ByteBuf, ByteBuf>() {
            @Override
            public Observable<Void> handle(HttpServerRequest<ByteBuf> request, final HttpServerResponse<ByteBuf> response) {
                System.out.println("New request recieved");
                System.out.println(request.getHttpMethod() + " " + request.getUri() + ' ' + request.getHttpVersion());
                for (Map.Entry<String, String> header : request.getHeaders().entries()) {
                    System.out.println(header.getKey() + ": " + header.getValue());
                }

                return request.getContent().materialize()
                              .flatMap(new Func1<Notification<ByteBuf>, Observable<Void>>() {
                                  @Override
                                  public Observable<Void> call(Notification<ByteBuf> notification) {
                                      if (notification.isOnCompleted()) {
                                          return response.writeStringAndFlush("Welcome!!!");
                                      } else if (notification.isOnError()) {
                                          return Observable.error(notification.getThrowable());
                                      } else {
                                          ByteBuf next = notification.getValue();
                                          System.out.println(next.toString(Charset.defaultCharset()));
                                          return Observable.empty();
                                      }
                                  }
                              });
            }
        }).startAndWait();

The above is a Http Welcome server and is certainly overly complex. This gives people an impression that its too complex to write anything in RxNetty.

  • There are groovy and java examples and most of the times they are out of sync. This is a maintenance tax as they demonstrate mostly the same scenario.
  • There is no validation for these examples with every build so they can just be broken.

I propose the following changes:

  • Remove the groovy examples as they do not do anything different.
  • Create sub-packages for different examples. eg: http, sse, udp, tcp.
  • Provide a very simple Hello World example for all transports.
  • Provide a README for every sub-package and give an idea about what each example does.
  • Add a simple validator with each test (client & server pair) that makes sure that we validate that the examples are fine on each build.
@NiteshKant NiteshKant added this to the 1.0.0 milestone May 23, 2014
@NiteshKant NiteshKant modified the milestones: 0.3.6, 1.0.0 Jun 16, 2014
@NiteshKant
Copy link
Member Author

Pull request #142 addressed all these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant