本文整理匯總了Golang中github.com/telemetryapp/gotelemetry.Flow類的典型用法代碼示例。如果您正苦於以下問題:Golang Flow類的具體用法?Golang Flow怎麽用?Golang Flow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Flow類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetDate
func (p *CrittercismPlugin) SetDate(job *job.Job, f *gotelemetry.Flow) {
data, found := f.TextData()
if !found {
job.ReportError(gotelemetry.NewError(400, "Cannot extract text data from flow"+f.Tag))
return
}
data.Text = time.Now().Format("Monday, January 2")
job.PostFlowUpdate(f)
job.Logf("Set app name to flow %s", f.Tag)
}
示例2: SetAppName
func (p *CrittercismPlugin) SetAppName(job *job.Job, f *gotelemetry.Flow) {
data, found := f.TextData()
if !found {
job.ReportError(gotelemetry.NewError(400, "Cannot extract text data from flow"+f.Tag))
return
}
data.Text = p.appName
job.PostFlowUpdate(f)
job.Logf("Set app name to flow %s", f.Tag)
}
示例3: FetchSumOfGraphIntoFlow
func (c *CrittercismAPIClient) FetchSumOfGraphIntoFlow(path, name string, interval int, f *gotelemetry.Flow) error {
if data, found := f.ValueData(); found == true {
value, err := c.FetchSumOfGraph(path, name, interval)
if err != nil {
return err
}
data.Value = value
return nil
}
return gotelemetry.NewError(400, "Cannot extract value data from flow"+f.Tag)
}
示例4: PostGraphToBarchart
func (p *CrittercismPlugin) PostGraphToBarchart(job *job.Job, path, name, groupBy string, interval int, f *gotelemetry.Flow) {
if data, found := f.BarchartData(); found == true {
jq, err := p.api.FetchGraphRaw(path, name, groupBy, interval)
if err != nil {
job.ReportError(err)
return
}
slices, err := jq.ArrayOfObjects("data", "slices")
if err != nil {
job.ReportError(err)
return
}
bars := []gotelemetry.BarchartBar{}
count := 10
for _, slice := range slices {
bar := gotelemetry.BarchartBar{}
bar.Color = "#267288"
bar.Label = slice["label"].(string)
bar.Value = slice["value"].(float64)
bars = append(bars, bar)
count -= 1
if count == 0 {
break
}
}
data.Bars = bars
job.PostFlowUpdate(f)
job.Logf("Updated flow %s", f.Tag)
return
}
job.ReportError(gotelemetry.NewError(400, "Cannot extract barchart data from flow"+f.Tag))
}
示例5: AppStoreRatings
func (p *CrittercismPlugin) AppStoreRatings(job *job.Job, f *gotelemetry.Flow) {
jq, err := p.api.Request("GET", "apps?attributes=appType,rating", nil)
if err != nil {
job.ReportError(err)
return
}
source, err := jq.Object()
if err != nil {
job.ReportError(err)
return
}
data, found := f.ValueData()
if !found {
job.ReportError(gotelemetry.NewError(400, "Cannot extract value data from flow"+f.Tag))
return
}
if appObj, ok := source[p.appId]; ok {
app := appObj.(map[string]interface{})
data.Value = app["rating"].(float64)
switch p.ratingKey {
case "ios":
data.Icon = "fa-apple"
case "android":
data.Icon = "fa-android"
case "wp":
data.Icon = "fa-windows"
case "html5":
data.Icon = "fa-html5"
}
}
job.PostFlowUpdate(f)
job.Logf("Updated flow %s", f.Tag)
}
示例6: FetchGraphIntoFlow
func (c *CrittercismAPIClient) FetchGraphIntoFlow(path, name string, duration int, scale int, f *gotelemetry.Flow) error {
if data, found := f.GraphData(); found == true {
series, err := c.FetchGraph(path, name, duration)
if err != nil {
return err
}
// Eliminate last value
if len(series) > 1 {
series = series[:len(series)-1]
}
data.Series[0].Values = series
data.StartTime = time.Now().Add(-time.Duration(scale) * time.Second).Unix()
return nil
}
return gotelemetry.NewError(400, "Cannot extract value data from flow"+f.Tag)
}
示例7: DailyMonthlyLoadsUsers
func (p *CrittercismPlugin) DailyMonthlyLoadsUsers(job *job.Job, f *gotelemetry.Flow) {
dau, err := p.api.FetchLastValueOfGraph("errorMonitoring/graph", "dau", 1440)
if err != nil {
job.ReportError(err)
return
}
mau, err := p.api.FetchLastValueOfGraph("errorMonitoring/graph", "mau", 86400)
if err != nil {
job.ReportError(err)
return
}
loads, err := p.api.FetchLastValueOfGraph("errorMonitoring/graph", "appLoads", 1440)
if err != nil {
job.ReportError(err)
return
}
data, success := f.MultivalueData()
if !success {
job.ReportError(gotelemetry.NewError(400, "Cannot extract multivalue data from flow"+f.Tag))
return
}
data.Values[0].Value = loads
data.Values[1].Value = dau
data.Values[2].Value = mau
job.PostFlowUpdate(f)
job.Logf("Updated flow %s", f.Tag)
}
示例8: PostImmediateFlowUpdate
func (j *Job) PostImmediateFlowUpdate(flow *gotelemetry.Flow) error {
return flow.PostUpdate()
}
示例9: ReadFlow
// ReadFlow populates a flow struct with the data that is currently on the server
// Note that it is not necessary to populate f.Data, as the method will automatically
// initialize a nil value with the appropriate data structure for the flow's variant.
func (j *Job) ReadFlow(f *gotelemetry.Flow) error {
return f.Read(j.credentials)
}
示例10: DailyMostFrequentCrashes
func (p *CrittercismPlugin) DailyMostFrequentCrashes(job *job.Job, f *gotelemetry.Flow) {
data, found := f.TableData()
if !found {
job.ReportError(gotelemetry.NewError(400, "Cannot extract table data from flow"+f.Tag))
}
crashes, err := p.api.FetchCrashStatus()
if err != nil {
job.ReportError(err)
return
}
crashes = crashes.Aggregate()
cells := [][]gotelemetry.TableCell{}
var count = 8
for _, crash := range crashes {
name := ""
if crash.Reason != "" {
name = crash.Reason
} else if crash.DisplayReason != nil {
name = *crash.DisplayReason
} else if crash.Name != nil {
name = *crash.Name
} else {
name = "N/A (" + crash.Reason + ")"
}
if len(name) > tableDataLength {
name = name[:tableDataLength-1]
}
cells = append(
cells,
[]gotelemetry.TableCell{
gotelemetry.TableCell{Value: name},
gotelemetry.TableCell{Value: crash.SessionCount},
},
)
count -= 1
if count == 0 {
break
}
}
for count > 0 {
cells = append(
cells,
[]gotelemetry.TableCell{
gotelemetry.TableCell{Value: ""},
gotelemetry.TableCell{Value: ""},
},
)
count -= 1
}
data.Cells = cells
job.PostFlowUpdate(f)
job.Logf("Updated flow %s", f.Tag)
}