Fix release, add xor wrap (#51)

This commit is contained in:
Dima 2021-04-13 13:37:03 +03:00 committed by GitHub
parent 50e335bc76
commit 8e04348ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 29 deletions

View File

@ -8,6 +8,8 @@ on:
branches:
- "main"
workflow_dispatch:
jobs:
release:
name: "Release"
@ -34,7 +36,7 @@ jobs:
- name: Add version to .jar name
run: |
JAR="target/scala-2.13/aqua-hll-${{ env.VERSION }}.jar"
JAR="aqua-hll-${{ env.VERSION }}.jar"
mv "cli/target/scala-2.13/aqua-hll.jar" $JAR
echo "JAR=$JAR" >> $GITHUB_ENV

View File

@ -62,7 +62,7 @@ case class TypescriptFunc(func: FuncResolved) {
| });
| $setCallbacks
| ${returnCallback.getOrElse("")}
| h.on('nameOfServiceWhereToSendXorError', 'errorProbably', (args) => {
| h.on('${conf.errorHandlingService}', '${conf.error}', (args) => {
| // assuming error is the single argument
| const [err] = args;
| reject(err);

View File

@ -5,10 +5,14 @@ import aqua.model.{LiteralModel, ValueModel}
case class BodyConfig(
getDataService: String = "getDataSrv",
callbackService: String = "callbackSrv",
errorHandlingService: String = "errorHandlingSrv",
error: String = "error",
respFuncName: String = "response",
relayVarName: String = "relay"
) {
val errorId: ValueModel = LiteralModel("\"" + error + "\"")
val errorHandlingCallback: ValueModel = LiteralModel("\"" + errorHandlingService + "\"")
val callbackSrvId: ValueModel = LiteralModel("\"" + callbackService + "\"")
val dataSrvId: ValueModel = LiteralModel("\"" + getDataService + "\"")

View File

@ -1,7 +1,8 @@
package aqua.model.transform
import aqua.model.body._
import aqua.model.{FuncCallable, FuncResolved, InitPeerIdModel, VarModel}
import aqua.model.{FuncCallable, FuncResolved, InitPeerIdModel, LiteralModel, VarModel}
import aqua.types.ScalarType.string
import aqua.types.{ArrowType, DataType}
import cats.data.Chain
import cats.free.Cofree
@ -11,6 +12,26 @@ object ForClient {
def apply(func: FuncResolved, conf: BodyConfig): Cofree[Chain, OpTag] = {
import conf._
def wrapXor(op: FuncOp): FuncOp =
FuncOp.node(
XorTag,
Chain(
op,
viaRelay(
FuncOp.leaf(
CallServiceTag(
errorHandlingCallback,
error,
Call(
(LiteralModel("%last_error%"), string) :: Nil,
None
)
)
)
)
)
)
// Get to init user through a relay
def viaRelay(op: FuncOp): FuncOp =
FuncOp.wrap(OnTag(InitPeerIdModel, Chain.one(VarModel(relayVarName))), op)
@ -74,33 +95,36 @@ object ForClient {
)
)
val body =
viaRelay(
FuncOp
.node(
SeqTag,
Chain
.fromSeq(
func.func.args.collect { case (argName, Left(_)) =>
getDataOp(argName)
} :+ getDataOp(relayVarName)
)
.append(
func.func
.apply(
funcArgsCall,
func.func.args.collect { case (argName, Right(arrowType)) =>
argName -> initPeerCallable(argName, arrowType)
}.toMap,
func.func.args.collect { case (argName, Left(_)) =>
argName
}.foldLeft(Set(relayVarName))(_ + _)
)
.value
._1
) ++ Chain.fromSeq(returnCallback.toSeq)
)
val body = {
wrapXor(
viaRelay(
FuncOp
.node(
SeqTag,
Chain
.fromSeq(
func.func.args.collect { case (argName, Left(_)) =>
getDataOp(argName)
} :+ getDataOp(relayVarName)
)
.append(
func.func
.apply(
funcArgsCall,
func.func.args.collect { case (argName, Right(arrowType)) =>
argName -> initPeerCallable(argName, arrowType)
}.toMap,
func.func.args.collect { case (argName, Left(_)) =>
argName
}.foldLeft(Set(relayVarName))(_ + _)
)
.value
._1
) ++ Chain.fromSeq(returnCallback.toSeq)
)
)
).tree
}
Topology.resolve(body)
}