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.
This commit is contained in:
Sybren A. Stüvel 2022-07-29 14:26:48 +02:00
parent 866513e06a
commit 48ca73f550
2 changed files with 6 additions and 6 deletions

View File

@ -86,7 +86,7 @@ func Load(ts TimeService) (*Service, error) {
} }
func (s *Service) Compile(ctx context.Context, sj api.SubmittedJob) (*AuthoredJob, 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 { if err != nil {
return nil, err return nil, err
} }
@ -140,7 +140,7 @@ func (s *Service) ListJobTypes() api.AvailableJobTypes {
defer s.mutex.Unlock() defer s.mutex.Unlock()
for typeName := range s.compilers { for typeName := range s.compilers {
compiler, err := s.compilerForJobType(typeName) compiler, err := s.compilerVMForJobType(typeName)
if err != nil { if err != nil {
log.Warn().Err(err).Str("jobType", typeName).Msg("unable to determine job type settings") log.Warn().Err(err).Str("jobType", typeName).Msg("unable to determine job type settings")
continue continue
@ -163,7 +163,7 @@ func (s *Service) ListJobTypes() api.AvailableJobTypes {
// GetJobType returns information about the named job type. // GetJobType returns information about the named job type.
// Returns ErrJobTypeUnknown when the name doesn't correspond with a known job type. // Returns ErrJobTypeUnknown when the name doesn't correspond with a known job type.
func (s *Service) GetJobType(typeName string) (api.AvailableJobType, error) { func (s *Service) GetJobType(typeName string) (api.AvailableJobType, error) {
compiler, err := s.compilerForJobType(typeName) compiler, err := s.compilerVMForJobType(typeName)
if err != nil { if err != nil {
return api.AvailableJobType{}, err return api.AvailableJobType{}, err
} }

View File

@ -150,9 +150,9 @@ func newGojaVM(registry *require.Registry) *goja.Runtime {
return vm return vm
} }
// compilerForJobType returns a Goja *Runtime that has the job compiler script for // compilerVMForJobType returns a Goja *Runtime that has the job compiler script
// the given job type loaded up. // for the given job type loaded up.
func (s *Service) compilerForJobType(jobTypeName string) (*VM, error) { func (s *Service) compilerVMForJobType(jobTypeName string) (*VM, error) {
program, ok := s.compilers[jobTypeName] program, ok := s.compilers[jobTypeName]
if !ok { if !ok {
return nil, ErrJobTypeUnknown return nil, ErrJobTypeUnknown