Merge remote-tracking branch 'origin/2.2.x'
# Conflicts: # docs/pom.xml # pom.xml
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
// TODO: add metrics
|
||||
public class CompletionContext {
|
||||
|
||||
private final Status status;
|
||||
|
||||
private final Throwable throwable;
|
||||
|
||||
public CompletionContext(Status status) {
|
||||
this(status, null);
|
||||
}
|
||||
|
||||
public CompletionContext(Status status, Throwable throwable) {
|
||||
this.status = status;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public Status status() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public Throwable getThrowable() {
|
||||
return this.throwable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator to = new ToStringCreator(this);
|
||||
to.append("status", this.status);
|
||||
to.append("throwable", this.throwable);
|
||||
return to.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request status state.
|
||||
*/
|
||||
public enum Status {
|
||||
|
||||
/** Request was handled successfully. */
|
||||
SUCCESS,
|
||||
/** 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,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A default implementation of {@link Request}.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
public class DefaultRequest<T> implements Request<T> {
|
||||
|
||||
private T context;
|
||||
|
||||
public DefaultRequest() {
|
||||
new DefaultRequestContext();
|
||||
}
|
||||
|
||||
public DefaultRequest(T context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(T context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Contains information relevant to the request.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
public class DefaultRequestContext {
|
||||
|
||||
/**
|
||||
* A {@link String} value of hint that can be used to choose the correct service
|
||||
* instance.
|
||||
*/
|
||||
private String hint = "default";
|
||||
|
||||
public DefaultRequestContext() {
|
||||
}
|
||||
|
||||
public DefaultRequestContext(String hint) {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
public void setHint(String hint) {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class DefaultResponse implements Response<ServiceInstance> {
|
||||
|
||||
private final ServiceInstance serviceInstance;
|
||||
|
||||
public DefaultResponse(ServiceInstance serviceInstance) {
|
||||
this.serviceInstance = serviceInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasServer() {
|
||||
return this.serviceInstance != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceInstance getServer() {
|
||||
return this.serviceInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(CompletionContext completionContext) {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class EmptyResponse implements Response<ServiceInstance> {
|
||||
|
||||
@Override
|
||||
public boolean hasServer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceInstance getServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(CompletionContext completionContext) {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Marker interface for a request.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
public interface Request<C> {
|
||||
|
||||
// Avoid breaking backward compatibility
|
||||
default C getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: define contents
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Response created for each request.
|
||||
*
|
||||
* @param <T> type of the server
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public interface Response<T> {
|
||||
|
||||
boolean hasServer();
|
||||
|
||||
T getServer();
|
||||
|
||||
/**
|
||||
* Notification that the request completed.
|
||||
* @deprecated <code>onComplete</code> callbacks for load-balanced calls are being
|
||||
* moved to a separate interface
|
||||
* @param completionContext - completion context
|
||||
*/
|
||||
@Deprecated
|
||||
void onComplete(CompletionContext completionContext);
|
||||
|
||||
}
|
||||
@@ -16,46 +16,46 @@
|
||||
|
||||
package org.springframework.cloud.client.loadbalancer.reactive;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* @deprecated in favour of
|
||||
* {@link org.springframework.cloud.client.loadbalancer.CompletionContext}
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
// TODO: add metrics
|
||||
public class CompletionContext {
|
||||
@Deprecated
|
||||
public class CompletionContext
|
||||
extends org.springframework.cloud.client.loadbalancer.CompletionContext {
|
||||
|
||||
private final Status status;
|
||||
|
||||
private final Throwable throwable;
|
||||
|
||||
public CompletionContext(Status status) {
|
||||
this(status, null);
|
||||
}
|
||||
|
||||
public CompletionContext(Status status, Throwable throwable) {
|
||||
super(resolveStatus(status), throwable);
|
||||
this.status = status;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public Throwable getThrowable() {
|
||||
return this.throwable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator to = new ToStringCreator(this);
|
||||
to.append("status", this.status);
|
||||
to.append("throwable", this.throwable);
|
||||
return to.toString();
|
||||
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. */
|
||||
|
||||
@@ -19,28 +19,21 @@ package org.springframework.cloud.client.loadbalancer.reactive;
|
||||
/**
|
||||
* A default implementation of {@link Request}.
|
||||
*
|
||||
* @deprecated in favour of
|
||||
* @author Spencer Gibb
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
public class DefaultRequest<T> implements Request<T> {
|
||||
|
||||
private T context;
|
||||
@Deprecated
|
||||
public class DefaultRequest<T>
|
||||
extends org.springframework.cloud.client.loadbalancer.DefaultRequest<T>
|
||||
implements Request<T> {
|
||||
|
||||
public DefaultRequest() {
|
||||
new DefaultRequestContext();
|
||||
}
|
||||
|
||||
public DefaultRequest(T context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(T context) {
|
||||
this.context = context;
|
||||
super(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,29 +19,19 @@ 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
|
||||
*/
|
||||
public class DefaultRequestContext {
|
||||
|
||||
/**
|
||||
* A {@link String} value of hint that can be used to choose the correct service
|
||||
* instance.
|
||||
*/
|
||||
private String hint = "default";
|
||||
@Deprecated
|
||||
public class DefaultRequestContext
|
||||
extends org.springframework.cloud.client.loadbalancer.DefaultRequestContext {
|
||||
|
||||
public DefaultRequestContext() {
|
||||
}
|
||||
|
||||
public DefaultRequestContext(String hint) {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
public void setHint(String hint) {
|
||||
this.hint = hint;
|
||||
super(hint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,24 +19,17 @@ 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
|
||||
*/
|
||||
public class DefaultResponse implements Response<ServiceInstance> {
|
||||
|
||||
private final ServiceInstance serviceInstance;
|
||||
@Deprecated
|
||||
public class DefaultResponse
|
||||
extends org.springframework.cloud.client.loadbalancer.DefaultResponse
|
||||
implements Response<ServiceInstance> {
|
||||
|
||||
public DefaultResponse(ServiceInstance serviceInstance) {
|
||||
this.serviceInstance = serviceInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasServer() {
|
||||
return this.serviceInstance != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceInstance getServer() {
|
||||
return this.serviceInstance;
|
||||
super(serviceInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,19 +19,14 @@ 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
|
||||
*/
|
||||
public class EmptyResponse implements Response<ServiceInstance> {
|
||||
|
||||
@Override
|
||||
public boolean hasServer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceInstance getServer() {
|
||||
return null;
|
||||
}
|
||||
@Deprecated
|
||||
public class EmptyResponse
|
||||
extends org.springframework.cloud.client.loadbalancer.EmptyResponse
|
||||
implements Response<ServiceInstance> {
|
||||
|
||||
@Override
|
||||
public void onComplete(CompletionContext completionContext) {
|
||||
|
||||
@@ -19,16 +19,12 @@ 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
|
||||
*/
|
||||
public interface Request<C> {
|
||||
|
||||
// Avoid breaking backward compatibility
|
||||
default C getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: define contents
|
||||
@Deprecated
|
||||
public interface Request<C>
|
||||
extends org.springframework.cloud.client.loadbalancer.Request<C> {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@ 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
|
||||
*/
|
||||
public interface Response<T> {
|
||||
|
||||
boolean hasServer();
|
||||
|
||||
T getServer();
|
||||
@Deprecated
|
||||
public interface Response<T>
|
||||
extends org.springframework.cloud.client.loadbalancer.Response<T> {
|
||||
|
||||
/**
|
||||
* Notification that the request completed.
|
||||
|
||||
Reference in New Issue
Block a user