From 48ca73f55032f0062980070e61c9658b06d1e5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 29 Jul 2022 14:26:48 +0200 Subject: [PATCH] Refactor, manager: rename `compilerForJobType` to `compilerVMForJobType` The function returns a `*VM`, which contains a compiler, and allows you to run a compiler, but is not a compiler itself. --- internal/manager/job_compilers/job_compilers.go | 6 +++--- internal/manager/job_compilers/scripts.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/manager/job_compilers/job_compilers.go b/internal/manager/job_compilers/job_compilers.go index 5ba76b5e..9ed335d5 100644 --- a/internal/manager/job_compilers/job_compilers.go +++ b/internal/manager/job_compilers/job_compilers.go @@ -86,7 +86,7 @@ func Load(ts TimeService) (*Service, error) { } func (s *Service) Compile(ctx context.Context, sj api.SubmittedJob) (*AuthoredJob, error) { - vm, err := s.compilerForJobType(sj.Type) + vm, err := s.compilerVMForJobType(sj.Type) if err != nil { return nil, err } @@ -140,7 +140,7 @@ func (s *Service) ListJobTypes() api.AvailableJobTypes { defer s.mutex.Unlock() for typeName := range s.compilers { - compiler, err := s.compilerForJobType(typeName) + compiler, err := s.compilerVMForJobType(typeName) if err != nil { log.Warn().Err(err).Str("jobType", typeName).Msg("unable to determine job type settings") continue @@ -163,7 +163,7 @@ func (s *Service) ListJobTypes() api.AvailableJobTypes { // GetJobType returns information about the named job type. // Returns ErrJobTypeUnknown when the name doesn't correspond with a known job type. func (s *Service) GetJobType(typeName string) (api.AvailableJobType, error) { - compiler, err := s.compilerForJobType(typeName) + compiler, err := s.compilerVMForJobType(typeName) if err != nil { return api.AvailableJobType{}, err } diff --git a/internal/manager/job_compilers/scripts.go b/internal/manager/job_compilers/scripts.go index 20982d7a..48901c09 100644 --- a/internal/manager/job_compilers/scripts.go +++ b/internal/manager/job_compilers/scripts.go @@ -150,9 +150,9 @@ func newGojaVM(registry *require.Registry) *goja.Runtime { return vm } -// compilerForJobType returns a Goja *Runtime that has the job compiler script for -// the given job type loaded up. -func (s *Service) compilerForJobType(jobTypeName string) (*VM, error) { +// compilerVMForJobType returns a Goja *Runtime that has the job compiler script +// for the given job type loaded up. +func (s *Service) compilerVMForJobType(jobTypeName string) (*VM, error) { program, ok := s.compilers[jobTypeName] if !ok { return nil, ErrJobTypeUnknown