diff --git a/pipeline_api/pipeline_api.go b/pipeline_api/pipeline_api.go index 32a4727..ccd864e 100644 --- a/pipeline_api/pipeline_api.go +++ b/pipeline_api/pipeline_api.go @@ -56,6 +56,12 @@ func (s *ApiServer) GetRunnerFromMap(u uuid.UUID) (*RunnerWrapper, bool) { return runner, ok } +func (s *ApiServer) AddRunnerToMap(u uuid.UUID, runner *runnermanager.Runner) { + s.allocatedRunnersMutex.Lock() + defer s.allocatedRunnersMutex.Unlock() + s.allocatedRunners[u] = &RunnerWrapper{runner: runner} +} + func (s *ApiServer) GetRunner( ctx context.Context, req *connect.Request[apiv2.GetRunnerRequest], @@ -114,9 +120,7 @@ func (s *ApiServer) GetRunner( runnerUuid := uuid.New() - s.allocatedRunnersMutex.Lock() - s.allocatedRunners[runnerUuid] = &RunnerWrapper{runner: response.Runner} - s.allocatedRunnersMutex.Unlock() + s.AddRunnerToMap(runnerUuid, response.Runner) res := connect.NewResponse(&apiv2.GetRunnerResponse{ Id: runnerUuid.String(),