KhaninArtur commented on a change in pull request #16611:
URL: https://github.com/apache/beam/pull/16611#discussion_r798494136
##########
File path: playground/backend/internal/code_processing/code_processing.go
##########
@@ -406,6 +409,31 @@ func cancelCheck(ctx context.Context, pipelineId
uuid.UUID, cancelChannel chan b
}
}
+// readGraphFile reads graph from the file and keeps it to the cache.
+// If context is done it means that the code processing was finished
(successfully/with error/timeout).
+// Write graph to the cache if this in the file.
+// In other case each pauseDuration checks that graph file exists or not and
try to save it to the cache.
+func readGraphFile(pipelineLifeCycleCtx, backgroundCtx context.Context,
cacheService cache.Cache, graphFilePath string, pipelineId uuid.UUID) {
+ ticker := time.NewTicker(pauseDuration)
+ for {
+ select {
+ // waiting when graph file appears
+ case <-ticker.C:
+ if _, err := os.Stat(graphFilePath); err == nil {
+ ticker.Stop()
+ utils.ReadAndSetToCacheGraph(backgroundCtx,
cacheService, pipelineId, graphFilePath)
Review comment:
Shouldn't we check if `utils.ReadAndSetToCacheGraph` returns an error
and if so – don't stop the ticker? Or we may have such errors only if something
definitely went wrong and there is no need to check the graph file again?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]