when I do bb hl:compile I get
[holy-lambda] PATH .holy-lambda/build/output.jar does not exists.. Exiting!hello again, yesterday I was so tired I was wrong that it had worked. I'd put a hack in my code to alter-var-root the autogenerated -main to invoke it with my handler name regardless of the args to -main so that I could proceed, but forgot to remove it when I tested it after following your advice to change settings in template.json.
When I retried today it still doesn't receive the correct handler name to lookup a handler in -main and nothing I change in template.json seems to make any difference.
Would you mind checking it please ? https://pastebin.com/kt787ms1
What runtime do you use? Is it native or Clojure one backed with Docker.
It seems it’s docker based, right?
Hope you are also using the -t parameter with SAM to specify the alternative template.json.
Clojure one backed with Docker
sam build uses template.json if it exists and converts it to .aws-sam/build/template.yaml
https://cljdoc.org/d/io.github.FieryCod/holy-lambda/0.6.7/doc/clojure-backend
Have you read this?
yes that's the example I'm following
I think I could solve my problem if I knew where the args for -main come from
ok the answer is it comes from Dockerfile , the line:
CMD java -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -jar output.jar "org.me.mynamespace.MyHandlerFn"the fully qualified function name at the end of that line is what is received by HL generated -main which is then used via lookup in the map PRVL_ROUTES to invoke your function when you test it with sam local invoke
Yes.
two of my life goals were to never need to use NPM or Docker, and I have failed at both
(I don't know anything about Docker)
Are you sure you running bb hl:compile and not bb hl:executable?
yes
Do you mind sharing a reproduction?
it's the same as the example given in the Getting Started guide but with my.namespace instead of basic.example
I'm copying the built jar over to .holy-lambda/build/output.jar in my build.clj instead until I find out why
I'm also getting this error when I test it with sam local invoke MyHandler
[holy-lambda] Runtime error:
{:via [{:type java.lang.Exception, :message "[holy-lambda]: Handler my.lambda not found!", :at [fierycod.holy_lambda.custom_runtime$next_iter invokeStatic "custom_runtime.clj" 76]}],I know it loads my namespace because I put a println in. It looks like it's to do with the routing via the generated -main
when doing sam local invoke MyHandler , what should I expect to be passed into -main ? because currently it gets the namespace of the -main function, not the Entrypoint of the template
a look at PRVL_ROUTES shows that it should be receiving the fully qualified handler name e.g. as that's the key in the map, but it only receives the namespace
Could you kindly show me your code?
sorry I can't
What is the entrypoint in your namespace?
I've tried everything for the entrypoint!
it doesn't seem to be used
Sam local invoke sends nothing by default.
ohhhh
well how do I simulate a request to my handler then ?
Is it an API?
yes
sam local start-api
ok I'll try that
meanwhile can I confirm that I can use a template.json instead of template.yaml for sam build ? because I don't want to use yaml
I can see that when I do sam build it generates .aws-sam/build/template.yaml which is the same as my template.json
(with sam local start-api I get the same :message "[holy-lambda]: Handler my.namespace not found!" error
What are you trying to achieve by sending the namespace to the entrypoint?
It should be qualified var.
Like: #’my.namespace/some-function
Not sure about sam build part, but you can use any deployment tool you want.
"What are you trying to achieve by sending the namespace to the entrypoint?"
I'm not! that's what my the generated -main of the namespace of my handler is receiving
what I'd like to know is where do the args to -main come from when I do sam local invoke Handler ?
Okay, then your template.yml is wrong.
Can you at least show me the definition of your handler in template.yml?
Main arguments most likely are not used in your case. All lambda environments can obtain the handler name from „_HANDLER” environment variable.
Handler: my.namespace.lambda/MyHandler
Thus when you are doing sam local Invoke SomeFunction there needs to be mapping between the function and the function in some Clojure namespace.
yes I know that the PRVL_ROUTES is correct because it's a map between the fully qualified name of my handler and its corresponding fully qualified var
Okay, handler name is wrong.
but the args received by -main is just the namespace of that -main and the handler function
It has to be: my.namespace.lambda.MyHandler
hehehe I'm sure I've tried that but let me try it again...
it works
😉
Cool!
I'm tired I probably messed something else up then
No worries mate! Happens to everyone ;)
I think what would help is a few comments in the example files to clarify what each entry should be
I'm also wondering whether the template.json could be at least partially auto-generated
anyway I'm new to this so thanks for all your help!