Cleanup jobschedule channel passing

This commit is contained in:
2022-12-28 17:13:33 -07:00
parent 0287213433
commit 663306c3be
4 changed files with 18 additions and 16 deletions
+6 -3
View File
@@ -4,6 +4,7 @@ import (
"context"
"net/http"
"git.ohea.xyz/cursorius/server/jobscheduler"
apiv1 "git.ohea.xyz/cursorius/server/proto/gen/api/v1"
"git.ohea.xyz/cursorius/server/proto/gen/api/v1/apiv1connect"
"github.com/bufbuild/connect-go"
@@ -12,7 +13,9 @@ import (
var log = logging.MustGetLogger("cursorius-server")
type ApiServer struct{}
type ApiServer struct {
runCh chan jobscheduler.Run
}
func (s *ApiServer) GetRunner(
ctx context.Context,
@@ -40,8 +43,8 @@ func (s *ApiServer) RunCommand(
return res, nil
}
func CreateHandler(mux *http.ServeMux) {
api_server := &ApiServer{}
func CreateHandler(mux *http.ServeMux, runCh chan jobscheduler.Run) {
api_server := &ApiServer{runCh: runCh}
path, handler := apiv1connect.NewGetRunnerServiceHandler(api_server)
mux.Handle(path, handler)
path, handler = apiv1connect.NewRunCommandServiceHandler(api_server)