Skip to content

Commit

Permalink
Fixed compilation and linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mfateev committed Jun 19, 2023
1 parent 5a9db4b commit 2e558cd
Show file tree
Hide file tree
Showing 35 changed files with 632 additions and 538 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
palantirGitVersionVersion = "${JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11) ? '0.15.0' : '0.13.0'}"
kotlinVersion = "${project.hasProperty("edgeDepsTest") ? '1.8.20' : (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16) ? '1.5.32' : '1.4.32')}"
kotlinVersion = '1.8.20' //"${project.hasProperty("edgeDepsTest") ? '1.8.20' : (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16) ? '1.5.32' : '1.4.32')}"
}
}

Expand Down
2 changes: 1 addition & 1 deletion temporal-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
// this module shouldn't carry temporal-sdk with it, especially for situations when users may be using a shaded artifact
compileOnly project(':temporal-sdk')

implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.20"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")

implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ abstract class BaseRootKotlinWorkflowInboundCallsInterceptor(protected val workf
// workflowContext.handleInterceptedSignal(input)
}


override fun handleQuery(input: WorkflowInboundCallsInterceptor.QueryInput): WorkflowInboundCallsInterceptor.QueryOutput {
TODO("Implement")
// return workflowContext.handleInterceptedQuery(input)
Expand All @@ -58,4 +57,4 @@ abstract class BaseRootKotlinWorkflowInboundCallsInterceptor(protected val workf
TODO("Implement")
// return workflowContext.handleInterceptedExecuteUpdate(input)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class DynamicKotlinWorkflowDefinition(
val result = workflowInvoker!!.execute(
WorkflowInboundCallsInterceptor.WorkflowInput(header!!, arrayOf(args))
)
return dataConverter.toPayloads(result!!.result).orElse(null)
return dataConverter.toPayloads(result.result).orElse(null)
}

internal inner class RootWorkflowInboundCallsInterceptor(workflowContext: KotlinWorkflowContext?) :
Expand All @@ -63,7 +63,7 @@ internal class DynamicKotlinWorkflowDefinition(
private var workflow: KotlinDynamicWorkflow? = null

override suspend fun init(outboundCalls: WorkflowOutboundCallsInterceptor) {
super.init(outboundCalls!!)
super.init(outboundCalls)
newInstance()
WorkflowInternal.registerListener(workflow)
}
Expand All @@ -78,4 +78,4 @@ internal class DynamicKotlinWorkflowDefinition(
workflow = factory.apply()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package io.temporal.internal.async

import io.temporal.workflow.Promise
import java.lang.reflect.Type

/**
Expand All @@ -28,29 +27,29 @@ import java.lang.reflect.Type
* implemented in other languages. Created through [Workflow.newActivityStub].
*/
interface KotlinActivityStub {
/**
* Executes an activity by its type name and arguments. Blocks until the activity completion.
*
* @param activityName name of an activity type to execute.
* @param resultClass the expected return type of the activity. Use Void.class for activities that
* return void type.
* @param args arguments of the activity.
* @param <R> return type.
* @return an activity result.
</R> */
suspend fun <R> execute(activityName: String, resultClass: Class<R>, vararg args: Any): R?
/**
* Executes an activity by its type name and arguments. Blocks until the activity completion.
*
* @param activityName name of an activity type to execute.
* @param resultClass the expected return type of the activity. Use Void.class for activities that
* return void type.
* @param args arguments of the activity.
* @param <R> return type.
* @return an activity result.
</R> */
suspend fun <R> execute(activityName: String, resultClass: Class<R>, vararg args: Any): R?

/**
* Executes an activity by its type name and arguments. Blocks until the activity completion.
*
* @param activityName name of an activity type to execute.
* @param resultClass the expected return class of the activity. Use Void.class for activities
* that return void type.
* @param resultType the expected return type of the activity. Differs from resultClass for
* generic types.
* @param args arguments of the activity.
* @param <R> return type.
* @return an activity result.
</R> */
suspend fun <R> execute(activityName: String, resultClass: Class<R>, resultType: Type, vararg args: Any): R?
}
/**
* Executes an activity by its type name and arguments. Blocks until the activity completion.
*
* @param activityName name of an activity type to execute.
* @param resultClass the expected return class of the activity. Use Void.class for activities
* that return void type.
* @param resultType the expected return type of the activity. Differs from resultClass for
* generic types.
* @param args arguments of the activity.
* @param <R> return type.
* @return an activity result.
</R> */
suspend fun <R> execute(activityName: String, resultClass: Class<R>, resultType: Type, vararg args: Any): R?
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ internal class KotlinActivityStubImpl(
private val activityExecutor: WorkflowOutboundCallsInterceptor
) : KotlinActivityStub {

private val options: ActivityOptions = ActivityOptions.newBuilder(options).validateAndBuildWithDefaults();
private val options: ActivityOptions = ActivityOptions.newBuilder(options).validateAndBuildWithDefaults()

override suspend fun <R> execute(activityName: String, resultClass: Class<R>, vararg args: Any): R? {
return activityExecutor
.executeActivity(
WorkflowOutboundCallsInterceptor.ActivityInput(
activityName, resultClass, resultClass, args, options, Header.empty()
activityName,
resultClass,
resultClass,
args,
options,
Header.empty()
)
).result
}
Expand All @@ -49,8 +54,13 @@ internal class KotlinActivityStubImpl(
return activityExecutor
.executeActivity(
WorkflowOutboundCallsInterceptor.ActivityInput(
activityName, resultClass, resultType, args, options, Header.empty()
activityName,
resultClass,
resultType,
args,
options,
Header.empty()
)
).result
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import io.temporal.api.query.v1.WorkflowQuery
import io.temporal.client.WorkflowClient
import io.temporal.common.context.ContextPropagator
import io.temporal.common.converter.DataConverter
import io.temporal.common.converter.DefaultDataConverter
import io.temporal.internal.replay.ReplayWorkflow
import io.temporal.internal.replay.ReplayWorkflowContext
import io.temporal.internal.replay.WorkflowContext
import io.temporal.internal.statemachines.UpdateProtocolCallback
import io.temporal.internal.sync.*
import io.temporal.internal.worker.WorkflowExecutorCache
import io.temporal.worker.WorkflowImplementationOptions
import kotlinx.coroutines.async
Expand Down Expand Up @@ -49,22 +47,27 @@ class KotlinWorkflow(

private val dispatcher = TemporalCoroutineDispatcher()
private val coroutineDispatcher = TemporalCallbackCoroutineDispatcher(dispatcher)
private val scope = TemporalScope()
private val scope = TemporalScope(workflowContext)

private var executionHandler: KotlinWorkflowExecutionHandler? = null

override fun start(event: HistoryEvent, context: ReplayWorkflowContext) {
require(
!(event.eventType != EventType.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED
|| !event.hasWorkflowExecutionStartedEventAttributes())
!(
event.eventType != EventType.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED ||
!event.hasWorkflowExecutionStartedEventAttributes()
)
) { "first event is not WorkflowExecutionStarted, but " + event.eventType }
val startEvent = event.workflowExecutionStartedEventAttributes
val workflowType = startEvent.workflowType
requireNotNull(workflow) { "Unknown workflow type: $workflowType" }
workflowContext!!.setReplayContext(context)
workflowContext.setReplayContext(context)

executionHandler = KotlinWorkflowExecutionHandler(
workflowContext, workflow, startEvent, workflowImplementationOptions!!
workflowContext,
workflow,
startEvent,
workflowImplementationOptions!!
)
// The following order is ensured by this code and DeterministicRunner implementation:
// 1. workflow.initialize
Expand Down Expand Up @@ -97,8 +100,8 @@ class KotlinWorkflow(
if (executionHandler == null) {
return false
}
dispatcher!!.eventLoop(defaultDeadlockDetectionTimeout)
return dispatcher!!.isDone() || executionHandler!!.isDone // Do not wait for all other threads.
dispatcher.eventLoop(defaultDeadlockDetectionTimeout)
return dispatcher.isDone() || executionHandler!!.isDone // Do not wait for all other threads.
}

override fun getOutput(): Optional<Payloads> {
Expand All @@ -112,8 +115,8 @@ class KotlinWorkflow(

override fun close() {
if (executionHandler != null) {
//TODO: Validate that cancel is the right operation to call here
dispatcher!!.cancel()
// TODO: Validate that cancel is the right operation to call here
dispatcher.cancel()
}
}

Expand All @@ -127,12 +130,12 @@ class KotlinWorkflow(
TODO("Implement stack trace if possible")
// return DefaultDataConverter.STANDARD_INSTANCE.toPayloads(runner!!.stackTrace())
}
val args = if (query.hasQueryArgs()) Optional.of(query.queryArgs) else Optional.empty()
// val args = if (query.hasQueryArgs()) Optional.of(query.queryArgs) else Optional.empty()
TODO("Implement query")
// return executionHandler!!.handleQuery(query.queryType, args)
}

override fun getWorkflowContext(): WorkflowContext? {
return workflowContext
}
}
}

0 comments on commit 2e558cd

Please sign in to comment.