Remove deprecated Request and Response classes. (#779)

This commit is contained in:
Olga Maciaszek-Sharma
2020-07-04 12:15:30 -05:00
committed by GitHub
parent 0528e84559
commit 43ea5b17fc
16 changed files with 34 additions and 308 deletions

View File

@@ -1,70 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
/**
* @deprecated in favour of
* {@link org.springframework.cloud.client.loadbalancer.CompletionContext}
* @author Spencer Gibb
*/
// TODO: add metrics
@Deprecated
public class CompletionContext
extends org.springframework.cloud.client.loadbalancer.CompletionContext {
private final Status status;
public CompletionContext(Status status) {
this(status, null);
}
public CompletionContext(Status status, Throwable throwable) {
super(resolveStatus(status), throwable);
this.status = status;
}
public Status getStatus() {
return this.status;
}
private static org.springframework.cloud.client.loadbalancer.CompletionContext.Status resolveStatus(
Status status) {
if (Status.SUCCESSS.equals(status)) {
return org.springframework.cloud.client.loadbalancer.CompletionContext.Status.SUCCESS;
}
return org.springframework.cloud.client.loadbalancer.CompletionContext.Status
.valueOf(status.name());
}
/**
* Request status state.
* @deprecated in favour of
* {@link org.springframework.cloud.client.loadbalancer.CompletionContext.Status}
*/
@Deprecated
public enum Status {
/** Request was handled successfully. */
SUCCESSS,
/** Request reached the server but failed due to timeout or internal error. */
FAILED,
/** Request did not go off box and should not be counted for statistics. */
DISCARD,
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
/**
* A default implementation of {@link Request}.
*
* @deprecated in favour of
* @author Spencer Gibb
* @author Olga Maciaszek-Sharma
*/
@Deprecated
public class DefaultRequest<T>
extends org.springframework.cloud.client.loadbalancer.DefaultRequest<T>
implements Request<T> {
public DefaultRequest() {
new DefaultRequestContext();
}
public DefaultRequest(T context) {
super(context);
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
/**
* Contains information relevant to the request.
*
* @deprecated in favour of
* {@link org.springframework.cloud.client.loadbalancer.DefaultRequestContext}
* @author Olga Maciaszek-Sharma
*/
@Deprecated
public class DefaultRequestContext
extends org.springframework.cloud.client.loadbalancer.DefaultRequestContext {
public DefaultRequestContext() {
}
public DefaultRequestContext(String hint) {
super(hint);
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
import org.springframework.cloud.client.ServiceInstance;
/**
* @deprecated in favour of
* {@link org.springframework.cloud.client.loadbalancer.DefaultResponse}
* @author Spencer Gibb
*/
@Deprecated
public class DefaultResponse
extends org.springframework.cloud.client.loadbalancer.DefaultResponse
implements Response<ServiceInstance> {
public DefaultResponse(ServiceInstance serviceInstance) {
super(serviceInstance);
}
@Override
public void onComplete(CompletionContext completionContext) {
// TODO: implement
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
import org.springframework.cloud.client.ServiceInstance;
/**
* @deprecated in favour of
* {@link org.springframework.cloud.client.loadbalancer.EmptyResponse}
* @author Spencer Gibb
*/
@Deprecated
public class EmptyResponse
extends org.springframework.cloud.client.loadbalancer.EmptyResponse
implements Response<ServiceInstance> {
@Override
public void onComplete(CompletionContext completionContext) {
// TODO: implement
}
}

View File

@@ -18,6 +18,11 @@ package org.springframework.cloud.client.loadbalancer.reactive;
import org.reactivestreams.Publisher;
import org.springframework.cloud.client.loadbalancer.DefaultRequest;
import org.springframework.cloud.client.loadbalancer.DefaultRequestContext;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
/**
* Reactive load balancer.
*
@@ -30,7 +35,7 @@ public interface ReactiveLoadBalancer<T> {
/**
* Default implementation of a request.
*/
Request<DefaultRequestContext> REQUEST = new DefaultRequest();
Request<DefaultRequestContext> REQUEST = new DefaultRequest<>();
/**
* Choose the next server based on the load balancing algorithm.

View File

@@ -23,7 +23,9 @@ import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Mono;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;

View File

@@ -1,30 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
/**
* Marker interface for a request.
*
* @deprecated in favour of {@link org.springframework.cloud.client.loadbalancer.Request}
* @author Spencer Gibb
* @author Olga Maciaszek-Sharma
*/
@Deprecated
public interface Request<C>
extends org.springframework.cloud.client.loadbalancer.Request<C> {
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2012-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.client.loadbalancer.reactive;
/**
* Response created for each request.
*
* @deprecated in favour of {@link org.springframework.cloud.client.loadbalancer.Response}
* @param <T> type of the server
* @author Spencer Gibb
*/
@Deprecated
public interface Response<T>
extends org.springframework.cloud.client.loadbalancer.Response<T> {
/**
* Notification that the request completed.
* @param completionContext - completion context
*/
void onComplete(CompletionContext completionContext);
}

View File

@@ -36,6 +36,10 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties;
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.junit.jupiter.SpringExtension;

View File

@@ -23,6 +23,9 @@ import reactor.core.publisher.Mono;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
/**
* A sample implementation of {@link ReactiveLoadBalancer} used for tests.

View File

@@ -25,8 +25,8 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerRequest;
import org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer;
import org.springframework.cloud.client.loadbalancer.reactive.Response;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.util.ReflectionUtils;

View File

@@ -18,9 +18,9 @@ package org.springframework.cloud.loadbalancer.core;
import reactor.core.publisher.Mono;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer;
import org.springframework.cloud.client.loadbalancer.reactive.Request;
import org.springframework.cloud.client.loadbalancer.reactive.Response;
/**
* A Reactor based implementation of {@link ReactiveLoadBalancer}.

View File

@@ -26,10 +26,10 @@ import reactor.core.publisher.Mono;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.reactive.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.reactive.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.reactive.Request;
import org.springframework.cloud.client.loadbalancer.reactive.Response;
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
/**
* A Round-Robin-based implementation of {@link ReactorServiceInstanceLoadBalancer}.

View File

@@ -34,11 +34,11 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties;
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.LoadBalancerRequest;
import org.springframework.cloud.client.loadbalancer.reactive.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.reactive.EmptyResponse;
import org.springframework.cloud.client.loadbalancer.reactive.Request;
import org.springframework.cloud.client.loadbalancer.reactive.Response;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer;

View File

@@ -32,14 +32,13 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.reactive.CompletionContext;
import org.springframework.cloud.client.loadbalancer.reactive.CompletionContext.Status;
import org.springframework.cloud.client.loadbalancer.reactive.DefaultRequest;
import org.springframework.cloud.client.loadbalancer.reactive.DefaultRequestContext;
import org.springframework.cloud.client.loadbalancer.reactive.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.CompletionContext;
import org.springframework.cloud.client.loadbalancer.DefaultRequest;
import org.springframework.cloud.client.loadbalancer.DefaultRequestContext;
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.client.loadbalancer.Response;
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer;
import org.springframework.cloud.client.loadbalancer.reactive.Request;
import org.springframework.cloud.client.loadbalancer.reactive.Response;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
@@ -98,7 +97,8 @@ public class LoadBalancerTests {
then(instance.isSecure()).isFalse();
}
response.onComplete(new CompletionContext(Status.SUCCESSS));
response.onComplete(
new CompletionContext(CompletionContext.Status.SUCCESS));
}).verifyComplete();
}
}