Files
go-trustlog/internal/grpcclient/config.go
ryan d313449c5c refactor: 重构trustlog-sdk目录结构到trustlog/go-trustlog
- 将所有trustlog-sdk文件移动到trustlog/go-trustlog/目录
- 更新README中所有import路径从trustlog-sdk改为go-trustlog
- 更新cookiecutter配置文件中的项目名称
- 更新根目录.lefthook.yml以引用新位置的配置
- 添加go.sum文件到版本控制
- 删除过时的示例文件

这次重构与trustlog-server保持一致的目录结构,
为未来支持多语言SDK(Python、Java等)预留空间。
2025-12-22 13:37:57 +08:00

31 lines
768 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package grpcclient
import (
"errors"
"google.golang.org/grpc"
)
// Config 客户端配置.
type Config struct {
// ServerAddrs gRPC服务器地址列表格式: "host:port"
// 支持多个地址,客户端将使用轮询负载均衡
ServerAddrs []string
// ServerAddr 单个服务器地址向后兼容如果设置了此字段将忽略ServerAddrs
ServerAddr string
// DialOptions 额外的gRPC拨号选项
DialOptions []grpc.DialOption
}
// GetAddrs 获取服务器地址列表.
func (c *Config) GetAddrs() ([]string, error) {
switch {
case len(c.ServerAddrs) > 0:
return c.ServerAddrs, nil
case c.ServerAddr != "":
return []string{c.ServerAddr}, nil
default:
return nil, errors.New("at least one server address is required")
}
}