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

noop job stream handler for adhoc flow #752

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 2 additions & 8 deletions server/neptune/adhoc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,7 @@ func NewServer(config *adhocconfig.Config) (*Server, error) {
"mode": "adhoc",
})

jobStore, err := job.NewStorageBackendStore(config.JobConfig, scope.SubScope("job.store"), config.CtxLogger)
if err != nil {
return nil, errors.Wrapf(err, "initializing job store")
}
receiverRegistry := job.NewReceiverRegistry()

jobStreamHandler := job.NewStreamHandler(jobStore, receiverRegistry, config.TerraformCfg.LogFilters, config.CtxLogger)
noopJobStreamHandler := &job.NoopStreamHandler{}

opts := &temporal.Options{
StatsReporter: statsReporter,
Expand Down Expand Up @@ -124,7 +118,7 @@ func NewServer(config *adhocconfig.Config) (*Server, error) {
config.ServerCfg.URL,
config.TemporalCfg.TerraformTaskQueue,
config.GithubCfg.TemporalAppInstallationID,
jobStreamHandler,
noopJobStreamHandler,
)
if err != nil {
return nil, errors.Wrap(err, "initializing terraform activities")
Expand Down
38 changes: 38 additions & 0 deletions server/neptune/temporalworker/job/noop_stream_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package job

import (
"context"
"sync"
)

type NoopStreamHandler struct {
wg sync.WaitGroup
}

func (n *NoopStreamHandler) RegisterJob(id string) chan string {
jobOutput := make(chan string)
n.wg.Add(1)
go func() {
defer n.wg.Done()
for line := range jobOutput {
n.handle(&OutputLine{
JobID: id,
Line: line,
})
}
}()

return jobOutput
}

func (n *NoopStreamHandler) CloseJob(ctx context.Context, jobID string) error {
return nil
}

func (n *NoopStreamHandler) CleanUp(ctx context.Context) error {
n.wg.Wait()
return nil
}

func (s *NoopStreamHandler) handle(_ *OutputLine) {
}
Loading