#Expose the functions as http requests
6 messages · Page 1 of 1 (latest)
@torn vault what you're trying to achieve is possible via an undocumented feature called client generators. Here's an example on how to use it.
Supose you have the following Go Code.
func main() {
// I want to call a dagger fucntion here
}
what you can do to achieve this by using the hello module as an example is the following:
dagger install github.com/shykes/hello
dagger client install go # this actually generates the SDK code
Once you run that, you can go ahead and change your Go code as follows:
import (
"context"
"fmt"
"gotest/dagger/dag" // this will be your Go project's import.
)
func main() {
fmt.Println(dag.Hello().Hello(context.Background()))
}
^ as you can see, the client generators generated the dag.Hello function for me to call it automatically 🙏
here's the PR which added this capability: https://github.com/dagger/dagger/pull/9531
Thank you so much, I will try
Other question, do you know if I could just return telemetry url and not wait the complete executation?
yes, you can get the cloud URL by calling dag.CloudURL():
func main() {
ctx := context.Background()
fmt.Println(dag.Cloud().TraceURL(context.Background()))
fmt.Println(dag.Hello().Hello(ctx))
defer dag.Close()
}
hey guys
I'm kind of building the same thing but using the python sdk (Im fine switching to go tho)
So the tdlr is I built an agentic workflow (yes, I know, everybody doing it) usfor each stageing dagger functions (context, coding, testing, etc) but I couldn't find a way to call it other than through the dagger cli, shell
I read the docs, asked the LLMs, couldn't find a way of getting to work where dagger is sitting still and I can call the functions other than cli/shell