Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDescribeInstancesRequest ¶
func NewDescribeInstancesRequest() *cvm.DescribeInstancesRequest
Types ¶
type CVMOperator ¶
type CVMOperator struct {
// contains filtered or unexported fields
}
与云商交换的操作器
func NewCVMOperator ¶
func NewCVMOperator(client *cvm.Client, account string) *CVMOperator
func (*CVMOperator) PageCvmQuery ¶
func (o *CVMOperator) PageCvmQuery() *CvmPager
带分页功能的查询 要把所有资源全部同步下来, 需要客户端拉起所有页面的实例数据 我们需要实现一个带分页查询功能的一个客户端, 这个客户端能把所有的页面都查询完 云商由速率限制? 比如每秒请求10页数据, 可以超过速率限制 pager里面是需要控制 云商接口的访问频率
func (*CVMOperator) QueryCvm ¶
func (o *CVMOperator) QueryCvm(ctx context.Context, req *cvm.DescribeInstancesRequest) (*host.HostSet, error)
查询cvm列表(只拉去一页), 查询完成后转换为标准的Host对象 https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=DescribeInstances
type CvmPager ¶
type CvmPager struct {
// contains filtered or unexported fields
}
跟web界面逻辑一页
- 从第一页开始查询, 100
- 一直点Next(下一页)? 什么时候就结束了,没有下一页了喃? 2.1 req.page_number+1
3.
3.1. 根据Total 和当前已经的offset进行比较, 需要云商返回的Total要准确 3.2. 根据当前页是否满了, 比如一页20 0-19(代表没有下一页)
func NewCvmPager ¶
func NewCvmPager(op *CVMOperator, args *CvmPagerRequest) *CvmPager
type CvmPagerRequest ¶
func (*CvmPagerRequest) Offset ¶
func (req *CvmPagerRequest) Offset() int64
Click to show internal directories.
Click to hide internal directories.