⬆️ Upgrade Passport and use Hyper SDK

This commit is contained in:
2024-06-22 12:29:20 +08:00
parent b951cd2696
commit 72299c810b
13 changed files with 137 additions and 172 deletions

View File

@ -0,0 +1,12 @@
package gap
import (
"git.solsynth.dev/hydrogen/passport/pkg/hyper"
"github.com/spf13/viper"
)
var H *hyper.HyperConn
func NewHyperClient() {
H = hyper.NewHyperConn(viper.GetString("consul.addr"))
}

View File

@ -7,8 +7,6 @@ import (
"github.com/hashicorp/consul/api"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func Register() error {
@ -40,12 +38,3 @@ func Register() error {
return client.Agent().ServiceRegister(registration)
}
func DiscoverPassport() (*grpc.ClientConn, error) {
target := fmt.Sprintf("consul://%s/Hydrogen.Passport", viper.GetString("consul.addr"))
return grpc.NewClient(
target,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin"}`),
)
}