Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Start service directly instead of making a starter type
Browse files Browse the repository at this point in the history
  • Loading branch information
boxhock committed Apr 23, 2021
1 parent 95a88f2 commit f6a5102
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
11 changes: 5 additions & 6 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,15 @@ func (srv *Service) subscribe(sub store.Subscription) error {
return errors.New("already subscribed to this jobid")
}

var startService services.Starter
var service services.Service
var err error
triggerJobRun := make(chan subscriber.Event, 100)
js, err := srv.store.LoadJobSpec(sub.Job)
if err != nil || gjson.GetBytes(js.Spec, "fluxmonitor").Raw == "null" {
startService = srv.subscribeRunlog
service, err = srv.subscribeRunlog(sub, triggerJobRun, js)
} else {
startService = srv.subscribeFluxmonitor
service, err = srv.subscribeFluxmonitor(sub, triggerJobRun, js)
}

triggerJobRun := make(chan subscriber.Event, 100)
service, err := startService(sub, triggerJobRun, js)
if err != nil {
return err
}
Expand Down
7 changes: 0 additions & 7 deletions services/service.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package services

import (
"github.com/smartcontractkit/external-initiator/store"
"github.com/smartcontractkit/external-initiator/subscriber"
)

type Starter func(sub store.Subscription, ch chan subscriber.Event, js *store.JobSpec) (Service, error)

type Service interface {
Stop()
}

0 comments on commit f6a5102

Please sign in to comment.