-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
94 implement rpc method priority #95
Conversation
… the priority is retrieved from the annotation when registering an interface
@@ -0,0 +1,48 @@ | |||
package org.openbase.jul.annotation |
Check warning
Code scanning / detekt
Checks whether files end with a line separator.
module/communication/mqtt/src/test/java/org/openbase/jul/communication/mqtt/RPCMethodTest.kt
Fixed
Show fixed
Hide fixed
module/communication/mqtt/src/main/java/org/openbase/jul/communication/mqtt/RPCMethod.kt
Fixed
Show fixed
Hide fixed
module/communication/default/src/main/java/org/openbase/jul/communication/iface/RPCServer.kt
Fixed
Show fixed
Hide fixed
@@ -92,10 +92,10 @@ | |||
val instance = FunctionProvider() | |||
|
|||
// correct use with class function | |||
RPCMethod(FunctionProvider::`no args no return`, instance).invoke(emptyList()) shouldBe protoAny.getDefaultInstance() | |||
RPCMethodWrapper(FunctionProvider::`no args no return`, instance=instance).invoke(emptyList()) shouldBe protoAny.getDefaultInstance() |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
|
||
// class function but no instance provided should throw an error | ||
shouldThrow<CouldNotPerformException> { RPCMethod(FunctionProvider::`no args no return`).invoke(emptyList()) } | ||
shouldThrow<CouldNotPerformException> { RPCMethodWrapper(FunctionProvider::`no args no return`).invoke(emptyList()) } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
@@ -105,12 +105,12 @@ | |||
|
|||
// wrong type of arg | |||
val wrongTypeArg: protoAny = protoAny.pack(Primitive.newBuilder().setString("WRONG").build()) | |||
shouldThrow<CouldNotPerformException> { RPCMethod(instance::`args no return`).invoke(listOf(wrongTypeArg)) } | |||
shouldThrow<CouldNotPerformException> { RPCMethodWrapper(instance::`args no return`).invoke(listOf(wrongTypeArg)) } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
|
||
// wrong number of args | ||
val toManyArg: protoAny = protoAny.pack(Primitive.newBuilder().setDouble(42.0).build()) | ||
shouldThrow<CouldNotPerformException> { RPCMethod(instance::`no args no return`).invoke(listOf(toManyArg)) } | ||
shouldThrow<CouldNotPerformException> { RPCMethod(instance::`args no return`).invoke(emptyList()) } | ||
shouldThrow<CouldNotPerformException> { RPCMethodWrapper(instance::`no args no return`).invoke(listOf(toManyArg)) } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
@@ -36,7 +37,7 @@ | |||
* @param function the function to be wrapped | |||
* @param instance the instance the function is called on, is only required | |||
*/ | |||
class RPCMethod(private val function: KFunction<*>, private val instance: Any = noInstance) { | |||
class RPCMethodWrapper(private val function: KFunction<*>, val priority: RPCMethod.Priority = RPCMethod.Priority.NORMAL, private val instance: Any = noInstance) { |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
📜 Description
Changes proposed in this pull request:
🔨 Breaking Changes
NORMAL
per default