Skip to content

Commit

Permalink
Adopt ring page handler within the BasicLifecycler
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswine committed Jan 14, 2022
1 parent 816b94b commit edf4b07
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ring/basic_lifecycler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ring
import (
"context"
"fmt"
"net/http"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -491,3 +492,20 @@ func (l *BasicLifecycler) run(fn func() error) error {
return <-errCh
}
}

func (l *BasicLifecycler) casRing(ctx context.Context, f func(in interface{}) (out interface{}, retry bool, err error)) error {
return l.store.CAS(ctx, l.ringKey, f)
}

func (l *BasicLifecycler) getRing(ctx context.Context) (*Desc, error) {
obj, err := l.store.Get(ctx, l.ringKey)
if err != nil {
return nil, err
}

return GetOrCreateRingDesc(obj), nil
}

func (l *BasicLifecycler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
newRingPageHandler(l.logger, l, l.cfg.HeartbeatPeriod).handle(w, req)
}

0 comments on commit edf4b07

Please sign in to comment.