-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement ErrorMessage header * Refactor ProtocolException to hold code numbers outside the gRPC Status.Code range * Write out the ErrorMessage when there is a failure cause. * * Now when closing the state machine, we invoke syscalls.fail(cause) on every failure with Code UNKNOWN. In other words, a failure is non-terminal when code is UNKNOWN, otherwise is terminal. * Now GrpcServerCallListenerAdaptor won't erase the cause anymore when getting an exception from the user code, because we need it for syscalls.fail(cause) * Make sure we don't write non-terminal failures for side effects
- Loading branch information
1 parent
0093ff2
commit e1a6389
Showing
19 changed files
with
281 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
sdk-core-impl/src/test/java/dev/restate/sdk/core/impl/AssertUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dev.restate.sdk.core.impl; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.InstanceOfAssertFactories.STRING; | ||
import static org.assertj.core.api.InstanceOfAssertFactories.type; | ||
|
||
import com.google.protobuf.MessageLite; | ||
import com.google.rpc.Code; | ||
import dev.restate.generated.service.protocol.Protocol; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public class AssertUtils { | ||
|
||
public static Consumer<List<MessageLite>> containsOnly(Consumer<? super MessageLite> consumer) { | ||
return msgs -> assertThat(msgs).satisfiesExactly(consumer); | ||
} | ||
|
||
public static Consumer<List<MessageLite>> containsOnlyExactErrorMessage(Throwable e) { | ||
return containsOnly(exactErrorMessage(e)); | ||
} | ||
|
||
public static Consumer<? super MessageLite> errorMessage( | ||
Consumer<? super Protocol.ErrorMessage> consumer) { | ||
return msg -> | ||
assertThat(msg).asInstanceOf(type(Protocol.ErrorMessage.class)).satisfies(consumer); | ||
} | ||
|
||
public static Consumer<? super MessageLite> exactErrorMessage(Throwable e) { | ||
return errorMessage( | ||
msg -> | ||
assertThat(msg) | ||
.returns(e.toString(), Protocol.ErrorMessage::getMessage) | ||
.returns(Code.UNKNOWN_VALUE, Protocol.ErrorMessage::getCode)); | ||
} | ||
|
||
public static Consumer<? super MessageLite> errorMessageStartingWith(String str) { | ||
return errorMessage( | ||
msg -> | ||
assertThat(msg).extracting(Protocol.ErrorMessage::getMessage, STRING).startsWith(str)); | ||
} | ||
|
||
public static Consumer<? super MessageLite> protocolExceptionErrorMessage(int code) { | ||
return errorMessage( | ||
msg -> | ||
assertThat(msg) | ||
.returns(code, Protocol.ErrorMessage::getCode) | ||
.extracting(Protocol.ErrorMessage::getMessage, STRING) | ||
.startsWith(ProtocolException.class.getCanonicalName())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.