Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
mproch committed Feb 9, 2021
1 parent 376aad7 commit eae5996
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/MigrationGuide.md
Expand Up @@ -18,6 +18,7 @@ To see biggest differences please consult the [changelog](Changelog.md).
Their handling has been source of many problems and they made it harder to reason about the exeuction of process.
* [#1373](https://github.com/TouK/nussknacker/pull/1373) Creating `ClassLoaderModelData` directly is not allowed, use
`ModelData.apply` with plain config, wrapping with ModelConfigToLoad by yourself is not needed.
* [#1406](https://github.com/TouK/nussknacker/pull/1406) `ServiceReturningType` is deprecated in favour of `EagerService`

## In version 0.3.0

Expand Down
Expand Up @@ -23,7 +23,7 @@ abstract class Service extends Lifecycle


/*
This is marker interface, for services which have Lazy/dynamic parameters. Invocation is handled with EagerServiceInvoker
This is marker interface, for services which have Lazy/dynamic parameters. Invocation is handled with ServiceInvoker
Lifecycle is handled on EagerService level (like in standard Service).
A sample use case is as follows:
- Enrichment with data from SQL database, ConnectionPool is created on level of EagerService
Expand Down
Expand Up @@ -26,6 +26,7 @@ trait ReturningType {
* This trait is more complex, as Service is not factory but is invoked directly
*/
// TODO: Replace with EagerService with LazyParameter's and ContextTransformation API
@deprecated("Use EagerService instead", since = "0.4.0")
trait ServiceReturningType {

/**
Expand Down
Expand Up @@ -6,6 +6,7 @@ import java.util.concurrent.atomic.AtomicInteger
import java.util.{Date, Optional, UUID}

import cats.data.Validated.Valid
import com.github.ghik.silencer.silent
import io.circe.generic.JsonCodec
import javax.annotation.Nullable
import org.apache.flink.api.common.ExecutionConfig
Expand Down Expand Up @@ -42,6 +43,7 @@ import pl.touk.nussknacker.engine.util.Implicits._
import pl.touk.nussknacker.engine.util.typing.TypingUtils
import pl.touk.nussknacker.test.WithDataList

import scala.annotation.nowarn
import scala.collection.JavaConverters._
import scala.collection.immutable
import scala.concurrent.{ExecutionContext, Future}
Expand Down Expand Up @@ -304,6 +306,9 @@ object SampleNodes {

}

// Remove @silent after upgrade to silencer 1.7
@silent("deprecated")
@nowarn("deprecated")
object ReturningDependentTypeService extends Service with ServiceReturningType {

@MethodToInvoke
Expand Down
Expand Up @@ -250,11 +250,13 @@ class NodeCompiler(definitions: ProcessDefinition[ObjectWithMethodDef],

def prepareCompiledLazyParameters(paramsDefs: List[Parameter]) = paramsDefs.collect {
case paramDef if paramDef.isLazyParameter =>
//TODO: do we need better error handling?
val param = serviceRef.parameters.find(_.name == paramDef.name).get
val compiled = objectParametersExpressionCompiler.compileParam(param, validationContext, paramDef, eager = false)
.toOption.get.typedValue.asInstanceOf[TypedExpression]
compiledgraph.evaluatedparam.Parameter(compiled, paramDef)
val compiledParam = (for {
param <- serviceRef.parameters.find(_.name == paramDef.name)
compiled <- objectParametersExpressionCompiler
.compileParam(param, validationContext, paramDef, eager = false).toOption
.flatMap(_.typedValue.cast[TypedExpression])
} yield compiled).getOrElse(throw new IllegalArgumentException(s"$paramDef is not defined as TypedExpression"))
compiledgraph.evaluatedparam.Parameter(compiledParam, paramDef)
}

def makeInvoker(service: ServiceInvoker, paramsDefs: List[Parameter])
Expand Down

0 comments on commit eae5996

Please sign in to comment.