-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e14b3eb
commit a9a80aa
Showing
3 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package executor | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/kubeshop/tracetest/server/model/events" | ||
) | ||
|
||
type tracePollerStartWorker struct { | ||
eventEmitter EventEmitter | ||
outputQueue Enqueuer | ||
} | ||
|
||
func NewTracePollerStartWorker( | ||
eventEmitter EventEmitter, | ||
) *tracePollerStartWorker { | ||
return &tracePollerStartWorker{ | ||
eventEmitter: eventEmitter, | ||
} | ||
} | ||
|
||
func (w *tracePollerStartWorker) SetOutputQueue(queue Enqueuer) { | ||
w.outputQueue = queue | ||
} | ||
|
||
func (w *tracePollerStartWorker) ProcessItem(ctx context.Context, job Job) { | ||
if w.isFirstRequest(job) { | ||
err := w.eventEmitter.Emit(ctx, events.TraceFetchingStart(job.Test.ID, job.Run.ID)) | ||
if err != nil { | ||
log.Printf("[TracePoller] Test %s Run %d: fail to emit TracePollingStart event: %s", job.Test.ID, job.Run.ID, err.Error()) | ||
} | ||
} | ||
|
||
log.Println("[TracePoller] processJob", job.EnqueueCount()) | ||
|
||
// TODO: check if there is more "pre-processing" things to do here | ||
|
||
w.outputQueue.Enqueue(ctx, job) | ||
} | ||
|
||
func (w *tracePollerStartWorker) isFirstRequest(job Job) bool { | ||
return job.EnqueueCount() == 0 | ||
} |