Skip to content

Commit

Permalink
feat: RF1 improves replication stategy to support 1 replica (#13469)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena authored Jul 10, 2024
1 parent 6ea83b4 commit 790135b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/ingester-rf1/ring_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-kit/log"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/ring"
ring_client "github.com/grafana/dskit/ring/client"
"github.com/grafana/dskit/services"
Expand Down Expand Up @@ -36,7 +37,7 @@ func NewRingClient(
logger: log.With(logger, "component", "ingester-rf1-client"),
cfg: cfg,
}
ringClient.ring, err = ring.New(cfg.LifecyclerConfig.RingConfig, "ingester-rf1", "ingester-rf1-ring", ringClient.logger, registerer)
ringClient.ring, err = newRing(cfg.LifecyclerConfig.RingConfig, "ingester-rf1", "ingester-rf1-ring", ringClient.logger, registerer)
if err != nil {
return nil, err
}
Expand All @@ -59,6 +60,22 @@ func NewRingClient(
return ringClient, nil
}

func newRing(cfg ring.Config, name, key string, logger log.Logger, reg prometheus.Registerer) (*ring.Ring, error) {
codec := ring.GetCodec()
// Suffix all client names with "-ring" to denote this kv client is used by the ring
store, err := kv.NewClient(
cfg.KVStore,
codec,
kv.RegistererWithKVName(reg, name+"-ring"),
logger,
)
if err != nil {
return nil, err
}

return ring.NewWithStoreClientAndStrategy(cfg, name, key, store, ring.NewIgnoreUnhealthyInstancesReplicationStrategy(), reg, logger)
}

func (q *RingClient) starting(ctx context.Context) error {
return services.StartManagerAndAwaitHealthy(ctx, q.subservices)
}
Expand Down

0 comments on commit 790135b

Please sign in to comment.