Fork me on GitHub
#portkey
<
2017-10-01
>
baptiste-from-paris14:10:07

I am trying to make portkey work with the example from the README . Once I depoly/mount the flatten function and I try to call it with query-params, I have a blank page as a respone

baptiste-from-paris14:10:46

Just to be sure, it should return a string right ?

baptiste-from-paris14:10:38

because I have this error

{
errorMessage: "Error loading class portkey.LambdaStub",
errorType: "java.lang.ExceptionInInitializerError"
}

baptiste-from-paris14:10:21

with this code

(defn welcome [] "Hello world !")

(pk/mount! welcome "/welcome")

cgrand15:10:19

@baptiste-from-paris @viesti ran into a similar issue yesterday, I haven’t had to dig in yet. Are you using it with lein? In which profile did you put portkey ?

baptiste-from-paris15:10:14

lein => yes lein install then

(defproject port "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.9.0-beta1"]
                 [portkey "0.1.0-SNAPSHOT"]]
  :main ^:skip-aot port.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

baptiste-from-paris15:10:31

I just generated a lein new app

viesti15:10:48

looks a bit different to what I ran into, what does the stack trace look like?

baptiste-from-paris15:10:31

and let me find the stacktrace, 1min

viesti15:10:58

thinking about global leiningen profile in my case now

baptiste-from-paris15:10:22

Error loading class portkey.LambdaStub: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
Caused by: java.lang.Exception: Nothing specified to load, compiling:(NO_SOURCE_PATH:0:0)
at clojure.core$throw_if.invokeStatic(core.clj:5808)
at clojure.core$throw_if.doInvoke(core.clj:5795)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.core$load_libs.invokeStatic(core.clj:5924)
at clojure.core$load_libs.doInvoke(core.clj:5910)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$require.invokeStatic(core.clj:5948)
at clojure.core$require.doInvoke(core.clj:5948)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.core$apply.invoke(core.clj:652)
at portkey.core$bootstrap$fn__17842.invoke(core.clj:187)
at portkey.LambdaStub.<clinit>(LambdaStub.java:23)
... 2 more
Caused by: java.lang.Exception: Nothing specified to load
... 15 more

cgrand15:10:52

Where do you get the exception? Locally or in AWS?

baptiste-from-paris15:10:18

no exceptions/errors locally

cgrand16:10:45

Oh I see an interesting line: require complaining to be called with no args. Would you mind opening an issue? Merci

viesti16:10:25

spotted that too but couldn’t explain, wild shot but what Leiningen version are you running on? Could could you try without a ~/.lein/profile.clj, if one is present, for a clean Leiningen repl.

baptiste-from-paris16:10:35

ok, will do tonight

viesti17:10:10

apparently I had introduced one breakage at least, which is probably unrelated

viesti17:10:37

should start working on test on the AWS code to run actual deploys in CircleCI

baptiste-from-paris17:10:49

@viesti I updated portkey and it’s now working... /cc @cgrand

baptiste-from-paris17:10:05

thank’s for your time and help

viesti17:10:57

interesting, meanwhile, the exception was caused by an empty list of requires: https://github.com/portkey-cloud/portkey/blob/master/src/main/clojure/portkey/core.clj#L187

viesti17:10:06

don’t yet know how that happened, a guard for that case could prevent it but a cause for that would be neat to know

cgrand18:10:38

Maybe part of a recent change to Clojure

viesti18:10:31

yes, saw 1.9.0-beta1 as dependency but couldn’t reproduce myself just now, but might still be related

viesti17:10:29

somewhat warm feeling that it works for you though now 🙂

baptiste-from-paris17:10:49

I’d really love to understand what’s happening in portkey but I am really lost ^^

baptiste-from-paris17:10:18

by the way, I’ve seen that you plan to add POST support, any idea what are the challenges with the addition ?

viesti17:10:53

yesterday landed first version of mounting a ring handler into master with pk/mount-ring!, it takes a var for now, so you have to call (pk/mount-ring! #‘my-handler)

viesti17:10:02

this would cover POST support

viesti17:10:55

guess I could close related tickets, and make new one about making this into a macro like pk/mount!

baptiste-from-paris18:10:25

ok nice, let me try then 🙂

viesti18:10:06

one fix more, mount-ring! might now work again

baptiste-from-paris18:10:46

yes, was not mounting ^^

viesti18:10:07

worked for me, even tried out now 🙂

viesti18:10:42

yesterday ran into an issue with instaparse, used by compojure, haven’t solved it yet but at least POST requests can be made

baptiste-from-paris18:10:41

what means /{proxy+} in the path ?

baptiste-from-paris18:10:14

*in aws api gateway

baptiste-from-paris18:10:34

why is it usefull ?

viesti18:10:55

we grab all requests under that path and proxy them to the lambda

viesti18:10:52

api gateway can have also more specific routes, like the ones created with mount!, the proxy resource allows us to get a more “raw” request into the lambda

viesti18:10:21

so that api gateway is more like a reverse proxy sitting in front of the lambda

baptiste-from-paris18:10:30

ok thanks, so other routes created with mount! should be bypassed right ?

viesti18:10:36

api gateway matches to the most specific route, so one could have say /{proxy+} with ANY method and a /hello with GET method and /hello would match for a GET request but a POST to /hello would go to the proxy route

viesti18:10:57

not yet sure if portkey should make some decision regarding this, but right now on the path to just deploying and exposing functions 🙂

baptiste-from-paris18:10:48

that’s amazing what you’ve done !

viesti18:10:23

thank you 🙂

baptiste-from-paris19:10:23

ok, POST working great 🙂 ! trying to add middleware

viesti19:10:08

would be happy to hear how it progresses 🙂

baptiste-from-paris20:10:21

by the way, do you know if it’s possible to package a conf file ?

cgrand21:10:28

@baptiste-from-paris use the :keeps option (takes a list of classes or resources (as strings))

baptiste-from-paris21:10:02

@cgrand it’s only vars & classes that can be kepts right ? not random file from a resources folder for example

cgrand22:10:56

@baptiste-from-paris classes and resources; vars I don’t remember having to