MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / exec

Function exec

cmd/client/create/cmd.go:62–98  ·  view source on GitHub ↗
(_ *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

60}
61
62func exec(_ *cobra.Command, _ []string) {
63 cfg := adminclient.NewConfiguration()
64 cfg.Servers = []adminclient.ServerConfiguration{{
65 URL: common.Config.ServiceAddr,
66 }}
67 cli := adminclient.NewAPIClient(cfg)
68 f := adminclient.ModelFunction{
69 Name: config.name,
70 Runtime: adminclient.ModelRuntimeConfig{
71 Type: fs_cmmon.WASMRuntime,
72 Config: map[string]interface{}{
73 fs_cmmon.RuntimeArchiveConfigKey: config.archive,
74 }},
75 Source: utils.MakeMemorySourceTubeConfig(config.inputs...),
76 Sink: *utils.MakeMemorySinkTubeConfig(config.output),
77 Replicas: config.replica,
78 }
79
80 res, err := cli.FunctionAPI.CreateFunction(context.Background()).Body(f).Execute()
81 if err != nil {
82 if res != nil {
83 body, e := io.ReadAll(res.Body)
84 if e != nil {
85 fmt.Printf("Failed to create function: %v\n", err)
86 } else {
87 fmt.Printf("Failed to create function: %v, %s\n", err, string(body))
88 }
89 } else {
90 fmt.Printf("Failed to create function: %v\n", err)
91 }
92 os.Exit(1)
93 }
94 if res.StatusCode != 200 {
95 fmt.Printf("Failed to create function with status code: %d\n", res.StatusCode)
96 os.Exit(1)
97 }
98}

Callers

nothing calls this directly

Calls 5

MakeMemorySinkTubeConfigFunction · 0.92
CreateFunctionMethod · 0.80
ExecuteMethod · 0.45
BodyMethod · 0.45

Tested by

no test coverage detected