cdn

package
v7.25.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 12 Imported by: 13

Documentation

Overview

cdn 包提供了 Fusion CDN的常见功能。相关功能的文档参考:https://developer.qiniu.com/fusion。 目前提供了文件和目录刷新,文件预取,获取域名带宽和流量数据,获取域名日志列表等功能。

Index

Constants

This section is empty.

Variables

View Source
var (
	FusionHost = "http://fusion.qiniuapi.com"
)

Fusion CDN服务域名

Functions

func CreateTimestampAntileechURL

func CreateTimestampAntileechURL(urlStr string, encryptKey string,
	durationInSeconds int64) (antileechURL string, err error)

CreateTimestampAntileechURL 用来构建七牛CDN时间戳防盗链的访问链接

Types

type BandwidthOption added in v7.25.0

type BandwidthOption Option

func WithBandwidthDataType added in v7.25.0

func WithBandwidthDataType(dataType DataType) BandwidthOption

type CdnManager

type CdnManager struct {
	// contains filtered or unexported fields
}

CdnManager 提供了文件和目录刷新,文件预取,获取域名带宽和流量数据,获取域名日志列表等功能

func NewCdnManager

func NewCdnManager(mac *auth.Credentials) *CdnManager

NewCdnManager 用来构建一个新的 CdnManager

func (*CdnManager) GetBandwidthData

func (m *CdnManager) GetBandwidthData(startDate, endDate, granularity string,
	domainList []string, opts ...BandwidthOption) (bandwidthData TrafficResp, err error)

func (*CdnManager) GetCdnLogList

func (m *CdnManager) GetCdnLogList(day string, domains []string) (
	listLogResult ListLogResult, err error)

GetCdnLogList 获取CDN域名访问日志的下载链接

func (*CdnManager) GetFluxData

func (m *CdnManager) GetFluxData(startDate, endDate, granularity string,
	domainList []string, opts ...FluxOption) (fluxData TrafficResp, err error)

GetFluxData 方法用来获取域名访问流量数据

StartDate	string		必须	开始日期,例如:2016-07-01
EndDate		string		必须	结束日期,例如:2016-07-03
Granularity	string		必须	粒度,取值:5min / hour /day
Domains		[]string	必须	域名列表
Opts                            非必须   可选项

func (*CdnManager) PrefetchUrls

func (m *CdnManager) PrefetchUrls(urls []string) (result PrefetchResp, err error)

PrefetchUrls 预取文件链接,每次最多不可以超过100条

func (*CdnManager) RefreshDirs

func (m *CdnManager) RefreshDirs(dirs []string) (result RefreshResp, err error)

RefreshDirs 刷新目录

func (*CdnManager) RefreshUrls

func (m *CdnManager) RefreshUrls(urls []string) (result RefreshResp, err error)

RefreshUrls 刷新文件

func (*CdnManager) RefreshUrlsAndDirs

func (m *CdnManager) RefreshUrlsAndDirs(urls, dirs []string) (result RefreshResp, err error)

RefreshUrlsAndDirs 方法用来刷新文件或目录 urls 要刷新的单个url列表,单次方法调用总数不超过100条;单个url,即一个具体的url, 例如:http://bar.foo.com/index.html dirs 要刷新的目录url列表,单次方法调用总数不超过10条;目录dir,即表示一个目录级的url, 例如:http://bar.foo.com/dir/

type DataType added in v7.25.0

type DataType int
const (
	// 静态cdn带宽(bps)
	DataTypeBandwidth DataType = iota + 1 // bandwidth
	// 302cdn带宽(bps)
	DataType302Bandwidth // 302bandwidth
	// 302MIX带宽(bps)
	DataType302mBandwidth // 302mbandwidth
	// 静态cdn流量(bytes)
	DataTypeFlow // flow
	// 302cdn流量(bytes)
	DataType302Flow // 302flow
	// 302MIX流量(bytes)
	DataType302mFlow // 302mflow
)

