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

@ -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
}

@ -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