Skip to content

Commit

Permalink
fix: speed up pubsub provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Jan 7, 2025
1 parent 00df8ac commit 4a9bdfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (s *Service) deploy(ctx context.Context, key model.DeploymentKey, module *s
pubSub, err := pubsub.New(module, key, s, s.timelineClient)
if err != nil {
observability.Deployment.Failure(ctx, optional.Some(key.String()))
return fmt.Errorf("failed to create pubsub service: %w", err)
return fmt.Errorf("failed to set up pubsub: %w", err)
}
s.pubSub = pubSub

Expand Down
12 changes: 12 additions & 0 deletions internal/dev/redpanda.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
_ "embed"
"fmt"
"os"
"sync"

"github.com/alecthomas/types/optional"

Expand All @@ -14,7 +15,17 @@ import (
//go:embed docker-compose.redpanda.yml
var redpandaDockerCompose string

// use this lock while checking redPandaRunning status and running `docker compose up` if needed
var redPandaLock *sync.Mutex = &sync.Mutex{}

Check warning on line 19 in internal/dev/redpanda.go

View workflow job for this annotation

GitHub Actions / Lint

var-declaration: should omit type *sync.Mutex from declaration of var redPandaLock; it will be inferred from the right-hand side (revive)
var redPandaRunning bool

func SetUpRedPanda(ctx context.Context) error {
redPandaLock.Lock()
defer redPandaLock.Unlock()

if redPandaRunning {
return nil
}
var profile optional.Option[string]
if _, ci := os.LookupEnv("CI"); !ci {
// include console except in CI
Expand All @@ -24,5 +35,6 @@ func SetUpRedPanda(ctx context.Context) error {
if err != nil {
return fmt.Errorf("could not start redpanda: %w", err)
}
redPandaRunning = true
return nil
}

0 comments on commit 4a9bdfc

Please sign in to comment.