diff --git a/changelog/@unreleased/pr-345.v2.yml b/changelog/@unreleased/pr-345.v2.yml new file mode 100644 index 000000000..98aa68f4a --- /dev/null +++ b/changelog/@unreleased/pr-345.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Delete unused classes from dialogue-target + links: + - https://github.com/palantir/dialogue/pull/345 diff --git a/dialogue-target/src/main/java/com/palantir/dialogue/Call.java b/dialogue-target/src/main/java/com/palantir/dialogue/Call.java deleted file mode 100644 index 48bef0a71..000000000 --- a/dialogue-target/src/main/java/com/palantir/dialogue/Call.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * 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.palantir.dialogue; - -/** - * Represents an active RPC call between a client and a server. Call instances are transient objects in the sense that - * they are created by a {@link Channel} when a client initiates a new call to an {@link Endpoint}, and disposed when - * the call terminates (successfully, with failure, or due to explicit {@link #cancel cancellation}). - */ -public interface Call { - - /** - * Executes this call and presents the success or failure result to the given observer. A call may only be executed - * once, repeated calls yield a {@link IllegalStateException}. - */ - void execute(Observer observer); - - /** Cancels this call. Call implementations should support multiple, idempotent cancellation. */ - void cancel(); -} diff --git a/dialogue-target/src/main/java/com/palantir/dialogue/Calls.java b/dialogue-target/src/main/java/com/palantir/dialogue/Calls.java deleted file mode 100644 index 9c24e7fa8..000000000 --- a/dialogue-target/src/main/java/com/palantir/dialogue/Calls.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * 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.palantir.dialogue; - -import com.google.common.util.concurrent.AbstractFuture; -import com.google.common.util.concurrent.ListenableFuture; -import com.palantir.conjure.java.api.errors.RemoteException; -import java.util.concurrent.Future; -import javax.annotation.Nullable; - -public final class Calls { - private Calls() {} - - /** - * Converts the given {@link Call} to a {@link Future} by {@link Call#execute executing} the Call and capturing its - * result. If the call fails with an {@link Observer#exception} or {@link Observer#failure}, the - * corresponding exception is captured by the Future and will be rethrown by {@link Future#get}. Cancelling the - * future cancels the underlying call. - */ - public static ListenableFuture toFuture(Call call) { - CallCancellingFuture future = new CallCancellingFuture<>(call); - call.execute(new Observer() { - @Override - public void success(Response value) { - future.set(value); - } - - @Override - public void failure(RemoteException error) { - future.setException(error); - } - - @Override - public void exception(Throwable throwable) { - future.setException(throwable); - } - }); - return future; - } - - private static final class CallCancellingFuture extends AbstractFuture { - private final Call call; - - private CallCancellingFuture(Call call) { - this.call = call; - } - - @Override - protected void interruptTask() { - super.interruptTask(); - call.cancel(); - } - - @Override - protected boolean set(@Nullable RespT value) { - return super.set(value); - } - - @Override - protected boolean setException(Throwable throwable) { - return super.setException(throwable); - } - } -} diff --git a/dialogue-target/src/main/java/com/palantir/dialogue/Header.java b/dialogue-target/src/main/java/com/palantir/dialogue/Header.java deleted file mode 100644 index f419f03f9..000000000 --- a/dialogue-target/src/main/java/com/palantir/dialogue/Header.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * 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.palantir.dialogue; - -import org.immutables.value.Value; - -@Value.Immutable -public interface Header { - String name(); - - String value(); -} diff --git a/dialogue-target/src/main/java/com/palantir/dialogue/Observer.java b/dialogue-target/src/main/java/com/palantir/dialogue/Observer.java deleted file mode 100644 index 948ff277f..000000000 --- a/dialogue-target/src/main/java/com/palantir/dialogue/Observer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * 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.palantir.dialogue; - -import com.palantir.conjure.java.api.errors.RemoteException; - -/** - * A callback interface for RPC responses. Successful calls are presented to {@link #success}. We distinguish between - * two types of non-successful responses: - *

- *

    - *
  • Application-level errors from the server, e.g., authorization problems, invalid arguments, etc., are presented - * to {@link #failure} as a {@link RemoteException} explaining the type of failure. These are typically "expected" - * errors in the sense that they are part of the API contract between client and server.
  • - *
  • All other errors, e.g., failed connections or DNS lookups, failed deserialization of server responses, etc., are - * presented to {@link #exception}. These are typically "unexpected" errors in the sense that they represent a - * configuration problem or a bug.
  • - *
- */ -public interface Observer { - void success(Response value); - - void failure(RemoteException error); - - void exception(Throwable throwable); -} diff --git a/dialogue-target/src/test/java/com/palantir/dialogue/CallsTest.java b/dialogue-target/src/test/java/com/palantir/dialogue/CallsTest.java deleted file mode 100644 index 83b8a14c3..000000000 --- a/dialogue-target/src/test/java/com/palantir/dialogue/CallsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * 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.palantir.dialogue; - -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import com.google.common.util.concurrent.ListenableFuture; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public final class CallsTest { - - @Mock - private Call call; - - @Test - public void toFuture_cancelsCallWhenCancellingWithInterrupt() { - ListenableFuture future = Calls.toFuture(call); - future.cancel(true); - verify(call).cancel(); - } - - @Test - public void toFuture_doesNotCancelCallWhenNotAllowedToInterrupt() { - ListenableFuture future = Calls.toFuture(call); - future.cancel(false); - verify(call, never()).cancel(); - } -}