Skip to content

Commit

Permalink
fix(contrib/opensergo): incorrect conversion between integer types (#…
Browse files Browse the repository at this point in the history
…3309)

* fix(contrib/opensergo): incorrect conversion between integer types

* remove nolint

* remove blank line
  • Loading branch information
demoManito authored Apr 30, 2024
1 parent a803e9d commit be624d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contrib/opensergo/opensergo.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ func (s *OpenSergo) ReportMetadata(ctx context.Context, app kratos.AppInfo) erro
if err != nil {
return err
}
portValue, err := strconv.Atoi(port)
portUint64, err := strconv.ParseUint(port, 10, 32)
if err != nil {
return err
}
serviceMetadata.Protocols = append(serviceMetadata.Protocols, u.Scheme)
serviceMetadata.ListeningAddresses = append(serviceMetadata.ListeningAddresses, &v1.SocketAddress{
Address: host,
PortValue: uint32(portValue),
PortValue: uint32(portUint64),
})
}
_, err = s.mdClient.ReportMetadata(ctx, &v1.ReportMetadataRequest{
Expand Down
5 changes: 3 additions & 2 deletions contrib/polaris/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func (p *Polaris) NodeFilter(opts ...RouterOption) selector.NodeFilter {
}

n := make(map[string]selector.Node, len(nodes))

for _, node := range nodes {
n[node.Address()] = node
}
Expand Down Expand Up @@ -112,10 +111,12 @@ func buildPolarisInstance(namespace string, nodes []selector.Node) *pb.ServiceIn
for _, node := range nodes {
host, port, err := net.SplitHostPort(node.Address())
if err != nil {
log.Errorf("split host port failed error: %v", err)
return nil
}
portUint64, err := strconv.ParseUint(port, 10, 32) //nolint:gomnd
portUint64, err := strconv.ParseUint(port, 10, 32)
if err != nil {
log.Errorf("parse port failed error: %v", err)
return nil
}
ins = append(ins, &v1.Instance{
Expand Down

0 comments on commit be624d0

Please sign in to comment.