Skip to content

Commit

Permalink
use kuberesolver for kubernetes service endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Jul 15, 2024
1 parent 23a9fe5 commit c7462f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ require (
github.com/rs/cors v1.10.1
github.com/rs/zerolog v1.32.0
github.com/segmentio/kafka-go v0.4.47
github.com/sercand/kuberesolver/v5 v5.1.1
github.com/sethvargo/go-password v0.2.0
github.com/shamaton/msgpack/v2 v2.1.1
github.com/shirou/gopsutil v3.21.11+incompatible
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUt
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUanQQB0=
github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg=
github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY=
github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
Expand Down
9 changes: 8 additions & 1 deletion pkg/rgrpc/todo/pool/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ import (
tx "github.com/cs3org/go-cs3apis/cs3/tx/v1beta1"
"github.com/cs3org/reva/v2/pkg/registry"
"github.com/pkg/errors"
"github.com/sercand/kuberesolver/v5"
"google.golang.org/grpc"
)

func init() {
// grpc go resolver.Register must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe.
kuberesolver.RegisterInCluster()
}

type Selectable[T any] interface {
Next(opts ...Option) (T, error)
}
Expand Down Expand Up @@ -97,7 +104,7 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) {
target := s.id
prefix := strings.SplitN(s.id, ":", 2)[0]
switch prefix {
case "dns", "unix":
case "dns", "unix", "kubernetes":
// use target as is
default:
// use service registry to look up address
Expand Down

0 comments on commit c7462f7

Please sign in to comment.