Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build engine handles module interface changes with dependencies #4779

Merged
merged 7 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions backend/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,47 +278,58 @@ func (s *Service) GetSchema(ctx context.Context, c *connect.Request[ftlv1.GetSch
return connect.NewResponse(sch.Msg), nil
}

func (s *Service) ApplyChangeset(ctx context.Context, req *connect.Request[ftlv1.ApplyChangesetRequest]) (*connect.Response[ftlv1.ApplyChangesetResponse], error) {
func (s *Service) ApplyChangeset(ctx context.Context, req *connect.Request[ftlv1.ApplyChangesetRequest], stream *connect.ServerStream[ftlv1.ApplyChangesetResponse]) error {
events := s.source.Subscribe(ctx)
cs, err := s.schemaClient.CreateChangeset(ctx, connect.NewRequest(&ftlv1.CreateChangesetRequest{
Modules: req.Msg.Modules,
ToRemove: req.Msg.ToRemove,
}))
if err != nil {
return nil, fmt.Errorf("failed to create changeset: %w", err)
return fmt.Errorf("failed to create changeset: %w", err)
}
key, err := key.ParseChangesetKey(cs.Msg.Changeset)
if err != nil {
return nil, fmt.Errorf("failed to parse changeset key: %w", err)
return fmt.Errorf("failed to parse changeset key: %w", err)
}
changeset := &schemapb.Changeset{
Key: cs.Msg.Changeset,
Modules: req.Msg.Modules,
ToRemove: req.Msg.ToRemove,
}
if err := stream.Send(&ftlv1.ApplyChangesetResponse{
Changeset: changeset,
}); err != nil {
return fmt.Errorf("failed to send changeset: %w", err)
}
for e := range channels.IterContext(ctx, events) {
switch event := e.(type) {
case *schema.ChangesetFinalizedNotification:
if event.Key != key {
continue
}
return connect.NewResponse(&ftlv1.ApplyChangesetResponse{
if err := stream.Send(&ftlv1.ApplyChangesetResponse{
Changeset: changeset,
}), nil
}); err != nil {
return fmt.Errorf("failed to send changeset: %w", err)
}
return nil
case *schema.ChangesetFailedNotification:
if event.Key != key {
continue
}
return nil, fmt.Errorf("failed to apply changeset: %s", event.Error)
return fmt.Errorf("failed to apply changeset: %s", event.Error)
case *schema.ChangesetCommittedNotification:
if event.Changeset.Key != key {
continue
}
changeset = event.Changeset.ToProto()
// We don't wait for cleanup, just return immediately
return connect.NewResponse(&ftlv1.ApplyChangesetResponse{
if err := stream.Send(&ftlv1.ApplyChangesetResponse{
Changeset: changeset,
}), nil
}); err != nil {
return fmt.Errorf("failed to send changeset: %w", err)
}
return nil
case *schema.ChangesetRollingBackNotification:
if event.Changeset.Key != key {
continue
Expand All @@ -328,7 +339,7 @@ func (s *Service) ApplyChangeset(ctx context.Context, req *connect.Request[ftlv1

}
}
return nil, fmt.Errorf("failed to apply changeset: context cancelled")
return fmt.Errorf("failed to apply changeset: context cancelled")
}

func (s *Service) PullSchema(ctx context.Context, req *connect.Request[ftlv1.PullSchemaRequest], resp *connect.ServerStream[ftlv1.PullSchemaResponse]) error {
Expand Down
109 changes: 55 additions & 54 deletions backend/protos/xyz/block/ftl/v1/admin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/protos/xyz/block/ftl/v1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@

// Creates and applies a changeset, returning the result
// This blocks until the changeset has completed
rpc ApplyChangeset(ApplyChangesetRequest) returns (ApplyChangesetResponse);
rpc ApplyChangeset(ApplyChangesetRequest) returns (stream ApplyChangesetResponse);

Check failure on line 235 in backend/protos/xyz/block/ftl/v1/admin.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

RPC "ApplyChangeset" on service "AdminService" changed from server unary to server streaming.

// Get the full schema.
rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) {
Expand Down
14 changes: 7 additions & 7 deletions backend/protos/xyz/block/ftl/v1/ftlv1connect/admin.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading