com.netflix.ribbon.transport.netty.http.SSEClient Maven / Gradle / Ivy
/*
*
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.ribbon.transport.netty.http;
import io.netty.channel.ChannelOption;
import io.reactivex.netty.client.RxClient;
import io.reactivex.netty.protocol.http.client.HttpClient;
import io.reactivex.netty.protocol.http.client.HttpClientBuilder;
import io.reactivex.netty.protocol.text.sse.ServerSentEvent;
import rx.functions.Func1;
import com.netflix.client.config.DefaultClientConfigImpl;
import com.netflix.client.config.IClientConfigKey;
import com.netflix.loadbalancer.Server;
public class SSEClient extends LoadBalancingHttpClient {
public static Builder sseClientBuilder() {
return new Builder(new Func1, LoadBalancingHttpClient>() {
@Override
public LoadBalancingHttpClient call(Builder t1) {
return new SSEClient(t1);
}
});
}
private SSEClient(LoadBalancingHttpClient.Builder t1) {
super(t1);
}
@Override
protected HttpClient getOrCreateRxClient(Server server) {
HttpClientBuilder clientBuilder =
new HttpClientBuilder(server.getHost(), server.getPort()).pipelineConfigurator(pipelineConfigurator);
int requestConnectTimeout = getProperty(IClientConfigKey.Keys.ConnectTimeout, null, DefaultClientConfigImpl.DEFAULT_CONNECT_TIMEOUT);
RxClient.ClientConfig rxClientConfig = new HttpClientConfig.Builder().build();
HttpClient client = clientBuilder.channelOption(
ChannelOption.CONNECT_TIMEOUT_MILLIS, requestConnectTimeout).config(rxClientConfig).build();
return client;
}
@Override
public void shutdown() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy