[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:
Vladislav Nosivskoy 2025-08-09 05:35:25 +03:00 committed by GitHub
parent 975eef12bf
commit 4768351563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 7 deletions

View File

@ -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())