[ https://issues.apache.org/jira/browse/BEAM-13124?focusedWorklogId=700482&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-700482 ]
ASF GitHub Bot logged work on BEAM-13124: ----------------------------------------- Author: ASF GitHub Bot Created on: 23/Dec/21 10:13 Start Date: 23/Dec/21 10:13 Worklog Time Spent: 10m Work Description: daria-malkova commented on a change in pull request #16277: URL: https://github.com/apache/beam/pull/16277#discussion_r774460653 ########## File path: playground/backend/internal/environment/beam.go ########## @@ -42,17 +42,23 @@ func NewExecutorConfig(compileCmd, runCmd, testCmd string, compileArgs, runArgs, // BeamEnvs contains all environments related of ApacheBeam. These will use to run pipelines type BeamEnvs struct { - ApacheBeamSdk pb.Sdk - ExecutorConfig *ExecutorConfig - preparedModDir string + ApacheBeamSdk pb.Sdk + ExecutorConfig *ExecutorConfig + preparedModDir string + numOfParallelJobs int } // NewBeamEnvs is a BeamEnvs constructor -func NewBeamEnvs(apacheBeamSdk pb.Sdk, executorConfig *ExecutorConfig, preparedModDir string) *BeamEnvs { - return &BeamEnvs{ApacheBeamSdk: apacheBeamSdk, ExecutorConfig: executorConfig, preparedModDir: preparedModDir} +func NewBeamEnvs(apacheBeamSdk pb.Sdk, executorConfig *ExecutorConfig, preparedModDir string, numOfParallelJobs int) *BeamEnvs { + return &BeamEnvs{ApacheBeamSdk: apacheBeamSdk, ExecutorConfig: executorConfig, preparedModDir: preparedModDir, numOfParallelJobs: numOfParallelJobs} } // PreparedModDir returns the path to the directory where prepared go.mod and go.sum are located func (b *BeamEnvs) PreparedModDir() string { return b.preparedModDir } + +// NumOfParallelJobs returns the max number of the possible code processing for the SDK on that instance at the same time Review comment: // NumOfParallelJobs returns the max number of the possible code executions on the instance simultaneously. ########## File path: playground/backend/internal/utils/system_utils.go ########## @@ -16,14 +16,59 @@ package utils import ( + "beam.apache.org/playground/backend/internal/environment" + "beam.apache.org/playground/backend/internal/logger" + "net/http" + "os" + "path/filepath" "reflect" "runtime" "strings" ) +const ( + executableFiles = "executable_files" Review comment: Don't we already have this constant somewhere? ########## File path: playground/backend/internal/utils/system_utils.go ########## @@ -16,14 +16,59 @@ package utils import ( + "beam.apache.org/playground/backend/internal/environment" + "beam.apache.org/playground/backend/internal/logger" + "net/http" + "os" + "path/filepath" "reflect" "runtime" "strings" ) +const ( + executableFiles = "executable_files" +) + // GetFuncName returns the name of the received func func GetFuncName(i interface{}) string { fullName := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() splitName := strings.Split(fullName, ".") return splitName[len(splitName)-1] } + +// GetReadinessFunction returns the function that checks the readiness of the server to process a new code processing request +func GetReadinessFunction(envs *environment.Environment) func(writer http.ResponseWriter, request *http.Request) { + return func(writer http.ResponseWriter, request *http.Request) { + if checkNumOfTheParallelJobs(envs.ApplicationEnvs.WorkingDir(), envs.BeamSdkEnvs.NumOfParallelJobs()) { + writer.WriteHeader(http.StatusOK) + } else { + writer.WriteHeader(http.StatusLocked) + } + } +} + +// checkNumOfTheParallelJobs checks the number of already working code processing. Review comment: of already -> of currently code processing -> code executions -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 700482) Time Spent: 2h 50m (was: 2h 40m) > [Playground] Create readiness endpoint > -------------------------------------- > > Key: BEAM-13124 > URL: https://issues.apache.org/jira/browse/BEAM-13124 > Project: Beam > Issue Type: New Feature > Components: beam-playground > Reporter: Artur Khanin > Assignee: Aydar Zaynutdinov > Priority: P3 > Labels: beam-playground-backend, beam-playground-beta-launch, > beam-playground-sprint-5 > Time Spent: 2h 50m > Remaining Estimate: 0h > > Need to add a new endpoint to check the instance's readiness. If the instance > is ready to receive one more code to process it this endpoint should return > status 200, in another case, it returns some error status (423 for example). -- This message was sent by Atlassian Jira (v8.20.1#820001)