func DataTypeOf added in v7.25.0

func DataTypeOf(datatype string) DataType

func (DataType) String added in v7.25.0

func (i DataType) String() string

func (DataType) Valid added in v7.25.0

func (d DataType) Valid() bool

type FluxOption added in v7.25.0

type FluxOption Option

func WithFluxDataType added in v7.25.0

func WithFluxDataType(dataType DataType) FluxOption

type ListLogRequest

type ListLogRequest struct {
	Day     string `json:"day"`
	Domains string `json:"domains"`
}

ListLogRequest 日志下载请求内容

type ListLogResult

type ListLogResult struct {
	Code  int                        `json:"code"`
	Error string                     `json:"error"`
	Data  map[string][]LogDomainInfo `json:"data"`
}

ListLogResult 日志下载相应内容

type LogDomainInfo

type LogDomainInfo struct {
	Name         string `json:"name"`
	Size         int64  `json:"size"`
	ModifiedTime int64  `json:"mtime"`
	URL          string `json:"url"`
}

LogDomainInfo 日志下载信息

type Option added in v7.25.0

type Option interface {
	Apply(opt interface{})
}

type OptionFunc added in v7.25.0

type OptionFunc func(interface{})

func (OptionFunc) Apply added in v7.25.0

func (f OptionFunc) Apply(opt interface{})

type PrefetchReq

type PrefetchReq struct {
	Urls []string `json:"urls"`
}

PrefetchReq 文件预取请求内容

type PrefetchResp

type PrefetchResp struct {
	Code        int      `json:"code"`
	Error       string   `json:"error"`
	RequestID   string   `json:"requestId,omitempty"`
	InvalidUrls []string `json:"invalidUrls,omitempty"`
	QuotaDay    int      `json:"quotaDay,omitempty"`
	SurplusDay  int      `json:"surplusDay,omitempty"`
}

PrefetchResp 文件预取响应内容

type RefreshReq

type RefreshReq struct {
	Urls []string `json:"urls"`
	Dirs []string `json:"dirs"`
}

RefreshReq 为缓存刷新请求内容

type RefreshResp

type RefreshResp struct {
	Code          int      `json:"code"`
	Error         string   `json:"error"`
	RequestID     string   `json:"requestId,omitempty"`
	InvalidUrls   []string `json:"invalidUrls,omitempty"`
	InvalidDirs   []string `json:"invalidDirs,omitempty"`
	URLQuotaDay   int      `json:"urlQuotaDay,omitempty"`
	URLSurplusDay int      `json:"urlSurplusDay,omitempty"`
	DirQuotaDay   int      `json:"dirQuotaDay,omitempty"`
	DirSurplusDay int      `json:"dirSurplusDay,omitempty"`
}

RefreshResp 缓存刷新响应内容

type TrafficData

type TrafficData struct {
	DomainChina   []int `json:"china"`
	DomainOversea []int `json:"oversea"`
}

TrafficData 为带宽/流量数据

type TrafficReq

type TrafficReq struct {
	StartDate   string `json:"startDate"`
	EndDate     string `json:"endDate"`
	Granularity string `json:"granularity"`
	Domains     string `json:"domains"`
	DataType    string `json:"type,omitempty"`
}

TrafficReq 为批量查询带宽/流量的API请求内容

StartDate 	开始日期,格式例如:2016-07-01
EndDate 	结束日期,格式例如:2016-07-03
Granularity	取值粒度,取值可选值:5min/hour/day
Domains 	域名列表,彼此用 ; 连接
DataType        计量数据类型, 可选 'bandwidth'(静态cdn带宽,默认)..., 参考 [DataType]

type TrafficResp

type TrafficResp struct {
	Code  int                    `json:"code"`
	Error string                 `json:"error"`
	Time  []string               `json:"time,omitempty"`
	Data  map[string]TrafficData `json:"data,omitempty"`
}

TrafficResp 为带宽/流量查询响应内容

Jump to

Keyboard shortcuts

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