From ccac6231308283dcdfb83da175d6ee1d9953b66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20M=C3=A4kinen?= Date: Thu, 26 Sep 2024 16:43:41 +1000 Subject: [PATCH] feat: add UpdateDeploy to DeployClient (#2836) --- internal/buildengine/deploy.go | 7 +++++-- internal/buildengine/engine.go | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/buildengine/deploy.go b/internal/buildengine/deploy.go index d4a33df95c..29911fb4dd 100644 --- a/internal/buildengine/deploy.go +++ b/internal/buildengine/deploy.go @@ -13,7 +13,6 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1" - "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect" schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" "github.com/TBD54566975/ftl/internal/log" "github.com/TBD54566975/ftl/internal/moduleconfig" @@ -32,6 +31,10 @@ type DeployClient interface { CreateDeployment(ctx context.Context, req *connect.Request[ftlv1.CreateDeploymentRequest]) (*connect.Response[ftlv1.CreateDeploymentResponse], error) ReplaceDeploy(ctx context.Context, req *connect.Request[ftlv1.ReplaceDeployRequest]) (*connect.Response[ftlv1.ReplaceDeployResponse], error) Status(ctx context.Context, req *connect.Request[ftlv1.StatusRequest]) (*connect.Response[ftlv1.StatusResponse], error) + UpdateDeploy(ctx context.Context, req *connect.Request[ftlv1.UpdateDeployRequest]) (*connect.Response[ftlv1.UpdateDeployResponse], error) + GetSchema(ctx context.Context, req *connect.Request[ftlv1.GetSchemaRequest]) (*connect.Response[ftlv1.GetSchemaResponse], error) + PullSchema(ctx context.Context, req *connect.Request[ftlv1.PullSchemaRequest]) (*connect.ServerStreamForClient[ftlv1.PullSchemaResponse], error) + Ping(ctx context.Context, req *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error) } // Deploy a module to the FTL controller with the given number of replicas. Optionally wait for the deployment to become ready. @@ -106,7 +109,7 @@ func Deploy(ctx context.Context, module Module, replicas int32, waitForDeployOnl return nil } -func terminateModuleDeployment(ctx context.Context, client ftlv1connect.ControllerServiceClient, module string) error { +func terminateModuleDeployment(ctx context.Context, client DeployClient, module string) error { logger := log.FromContext(ctx).Module(module).Scope("terminate") status, err := client.Status(ctx, connect.NewRequest(&ftlv1.StatusRequest{})) diff --git a/internal/buildengine/engine.go b/internal/buildengine/engine.go index d164b38f8b..1a5b152e3b 100644 --- a/internal/buildengine/engine.go +++ b/internal/buildengine/engine.go @@ -20,7 +20,6 @@ import ( "golang.org/x/sync/errgroup" ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1" - "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect" "github.com/TBD54566975/ftl/backend/schema" "github.com/TBD54566975/ftl/internal/log" "github.com/TBD54566975/ftl/internal/moduleconfig" @@ -66,7 +65,7 @@ type Listener interface { // Engine for building a set of modules. type Engine struct { - client ftlv1connect.ControllerServiceClient + client DeployClient moduleMetas *xsync.MapOf[string, moduleMeta] projectRoot string moduleDirs []string @@ -124,7 +123,7 @@ func WithStartTime(startTime time.Time) Option { // pull in missing schemas. // // "dirs" are directories to scan for local modules. -func New(ctx context.Context, client ftlv1connect.ControllerServiceClient, projectRoot string, moduleDirs []string, options ...Option) (*Engine, error) { +func New(ctx context.Context, client DeployClient, projectRoot string, moduleDirs []string, options ...Option) (*Engine, error) { ctx = rpc.ContextWithClient(ctx, client) e := &Engine{ client: client,