Closed FuadEfendi closed 1 year ago
I probably misunderstood: are those templates to create function?
And also, which package contains RuntimeRequest and RuntimeResponse classes? Because Kotlin doesn't have it!
@FuadEfendi Yes, these are templates and are merged in with the open runtimes code when deployed: https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/java-18.0/src/main/java/io/openruntimes/java
I got it, Open Runtimes will run build.sh
script which will generate Wrapper.java class from Index.java template.
However, template (in this repository) contains bug, env
is not defined.
Docker Error: /usr/local/src/src/main/java/io/openruntimes/java/Wrapper.java:53: error: cannot find symbol
if (env == null
^
symbol: variable env
location: class Wrapper
So that instead of this one, I use https://github.com/open-runtimes/open-runtimes/blob/main/runtimes/java-11.0/example/Index.java
Also, RuntimeRequest & RuntimeResponse are here: https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/java-11.0/src/main/java/io/openruntimes/java
It is very strange to have build.sh
script whose only task is to use predefined hardcoded class and package name, and not allowing developers to ensure their code can be compiled and tested.
@FuadEfendi,
However, template (in this repository) contains bug, env is not defined.
Would you please give more info/context on this? Where exactly is the bug?
It is very strange to have build.sh script whose only task is to use predefined hardcoded class and package name,
I think this was mostly done to avoid requiring developers to add any additional dependencies. Do you have any other suggestion on how to improve this?
not allowing developers to ensure their code can be compiled and tested.
The best way to test is to run the code through open runtimes as instructed in the usage documentation for the respective runtime.
stnguyen90,
env
is undefined. It is HashMap? TreeMap? what is env
?
https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/java-11.0
I follow step by step tutorial to generate function and deploy it, I didn't change any code in provided autogenerated example function and it cannot be built.
Docker Error: /usr/local/src/src/main/java/io/openruntimes/java/Wrapper.java:53: error: cannot find symbol
if (env == null
^
symbol: variable env
location: class Wrapper
/usr/local/src/src/main/java/io/openruntimes/java/Wrapper.java:54: error: cannot find symbol
|| !env.containsKey("APPWRITE_FUNCTION_ENDPOINT")
^
symbol: variable env
location: class Wrapper
/usr/local/src/src/main/java/io/openruntimes/java/Wrapper.java:55: error: cannot find symbol
|| !env.containsKey("APPWRITE_FUNCTION_API_KEY")
^
symbol: variable env
location: class Wrapper
Note: /usr/local/src/src/main/java/io/openruntimes/java/RuntimeRequest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
errors
FAILURE: Build failed with an exception.
The best way to test is to run the code through open runtimes as instructed in the usage documentation for the respective runtime.
My function needs to read data from Postgre and load it to Appwrite in multithreaded environment and a lot of other things such as run AI at Google in-between, and my Gradle has more that 100 lines of code, and I am writing Unit and Integration tests too; there is no way to import RuntimeRequest / RuntimeResponse from Maven public repository, and dependency on org.rapidoid:rapidoid-http-server:5.5.5
is non-documented.
@FuadEfendi,
stnguyen90,
env
is undefined. It is HashMap? TreeMap? what isenv
? https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/java-11.0
I see what you mean about the type of the Variables. How about we use this issue to improve some of that documentation?
I follow step by step tutorial to generate function and deploy it, I didn't change any code in provided autogenerated example function and it cannot be built.
I think there's a typo in the readme you're using. Can you try this?
var variables = req.getVariables();
if (env == null
|| !env.containsKey("APPWRITE_FUNCTION_ENDPOINT")
|| !env.containsKey("APPWRITE_FUNCTION_API_KEY")
|| variables.get("APPWRITE_FUNCTION_ENDPOINT") == null
|| variables.get("APPWRITE_FUNCTION_API_KEY") == null) {
System.out.println("Environment variables are not set. Function cannot use Appwrite SDK.");
}
stnguyen90, variables
are defined, but where env
comes from?
My steps are very standard for newbies, and everything should work as prescribed, but it doesn't because of a bug in Java template:
Deploy fails; I know why, but newbies don't know yet ;)
I think simplest solution for complex use cases is to design standard Java application with dependency of io.appwrite:sdk-for-kotlin:1.1.0
and to forget about RuntimeRequest/RuntimeResponse; to deploy it as JAR (or to use source codes); and finally to plug it into template method call:
public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception {
// convert RuntimeRequest to MyRequest
MyResponse = (new MyApplication(MyReguest...).start();
// convert MyResponse to RuntimeResponse
I think I can also use precompiled published JAR in custom local repository and configure Gradle for this dependency; and OpenRuntimes has examples too which I need to try: https://github.com/open-runtimes/open-runtimes/blob/main/runtimes/java-11.0/README.md
stnguyen90, variables are defined, but where env comes from?
@FuadEfendi, ah I see what you mean now! This is what you're referring to:
This looks like a bug from when we changed req.env
to req.variables
! We can leave this issue to fix that bug then.
👟 Reproduction steps
Missing
public class Index {...}
👍 Expected behavior
public class Index {...}
👎 Actual Behavior
Missing
public class Index {...}
🎲 Appwrite version
Version 1.0.x
💻 Operating system
Linux
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?