Skip to content

Commit

Permalink
ftl call suggests verbs if no match found
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-chiorean committed May 17, 2024
1 parent dce2ea4 commit 87de5cc
Show file tree
Hide file tree
Showing 10 changed files with 1,040 additions and 721 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ This guide is for you.

## Development Prerequisites

We recommend that you use OrbStack instead of Docker desktop when developing on this project:
```
brew install orbstack
```
or [OrbStack Website](https://orbstack.dev/)

The tools used by this project are managed by
[Hermit](https://cashapp.github.io/hermit/), a self-bootstrapping package
installer. To activate the Hermit environment, cd into the source directory and
Expand Down
34 changes: 34 additions & 0 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1481,3 +1481,37 @@ func makeBackoff(min, max time.Duration) backoff.Backoff {
Factor: 2,
}
}

func (c *Service) GetVerbs(ctx context.Context, req *connect.Request[ftlv1.VerbsRequest]) (*connect.Response[ftlv1.VerbsResponse], error) {
logger := log.FromContext(ctx)
deployments, err := c.dal.GetDeploymentsWithMinReplicas(ctx)
if err != nil {
logger.Errorf(err, "Failed to get deployments")
return nil, err
}
sch := &schema.Schema{
Modules: slices.Map(deployments, func(d dal.Deployment) *schema.Module {
return d.Schema
}),
}
sch.Modules = append(sch.Modules, schema.Builtins())

// map verbs by module name so we can search them
moduVerbs := []string{}
for _, deployment := range deployments {
for _, decl := range deployment.Schema.Decls {
switch decl := decl.(type) {
case *schema.Verb:
//nolint:forcetypeassert
v := decl.ToProto().(*schemapb.Verb)
moduVerbs = append(moduVerbs, fmt.Sprintf("%s.%s", deployment.Module, v.Name))
}
}
}

return connect.NewResponse(
&ftlv1.VerbsResponse{
Verbs: moduVerbs,
},
), nil
}
Loading

0 comments on commit 87de5cc

Please sign in to comment.