Skip to content
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

Merged
merged 9 commits into from
Jan 21, 2023

Conversation

pLeminoq
Copy link
Contributor

📜 Description

Changes proposed in this pull request:

  • Introduce a new priority for RPC Methods
    • High priority methods are executed serially
    • Normal priority methods are executed in parallel

🔨 Breaking Changes

  • There should not be an API change since the new priority is on NORMAL per default

@pLeminoq pLeminoq linked an issue Jan 21, 2023 that may be closed by this pull request
@pLeminoq pLeminoq self-assigned this Jan 21, 2023
@@ -0,0 +1,48 @@
package org.openbase.jul.annotation

Check warning

Code scanning / detekt

Checks whether files end with a line separator.

The file /home/runner/work/jul/jul/module/annotation/src/main/java/org/openbase/jul/annotation/RPCMethod.kt is not ending with a new line.
@@ -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.

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.

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.

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.

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.

Line detected that is longer than the defined maximum line length in the code style.
@DivineThreepwood DivineThreepwood merged commit 9101490 into dev Jan 21, 2023
@DivineThreepwood DivineThreepwood deleted the 94-implement-rpc-method-priority branch January 21, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement RPC Method Priority
2 participants