use of org.webpieces.http2client.api.Http2Client 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 org.webpieces.http2client.api.Http2Client in project webpieces by deanhiller.
the class IntegSingleRequest method createHttpClient.
public static Http2Socket createHttpClient(String id, boolean isHttp, InetSocketAddress addr) {
BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
HpackParser hpackParser = HpackParserFactory.createParser(pool2, false);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
InjectionConfig injConfig = new InjectionConfig(hpackParser);
String host = addr.getHostName();
int port = addr.getPort();
ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
SSLEngine engine = ssl.createSslEngine(host, port);
Http2Client client = Http2ClientFactory.createHttpClient("myClient", mgr, injConfig);
Http2Socket socket;
if (isHttp) {
socket = client.createHttpSocket(new Http2CloseListener());
} else {
socket = client.createHttpsSocket(engine, new Http2CloseListener());
}
return socket;
}
use of org.webpieces.http2client.api.Http2Client in project webpieces by deanhiller.
the class CompanyTest method initialize.
public void initialize() {
log.info("Setting up test");
// Necessary to avoid errors that could be confusing to developers...(fail early instead with what is wrong)
Asserts.assertWasCompiledWithParamNames("test");
try {
startServer();
} catch (IOException ex) {
throw SneakyThrow.sneak(ex);
}
if (serverHttpAddr == null || serverHttpsAddr == null)
throw new IllegalStateException("startServer method forgot to set the serverHttpAddr and serverHttpsAddr");
simulateContext();
Http2Client http2Client = getClient();
Injector injector = Guice.createInjector(new ClientTestModule(http2Client));
restClientCreator = injector.getInstance(RESTClientCreator.class);
initialized = true;
}
use of org.webpieces.http2client.api.Http2Client in project webpieces by deanhiller.
the class TestC3InitialHttpConnections method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
mockChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
Http2Config config = new Http2Config();
// start with 1 max concurrent
config.setInitialRemoteMaxConcurrent(1);
config.setLocalSettings(localSettings);
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
Http2Client client = Http2ClientFactory.createHttpClient("test2Client", mockChanMgr, injConfig);
mockChanMgr.addTCPChannelToReturn(mockChannel);
socket = client.createHttpSocket(new SocketListener());
XFuture<Void> connect = socket.connect(new InetSocketAddress(555));
connect.get(2, TimeUnit.SECONDS);
}
use of org.webpieces.http2client.api.Http2Client in project webpieces by deanhiller.
the class IntegSingleRequest method createHttpClient.
public static Http2Socket createHttpClient(String id, boolean isHttp, InetSocketAddress addr) {
BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
HpackParser hpackParser = HpackParserFactory.createParser(pool2, false);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
InjectionConfig injConfig = new InjectionConfig(hpackParser);
String host = addr.getHostName();
int port = addr.getPort();
ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
SSLEngine engine = ssl.createSslEngine(host, port);
Http2Client client = Http2ClientFactory.createHttpClient(id, mgr, injConfig);
Http2Socket socket;
if (isHttp) {
socket = client.createHttpSocket(new SocketListener());
} else {
socket = client.createHttpsSocket(engine, new SocketListener());
}
return socket;
}
Aggregations