hello all 🙂
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
Just to be sure, it should return a string right ?
because I have this error
{
errorMessage: "Error loading class portkey.LambdaStub",
errorType: "java.lang.ExceptionInInitializerError"
}
with this code
(defn welcome [] "Hello world !")
(pk/mount! welcome "/welcome")
@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 ?
lein => yes lein install
then
(defproject port "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "<http://example.com/FIXME>"
:license {:name "Eclipse Public License"
:url "<http://www.eclipse.org/legal/epl-v10.html>"}
: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}})
I just generated a lein new app
looks a bit different to what I ran into, what does the stack trace look like?
ok, so that’s the route => https://pywts6bswb.execute-api.eu-west-1.amazonaws.com/repl/woo
and let me find the stacktrace, 1min
thinking about global leiningen profile in my case now
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
Where do you get the exception? Locally or in AWS?
aws
no exceptions/errors locally
Oh I see an interesting line: require complaining to be called with no args. Would you mind opening an issue? Merci
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.
ok, will do tonight
apparently I had introduced one breakage at least, which is probably unrelated
should start working on test on the AWS code to run actual deploys in CircleCI
thank’s for your time and help
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
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
somewhat warm feeling that it works for you though now 🙂
I’d really love to understand what’s happening in portkey but I am really lost ^^
by the way, I’ve seen that you plan to add POST support, any idea what are the challenges with the addition ?
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)
this would cover POST support
guess I could close related tickets, and make new one about making this into a macro like pk/mount!
ok nice, let me try then 🙂
yes, saw 1.9.0-beta1 as dependency but couldn’t reproduce myself just now, but might still be related
one fix more, mount-ring! might now work again
yes, was not mounting ^^
worked for me, even tried out now 🙂
yesterday ran into an issue with instaparse, used by compojure, haven’t solved it yet but at least POST requests can be made
what means /{proxy+}
in the path ?
*in aws api gateway
it’s a swagger path template (https://swagger.io/specification/#pathTemplating), with a greedy variable (http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html#api-gateway-set-up-lambda-proxy-integration-on-proxy-resource), meaning that matches everything after /
and binds the match to variable named proxy
ok, thanks
why is it usefull ?
we grab all requests under that path and proxy them to the lambda
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
ok
so that api gateway is more like a reverse proxy sitting in front of the lambda
ok thanks, so other routes created with mount!
should be bypassed right ?
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
ok thanks !
not yet sure if portkey should make some decision regarding this, but right now on the path to just deploying and exposing functions 🙂
that’s amazing what you’ve done !
thank you 🙂
ok, POST working great 🙂 ! trying to add middleware
would be happy to hear how it progresses 🙂
by the way, do you know if it’s possible to package a conf file ?
@baptiste-from-paris use the :keeps
option (takes a list of classes or resources (as strings))
nice !
thx
@cgrand it’s only vars & classes that can be kepts right ? not random file from a resources folder for example
@baptiste-from-paris classes and resources; vars I don’t remember having to