trpc.group/trpc-go/trpc-go@v1.0.3/naming/registry/node.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 package registry 15 16 import ( 17 "fmt" 18 "net" 19 "time" 20 ) 21 22 // Node is the information of a node. 23 type Node struct { 24 ServiceName string // 服务名 25 ContainerName string // 容器名 26 Address string // 目标地址 ip:port 27 Network string // 网络层协议 tcp/udp 28 Protocol string // 业务协议 trpc/http 29 SetName string // 节点 Set 名 30 Weight int // 权重 31 CostTime time.Duration // 当次请求耗时 32 EnvKey string // 透传的环境信息 33 Metadata map[string]interface{} 34 // ParseAddr should be used to convert Node to net.Addr if it's not nil. 35 // See test case TestSelectorRemoteAddrUseUserProvidedParser in client package. 36 ParseAddr func(network, address string) net.Addr 37 } 38 39 // String returns an abbreviation information of node. 40 func (n *Node) String() string { 41 return fmt.Sprintf("service:%s, addr:%s, cost:%s", n.ServiceName, n.Address, n.CostTime) 42 }