id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c170400 | content = fmt.Sprintf("\033[1;37m%s\033[0m", content)
case 304:
content = fmt.Sprintf("\033[1;33m%s\033[0m", content)
case 401, 403:
content = fmt.Sprintf("\033[4;31m%s\033[0m", content)
case 404:
content = fmt.Sprintf("\033[1;31m%s\033[0m", content)
case 500:
content = fmt.Sprintf("\033[1;36m%s\033[0m", content)
}
}
log.Println(content)
}
} | |
c170401 |
return &TplFile{name, data, ext}
} | |
c170402 | }
}
lastDir := dirs[len(dirs)-1]
// We still walk the last (original) directory because it's non-sense we load templates not exist in original directory.
if err = filepath.Walk(lastDir, func(path string, info os.FileInfo, err error) error {
r, err := filepath.Rel(lastDir, path)
if err != nil {
return err
}
ext := GetExt(r)
for _, extension := range opt.Extensions {
if ext != extension {
continue
}
var data []byte
if !omitData {
// Loop over candidates of directory, break out once found.
// The file always exists because it's inside the walk function,
// and read original file is the worst case.
for i := range dirs {
path = filepath.Join(dirs[i], r)
if !com.IsFile(path) {
continue
}
data, err = ioutil.ReadFile(path)
if err != nil {
return err
}
break
}
}
name := filepath.ToSlash((r[0 : len(r)-len(ext)]))
fs.files = append(fs.files, NewTplFile(name, data, ext))
}
return nil
}); err != nil {
panic("NewTemplateFileSystem: " + err.Error())
}
return fs
} | |
c170403 |
sets: make(map[string]*template.Template),
dirs: make(map[string]string),
}
} | |
c170404 | base64.StdEncoding.EncodeToString([]byte(etag))
} | |
c170405 | err != nil {
return err
}
}
return g.Populate()
} | |
c170406 | fmt.Fprintf(&buf, " named %s", o.Name)
}
return buf.String()
} | |
c170407 | g.unnamedType[o.reflectType] = true
}
g.unnamed = append(g.unnamed, o)
} else {
if g.named == nil {
g.named = make(map[string]*Object)
}
if g.named[o.Name] != nil {
return fmt.Errorf("provided two instances named %s", o.Name)
}
g.named[o.Name] = o
}
if g.Logger != nil {
if o.created {
g.Logger.Debugf("created %s", o)
} else if o.embedded {
g.Logger.Debugf("provided embedded %s", o)
} else {
g.Logger.Debugf("provided %s", o)
}
}
}
return nil
} | |
c170408 | g.unnamed {
if o.Complete {
continue
}
if err := g.populateUnnamedInterface(o); err != nil {
return err
}
}
for _, o := range g.named {
if o.Complete {
continue
}
if err := g.populateUnnamedInterface(o); err != nil {
return err
}
}
return nil
} | |
c170409 | _, o := range g.named {
if !o.embedded {
objects = append(objects, o)
}
}
// randomize to prevent callers from relying on ordering
for i := 0; i < len(objects); i++ {
j := rand.Intn(i + 1)
objects[i], objects[j] = objects[j], objects[i]
}
return objects
} | |
c170410 | store,
name: name,
client: client,
cancel: cancel,
subscription: sub,
logger: logger,
closed: make(chan struct{}),
}
// Receive() will create goroutines as necessary to handle incoming messages. Reconnect
// on error. Stop processing messages only if Stop() is called
go func() {
for {
err := rcv.subscription.Receive(cctx, func(ctx context.Context, m *pubsub.Message) {
rcv.handleMessage(m)
m.Ack()
})
if err == context.Canceled {
close(rcv.closed)
rcv.Stop()
break
}
if err != nil {
rcv.logger.Error(err.Error())
}
time.Sleep(1 * time.Second)
}
}()
return rcv, nil
} | |
c170411 | send("metricsReceived", float64(metricsReceived))
errors := atomic.LoadUint32(&rcv.errors)
send("errors", float64(errors))
if !rcv.statsAsCounters {
atomic.AddUint32(&rcv.messagesReceived, -messagesReceived)
atomic.AddUint32(&rcv.metricsReceived, -metricsReceived)
atomic.AddUint32(&rcv.errors, -errors)
}
} | |
c170412 | NewConfig(),
PromRegistry: prometheus.NewPedanticRegistry(),
exit: make(chan bool),
}
return app
} | |
c170413 | write-strategy")
}
if cfg.Common.MetricEndpoint == "" {
cfg.Common.MetricEndpoint = MetricEndpointLocal
}
if cfg.Common.MetricEndpoint != MetricEndpointLocal {
u, err := url.Parse(cfg.Common.MetricEndpoint)
if err != nil {
return fmt.Errorf("common.metric-endpoint parse error: %s", err.Error())
}
if u.Scheme != "tcp" && u.Scheme != "udp" {
return fmt.Errorf("common.metric-endpoint supports only tcp and udp protocols. %#v is unsupported", u.Scheme)
}
}
app.Config = cfg
return nil
} | |
c170414 | prometheus.Labels(app.Config.Prometheus.Labels),
app.PromRegistry,
)
}
return err
} | |
c170415 | }
if app.Tags != nil {
app.Tags.Stop()
app.Tags = nil
}
app.startPersister()
if app.Collector != nil {
app.Collector.Stop()
app.Collector = nil
}
app.Collector = NewCollector(app)
return nil
} | |
c170416 |
}
if app.Receivers != nil {
for i := 0; i < len(app.Receivers); i++ {
app.Receivers[i].Stop()
logger.Debug("receiver stopped", zap.String("name", app.Receivers[i].Name))
}
app.Receivers = nil
}
} | |
c170417 | []byte("newest"), nil
case OffsetOldest:
return []byte("oldest"), nil
}
return []byte(fmt.Sprintf("%v", *o)), nil
} | |
c170418 | time.ParseDuration(offsetName)
if err != nil {
return err
}
*o = Offset(time.Now().Add(d).UnixNano())
}
return nil
} | |
c170419 | return []byte("protobuf"), nil
case ProtocolPickle:
return []byte("pickle"), nil
}
return nil, fmt.Errorf("Unsupported offset type %v, supported offsets: %v", p, supportedProtocols)
} | |
c170420 |
return fmt.Errorf("Unsupported protocol type %v, supported: %v", protocolName, supportedProtocols)
}
return nil
} | |
c170421 |
var err error
d.Duration, err = time.ParseDuration(string(text))
return err
} | |
c170422 | &Duration{Duration: 60 * time.Second},
FetchInterval: &Duration{Duration: 250 * time.Millisecond},
KafkaVersion: "0.11.0.0",
}
} | |
c170423 |
if !rcv.statsAsCounters {
atomic.AddUint64(&rcv.metricsReceived, -metricsReceived)
atomic.AddUint64(&rcv.errors, -errors)
}
} | |
c170424 | cacheSettings{
maxSize: 1000000,
tagsEnabled: false,
xlog: nil,
}
c.settings.Store(&settings)
c.writeoutQueue = NewWriteoutQueue(c)
return c
} | |
c170425 |
newSettings.maxSize = int32(maxSize)
c.settings.Store(&newSettings)
} | |
c170426 | return c.data[uint(fnv32(key))%uint(shardCount)]
} | |
c170427 | return
}
shard := c.GetShard(p.Metric)
shard.Lock()
if values, exists := shard.items[p.Metric]; exists {
values.Data = append(values.Data, p.Data...)
} else {
shard.items[p.Metric] = p
}
shard.Unlock()
atomic.AddInt32(&c.stat.size, int32(count))
} | |
c170428 | shard.Unlock()
if exists {
atomic.AddInt32(&c.stat.size, -int32(len(p.Data)))
}
return p, exists
} | |
c170429 | nil, badErr
}
if Type, ok = pickleGetStr(&d); !ok {
return nil, badErr
}
if !(pickleMaybeMemo(&d) && expectBytes(&d, []byte("U\x06metric")) && pickleMaybeMemo(&d)) {
return nil, badErr
}
if Metric, ok = pickleGetStr(&d); !ok {
return nil, badErr
}
if !pickleMaybeMemo(&d) {
return nil, badErr
}
req.Metric = Metric
req.Type = Type
} else {
return nil, badErr
}
return req, nil
} | |
c170430 | cache,
readTimeout: 30 * time.Second,
}
} | |
c170431 |
Metric: metric,
Data: []Point{
Point{
Value: value,
Timestamp: timestamp,
},
},
}
} | |
c170432 | OnePoint(metric, value, time.Now().Unix())
} | |
c170433 | p.Metric,
Data: p.Data,
}
} | |
c170434 |
return nil, fmt.Errorf("bad message: %#v", line)
}
// 315522000 == "1980-01-01 00:00:00"
// if tsf < 315532800 {
// return nil, fmt.Errorf("bad message: %#v", line)
// }
// 4102444800 = "2100-01-01 00:00:00"
// Hello people from the future
// if tsf > 4102444800 {
// return nil, fmt.Errorf("bad message: %#v", line)
// }
return OnePoint(row[0], value, int64(tsf)), nil
} | |
c170435 | len(p.Data); i++ {
if p.Data[i].Value != other.Data[i].Value {
return false
}
if p.Data[i].Timestamp != other.Data[i].Timestamp {
return false
}
}
return true
} | |
c170436 | := range s {
if schema.Pattern.MatchString(metric) {
return schema, true
}
}
return Schema{}, false
} | |
c170437 | && err2 == nil {
retention := whisper.NewRetention(int(val1), int(val2))
retentions = append(retentions, &retention)
continue
}
// try new format
retention, err := whisper.ParseRetentionDef(retentionDef)
if err != nil {
return nil, err
}
retentions = append(retentions, retention)
}
return retentions, nil
} | |
c170438 | zap.Duration("runtime", time.Since(startTime)),
)
}()
err := points.ReadFromFile(filename, func(p *points.Points) {
pointsCount += len(p.Data)
storeFunc(p)
})
return err
} | |
c170439 | len(list) == 0 {
logger.Info("nothing for restore")
return
}
sort.Strings(list)
for index, fileWithSortPrefix := range list {
list[index] = strings.SplitN(fileWithSortPrefix, ":", 2)[1]
}
logger.Info("start restore", zap.Int("files", len(list)))
for _, fn := range list {
filename := path.Join(dumpDir, fn)
app.RestoreFromFile(filename, storeFunc)
err = os.Remove(filename)
if err != nil {
logger.Error("remove failed", zap.String("filename", filename), zap.Error(err))
}
}
} | |
c170440 | throttledStoreFunc := func(p *points.Points) {
for i := 0; i < len(p.Data); i++ {
<-ticker.C
}
storeFunc(p)
}
app.RestoreFromDir(path, throttledStoreFunc)
} else {
app.RestoreFromDir(path, storeFunc)
}
} | |
c170441 | os.RemoveAll(tmpDir); err != nil {
t.Fatal(err)
}
}()
callback(tmpDir)
} | |
c170442 | atomic.AddUint32(&q.stat.deleteErrors, 1)
q.logger.Error("delete from queue database failed", zap.Error(err))
}
} | |
c170443 | aggregation,
workersCount: 1,
rootPath: rootPath,
maxUpdatesPerSecond: 0,
logger: zapwriter.Logger("persister"),
createLogger: zapwriter.Logger("whisper:new"),
}
} | |
c170444 | nil,
xFilesFactor: 0.5,
aggregationMethodStr: "average",
aggregationMethod: whisper.Average,
},
}
} | |
c170445 |
if s.pattern.MatchString(metric) {
return s
}
}
return a.Default
} | |
c170446 | return result, errors.New("unfinished line in file")
}
p, err := points.ParseText(string(line))
if err != nil {
return result, err
}
result = append(result, p)
}
return result, nil
} | |
c170447 | client.doJsonRequest("PUT", "/v1/integration/pagerduty", pdIntegration, nil)
} | |
c170448 | client.doJsonRequest("GET", "/v1/integration/pagerduty", nil, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170449 | client.doJsonRequest("POST", "/v1/integration/slack", slackIntegration, nil)
} | |
c170450 | client.doJsonRequest("PUT", "/v1/integration/slack", slackIntegration, nil)
} | |
c170451 | client.doJsonRequest("GET", "/v1/integration/slack", nil, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170452 | client.doJsonRequest("POST", "/v1/integration/aws", awsAccount, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170453 | client.doJsonRequest("GET", "/v1/integration/aws", nil, &response); err != nil {
return nil, err
}
return &response.Accounts, nil
} | |
c170454 | client.doJsonRequest("DELETE", "/v1/integration/aws", awsAccount, nil)
} | |
c170455 | client.doJsonRequest("GET", "/v1/integration/gcp", nil, &list); err != nil {
return nil, err
}
return list, nil
} | |
c170456 | client.doJsonRequest("POST", "/v1/integration/gcp", cir, nil)
} | |
c170457 | client.doJsonRequest("POST", "/v1/integration/gcp/host_filters", cir, nil)
} | |
c170458 | client.doJsonRequest("DELETE", "/v1/integration/gcp", cir, nil)
} | |
c170459 | fmt.Sprintf("/v1/dashboard/lists/manual/%d", id), nil, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170460 |
if err := client.doJsonRequest("GET", "/v1/dashboard/lists/manual", nil, &out); err != nil {
return nil, err
}
return out.DashboardLists, nil
} | |
c170461 | client.doJsonRequest("POST", "/v1/dashboard/lists/manual", list, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170462 |
return client.doJsonRequest("PUT", fmt.Sprintf("/v1/dashboard/lists/manual/%d", *list.Id), req, nil)
} | |
c170463 | err := client.doJsonRequest("GET", fmt.Sprintf("/v1/dashboard/lists/manual/%d/dashboards", id), nil, &out); err != nil {
return nil, err
}
return out.Dashboards, nil
} | |
c170464 | map[string]string{"metric_query": query, "event_query": eventQuery}
return client.SnapshotGeneric(options, start, end)
} | |
c170465 | &out); err != nil {
return nil, err
}
return out.Results.Hosts, nil
} | |
c170466 | &out); err != nil {
return nil, err
}
return out.Results.Metrics, nil
} | |
c170467 |
if err := client.doJsonRequest("POST", "/v1/alert", alert, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170468 | client.doJsonRequest("PUT", fmt.Sprintf("/v1/alert/%d", alert.Id),
alert, nil)
} | |
c170469 | nil, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170470 | &out); err != nil {
return nil, err
}
return out.Alerts, nil
} | |
c170471 | if len(handle) > 0 {
comment.Handle = String(handle)
}
if err := client.doJsonRequest("POST", "/v1/comments", &comment, &out); err != nil {
return nil, err
}
return out.Comment, nil
} | |
c170472 | := client.doJsonRequest("POST", "/v1/comments", &comment, &out); err != nil {
return nil, err
}
return out.Comment, nil
} | |
c170473 | if len(handle) > 0 {
comment.Handle = String(handle)
}
return client.doJsonRequest("PUT", fmt.Sprintf("/v1/comments/%d", id),
&comment, nil)
} | |
c170474 | client.doJsonRequest("POST", "/v1/monitor", monitor, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170475 | client.doJsonRequest("PUT", fmt.Sprintf("/v1/monitor/%d", *monitor.Id),
monitor, nil)
} | |
c170476 | client.doJsonRequest("GET", fmt.Sprintf("/v1/monitor/%d", id), nil, &out); err != nil {
return nil, err
}
return &out, nil
} | |
c170477 | self.doJsonRequest("GET", fmt.Sprintf("/v1/monitor?%v", query.Encode()), nil, &out.Monitors)
if err != nil {
return nil, err
}
return out.Monitors, nil
} | |
c170478 | = self.doJsonRequest("GET", fmt.Sprintf("/v1/monitor?%v", query.Encode()), nil, &out.Monitors)
if err != nil {
return nil, err
}
return out.Monitors, nil
} | |
c170479 | &out.Monitors); err != nil {
return nil, err
}
return out.Monitors, nil
} | |
c170480 | `json:"locations,omitempty"`
}
if err := client.doJsonRequest("GET", "/v1/synthetics/locations", nil, &out); err != nil {
return nil, err
}
return out.Locations, nil
} | |
c170481 | v != nil {
return *v, true
}
return false, false
} | |
c170482 | true
}
return 0, false
} | |
c170483 | return *v, true
}
return "", false
} | |
c170484 | return *v, true
}
return "", false
} | |
c170485 | return *v, true
}
return PrecisionT(""), false
} | |
c170486 | return v, nil
default:
return "", errors.New("unsupported id type")
}
} | |
c170487 |
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/dash/%s", stringId), nil, &out); err != nil {
return nil, err
}
return out.Dashboard, nil
} | |
c170488 |
if err := client.doJsonRequest("GET", "/v1/dash", nil, &out); err != nil {
return nil, err
}
return out.Dashboards, nil
} | |
c170489 |
if err := client.doJsonRequest("POST", "/v1/dash", dash, &out); err != nil {
return nil, err
}
return out.Dashboard, nil
} | |
c170490 | fmt.Sprintf("/v1/dash/%d", *dash.Id),
dash, nil)
} | |
c170491 | client.doJsonRequest("POST", "/v1/invite_users",
reqInviteUsers{Emails: emails}, nil)
} | |
c170492 | struct {
*User `json:"user"`
}{}
if err := self.doJsonRequest("POST", "/v1/user", in, &out); err != nil {
return nil, err
}
return out.User, nil
} | |
c170493 |
uri := "/v1/user"
err = client.doJsonRequest("GET", uri, nil, &udata)
users = udata.Users
return
} | |
c170494 | = client.doJsonRequest("GET", uri, nil, &udata)
user = udata.User
return
} | |
c170495 |
return client.doJsonRequest("PUT", uri, user, nil)
} | |
c170496 | uri := "/v1/user/" + handle
return client.doJsonRequest("DELETE", uri, nil, nil)
} | |
c170497 | nil, &board); err != nil {
return nil, err
}
return &board, nil
} | |
c170498 | client.doJsonRequest("DELETE", fmt.Sprintf("/v1/dashboard/%s", id), nil, nil)
} | |
c170499 | board, &createdBoard); err != nil {
return nil, err
}
return &createdBoard, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.