Skip to content

Commit

Permalink
Convert freezer request methods to pointer receivers (knative#12312)
Browse files Browse the repository at this point in the history
* convert request methods to pointer receivers

* returning a pointer
  • Loading branch information
psschwei authored Nov 18, 2021
1 parent 218c102 commit 18586ea
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/queue/concurrency_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ConcurrencyStateHandler(logger *zap.SugaredLogger, h http.Handler, pause, r
// We need to doublecheck this since another request can have reached the
// handler meanwhile. We don't want to do anything in that case.
if !paused && inFlight.Load() == 0 {
logger.Info("Requests dropped to zero")
logger.Debug("Requests dropped to zero")
pause(logger)
paused = true
logger.Debug("To-Zero request successfully processed")
Expand All @@ -77,7 +77,7 @@ func ConcurrencyStateHandler(logger *zap.SugaredLogger, h http.Handler, pause, r
return
}

logger.Info("Requests increased from zero")
logger.Debug("Requests increased from zero")
resume(logger)
paused = false
logger.Debug("From-Zero request successfully processed")
Expand Down Expand Up @@ -110,7 +110,7 @@ type ConcurrencyEndpoint struct {
token atomic.Value
}

func NewConcurrencyEndpoint(e, m string) ConcurrencyEndpoint {
func NewConcurrencyEndpoint(e, m string) *ConcurrencyEndpoint {
c := ConcurrencyEndpoint{
endpoint: os.Expand(e, func(s string) string {
if s == "HOST_IP" {
Expand All @@ -121,22 +121,22 @@ func NewConcurrencyEndpoint(e, m string) ConcurrencyEndpoint {
mountPath: m,
}
c.RefreshToken()
return c
return &c
}

// Pause freezes a container, retrying until either successful or a timeout is
// reached, at which point the container is killed
func (c ConcurrencyEndpoint) Pause(logger *zap.SugaredLogger) {
func (c *ConcurrencyEndpoint) Pause(logger *zap.SugaredLogger) {
retryRequest(logger, c.Request, "pause")
}

// Resume thaws a container, retrying until either successful or a timeout is
// reached, at which point the container is killed
func (c ConcurrencyEndpoint) Resume(logger *zap.SugaredLogger) {
func (c *ConcurrencyEndpoint) Resume(logger *zap.SugaredLogger) {
retryRequest(logger, c.Request, "resume")
}

func (c ConcurrencyEndpoint) Request(action string) error {
func (c *ConcurrencyEndpoint) Request(action string) error {
bodyText := fmt.Sprintf(`{ "action": %q }`, action)
body := bytes.NewBufferString(bodyText)
req, err := http.NewRequest(http.MethodPost, c.endpoint, body)
Expand Down

0 comments on commit 18586ea

Please sign in to comment.