1 Star 6 Fork 4

张奇峰/fastdfs_client_go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tracker_storage_tcp_get_group_info.go 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
qifeng001 提交于 2025-11-12 14:31 +08:00 . add: 增加通过组查询storage servers 函数
package fastdfs_client_go
import "errors"
// GetGroupInfo 指定 group 名称获取 group 信息
// @groupName 组名,例如: group1
func (c *trackerServerTcpClient) GetGroupInfo(groupName string) (resGroupInfo *GroupInfo, err error) {
if len(groupName) < 1 {
return resGroupInfo, errors.New(ERROR_GET_GROUP_INFO_FAILED_GROUP_NOT_EMPTY)
}
resGroupInfo, err = c.getGroupInfoByTracker(TRACKER_PROTO_CMD_SERVER_LIST_ONE_GROUP, groupName)
if err != nil {
return resGroupInfo, err
}
return resGroupInfo, nil
}
// getGroupInfoByTracker 主要通过 tracker server 获取 group 组信息
// @groupName 组名 (body 参数)
func (c *trackerServerTcpClient) getGroupInfoByTracker(cmd byte, groupName string) (*GroupInfo, error) {
trackerSendParams := &trackerTcpConn{}
// 将命令参数设置在 header 头部分
trackerSendParams.header.pkgLen = 16
trackerSendParams.header.cmd = cmd
trackerSendParams.header.status = 0
trackerSendParams.groupName = groupName
trackerSendParams.remoteFilename = ""
if err := c.sendHeaderByTrackerServer(trackerSendParams); err != nil {
return nil, err
}
return &GroupInfo{
groupName: trackerSendParams.groupInfo.groupName,
totalMb: trackerSendParams.groupInfo.totalMb,
freeMb: trackerSendParams.groupInfo.freeMb,
reservedMb: trackerSendParams.groupInfo.reservedMb,
trunkFreeMb: trackerSendParams.groupInfo.trunkFreeMb,
serverCount: trackerSendParams.groupInfo.serverCount,
serverPort: trackerSendParams.groupInfo.serverPort,
readableServerCount: trackerSendParams.groupInfo.readableServerCount,
writableServerCount: trackerSendParams.groupInfo.writableServerCount,
currentWriteServerCount: trackerSendParams.groupInfo.currentWriteServerCount,
storePathCount: trackerSendParams.groupInfo.storePathCount,
subdirCountPerPath: trackerSendParams.groupInfo.subdirCountPerPath,
currentTrunkFileId: trackerSendParams.groupInfo.currentTrunkFileId,
}, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/daitougege/fastdfs_client_go.git
git@gitee.com:daitougege/fastdfs_client_go.git
daitougege
fastdfs_client_go
fastdfs_client_go
master

搜索帮助