Skip to content

Commit

Permalink
chore: serve timeline service and dial client (#3640)
Browse files Browse the repository at this point in the history
We will also need to do this for other services that need to call
timeline later.
  • Loading branch information
matt2e authored Dec 5, 2024
1 parent db7ca30 commit 25ee4ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions frontend/cli/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
"github.com/TBD54566975/ftl/backend/provisioner"
"github.com/TBD54566975/ftl/backend/provisioner/scaling/localscaling"
"github.com/TBD54566975/ftl/backend/timeline"
"github.com/TBD54566975/ftl/internal/bind"
"github.com/TBD54566975/ftl/internal/configuration"
"github.com/TBD54566975/ftl/internal/configuration/manager"
Expand Down Expand Up @@ -62,6 +63,7 @@ type serveCommonConfig struct {
GrafanaImage string `help:"The container image to start for the automatic Grafana instance" default:"grafana/otel-lgtm" env:"FTL_GRAFANA_IMAGE" hidden:""`
DisableGrafana bool `help:"Disable the automatic Grafana that is started if no telemetry collector is specified." default:"false"`
Ingress ingress.Config `embed:"" prefix:"ingress-"`
Timeline timeline.Config `embed:"" prefix:"timeline-"`
Recreate bool `help:"Recreate any stateful resources if they already exist." default:"false"`
controller.CommonConfig
provisioner.CommonProvisionerConfig
Expand Down Expand Up @@ -302,6 +304,14 @@ func (s *serveCommonConfig) run(
})
}

// Start Timeline
wg.Go(func() error {
err := timeline.Start(ctx, s.Timeline, schemaEventSourceFactory())
if err != nil {
return fmt.Errorf("timeline failed: %w", err)
}
return nil
})
// Start Cron
wg.Go(func() error {
err := cron.Start(ctx, schemaEventSourceFactory(), verbClient)
Expand Down
6 changes: 6 additions & 0 deletions frontend/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/TBD54566975/ftl"
"github.com/TBD54566975/ftl/backend/controller/admin"
provisionerconnect "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/provisioner/v1beta1/provisionerpbconnect"
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/timeline/v1/timelinev1connect"
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
"github.com/TBD54566975/ftl/internal"
_ "github.com/TBD54566975/ftl/internal/automaxprocs" // Set GOMAXPROCS to match Linux container CPU quota.
Expand All @@ -39,6 +40,7 @@ type InteractiveCLI struct {
Version kong.VersionFlag `help:"Show version."`
Endpoint *url.URL `default:"http://127.0.0.1:8892" help:"FTL endpoint to bind/connect to." env:"FTL_ENDPOINT"`
ProvisionerEndpoint *url.URL `help:"Provisioner endpoint." env:"FTL_PROVISIONER_ENDPOINT" default:"http://127.0.0.1:8893"`
TimelineEndpoint *url.URL `help:"Timeline endpoint." env:"FTL_TIMELINE_ENDPOINT" default:"http://127.0.0.1:8894"`

Ping pingCmd `cmd:"" help:"Ping the FTL cluster."`
Status statusCmd `cmd:"" help:"Show FTL status."`
Expand Down Expand Up @@ -231,6 +233,10 @@ func makeBindContext(logger *log.Logger, cancel context.CancelFunc) terminal.Kon
ctx = rpc.ContextWithClient(ctx, provisionerServiceClient)
kctx.BindTo(provisionerServiceClient, (*provisionerconnect.ProvisionerServiceClient)(nil))

timelineServiceClient := rpc.Dial(timelinev1connect.NewTimelineServiceClient, cli.TimelineEndpoint.String(), log.Error)
ctx = rpc.ContextWithClient(ctx, timelineServiceClient)
kctx.BindTo(timelineServiceClient, (*timelinev1connect.TimelineServiceClient)(nil))

err = kctx.BindToProvider(func() (*providers.Registry[configuration.Configuration], error) {
return providers.NewDefaultConfigRegistry(), nil
})
Expand Down

0 comments on commit 25ee4ef

Please sign in to comment.