本文整理匯總了Golang中github.com/feyeleanor/sets.SSet函數的典型用法代碼示例。如果您正苦於以下問題:Golang SSet函數的具體用法?Golang SSet怎麽用?Golang SSet使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SSet函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetMetricStatistics
// Get statistics for specified metric
//
// If the arguments are invalid or the server returns an error, the error will
// be set and the other values undefined.
func (c *CloudWatch) GetMetricStatistics(req *GetMetricStatisticsRequest) (result *GetMetricStatisticsResponse, err error) {
statisticsSet := sets.SSet(req.Statistics...)
// Kick out argument errors
switch {
case req.EndTime.IsZero():
err = errors.New("No endTime specified")
case req.StartTime.IsZero():
err = errors.New("No startTime specified")
case req.MetricName == "":
err = errors.New("No metricName specified")
case req.Namespace == "":
err = errors.New("No Namespace specified")
case req.Period < 60 || req.Period%60 != 0:
err = errors.New("Period not 60 seconds or a multiple of 60 seconds")
case len(req.Statistics) < 1:
err = errors.New("No statistics supplied")
case validMetricStatistics.Union(statisticsSet).Len() != validMetricStatistics.Len():
err = errors.New("Invalid statistic values supplied")
case req.Unit != "" && !validUnits.Member(req.Unit):
err = errors.New("Unit is not a valid value")
}
if err != nil {
return
}
// Serialize all the params
params := aws.MakeParams("GetMetricStatistics")
params["EndTime"] = req.EndTime.UTC().Format(time.RFC3339)
params["StartTime"] = req.StartTime.UTC().Format(time.RFC3339)
params["MetricName"] = req.MetricName
params["Namespace"] = req.Namespace
params["Period"] = strconv.Itoa(req.Period)
if req.Unit != "" {
params["Unit"] = req.Unit
}
// Serialize the lists of data
for i, d := range req.Dimensions {
prefix := "Dimensions.member." + strconv.Itoa(i+1)
params[prefix+".Name"] = d.Name
params[prefix+".Value"] = d.Value
}
for i, d := range req.Statistics {
prefix := "Statistics.member." + strconv.Itoa(i+1)
params[prefix] = d
}
result = new(GetMetricStatisticsResponse)
err = c.query("GET", "/", params, result)
return
}
示例2: Init
func (cwi *CloudwatchInput) Init(config interface{}) (err error) {
conf := config.(*CloudwatchInputConfig)
statisticsSet := sets.SSet(conf.Statistics...)
switch {
case conf.MetricName == "":
err = errors.New("No metric name supplied")
case conf.Period < 60 || conf.Period%60 != 0:
err = errors.New("Period must be divisible by 60")
case len(conf.Statistics) < 1:
err = errors.New("text·2")
case conf.Unit != "" && !validUnits.Member(conf.Unit):
err = errors.New("Unit is not a valid value")
case len(conf.Statistics) < 1:
err = errors.New("No statistics supplied")
case validMetricStatistics.Union(statisticsSet).Len() != validMetricStatistics.Len():
err = errors.New("Invalid statistic values supplied")
}
if err != nil {
return
}
dims := make([]cloudwatch.Dimension, 0)
for k, v := range conf.Dimensions {
dims = append(dims, cloudwatch.Dimension{k, v})
}
auth := aws.Auth{AccessKey: conf.AccessKey, SecretKey: conf.SecretKey}
cwi.req = &cloudwatch.GetMetricStatisticsRequest{
MetricName: conf.MetricName,
Period: conf.Period,
Unit: conf.Unit,
Statistics: conf.Statistics,
Dimensions: dims,
}
cwi.pollInterval, err = time.ParseDuration(conf.PollInterval)
if err != nil {
return
}
region, ok := aws.Regions[conf.Region]
if !ok {
err = errors.New("Region of that name not found.")
return
}
cwi.namespace = conf.Namespace
cwi.cw, err = cloudwatch.NewCloudWatch(auth, region.CloudWatchServicepoint,
conf.Namespace)
return
}
示例3:
}
var validUnits = sets.SSet(
"Seconds",
"Microseconds",
"Milliseconds",
"Bytes",
"Kilobytes",
"Megabytes",
"Gigabytes",
"Terabytes",
"Bits",
"Kilobits",
"Megabits",
"Gigabits",
"Terabits",
"Percent",
"Count",
"Bytes/Second",
"Kilobytes/Second",
"Megabytes/Second",
"Gigabytes/Second",
"Terabytes/Second",
"Bits/Second",
"Kilobits/Second",
"Megabits/Second",
"Gigabits/Second",
"Terabits/Second",
"Count/Second",
)
var validMetricStatistics = sets.SSet(
示例4:
var validUnits = sets.SSet(
UnitSeconds,
UnitMicroseconds,
UnitMilliseconds,
UnitBytes,
UnitKilobytes,
UnitMegabytes,
UnitGigabytes,
UnitTerabytes,
UnitBits,
UnitKilobits,
UnitMegabits,
UnitGigabits,
UnitTerabits,
UnitPercent,
UnitCount,
UnitBytesPerSecond,
UnitKilobytesPerSecond,
UnitMegabytesPerSecond,
UnitGigabytesPerSecond,
UnitTerabytesPerSecond,
UnitBitsPerSecond,
UnitKilobitsPerSecond,
UnitMegabitsPerSecond,
UnitGigabitsPerSecond,
UnitTerabitsPerSecond,
UnitCountPerSecond,
UnitNone,
)