lagon icon indicating copy to clipboard operation
lagon copied to clipboard

Way to call commands programmatically?

Open tompeace opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. I’d like to build some workers into an app of my own written in JS, is there a way to import Lagon and call these functions for eg. from a job queue?

Describe the solution you'd like Being able to do something like this

import { deploy } from “lagon”
const myCode = “….”
const myFunction = deploy(myCode)
const result = await fetch(myFunction.endpoint)

A problem I may see is my app and lagon might not share the same process? Also that the cli is written in rust?

tompeace avatar Nov 16 '22 11:11 tompeace

You can't import Lagon from Node, as both the CLI and Runtime are written in Rust and we don't yet provide a binding.

The easiest option might be to execute the CLI (lagon deploy <file>), but not that I wouldn't recommend using Lagon for any applications right now. It's still in heavy development, and features, documentation, and performances are missing.

QuiiBz avatar Nov 16 '22 19:11 QuiiBz

What would providing the bindings look like do you think? I hear a lot of talk of napi vs wasm - eg from which I’m deducing n-api would be best suited here?

tompeace avatar Nov 16 '22 23:11 tompeace

I think the best option would be to use napi-rs. It's already used by big projects and works for every latest Node.js version.

QuiiBz avatar Nov 17 '22 07:11 QuiiBz