Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not assign server.route to a val and use that #73

Open
doofin opened this issue Feb 20, 2018 · 0 comments
Open

Can not assign server.route to a val and use that #73

doofin opened this issue Feb 20, 2018 · 0 comments

Comments

@doofin
Copy link

doofin commented Feb 20, 2018

Type parameters for client here worked

  case class objParam(url:String)
  def getAtw[t](): ClientProxy[t, ByteBuffer, Default.Pickler, Default.Pickler] ={ // ok
    val a=autowireJs
    a.atwParams=objParam(sharedOlogx.rpcAuthed_ologx_path)
    a[t]
  }
  object autowireJs2 extends autowire.Client[ByteBuffer, Pickler, Pickler]   {
    override def doCall(req: Request): Future[ByteBuffer] = {
      dom.ext.Ajax
        .post(
          url = sharedOlogx.rpcAuthed_ologx_path + "/" + req.path.mkString("/"),
          data = Pickle.intoBytes(req.args),
          responseType = "arraybuffer",
          headers = Map(("Content-Type", "application/octet-stream"))
        )
        .map(r => TypedArrayBuffer.wrap(r.response.asInstanceOf[ArrayBuffer]))
    }

but the server side do not work(it compiles,but get runtime error when client tries to do rpc call)

      object autowireServer extends autowire.Server[ByteBuffer, Pickler, Pickler]{
        override def read[R: Pickler](p: ByteBuffer) = Unpickle[R].fromBytes(p)

        override def write[R: Pickler](r: R) = Pickle.intoBytes(r)

        @inline
        final def run[t](apiImpl: t,  // damn! this can not be made generic
                   reqPathList: List[String],
                   reqBodyBytes: ByteString): Future[ByteBuffer] = {
          lg("atw reqPathList:"+reqPathList)
          this.route[t](apiImpl)( // the problem is route[t] 
            autowire.Core.Request(
              reqPathList,
              read[Map[String, ByteBuffer]](reqBodyBytes.asByteBuffer))
          )
        }

      }

even if i inline it

the error is

scala.MatchError: Request(List(rpcAuthedOlogx, tst),Map()) (of class autowire.Core$Request)
at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:254)
at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:252)
at jvmUtils$akkaHttpUtil$rpc_server$autowireServerCls$$anonfun$run$1.applyOrElse(jvmUtils.scala:246)

@doofin doofin changed the title Autowire does not support method overloading and type parameters on the interfaces/traits used for making the RPCs?Why Can not assign server.route to a val and use that Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant