/** * Creates a new decorator that supports all thrift protocols and defaults to * {@link ThriftSerializationFormats#BINARY TBinary} protocol when the client doesn't specify one. * * <p>Currently, the only way to specify a serialization format is by using the HTTP session * protocol and setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator() { return newDecorator(ThriftSerializationFormats.BINARY); }
/** * Creates a new decorator that supports only the formats specified and defaults to the specified * {@code defaultSerializationFormat} when the client doesn't specify one. * Currently, the only way to specify a serialization format is by using the HTTP session protocol and * setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. * * @param defaultSerializationFormat the default serialization format to use when not specified by the * client * @param otherAllowedSerializationFormats other serialization formats that should be supported by this * service in addition to the default */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator( SerializationFormat defaultSerializationFormat, SerializationFormat... otherAllowedSerializationFormats) { requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats"); return newDecorator(defaultSerializationFormat, Arrays.asList(otherAllowedSerializationFormats)); }
@Override protected void configure(ServerBuilder sb) throws Exception { // Used for testing if changing the timeout dynamically works. sb.service("/sleep", ThriftCallService.of(sleepService) .decorate(DynamicTimeoutService::new) .decorate(THttpService.newDecorator())); // Used for testing if disabling the timeout dynamically works. sb.service("/fakeSleep", ThriftCallService.of(fakeSleepService) .decorate(TimeoutDisablingService::new) .decorate(THttpService.newDecorator())); sb.defaultRequestTimeout(Duration.ofSeconds(1)); } };
@Override protected void configure(ServerBuilder sb) { sb.service("/thrift-never", ThriftCallService.of(serviceHandler) .decorate(ThrottlingRpcService.newDecorator(never())) .decorate(THttpService.newDecorator())); sb.service("/thrift-always", ThriftCallService.of(serviceHandler) .decorate(ThrottlingRpcService.newDecorator(always())) .decorate(THttpService.newDecorator())); } };
/** * Creates a new decorator that supports all thrift protocols and defaults to * {@link ThriftSerializationFormats#BINARY TBinary} protocol when the client doesn't specify one. * * <p>Currently, the only way to specify a serialization format is by using the HTTP session * protocol and setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator() { return newDecorator(ThriftSerializationFormats.BINARY); }
/** * Creates a new decorator that supports all thrift protocols and defaults to * {@link ThriftSerializationFormats#BINARY TBinary} protocol when the client doesn't specify one. * * <p>Currently, the only way to specify a serialization format is by using the HTTP session * protocol and setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator() { return newDecorator(ThriftSerializationFormats.BINARY); }
/** * Creates a new decorator that supports all thrift protocols and defaults to * {@link ThriftSerializationFormats#BINARY TBinary} protocol when the client doesn't specify one. * * <p>Currently, the only way to specify a serialization format is by using the HTTP session * protocol and setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator() { return newDecorator(ThriftSerializationFormats.BINARY); }
/** * Creates a new decorator that supports only the formats specified and defaults to the specified * {@code defaultSerializationFormat} when the client doesn't specify one. * Currently, the only way to specify a serialization format is by using the HTTP session protocol and * setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. * * @param defaultSerializationFormat the default serialization format to use when not specified by the * client * @param otherAllowedSerializationFormats other serialization formats that should be supported by this * service in addition to the default */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator( SerializationFormat defaultSerializationFormat, SerializationFormat... otherAllowedSerializationFormats) { requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats"); return newDecorator(defaultSerializationFormat, Arrays.asList(otherAllowedSerializationFormats)); }
/** * Creates a new decorator that supports only the formats specified and defaults to the specified * {@code defaultSerializationFormat} when the client doesn't specify one. * Currently, the only way to specify a serialization format is by using the HTTP session protocol and * setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. * * @param defaultSerializationFormat the default serialization format to use when not specified by the * client * @param otherAllowedSerializationFormats other serialization formats that should be supported by this * service in addition to the default */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator( SerializationFormat defaultSerializationFormat, SerializationFormat... otherAllowedSerializationFormats) { requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats"); return newDecorator(defaultSerializationFormat, Arrays.asList(otherAllowedSerializationFormats)); }
/** * Creates a new decorator that supports only the formats specified and defaults to the specified * {@code defaultSerializationFormat} when the client doesn't specify one. * Currently, the only way to specify a serialization format is by using the HTTP session protocol and * setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}. * * @param defaultSerializationFormat the default serialization format to use when not specified by the * client * @param otherAllowedSerializationFormats other serialization formats that should be supported by this * service in addition to the default */ public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator( SerializationFormat defaultSerializationFormat, SerializationFormat... otherAllowedSerializationFormats) { requireNonNull(otherAllowedSerializationFormats, "otherAllowedSerializationFormats"); return newDecorator(defaultSerializationFormat, Arrays.asList(otherAllowedSerializationFormats)); }
private void configureThriftService(ServerBuilder sb, ProjectManager pm, CommandExecutor executor, WatchService watchService, MetadataService mds) { final CentralDogmaServiceImpl service = new CentralDogmaServiceImpl(pm, executor, watchService, mds); Service<HttpRequest, HttpResponse> thriftService = ThriftCallService.of(service) .decorate(CentralDogmaTimeoutScheduler::new) .decorate(CentralDogmaExceptionTranslator::new) .decorate(THttpService.newDecorator()); if (cfg.isCsrfTokenRequiredForThrift()) { thriftService = thriftService.decorate(HttpAuthService.newDecorator(new CsrfTokenAuthorizer())); } else { thriftService = thriftService.decorate(TokenlessClientLogger::new); } // Enable content compression for API responses. thriftService = thriftService.decorate(contentEncodingDecorator()); sb.service("/cd/thrift/v1", thriftService); }
private void configureThriftService(ServerBuilder sb, ProjectManager pm, CommandExecutor executor, WatchService watchService, MetadataService mds) { final CentralDogmaServiceImpl service = new CentralDogmaServiceImpl(pm, executor, watchService, mds); Service<HttpRequest, HttpResponse> thriftService = ThriftCallService.of(service) .decorate(CentralDogmaTimeoutScheduler::new) .decorate(CentralDogmaExceptionTranslator::new) .decorate(THttpService.newDecorator()); if (cfg.isCsrfTokenRequiredForThrift()) { thriftService = thriftService.decorate(HttpAuthService.newDecorator(new CsrfTokenAuthorizer())); } else { thriftService = thriftService.decorate(TokenlessClientLogger::new); } // Enable content compression for API responses. thriftService = thriftService.decorate(contentEncodingDecorator()); sb.service("/cd/thrift/v1", thriftService); }
private void configureThriftService(ServerBuilder sb, ProjectManager pm, CommandExecutor executor, WatchService watchService, MetadataService mds) { final CentralDogmaServiceImpl service = new CentralDogmaServiceImpl(pm, executor, watchService, mds); Service<HttpRequest, HttpResponse> thriftService = ThriftCallService.of(service) .decorate(CentralDogmaTimeoutScheduler::new) .decorate(CentralDogmaExceptionTranslator::new) .decorate(THttpService.newDecorator()); if (cfg.isCsrfTokenRequiredForThrift()) { thriftService = thriftService.decorate(HttpAuthService.newDecorator(new CsrfTokenAuthorizer())); } else { thriftService = thriftService.decorate(TokenlessClientLogger::new); } // Enable content compression for API responses. thriftService = thriftService.decorate(contentEncodingDecorator()); sb.service("/cd/thrift/v1", thriftService); }