feature/embed_akka_adapter: ConnectorEndpoints deal with ignored fields of OutBound; make connector.name.export.as.endpoint=mapped always correct; add props akka_connector.timeout comment and example

This commit is contained in:
shuang 2020-07-24 10:55:40 +08:00
parent 86c58b3b06
commit 14416174e8
3 changed files with 12 additions and 6 deletions

View File

@ -714,6 +714,8 @@ featured_apis=elasticSearchWarehouseV300
# akka_connector.loglevel=INFO/DEBUG etc.
# In case isn't defined default value is "akka-connector-actor"
# akka_connector.name_of_actor=SOME_ACTOR_NAME
# akka connector timeout seconds, default is 3 seconds
# akka_connector.timeout=10
# --------------------------------------------------------------

View File

@ -114,7 +114,7 @@ import code.views.system.{AccountAccess, ViewDefinition}
import code.webhook.{MappedAccountWebhook, WebhookHelperActors}
import code.webuiprops.WebUiProps
import com.openbankproject.commons.model.ErrorMessage
import com.openbankproject.commons.util.ApiVersion
import com.openbankproject.commons.util.{ApiVersion, Functions}
import com.openbankproject.commons.util.Functions.Implicits._
import javax.mail.internet.MimeMessage
import net.liftweb.common._
@ -613,6 +613,10 @@ class Boot extends MdcLoggable {
.filter(it => starConnectorTypes.exists(it.startsWith(_)))
assert(allSupportedConnectors.contains(connectorName), s"connector.name.export.as.endpoint=$connectorName, this value should be one of ${allSupportedConnectors.mkString(",")}")
case _ if connectorName == "mapped" =>
Functions.doNothing
case Full(connector) =>
assert(connector == connectorName, s"When 'connector=$connector', this props must be: connector.name.export.as.endpoint=$connector, but current it is $connectorName")
}

View File

@ -27,7 +27,7 @@ import scala.reflect.runtime.{universe => ru}
object ConnectorEndpoints extends RestHelper{
def registerConnectorEndpoints = {
oauthServe(connectorGetMethod)
oauthServe(connectorEndpoints)
}
/**
@ -40,13 +40,13 @@ object ConnectorEndpoints extends RestHelper{
else None
}
lazy val connectorGetMethod: OBPEndpoint = {
lazy val connectorEndpoints: OBPEndpoint = {
case "connector" :: methodName :: Nil JsonAny json -> req if(hashMethod(methodName, json)) => {
cc => {
val methodSymbol: ru.MethodSymbol = getMethod(methodName, json).get
val outBoundType = Class.forName(s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}")
val mf = ManifestFactory.classType[TopicTrait](outBoundType)
val formats = CustomJsonFormats.formats
val formats = CustomJsonFormats.nullTolerateFormats
val outBound = json.extract[TopicTrait](formats, mf)
val optionCC = Option(cc)
@ -174,8 +174,8 @@ object ConnectorEndpoints extends RestHelper{
val (mName, paramNames, _, _, isParamOption) = quadruple
mName == methodName && paramNames.forall(paramName => isParamOption(paramName) || (json \ paramName) != JNothing)
}
.sortBy(_._2.size)
.lastOption
.sortBy(_._2.size)
.lastOption
.map(_._3)
}