Skip to content

Commit

Permalink
Merge pull request #24 from houseme/main
Browse files Browse the repository at this point in the history
improve code
  • Loading branch information
houseme authored Feb 19, 2022
2 parents 10a7b81 + 056ba8d commit de48ea3
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 62 deletions.
6 changes: 3 additions & 3 deletions balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (bb *balancerBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOpti
}
}

// Name 返回Name
// Name return name
func (bb *balancerBuilder) Name() string {
return scheme
}
Expand All @@ -74,7 +74,7 @@ type polarisNamingBalancer struct {
connErr error // the last connection error; cleared upon leaving TransientFailure
}

// of sc has changed.
// HandleSubConnStateChange .is called by gRPC of sc has changed.
// Balancer is expected to aggregate all the state of SubConn and report
// that back to gRPC.
// Balancer should also generate and update Pickers when its internal state has
Expand Down Expand Up @@ -323,7 +323,7 @@ func buildSourceInfo(options *dialOptions) *model.ServiceInfo {
func (pnp *polarisNamingPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
request := &api.GetOneInstanceRequest{}
request.Namespace = getNamespace(pnp.options)
request.Service = pnp.balancer.target.Authority
request.Service = pnp.balancer.target.URL.Host
if len(pnp.options.DstMetadata) > 0 {
request.Metadata = pnp.options.DstMetadata
}
Expand Down
5 changes: 3 additions & 2 deletions examples/quickstart/consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (
"log"
"net/http"

"github.com/polarismesh/grpc-go-polaris/examples/quickstart/pb"
"google.golang.org/grpc"

"github.com/polarismesh/grpc-go-polaris/examples/quickstart/pb"

polaris "github.com/polarismesh/grpc-go-polaris"
)

Expand All @@ -34,7 +35,7 @@ const (
)

func main() {
//grpc客户端连接获取
// grpc客户端连接获取
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
conn, err := grpc.DialContext(ctx, "polaris://EchoServerGRPC/", grpc.WithInsecure(),
Expand Down
14 changes: 4 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ module github.com/polarismesh/grpc-go-polaris
go 1.13

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/uuid v1.1.2
github.com/kr/pretty v0.1.0 // indirect
github.com/polarismesh/polaris-go v1.0.0
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.6 // indirect
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/polarismesh/polaris-go v1.0.1
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
google.golang.org/grpc v1.44.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
gopkg.in/yaml.v2 v2.2.4 // indirect
)
Loading

0 comments on commit de48ea3

Please sign in to comment.