use of javax.inject.Singleton in project webpieces by deanhiller.
the class GuiceModule method createClient.
@Provides
@Singleton
public Http2Client createClient(MeterRegistry metrics) {
BackpressureConfig config = new BackpressureConfig();
// clients should NOT have backpressure or it could screw the server over when the server does not support backpresssure
config.setMaxBytes(null);
// This is an http1_1 client masquerading as an http2 client so we can switch to http2 faster when ready!!
Http2Client httpClient = Http2to11ClientFactory.createHttpClient("httpclient", 10, config, metrics);
return httpClient;
}
use of javax.inject.Singleton in project webpieces by deanhiller.
the class WebServerModule method providesAsyncServerMgr.
@Provides
@Singleton
public HttpFrontendManager providesAsyncServerMgr(ChannelManager chanMgr, ScheduledExecutorService timer, BufferPool pool, Time time, WebServerConfig config, MeterRegistry metrics) {
HttpParser httpParser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), pool);
HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
InjectionConfig injConfig = new InjectionConfig(http2Parser, time, config.getHttp2Config());
return HttpFrontendFactory.createFrontEnd(chanMgr, timer, injConfig, httpParser, metrics);
}
use of javax.inject.Singleton in project roboguice by roboguice.
the class MiniGuiceTest method testSingletonsAreEager.
public void testSingletonsAreEager() {
final AtomicBoolean sInjected = new AtomicBoolean();
R.injected = false;
MiniGuice.inject(A.class, new Object() {
@Provides
F provideF(R r) {
return new F();
}
@Provides
@Singleton
S provideS() {
sInjected.set(true);
return new S();
}
});
assertTrue(R.injected);
assertTrue(sInjected.get());
}
use of javax.inject.Singleton in project jianshi by wingjay.
the class AppModule method provideOkHttpClient.
@Provides
@Singleton
OkHttpClient provideOkHttpClient(GlobalRequestInterceptor globalRequestInterceptor) {
OkHttpClient.Builder builder = new OkHttpClient.Builder().connectionPool(new ConnectionPool(5, 59, TimeUnit.SECONDS)).connectTimeout(20, TimeUnit.SECONDS).readTimeout(20, TimeUnit.SECONDS).addInterceptor(globalRequestInterceptor).retryOnConnectionFailure(false);
if (BuildConfig.DEBUG) {
builder.addNetworkInterceptor(new StethoInterceptor());
}
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
builder.addInterceptor(httpLoggingInterceptor);
return builder.build();
}
use of javax.inject.Singleton in project u2020 by JakeWharton.
the class DebugApiModule method provideLoggingInterceptor.
@Provides
@Singleton
HttpLoggingInterceptor provideLoggingInterceptor() {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(message -> Timber.tag("OkHttp").v(message));
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
return loggingInterceptor;
}
Aggregations