Hi everyone,
My server logic requires some functionality that’s not easily available with the given runtimes (lua, go and typescript), so I’m thinking of setting it up as a microservice that runs along with the server, and the server sends requests to it by HTTP and retrieves the results.
My questions:
- Is it possible to send HTTP requests from the typescript runtime? As far as I see, es5 doesn’t support http requests or importing/exporting modules.
- I know that the Go language can be used to issue HTTP requests, but I saw on this page (Go Runtime - Heroic Labs Documentation) that we’re not supposed to use goroutines in our runtime so I’m wondering how that will work.
Could you advise?
Hello @jorgedegoozman
-
Yes, we provide an http request function in the JS runtime.
-
What the docs are trying to convey (a bit poorly) is that the use of goroutines to do things like background job scheduling or types of workloads that are outside the regular req/res flow should take into consideration that if you’re planning on using Heroic Cloud and scale out to a multi-node environment can potentially cause issues. Otherwise, the use of goroutines in custom code where it makes sense is generally ok.
Can you provide a bit more detail on what functionality would need to live on this separate microservice, and why you’d need goroutines for issuing the http requests if you’d be using the Go runtime?
Best.
Hello! Thanks for the tip - I’ll give http request a try.
Nevermind me thinking that I’d need goroutines for issuing http requests. I’m not actually experienced with Go, I just thought that I might switch to it if it provides me with the necessary functionality, and this is the impression I had.
As for the functionality that I need - I just feel like the es5 environment for the javascript runtime is limiting. I tried using await/async, import/export, fetch, etc.. and found that they didn’t exist in es5. I also need to be able to use some third-party functionality libraries that I tried using with the nakama runtime, but had lots of issues (can’t use async/await, can’t import, or they simply don’t work in the sandbox, probably because they depend on the node.js environment). I know that we can use rollup/babel to compile modern javascript down to es5 and I did that, but I tried using “fetch” inside one of the Nakama rpcs and it kept telling me fetch isn’t defined, so I gave up.
I may be (probably am) wrong, though.