mirror of
https://github.com/fluencelabs/aqua.git
synced 2025-04-25 06:52:13 +00:00
Config options to omit xor wrapper, relay passing (#105)
This commit is contained in:
parent
0e550491fa
commit
53ad29ab31
@ -58,12 +58,11 @@ case class TypescriptFunc(func: FuncCallable) {
|
|||||||
| `,
|
| `,
|
||||||
| )
|
| )
|
||||||
| .configHandler((h) => {
|
| .configHandler((h) => {
|
||||||
| h.on('${conf.getDataService}', 'relay', () => {
|
| ${conf.relayVarName.fold("") { r =>
|
||||||
|
s"""h.on('${conf.getDataService}', '$r', () => {
|
||||||
| return client.relayPeerId!;
|
| return client.relayPeerId!;
|
||||||
| });
|
| });""".stripMargin
|
||||||
| h.on('getRelayService', 'hasRelay', () => {// Not Used
|
}}
|
||||||
| return client.relayPeerId !== undefined;
|
|
||||||
| });
|
|
||||||
| $setCallbacks
|
| $setCallbacks
|
||||||
| ${returnCallback.getOrElse("")}
|
| ${returnCallback.getOrElse("")}
|
||||||
| h.onEvent('${conf.errorHandlingService}', '${conf.errorFuncName}', (args) => {
|
| h.onEvent('${conf.errorHandlingService}', '${conf.errorFuncName}', (args) => {
|
||||||
|
@ -29,24 +29,39 @@ object AquaCli extends IOApp {
|
|||||||
.map(_ => true)
|
.map(_ => true)
|
||||||
.withDefault(false)
|
.withDefault(false)
|
||||||
|
|
||||||
|
val noRelay: Opts[Boolean] =
|
||||||
|
Opts
|
||||||
|
.flag("no-relay", "Do not generate a pass through the relay node")
|
||||||
|
.map(_ => true)
|
||||||
|
.withDefault(false)
|
||||||
|
|
||||||
|
val noXorWrapper: Opts[Boolean] =
|
||||||
|
Opts
|
||||||
|
.flag("no-xor", "Do not generate a wrapper that catches and displays errors")
|
||||||
|
.map(_ => true)
|
||||||
|
.withDefault(false)
|
||||||
|
|
||||||
def mainOpts: Opts[IO[ExitCode]] =
|
def mainOpts: Opts[IO[ExitCode]] =
|
||||||
(inputOpts, importOpts, outputOpts, compileToAir).mapN { case (input, imports, output, toAir) =>
|
(inputOpts, importOpts, outputOpts, compileToAir, noRelay, noXorWrapper).mapN {
|
||||||
AquaCompiler
|
case (input, imports, output, toAir, noRelay, noXor) =>
|
||||||
.compileFilesTo[IO](
|
AquaCompiler
|
||||||
input,
|
.compileFilesTo[IO](
|
||||||
imports,
|
input,
|
||||||
output,
|
imports,
|
||||||
if (toAir) AquaCompiler.AirTarget else AquaCompiler.TypescriptTarget,
|
output,
|
||||||
BodyConfig()
|
if (toAir) AquaCompiler.AirTarget else AquaCompiler.TypescriptTarget, {
|
||||||
)
|
val bc = BodyConfig(wrapWithXor = !noXor)
|
||||||
.map {
|
bc.copy(relayVarName = bc.relayVarName.filterNot(_ => noRelay))
|
||||||
case Validated.Invalid(errs) =>
|
}
|
||||||
errs.map(println)
|
)
|
||||||
ExitCode.Error
|
.map {
|
||||||
case Validated.Valid(res) =>
|
case Validated.Invalid(errs) =>
|
||||||
res.map(println)
|
errs.map(println)
|
||||||
ExitCode.Success
|
ExitCode.Error
|
||||||
}
|
case Validated.Valid(res) =>
|
||||||
|
res.map(println)
|
||||||
|
ExitCode.Success
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def run(args: List[String]): IO[ExitCode] =
|
override def run(args: List[String]): IO[ExitCode] =
|
||||||
|
@ -8,7 +8,7 @@ case class BodyConfig(
|
|||||||
errorHandlingService: String = "errorHandlingSrv",
|
errorHandlingService: String = "errorHandlingSrv",
|
||||||
errorFuncName: String = "error",
|
errorFuncName: String = "error",
|
||||||
respFuncName: String = "response",
|
respFuncName: String = "response",
|
||||||
relayVarName: String = "relay",
|
relayVarName: Option[String] = Some("relay"),
|
||||||
wrapWithXor: Boolean = true
|
wrapWithXor: Boolean = true
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ object Transform {
|
|||||||
|
|
||||||
def forClient(func: FuncCallable, conf: BodyConfig): Cofree[Chain, OpTag] = {
|
def forClient(func: FuncCallable, conf: BodyConfig): Cofree[Chain, OpTag] = {
|
||||||
val initCallable: InitPeerCallable = InitViaRelayCallable(
|
val initCallable: InitPeerCallable = InitViaRelayCallable(
|
||||||
Chain.one(VarModel(conf.relayVarName, ScalarType.string))
|
Chain.fromOption(conf.relayVarName).map(VarModel(_, ScalarType.string))
|
||||||
)
|
)
|
||||||
val errorsCatcher = ErrorsCatcher(
|
val errorsCatcher = ErrorsCatcher(
|
||||||
enabled = conf.wrapWithXor,
|
enabled = conf.wrapWithXor,
|
||||||
@ -23,8 +23,8 @@ object Transform {
|
|||||||
val argsProvider: ArgsProvider =
|
val argsProvider: ArgsProvider =
|
||||||
ArgsFromService(
|
ArgsFromService(
|
||||||
conf.dataSrvId,
|
conf.dataSrvId,
|
||||||
conf.relayVarName -> ScalarType.string :: func.args.dataArgs.toList.map(add =>
|
conf.relayVarName.map(_ -> ScalarType.string).toList ::: func.args.dataArgs.toList.map(
|
||||||
add.name -> add.dataType
|
add => add.name -> add.dataType
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user