Skip to content

Commit

Permalink
feat: add UpdateDeploy to DeployClient (#2836)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmakine authored Sep 26, 2024
1 parent d4bdbf5 commit ccac623
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions internal/buildengine/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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{}))
Expand Down
5 changes: 2 additions & 3 deletions internal/buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ccac623

Please sign in to comment.