forked from mooncake-track/Mooncake
[TE] Add multi-endpoint etcd support for Transfer Engine metadata plugin (#729)
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
This commit is contained in:
parent
975eef12bf
commit
4768351563
|
|
@ -44,13 +44,29 @@ func NewEtcdClient(endpoints *C.char, errMsg **C.char) int {
|
|||
}
|
||||
|
||||
MaxMsgSize := 32*1024*1024
|
||||
endpoint := C.GoString(endpoints)
|
||||
cli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: []string{endpoint},
|
||||
DialTimeout: 5 * time.Second,
|
||||
MaxCallSendMsgSize: MaxMsgSize,
|
||||
MaxCallRecvMsgSize: MaxMsgSize,
|
||||
})
|
||||
endpointStr := C.GoString(endpoints)
|
||||
// Support multiple endpoints separated by comma or semicolon
|
||||
// Normalize separators to semicolon first, then split
|
||||
endpointStr = strings.ReplaceAll(endpointStr, ",", ";")
|
||||
parts := strings.Split(endpointStr, ";")
|
||||
var validEndpoints []string
|
||||
for _, ep := range parts {
|
||||
ep = strings.TrimSpace(ep)
|
||||
if ep != "" {
|
||||
validEndpoints = append(validEndpoints, ep)
|
||||
}
|
||||
}
|
||||
if len(validEndpoints) == 0 {
|
||||
*errMsg = C.CString("no valid endpoints provided")
|
||||
return -1
|
||||
}
|
||||
|
||||
cli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: validEndpoints,
|
||||
DialTimeout: 5 * time.Second,
|
||||
MaxCallSendMsgSize: MaxMsgSize,
|
||||
MaxCallRecvMsgSize: MaxMsgSize,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
*errMsg = C.CString(err.Error())
|
||||
|
|
|
|||
Loading…
Reference in New Issue