cvm

package
v0.0.0-...-6a8978f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 12 Imported by: 0

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

查询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界面逻辑一页

  1. 从第一页开始查询, 100
  2. 一直点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

func (*CvmPager) Next

func (c *CvmPager) Next() bool

判断是否由下一页

func (*CvmPager) Scan

func (c *CvmPager) Scan(ctx context.Context, set *host.HostSet) error

请求该页的数据

type CvmPagerRequest

type CvmPagerRequest struct {
	PageSize   int64
	PageNumber int64
}

func (*CvmPagerRequest) Offset

func (req *CvmPagerRequest) Offset() int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL