From b15e478e9f5155e14c2dabaecab0eb9e3b51c17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Mon, 6 May 2024 18:57:02 +0000 Subject: [PATCH] Create gearmin server with listener This means now we can create a listener with crypto/tls. --- hack/ccp/go.mod | 2 +- hack/ccp/go.sum | 6 ++---- hack/ccp/internal/controller/submit_test.go | 7 +++---- hack/ccp/internal/servercmd/server.go | 9 ++++++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hack/ccp/go.mod b/hack/ccp/go.mod index d93be2b1d..53ddd22bc 100644 --- a/hack/ccp/go.mod +++ b/hack/ccp/go.mod @@ -6,7 +6,7 @@ require ( connectrpc.com/connect v1.16.0 connectrpc.com/grpchealth v1.3.0 connectrpc.com/grpcreflect v1.2.0 - github.com/artefactual-labs/gearmin v0.0.0-20240503085057-24b15200761a + github.com/artefactual-labs/gearmin v0.0.0-20240506072626-8c1a583fd630 github.com/doug-martin/goqu/v9 v9.19.0 github.com/elliotchance/orderedmap/v2 v2.2.0 github.com/fsnotify/fsnotify v1.7.0 diff --git a/hack/ccp/go.sum b/hack/ccp/go.sum index 819559cf0..76f662054 100644 --- a/hack/ccp/go.sum +++ b/hack/ccp/go.sum @@ -26,8 +26,8 @@ github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk= github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c h1:651/eoCRnQ7YtSjAnSzRucrJz+3iGEFt+ysraELS81M= github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/artefactual-labs/gearmin v0.0.0-20240503085057-24b15200761a h1:BVog6YUNmBoxv/nGSeoHT2eCTRqtRKh1Uw5ySzihTWc= -github.com/artefactual-labs/gearmin v0.0.0-20240503085057-24b15200761a/go.mod h1:aN5kqGkz5XmmJ/vTm/meKbLS1DezOuSlprnWSIk7gzA= +github.com/artefactual-labs/gearmin v0.0.0-20240506072626-8c1a583fd630 h1:eJfMprHs8o9O6cRbp3O8V92IG3vHsqplH48BkI7WpQo= +github.com/artefactual-labs/gearmin v0.0.0-20240506072626-8c1a583fd630/go.mod h1:C+JaJpQwRvWN3sa2z2jy+ziy7mQuuTIsTiRFJbUBO38= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bep/clocks v0.5.0 h1:hhvKVGLPQWRVsBP/UB7ErrHYIO42gINVbvqxvYTPVps= @@ -253,8 +253,6 @@ github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/peterbourgon/ff/v3 v3.4.0 h1:QBvM/rizZM1cB0p0lGMdmR7HxZeI/ZrBWB4DqLkMUBc= github.com/peterbourgon/ff/v3 v3.4.0/go.mod h1:zjJVUhx+twciwfDl0zBcFzl4dW8axCRyXE/eKY9RztQ= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/hack/ccp/internal/controller/submit_test.go b/hack/ccp/internal/controller/submit_test.go index 8062837fb..692cc796c 100644 --- a/hack/ccp/internal/controller/submit_test.go +++ b/hack/ccp/internal/controller/submit_test.go @@ -69,10 +69,9 @@ func TestSubmitJob(t *testing.T) { func fakeGearman(t *testing.T) *gearmin.Server { t.Helper() - srv := gearmin.NewServer(gearmin.Config{ListenAddr: "127.0.0.1:0"}) - t.Cleanup(func() { - srv.Stop() - }) + srv, err := gearmin.NewServerWithAddr("127.0.0.1:0") + assert.NilError(t, err) + t.Cleanup(func() { srv.Stop() }) return srv } diff --git a/hack/ccp/internal/servercmd/server.go b/hack/ccp/internal/servercmd/server.go index ea1b0487f..2c648a412 100644 --- a/hack/ccp/internal/servercmd/server.go +++ b/hack/ccp/internal/servercmd/server.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "net" "path/filepath" "time" @@ -98,9 +99,11 @@ func (s *Server) Run() error { } s.logger.V(1).Info("Creating Gearman job server.") - s.gearman = gearmin.NewServer(gearmin.Config{ListenAddr: s.config.gearmin.addr}) - if err := s.gearman.Start(); err != nil { - return fmt.Errorf("error creating Gearmin job server: %v", err) + ln, err := net.Listen("tcp", s.config.gearmin.addr) + if err != nil { + return fmt.Errorf("error creating gearmin listener: %v", err) + } else { + s.gearman = gearmin.NewServer(ln) } s.logger.V(1).Info("Creating controller.")