Java Code Examples for com.linecorp.armeria.server.ServerBuilder#maxRequestLength()
The following examples show how to use
com.linecorp.armeria.server.ServerBuilder#maxRequestLength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrpcServiceServerTest.java From armeria with Apache License 2.0 | 6 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.workerGroup(EventLoopGroups.newEventLoopGroup(1), true); sb.maxRequestLength(0); sb.serviceUnder("/", GrpcService.builder() .setMaxInboundMessageSizeBytes(MAX_MESSAGE_SIZE) .addService(ServerInterceptors.intercept( new UnitTestServiceImpl(), REPLACE_EXCEPTION, ADD_TO_CONTEXT)) .enableUnframedRequests(true) .supportedSerializationFormats( GrpcSerializationFormats.values()) .useBlockingTaskExecutor(true) .build() .decorate(LoggingService.newDecorator()) .decorate((delegate, ctx, req) -> { ctx.log().whenComplete().thenAccept(requestLogQueue::add); return delegate.serve(ctx, req); })); }
Example 2
Source File: ArmeriaGrpcServerInteropTest.java From armeria with Apache License 2.0 | 6 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.https(new InetSocketAddress("127.0.0.1", 0)); sb.tls(ssc.certificateFile(), ssc.privateKeyFile()); sb.tlsCustomizer(ssl -> { try { ssl.trustManager(TestUtils.loadCert("ca.pem")); } catch (IOException e) { Exceptions.throwUnsafely(e); } }); sb.maxRequestLength(16 * 1024 * 1024); sb.serviceUnder("/", grpcService.decorate((delegate, ctx, req) -> { ctxCapture.set(ctx); return delegate.serve(ctx, req); })); }
Example 3
Source File: GrpcServiceServerTest.java From armeria with Apache License 2.0 | 5 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.workerGroup(EventLoopGroups.newEventLoopGroup(1), true); sb.maxRequestLength(0); sb.serviceUnder("/", GrpcService.builder() .addService(new UnitTestServiceImpl()) .build() .decorate(LoggingService.newDecorator()) .decorate((delegate, ctx, req) -> { ctx.log().whenComplete().thenAccept(requestLogQueue::add); return delegate.serve(ctx, req); })); }
Example 4
Source File: GrpcServiceServerTest.java From armeria with Apache License 2.0 | 5 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.workerGroup(EventLoopGroups.newEventLoopGroup(1), true); sb.maxRequestLength(Long.MAX_VALUE); sb.serviceUnder("/", GrpcService.builder() .addService(new UnitTestServiceImpl()) .build() .decorate(LoggingService.newDecorator()) .decorate((delegate, ctx, req) -> { ctx.log().whenComplete().thenAccept(requestLogQueue::add); return delegate.serve(ctx, req); })); }
Example 5
Source File: GrpcFlowControlTest.java From armeria with Apache License 2.0 | 5 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.maxRequestLength(0); sb.requestTimeoutMillis(0); sb.serviceUnder("/", GrpcService.builder() .addService(new FlowControlService()) .setMaxInboundMessageSizeBytes(Integer.MAX_VALUE) .build()); }
Example 6
Source File: ArmeriaConfigurationUtil.java From armeria with Apache License 2.0 | 4 votes |
/** * Configures the {@link ServerBuilder} with the specified {@code settings}. */ static void configureServer(ServerBuilder serverBuilder, ArmeriaSettings settings) { requireNonNull(serverBuilder, "serverBuilder"); requireNonNull(settings, "settings"); if (settings.getGracefulShutdownQuietPeriodMillis() >= 0 && settings.getGracefulShutdownTimeoutMillis() >= 0) { serverBuilder.gracefulShutdownTimeoutMillis(settings.getGracefulShutdownQuietPeriodMillis(), settings.getGracefulShutdownTimeoutMillis()); logger.debug("Set graceful shutdown timeout: quiet period {} ms, timeout {} ms", settings.getGracefulShutdownQuietPeriodMillis(), settings.getGracefulShutdownTimeoutMillis()); } if (settings.getMaxRequestLength() != null) { serverBuilder.maxRequestLength(settings.getMaxRequestLength()); } if (settings.getMaxNumConnections() != null) { serverBuilder.maxNumConnections(settings.getMaxNumConnections()); } if (!settings.isDateHeaderEnabled()) { serverBuilder.disableDateHeader(); } if (!settings.isServerHeaderEnabled()) { serverBuilder.disableServerHeader(); } if (settings.getDefaultHostname() != null) { serverBuilder.defaultHostname(settings.getDefaultHostname()); } if (settings.isVerboseResponses()) { serverBuilder.verboseResponses(true); } if (settings.getPorts().isEmpty()) { serverBuilder.port(new ServerPort(DEFAULT_PORT.getPort(), DEFAULT_PORT.getProtocols())); } else { configurePorts(serverBuilder, settings.getPorts()); } if (settings.getSsl() != null) { configureTls(serverBuilder, settings.getSsl()); } if (settings.getCompression() != null) { configureCompression(serverBuilder, settings.getCompression()); } if (settings.getHttp1() != null) { configureHttp1(serverBuilder, settings.getHttp1()); } if (settings.getHttp2() != null) { configureHttp2(serverBuilder, settings.getHttp2()); } if (settings.getProxy() != null) { configureProxy(serverBuilder, settings.getProxy()); } if (settings.getAccessLog() != null) { configureAccessLog(serverBuilder, settings.getAccessLog()); } }
Example 7
Source File: GrpcClientTest.java From armeria with Apache License 2.0 | 4 votes |
@Override protected void configure(ServerBuilder sb) { sb.workerGroup(EventLoopGroups.newEventLoopGroup(1), true); sb.maxRequestLength(MAX_MESSAGE_SIZE); sb.idleTimeoutMillis(0); sb.http(0); sb.https(0); sb.tlsSelfSigned(); final ServerServiceDefinition interceptService = ServerInterceptors.intercept( new TestServiceImpl(Executors.newSingleThreadScheduledExecutor()), new ServerInterceptor() { @Override public <REQ, RESP> Listener<REQ> interceptCall( ServerCall<REQ, RESP> call, Metadata requestHeaders, ServerCallHandler<REQ, RESP> next) { final HttpHeadersBuilder fromClient = HttpHeaders.builder(); MetadataUtil.fillHeaders(requestHeaders, fromClient); CLIENT_HEADERS_CAPTURE.set(fromClient.build()); return next.startCall( new SimpleForwardingServerCall<REQ, RESP>(call) { @Override public void close(Status status, Metadata trailers) { trailers.merge(requestHeaders); super.close(status, trailers); } }, requestHeaders); } }); sb.serviceUnder("/", GrpcService.builder() .addService(interceptService) .setMaxInboundMessageSizeBytes(MAX_MESSAGE_SIZE) .setMaxOutboundMessageSizeBytes(MAX_MESSAGE_SIZE) .useClientTimeoutHeader(false) .build() .decorate((client, ctx, req) -> { final HttpResponse res = client.serve(ctx, req); return new FilteredHttpResponse(res) { private boolean headersReceived; @Override protected HttpObject filter(HttpObject obj) { if (obj instanceof HttpHeaders) { if (!headersReceived) { headersReceived = true; } else { SERVER_TRAILERS_CAPTURE.set((HttpHeaders) obj); } } return obj; } }; })); }
Example 8
Source File: GrpcServiceServerTest.java From armeria with Apache License 2.0 | 4 votes |
@Override protected void configure(ServerBuilder sb) throws Exception { sb.workerGroup(EventLoopGroups.newEventLoopGroup(1), true); sb.maxRequestLength(0); sb.service( GrpcService.builder() .setMaxInboundMessageSizeBytes(MAX_MESSAGE_SIZE) .addService(ServerInterceptors.intercept( new UnitTestServiceImpl(), REPLACE_EXCEPTION, ADD_TO_CONTEXT)) .enableUnframedRequests(true) .supportedSerializationFormats(GrpcSerializationFormats.values()) .build(), service -> service .decorate(LoggingService.newDecorator()) .decorate((delegate, ctx, req) -> { ctx.log().whenComplete().thenAccept(requestLogQueue::add); return delegate.serve(ctx, req); })); // For simplicity, mount onto subpaths with custom options sb.serviceUnder( "/json-preserving/", GrpcService.builder() .addService(new UnitTestServiceImpl()) .supportedSerializationFormats(GrpcSerializationFormats.values()) .jsonMarshallerFactory(serviceDescriptor -> { return GrpcJsonMarshaller.builder() .jsonMarshallerCustomizer(marshaller -> { marshaller.preservingProtoFieldNames(true); }) .build(serviceDescriptor); }) .build()); sb.serviceUnder( "/no-client-timeout/", GrpcService.builder() .addService(new UnitTestServiceImpl()) .useClientTimeoutHeader(false) .build()); sb.service( GrpcService.builder() .addService(ProtoReflectionService.newInstance()) .build(), service -> service.decorate(LoggingService.newDecorator())); }