public Module getModule() { return binder -> { binder.bind(ThriftHeaderProvider.class).to(DefaultThriftHeaderProvider.class).in(SINGLETON); driftClientBinder(binder) .bindDriftClient(PrestoThriftService.class) .withAddressSelector(extendedSimpleAddressSelector()); }; } }
@Override public void configure(Binder binder) { driftClientBinder(binder) .bindDriftClient(PrestoThriftService.class) .withExceptionClassifier(t -> { if (t instanceof PrestoThriftServiceException) { boolean retryable = ((PrestoThriftServiceException) t).isRetryable(); return new ExceptionClassification(Optional.of(retryable), HostStatus.NORMAL); } return NORMAL_EXCEPTION; }); binder.bind(ThriftConnector.class).in(Scopes.SINGLETON); binder.bind(ThriftMetadata.class).in(Scopes.SINGLETON); binder.bind(ThriftSplitManager.class).in(Scopes.SINGLETON); binder.bind(ThriftPageSourceProvider.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(ThriftConnectorConfig.class); binder.bind(ThriftSessionProperties.class).in(Scopes.SINGLETON); binder.bind(ThriftIndexProvider.class).in(Scopes.SINGLETON); binder.bind(ThriftConnectorStats.class).in(Scopes.SINGLETON); newExporter(binder).export(ThriftConnectorStats.class) .as(generatedNameOf(ThriftConnectorStats.class, connectorId)); }
binder -> driftClientBinder(binder) .bindDriftClient(Client.class) .withAddressSelector(new MockAddressSelector()) .withMethodInvocationFilter(staticFilterBinder(passThroughFilter, shortCircuitFilter)) .withExceptionClassifier(clientClassifier), binder -> driftClientBinder(binder) .bindDriftClient(Client.class, CustomClient.class) .withAddressSelector(new MockAddressSelector()) .withMethodInvocationFilter(staticFilterBinder(passThroughFilter, shortCircuitFilter)) .withExceptionClassifier(customClientClassifier));
binder -> driftClientBinder(binder) .bindDriftClient(Client.class) .withAddressSelector(new MockAddressSelector()) .withExceptionClassifier(clientClassifier), binder -> driftClientBinder(binder) .bindDriftClient(Client.class, CustomClient.class) .withAddressSelector(new MockAddressSelector()) .withExceptionClassifier(customClientClassifier));
transportModule, binder -> driftClientBinder(binder).bindDriftClient(DriftScribe.class) .withAddressSelector(addressSelector) .withMethodInvocationFilter(staticFilterBinder(filters)), binder -> driftClientBinder(binder).bindDriftClient(DriftScribe.class, CustomClient.class) .withAddressSelector(addressSelector) .withMethodInvocationFilter(staticFilterBinder(filters)), binder -> binder.bind(ScribeUser.class).in(Scopes.SINGLETON));
DriftClientBindingBuilder(Binder binder, Annotation annotation, String prefix) { this.binder = binder.skipSources(getClass()); this.annotation = requireNonNull(annotation, "annotation is null"); this.prefix = requireNonNull(prefix, "prefix is null"); // add MethodInvocationFilter extension binding point filterBinder(); // add ExceptionClassifier extension binding point classifierBinder(); }
public DriftClientBindingBuilder withExceptionClassifier(ExceptionClassifier exceptionClassifier) { classifierBinder().addBinding().toInstance(exceptionClassifier); return this; }
public DriftClientBindingBuilder withMethodInvocationFilter(MethodInvocationFilterBinder filterBinder) { filterBinder.bind(filterBinder(), binder, annotation, prefix); return this; }
private <T> DriftClientBindingBuilder bindDriftClient(Class<T> clientInterface, String configPrefix, Class<? extends Annotation> annotation) { Annotation clientAnnotation = getDriftClientAnnotation(clientInterface, annotation); configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, configPrefix); TypeLiteral<DriftClient<T>> typeLiteral = driftClientTypeLiteral(clientInterface); Provider<T> instanceProvider = new DriftClientInstanceProvider<>(clientAnnotation, Key.get(typeLiteral, annotation)); Provider<DriftClient<T>> factoryProvider = new DriftClientProvider<>(clientInterface, clientAnnotation); binder.bind(Key.get(clientInterface, annotation)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral, annotation)).toProvider(factoryProvider).in(Scopes.SINGLETON); if (annotation == DefaultClient.class) { binder.bind(Key.get(clientInterface)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral)).toProvider(factoryProvider).in(Scopes.SINGLETON); } return new DriftClientBindingBuilder(binder, clientAnnotation, configPrefix); }
driftServerBinder(binder).bindService(MismatchServiceHandler.class); driftServerBinder(binder).bindService(ThrowingServiceHandler.class); driftClientBinder(binder).bindDriftClient(EchoService.class).withAddressSelector(simpleAddressSelector()); driftClientBinder(binder).bindDriftClient(MismatchService.class).withAddressSelector(simpleAddressSelector()); driftClientBinder(binder).bindDriftClient(ThrowingService.class).withAddressSelector(simpleAddressSelector()) .withExceptionClassifier(t -> { if (t instanceof ExampleException) { boolean retryable = ((ExampleException) t).isRetryable();
DriftClientBindingBuilder(Binder binder, Annotation annotation, String prefix) { this.binder = binder.skipSources(getClass()); this.annotation = requireNonNull(annotation, "annotation is null"); this.prefix = requireNonNull(prefix, "prefix is null"); // add MethodInvocationFilter extension binding point filterBinder(); // add ExceptionClassifier extension binding point classifierBinder(); }
public DriftClientBindingBuilder withExceptionClassifier(ExceptionClassifier exceptionClassifier) { classifierBinder().addBinding().toInstance(exceptionClassifier); return this; }
public DriftClientBindingBuilder withMethodInvocationFilter(MethodInvocationFilterBinder filterBinder) { filterBinder.bind(filterBinder(), binder, annotation, prefix); return this; }
private <T> DriftClientBindingBuilder bindDriftClient(Class<T> clientInterface, String configPrefix, Class<? extends Annotation> annotation) { Annotation clientAnnotation = getDriftClientAnnotation(clientInterface, annotation); configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, configPrefix); TypeLiteral<DriftClient<T>> typeLiteral = driftClientTypeLiteral(clientInterface); Provider<T> instanceProvider = new DriftClientInstanceProvider<>(clientAnnotation, Key.get(typeLiteral, annotation)); Provider<DriftClient<T>> factoryProvider = new DriftClientProvider<>(clientInterface, clientAnnotation); binder.bind(Key.get(clientInterface, annotation)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral, annotation)).toProvider(factoryProvider).in(Scopes.SINGLETON); if (annotation == DefaultClient.class) { binder.bind(Key.get(clientInterface)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral)).toProvider(factoryProvider).in(Scopes.SINGLETON); } return new DriftClientBindingBuilder(binder, clientAnnotation, configPrefix); }
public Module getModule() { return binder -> { binder.bind(ThriftHeaderProvider.class).to(DefaultThriftHeaderProvider.class).in(SINGLETON); driftClientBinder(binder) .bindDriftClient(PrestoThriftService.class) .withAddressSelector(extendedSimpleAddressSelector()); }; } }
@Override public void configure(Binder binder) { driftClientBinder(binder) .bindDriftClient(PrestoThriftService.class) .withExceptionClassifier(t -> { if (t instanceof PrestoThriftServiceException) { boolean retryable = ((PrestoThriftServiceException) t).isRetryable(); return new ExceptionClassification(Optional.of(retryable), HostStatus.NORMAL); } return NORMAL_EXCEPTION; }); binder.bind(ThriftConnector.class).in(Scopes.SINGLETON); binder.bind(ThriftMetadata.class).in(Scopes.SINGLETON); binder.bind(ThriftSplitManager.class).in(Scopes.SINGLETON); binder.bind(ThriftPageSourceProvider.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(ThriftConnectorConfig.class); binder.bind(ThriftSessionProperties.class).in(Scopes.SINGLETON); binder.bind(ThriftIndexProvider.class).in(Scopes.SINGLETON); binder.bind(ThriftConnectorStats.class).in(Scopes.SINGLETON); newExporter(binder).export(ThriftConnectorStats.class).withGeneratedName(); }
public DriftClientBindingBuilder withExceptionClassifier(ExceptionClassifierBinder classifierBinder) { classifierBinder.bind(classifierBinder(), annotation, prefix); return this; }
public DriftClientBindingBuilder withExceptionClassifier(ExceptionClassifierBinder classifierBinder) { classifierBinder.bind(classifierBinder(), annotation, prefix); return this; }