Skip to content

Commit

Permalink
fix: include changesets in GetSchema (#4717)
Browse files Browse the repository at this point in the history
fixes: #4702
  • Loading branch information
stuartwdouglas authored Feb 28, 2025
1 parent bc24625 commit 51479c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/schemaservice/schemaservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"errors"
"fmt"
"maps"
"net/url"
"os/signal"
gslices "slices"
"syscall"
"time"

"connectrpc.com/connect"
"golang.org/x/exp/maps"
"golang.org/x/sync/errgroup"

ftlv1 "github.com/block/ftl/backend/protos/xyz/block/ftl/v1"
Expand Down Expand Up @@ -120,7 +121,8 @@ func (s *Service) GetSchema(ctx context.Context, c *connect.Request[ftlv1.GetSch
schema.Builtins().ToProto(),
}
modules = append(modules, slices.Map(schemas, func(d *schema.Module) *schemapb.Module { return d.ToProto() })...)
return connect.NewResponse(&ftlv1.GetSchemaResponse{Schema: &schemapb.Schema{Modules: modules}}), nil
changesets := slices.Map(gslices.Collect(maps.Values(view.GetChangesets())), func(c *schema.Changeset) *schemapb.Changeset { return c.ToProto() })
return connect.NewResponse(&ftlv1.GetSchemaResponse{Schema: &schemapb.Schema{Modules: modules}, Changesets: changesets}), nil
}

func (s *Service) PullSchema(ctx context.Context, req *connect.Request[ftlv1.PullSchemaRequest], stream *connect.ServerStream[ftlv1.PullSchemaResponse]) error {
Expand Down Expand Up @@ -329,11 +331,11 @@ func (s *Service) watchModuleChanges(ctx context.Context, subscriptionID string,
}

modules := append([]*schema.Module{}, schema.Builtins())
modules = append(modules, maps.Values(view.GetCanonicalDeployments())...)
modules = append(modules, gslices.Collect(maps.Values(view.GetCanonicalDeployments()))...)

notification := &schema.FullSchemaNotification{
Schema: &schema.Schema{Modules: modules},
Changesets: maps.Values(view.GetChangesets()),
Changesets: gslices.Collect(maps.Values(view.GetChangesets())),
}
err = sendChange(&ftlv1.PullSchemaResponse{
Event: &schemapb.Notification{Value: &schemapb.Notification_FullSchemaNotification{notification.ToProto()}},
Expand Down

0 comments on commit 51479c4

Please sign in to comment.