io.reactivex.netty.RxNetty.createHttpServer()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(46)

本文整理了Java中io.reactivex.netty.RxNetty.createHttpServer方法的一些代码示例,展示了RxNetty.createHttpServer的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RxNetty.createHttpServer方法的具体详情如下:
包路径:io.reactivex.netty.RxNetty
类名称:RxNetty
方法名:createHttpServer

RxNetty.createHttpServer介绍

暂无

代码示例

代码示例来源:origin: io.reactivex/rxnetty

public static void main(String[] args) {
    RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() {
      @Override
      public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
        throw new NullPointerException("doomsday");
      }
    }).startAndWait();
  }
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

public static void main(String[] args) {
    RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() {
      @Override
      public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
        throw new NullPointerException("doomsday");
      }
    }).startAndWait();
  }
}

代码示例来源:origin: com.netflix.eureka/eureka2-testkit

public void start() {
  httpServer = RxNetty.createHttpServer(VIEW_PORT, new RequestHandler<ByteBuf, ByteBuf>() {
    @Override
    public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
      DeploymentReport report = createReport();
      String result;
      try {
        result = MAPPER.writeValueAsString(report);
      } catch (IOException e) {
        return Observable.error(e);
      }
      return response.writeStringAndFlush(result);
    }
  }).start();
}

代码示例来源:origin: com.netflix.eureka2/eureka-testkit

public void start() {
  httpServer = RxNetty.createHttpServer(VIEW_PORT, new RequestHandler<ByteBuf, ByteBuf>() {
    @Override
    public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
      DeploymentReport report = createReport();
      String result;
      try {
        result = MAPPER.writeValueAsString(report);
      } catch (IOException e) {
        return Observable.error(e);
      }
      return response.writeStringAndFlush(result);
    }
  }).start();
}

代码示例来源:origin: com.netflix.eureka/eureka2-test-utils

public Eureka1Server() {
  this.server = RxNetty.createHttpServer(0, new RequestHandler<ByteBuf, ByteBuf>() {
    @Override
    public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
      logger.info("Eureka request {} {}", request.getHttpMethod(), request.getPath());
      String path = request.getPath();
      Matcher matcher = APPLICATIONS_PATH.matcher(path);
      if (matcher.matches()) {
        return applicationsResource(request, response);
      }
      matcher = REGISTRATION_PATH.matcher(path);
      if (matcher.matches()) {
        return registrationResource(request, response, matcher.group(1));
      }
      matcher = INSTANCE_PATH.matcher(path);
      if (matcher.matches()) {
        return instanceResource(request, response, matcher.group(1), matcher.group(2));
      }
      return notSupportedError(request, response);
    }
  });
  applications.setAppsHashCode("0");
}

代码示例来源:origin: sanjayvacharya/sleeplessinslc

public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, Application application,
  boolean start) {
  HttpServer<ByteBuf, ByteBuf> httpServer = RxNetty.createHttpServer(port,
   new RxNettyHttpContainer(application));
  if (start) {
   httpServer.start();
  }
  return httpServer;
 }
}

代码示例来源:origin: com.netflix.karyon/karyon3-rxnetty

@Override
  public HttpServer<ByteBuf, ByteBuf> get() {
    try {
      return RxNetty.createHttpServer(config.getServerPort(), new HttpRoutingRequestHandler(binding.getProvider().get()));
    } catch (Exception e) {
      throw new ProvisionException("Error creating server " + qualifier.getCanonicalName(), e);
    }
  }
});

代码示例来源:origin: com.netflix.eureka/eureka2-dashboard

@PostConstruct
public void start() {
  server = RxNetty.createHttpServer(config.getDashboardPort(),
      RequestHandlerWithErrorMapper.from(
          new MainRequestHandler(config),
          new FileErrorResponseMapper())).start();
  logger.info("Starting HTTP dashboard server on port {}...", server.getServerPort());
}

代码示例来源:origin: com.netflix.eureka2/eureka-dashboard

@PostConstruct
public void start() {
  server = RxNetty.createHttpServer(config.getDashboardPort(),
      RequestHandlerWithErrorMapper.from(
          new MainRequestHandler(config),
          new FileErrorResponseMapper())).start();
  logger.info("Starting HTTP dashboard server on port {}...", server.getServerPort());
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-bus-turbine

@Bean
public HttpServer<ByteBuf, ServerSentEvent> aggregatorServer() {
  // multicast so multiple concurrent subscribers get the same stream
  Observable<Map<String, Object>> publishedStreams = StreamAggregator.aggregateGroupedStreams(hystrixSubject()
        .groupBy(data -> InstanceKey.create((String) data.get("instanceId"))))
      .doOnUnsubscribe(() -> log.info("BusTurbine => Unsubscribing aggregation."))
      .doOnSubscribe(() -> log.info("BusTurbine => Starting aggregation"))
      .flatMap(o -> o).publish().refCount();
  int port = new Integer(env.getProperty("server.port", "8989"));
  HttpServer<ByteBuf, ServerSentEvent> httpServer = RxNetty.createHttpServer(port, (request, response) -> {
    log.info("BusTurbine => SSE Request Received");
    response.getHeaders().setHeader("Content-Type", "text/event-stream");
    return publishedStreams
        .doOnUnsubscribe(() -> log.info("BusTurbine => Unsubscribing RxNetty server connection"))
        .flatMap(data -> response.writeAndFlush(new ServerSentEvent(null, null, JsonUtility.mapToJson(data))));
  }, sseServerConfigurator());
  return httpServer;
}

代码示例来源:origin: com.netflix.turbine/turbine-core

public static void startServerSentEventServer(int port, Observable<GroupedObservable<TypeAndNameKey, Map<String, Object>>> streams) {
  logger.info("Turbine => Starting server on " + port);
  // multicast so multiple concurrent subscribers get the same stream
  Observable<Map<String, Object>> publishedStreams = streams
      .doOnUnsubscribe(() -> logger.info("Turbine => Unsubscribing aggregation."))
      .doOnSubscribe(() -> logger.info("Turbine => Starting aggregation"))
      .flatMap(o -> o).publish().refCount();
  RxNetty.createHttpServer(port, (request, response) -> {
    logger.info("Turbine => SSE Request Received");
    response.getHeaders().setHeader("Content-Type", "text/event-stream");
    return publishedStreams
        .doOnUnsubscribe(() -> logger.info("Turbine => Unsubscribing RxNetty server connection"))
        .flatMap(data -> {
          return response.writeAndFlush(new ServerSentEvent(null, null, JsonUtility.mapToJson(data)));
        });
  }, PipelineConfigurators.<ByteBuf> sseServerConfigurator()).startAndWait();
}

代码示例来源:origin: com.mesosphere.mesos.rx.java/mesos-rxjava-test

this.subscribedLatch = new CountDownLatch(1);
this.sem = new Semaphore(0);
this.server = RxNetty.createHttpServer(0, (request, response) -> {
  response.getHeaders().setHeader("Accept", receiveCodec.mediaType());

代码示例来源:origin: mesosphere/mesos-rxjava

this.subscribedLatch = new CountDownLatch(1);
this.sem = new Semaphore(0);
this.server = RxNetty.createHttpServer(0, (request, response) -> {
  response.getHeaders().setHeader("Accept", receiveCodec.mediaType());

相关文章