id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
128,400
influxdata/telegraf
plugins/inputs/ipmi_sensor/ipmi.go
aToFloat
func aToFloat(val string) (float64, error) { f, err := strconv.ParseFloat(val, 64) if err != nil { return 0.0, err } return f, nil }
go
func aToFloat(val string) (float64, error) { f, err := strconv.ParseFloat(val, 64) if err != nil { return 0.0, err } return f, nil }
[ "func", "aToFloat", "(", "val", "string", ")", "(", "float64", ",", "error", ")", "{", "f", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "val", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0.0", ",", "err", "\n", "}", ...
// aToFloat converts string representations of numbers to float64 values
[ "aToFloat", "converts", "string", "representations", "of", "numbers", "to", "float64", "values" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ipmi_sensor/ipmi.go#L246-L252
128,401
influxdata/telegraf
plugins/parsers/influx/parser.go
NewParser
func NewParser(handler *MetricHandler) *Parser { return &Parser{ machine: NewMachine(handler), handler: handler, } }
go
func NewParser(handler *MetricHandler) *Parser { return &Parser{ machine: NewMachine(handler), handler: handler, } }
[ "func", "NewParser", "(", "handler", "*", "MetricHandler", ")", "*", "Parser", "{", "return", "&", "Parser", "{", "machine", ":", "NewMachine", "(", "handler", ")", ",", "handler", ":", "handler", ",", "}", "\n", "}" ]
// NewParser returns a Parser than accepts line protocol
[ "NewParser", "returns", "a", "Parser", "than", "accepts", "line", "protocol" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/influx/parser.go#L50-L55
128,402
influxdata/telegraf
plugins/parsers/influx/parser.go
NewSeriesParser
func NewSeriesParser(handler *MetricHandler) *Parser { return &Parser{ machine: NewSeriesMachine(handler), handler: handler, } }
go
func NewSeriesParser(handler *MetricHandler) *Parser { return &Parser{ machine: NewSeriesMachine(handler), handler: handler, } }
[ "func", "NewSeriesParser", "(", "handler", "*", "MetricHandler", ")", "*", "Parser", "{", "return", "&", "Parser", "{", "machine", ":", "NewSeriesMachine", "(", "handler", ")", ",", "handler", ":", "handler", ",", "}", "\n", "}" ]
// NewSeriesParser returns a Parser than accepts a measurement and tagset
[ "NewSeriesParser", "returns", "a", "Parser", "than", "accepts", "a", "measurement", "and", "tagset" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/influx/parser.go#L58-L63
128,403
influxdata/telegraf
plugins/outputs/prometheus_client/prometheus_client.go
Expire
func (p *PrometheusClient) Expire() { now := p.now() for name, family := range p.fam { for key, sample := range family.Samples { if p.ExpirationInterval.Duration != 0 && now.After(sample.Expiration) { for k := range sample.Labels { family.LabelSet[k]-- } delete(family.Samples, key) if len(f...
go
func (p *PrometheusClient) Expire() { now := p.now() for name, family := range p.fam { for key, sample := range family.Samples { if p.ExpirationInterval.Duration != 0 && now.After(sample.Expiration) { for k := range sample.Labels { family.LabelSet[k]-- } delete(family.Samples, key) if len(f...
[ "func", "(", "p", "*", "PrometheusClient", ")", "Expire", "(", ")", "{", "now", ":=", "p", ".", "now", "(", ")", "\n", "for", "name", ",", "family", ":=", "range", "p", ".", "fam", "{", "for", "key", ",", "sample", ":=", "range", "family", ".", ...
// Expire removes Samples that have expired.
[ "Expire", "removes", "Samples", "that", "have", "expired", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/prometheus_client/prometheus_client.go#L276-L292
128,404
influxdata/telegraf
plugins/outputs/prometheus_client/prometheus_client.go
Collect
func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) { p.Lock() defer p.Unlock() p.Expire() for name, family := range p.fam { // Get list of all labels on MetricFamily var labelNames []string for k, v := range family.LabelSet { if v > 0 { labelNames = append(labelNames, k) } } desc ...
go
func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) { p.Lock() defer p.Unlock() p.Expire() for name, family := range p.fam { // Get list of all labels on MetricFamily var labelNames []string for k, v := range family.LabelSet { if v > 0 { labelNames = append(labelNames, k) } } desc ...
[ "func", "(", "p", "*", "PrometheusClient", ")", "Collect", "(", "ch", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n\n", "p", ".", "Expire", "(", ")", "\n\n", "for...
// Collect implements prometheus.Collector
[ "Collect", "implements", "prometheus", ".", "Collector" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/prometheus_client/prometheus_client.go#L295-L343
128,405
influxdata/telegraf
plugins/outputs/prometheus_client/prometheus_client.go
CreateSampleID
func CreateSampleID(tags map[string]string) SampleID { pairs := make([]string, 0, len(tags)) for k, v := range tags { pairs = append(pairs, fmt.Sprintf("%s=%s", k, v)) } sort.Strings(pairs) return SampleID(strings.Join(pairs, ",")) }
go
func CreateSampleID(tags map[string]string) SampleID { pairs := make([]string, 0, len(tags)) for k, v := range tags { pairs = append(pairs, fmt.Sprintf("%s=%s", k, v)) } sort.Strings(pairs) return SampleID(strings.Join(pairs, ",")) }
[ "func", "CreateSampleID", "(", "tags", "map", "[", "string", "]", "string", ")", "SampleID", "{", "pairs", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "tags", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "tags", "{",...
// CreateSampleID creates a SampleID based on the tags of a telegraf.Metric.
[ "CreateSampleID", "creates", "a", "SampleID", "based", "on", "the", "tags", "of", "a", "telegraf", ".", "Metric", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/prometheus_client/prometheus_client.go#L365-L372
128,406
influxdata/telegraf
internal/models/running_output.go
AddMetric
func (ro *RunningOutput) AddMetric(metric telegraf.Metric) { if ok := ro.Config.Filter.Select(metric); !ok { ro.metricFiltered(metric) return } ro.Config.Filter.Modify(metric) if len(metric.FieldList()) == 0 { ro.metricFiltered(metric) return } if output, ok := ro.Output.(telegraf.AggregatingOutput); ok...
go
func (ro *RunningOutput) AddMetric(metric telegraf.Metric) { if ok := ro.Config.Filter.Select(metric); !ok { ro.metricFiltered(metric) return } ro.Config.Filter.Modify(metric) if len(metric.FieldList()) == 0 { ro.metricFiltered(metric) return } if output, ok := ro.Output.(telegraf.AggregatingOutput); ok...
[ "func", "(", "ro", "*", "RunningOutput", ")", "AddMetric", "(", "metric", "telegraf", ".", "Metric", ")", "{", "if", "ok", ":=", "ro", ".", "Config", ".", "Filter", ".", "Select", "(", "metric", ")", ";", "!", "ok", "{", "ro", ".", "metricFiltered", ...
// AddMetric adds a metric to the output. // // Takes ownership of metric
[ "AddMetric", "adds", "a", "metric", "to", "the", "output", ".", "Takes", "ownership", "of", "metric" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/running_output.go#L102-L131
128,407
influxdata/telegraf
internal/models/running_output.go
Write
func (ro *RunningOutput) Write() error { if output, ok := ro.Output.(telegraf.AggregatingOutput); ok { ro.aggMutex.Lock() metrics := output.Push() ro.buffer.Add(metrics...) output.Reset() ro.aggMutex.Unlock() } atomic.StoreInt64(&ro.newMetricsCount, 0) // Only process the metrics in the buffer now. Met...
go
func (ro *RunningOutput) Write() error { if output, ok := ro.Output.(telegraf.AggregatingOutput); ok { ro.aggMutex.Lock() metrics := output.Push() ro.buffer.Add(metrics...) output.Reset() ro.aggMutex.Unlock() } atomic.StoreInt64(&ro.newMetricsCount, 0) // Only process the metrics in the buffer now. Met...
[ "func", "(", "ro", "*", "RunningOutput", ")", "Write", "(", ")", "error", "{", "if", "output", ",", "ok", ":=", "ro", ".", "Output", ".", "(", "telegraf", ".", "AggregatingOutput", ")", ";", "ok", "{", "ro", ".", "aggMutex", ".", "Lock", "(", ")", ...
// Write writes all metrics to the output, stopping when all have been sent on // or error.
[ "Write", "writes", "all", "metrics", "to", "the", "output", "stopping", "when", "all", "have", "been", "sent", "on", "or", "error", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/running_output.go#L135-L164
128,408
influxdata/telegraf
internal/models/running_output.go
WriteBatch
func (ro *RunningOutput) WriteBatch() error { batch := ro.buffer.Batch(ro.MetricBatchSize) if len(batch) == 0 { return nil } err := ro.write(batch) if err != nil { ro.buffer.Reject(batch) return err } ro.buffer.Accept(batch) return nil }
go
func (ro *RunningOutput) WriteBatch() error { batch := ro.buffer.Batch(ro.MetricBatchSize) if len(batch) == 0 { return nil } err := ro.write(batch) if err != nil { ro.buffer.Reject(batch) return err } ro.buffer.Accept(batch) return nil }
[ "func", "(", "ro", "*", "RunningOutput", ")", "WriteBatch", "(", ")", "error", "{", "batch", ":=", "ro", ".", "buffer", ".", "Batch", "(", "ro", ".", "MetricBatchSize", ")", "\n", "if", "len", "(", "batch", ")", "==", "0", "{", "return", "nil", "\n...
// WriteBatch writes a single batch of metrics to the output.
[ "WriteBatch", "writes", "a", "single", "batch", "of", "metrics", "to", "the", "output", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/running_output.go#L167-L181
128,409
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
Connect
func (a *AzureMonitor) Connect() error { a.cache = make(map[time.Time]map[uint64]*aggregate, 36) if a.Timeout.Duration == 0 { a.Timeout.Duration = defaultRequestTimeout } a.client = &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, }, Timeout: a.Timeout.Duration, } if a.Nam...
go
func (a *AzureMonitor) Connect() error { a.cache = make(map[time.Time]map[uint64]*aggregate, 36) if a.Timeout.Duration == 0 { a.Timeout.Duration = defaultRequestTimeout } a.client = &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, }, Timeout: a.Timeout.Duration, } if a.Nam...
[ "func", "(", "a", "*", "AzureMonitor", ")", "Connect", "(", ")", "error", "{", "a", ".", "cache", "=", "make", "(", "map", "[", "time", ".", "Time", "]", "map", "[", "uint64", "]", "*", "aggregate", ",", "36", ")", "\n\n", "if", "a", ".", "Time...
// Connect initializes the plugin and validates connectivity
[ "Connect", "initializes", "the", "plugin", "and", "validates", "connectivity" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L114-L182
128,410
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
vmInstanceMetadata
func vmInstanceMetadata(c *http.Client) (string, string, error) { req, err := http.NewRequest("GET", vmInstanceMetadataURL, nil) if err != nil { return "", "", fmt.Errorf("error creating request: %v", err) } req.Header.Set("Metadata", "true") resp, err := c.Do(req) if err != nil { return "", "", err } defe...
go
func vmInstanceMetadata(c *http.Client) (string, string, error) { req, err := http.NewRequest("GET", vmInstanceMetadataURL, nil) if err != nil { return "", "", fmt.Errorf("error creating request: %v", err) } req.Header.Set("Metadata", "true") resp, err := c.Do(req) if err != nil { return "", "", err } defe...
[ "func", "vmInstanceMetadata", "(", "c", "*", "http", ".", "Client", ")", "(", "string", ",", "string", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "vmInstanceMetadataURL", ",", "nil", ")", "\n", "...
// vmMetadata retrieves metadata about the current Azure VM
[ "vmMetadata", "retrieves", "metadata", "about", "the", "current", "Azure", "VM" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L185-L230
128,411
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
Write
func (a *AzureMonitor) Write(metrics []telegraf.Metric) error { azmetrics := make(map[uint64]*azureMonitorMetric, len(metrics)) for _, m := range metrics { id := hashIDWithTagKeysOnly(m) if azm, ok := azmetrics[id]; !ok { amm, err := translate(m, a.NamespacePrefix) if err != nil { log.Printf("E! [output...
go
func (a *AzureMonitor) Write(metrics []telegraf.Metric) error { azmetrics := make(map[uint64]*azureMonitorMetric, len(metrics)) for _, m := range metrics { id := hashIDWithTagKeysOnly(m) if azm, ok := azmetrics[id]; !ok { amm, err := translate(m, a.NamespacePrefix) if err != nil { log.Printf("E! [output...
[ "func", "(", "a", "*", "AzureMonitor", ")", "Write", "(", "metrics", "[", "]", "telegraf", ".", "Metric", ")", "error", "{", "azmetrics", ":=", "make", "(", "map", "[", "uint64", "]", "*", "azureMonitorMetric", ",", "len", "(", "metrics", ")", ")", "...
// Write writes metrics to the remote endpoint
[ "Write", "writes", "metrics", "to", "the", "remote", "endpoint" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L263-L314
128,412
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
Add
func (a *AzureMonitor) Add(m telegraf.Metric) { // Azure Monitor only supports aggregates 30 minutes into the past and 4 // minutes into the future. Future metrics are dropped when pushed. t := m.Time() tbucket := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), 0, 0, t.Location()) if tbucket.Before(a...
go
func (a *AzureMonitor) Add(m telegraf.Metric) { // Azure Monitor only supports aggregates 30 minutes into the past and 4 // minutes into the future. Future metrics are dropped when pushed. t := m.Time() tbucket := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), 0, 0, t.Location()) if tbucket.Before(a...
[ "func", "(", "a", "*", "AzureMonitor", ")", "Add", "(", "m", "telegraf", ".", "Metric", ")", "{", "// Azure Monitor only supports aggregates 30 minutes into the past and 4", "// minutes into the future. Future metrics are dropped when pushed.", "t", ":=", "m", ".", "Time", ...
// Add will append a metric to the output aggregate
[ "Add", "will", "append", "a", "metric", "to", "the", "output", "aggregate" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L464-L534
128,413
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
Push
func (a *AzureMonitor) Push() []telegraf.Metric { var metrics []telegraf.Metric for tbucket, aggs := range a.cache { // Do not send metrics early if tbucket.After(a.timeFunc().Add(-time.Minute)) { continue } for _, agg := range aggs { // Only send aggregates that have had an update since the last push. ...
go
func (a *AzureMonitor) Push() []telegraf.Metric { var metrics []telegraf.Metric for tbucket, aggs := range a.cache { // Do not send metrics early if tbucket.After(a.timeFunc().Add(-time.Minute)) { continue } for _, agg := range aggs { // Only send aggregates that have had an update since the last push. ...
[ "func", "(", "a", "*", "AzureMonitor", ")", "Push", "(", ")", "[", "]", "telegraf", ".", "Metric", "{", "var", "metrics", "[", "]", "telegraf", ".", "Metric", "\n", "for", "tbucket", ",", "aggs", ":=", "range", "a", ".", "cache", "{", "// Do not send...
// Push sends metrics to the output metric buffer
[ "Push", "sends", "metrics", "to", "the", "output", "metric", "buffer" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L572-L609
128,414
influxdata/telegraf
plugins/outputs/azure_monitor/azure_monitor.go
Reset
func (a *AzureMonitor) Reset() { for tbucket := range a.cache { // Remove aggregates older than 30 minutes if tbucket.Before(a.timeFunc().Add(-time.Minute * 30)) { delete(a.cache, tbucket) continue } // Metrics updated within the latest 1m have not been pushed and should // not be cleared. if tbucket...
go
func (a *AzureMonitor) Reset() { for tbucket := range a.cache { // Remove aggregates older than 30 minutes if tbucket.Before(a.timeFunc().Add(-time.Minute * 30)) { delete(a.cache, tbucket) continue } // Metrics updated within the latest 1m have not been pushed and should // not be cleared. if tbucket...
[ "func", "(", "a", "*", "AzureMonitor", ")", "Reset", "(", ")", "{", "for", "tbucket", ":=", "range", "a", ".", "cache", "{", "// Remove aggregates older than 30 minutes", "if", "tbucket", ".", "Before", "(", "a", ".", "timeFunc", "(", ")", ".", "Add", "(...
// Reset clears the cache of aggregate metrics
[ "Reset", "clears", "the", "cache", "of", "aggregate", "metrics" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/azure_monitor/azure_monitor.go#L612-L628
128,415
influxdata/telegraf
plugins/inputs/procstat/native_finder_windows.go
Pattern
func (pg *NativeFinder) Pattern(pattern string) ([]PID, error) { var pids []PID regxPattern, err := regexp.Compile(pattern) if err != nil { return pids, err } procs, err := process.Processes() if err != nil { return pids, err } for _, p := range procs { name, err := p.Name() if err != nil { //skip, t...
go
func (pg *NativeFinder) Pattern(pattern string) ([]PID, error) { var pids []PID regxPattern, err := regexp.Compile(pattern) if err != nil { return pids, err } procs, err := process.Processes() if err != nil { return pids, err } for _, p := range procs { name, err := p.Name() if err != nil { //skip, t...
[ "func", "(", "pg", "*", "NativeFinder", ")", "Pattern", "(", "pattern", "string", ")", "(", "[", "]", "PID", ",", "error", ")", "{", "var", "pids", "[", "]", "PID", "\n", "regxPattern", ",", "err", ":=", "regexp", ".", "Compile", "(", "pattern", ")...
//Pattern matches on the process name
[ "Pattern", "matches", "on", "the", "process", "name" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder_windows.go#L25-L47
128,416
influxdata/telegraf
plugins/inputs/procstat/native_finder_windows.go
FullPattern
func (pg *NativeFinder) FullPattern(pattern string) ([]PID, error) { var pids []PID procs, err := getWin32ProcsByVariable("CommandLine", like, pattern, Timeout) if err != nil { return pids, err } for _, p := range procs { pids = append(pids, PID(p.ProcessID)) } return pids, nil }
go
func (pg *NativeFinder) FullPattern(pattern string) ([]PID, error) { var pids []PID procs, err := getWin32ProcsByVariable("CommandLine", like, pattern, Timeout) if err != nil { return pids, err } for _, p := range procs { pids = append(pids, PID(p.ProcessID)) } return pids, nil }
[ "func", "(", "pg", "*", "NativeFinder", ")", "FullPattern", "(", "pattern", "string", ")", "(", "[", "]", "PID", ",", "error", ")", "{", "var", "pids", "[", "]", "PID", "\n", "procs", ",", "err", ":=", "getWin32ProcsByVariable", "(", "\"", "\"", ",",...
//FullPattern matches the cmdLine on windows and will find a pattern using a WMI like query
[ "FullPattern", "matches", "the", "cmdLine", "on", "windows", "and", "will", "find", "a", "pattern", "using", "a", "WMI", "like", "query" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder_windows.go#L50-L60
128,417
influxdata/telegraf
plugins/inputs/procstat/native_finder_windows.go
getWin32ProcsByVariable
func getWin32ProcsByVariable(variable string, qType queryType, value string, timeout time.Duration) ([]process.Win32_Process, error) { var dst []process.Win32_Process var query string // should look like "WHERE CommandLine LIKE "procstat" query = fmt.Sprintf("WHERE %s %s %q", variable, qType, value) q := wmi.Creat...
go
func getWin32ProcsByVariable(variable string, qType queryType, value string, timeout time.Duration) ([]process.Win32_Process, error) { var dst []process.Win32_Process var query string // should look like "WHERE CommandLine LIKE "procstat" query = fmt.Sprintf("WHERE %s %s %q", variable, qType, value) q := wmi.Creat...
[ "func", "getWin32ProcsByVariable", "(", "variable", "string", ",", "qType", "queryType", ",", "value", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "[", "]", "process", ".", "Win32_Process", ",", "error", ")", "{", "var", "dst", "[", "]", ...
//GetWin32ProcsByVariable allows you to query any variable with a like query
[ "GetWin32ProcsByVariable", "allows", "you", "to", "query", "any", "variable", "with", "a", "like", "query" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder_windows.go#L63-L76
128,418
influxdata/telegraf
plugins/inputs/procstat/native_finder_windows.go
WMIQueryWithContext
func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, connectServerArgs ...interface{}) error { errChan := make(chan error, 1) go func() { errChan <- wmi.Query(query, dst, connectServerArgs...) }() select { case <-ctx.Done(): return ctx.Err() case err := <-errChan: return err } }
go
func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, connectServerArgs ...interface{}) error { errChan := make(chan error, 1) go func() { errChan <- wmi.Query(query, dst, connectServerArgs...) }() select { case <-ctx.Done(): return ctx.Err() case err := <-errChan: return err } }
[ "func", "WMIQueryWithContext", "(", "ctx", "context", ".", "Context", ",", "query", "string", ",", "dst", "interface", "{", "}", ",", "connectServerArgs", "...", "interface", "{", "}", ")", "error", "{", "errChan", ":=", "make", "(", "chan", "error", ",", ...
// WMIQueryWithContext - wraps wmi.Query with a timed-out context to avoid hanging
[ "WMIQueryWithContext", "-", "wraps", "wmi", ".", "Query", "with", "a", "timed", "-", "out", "context", "to", "avoid", "hanging" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder_windows.go#L79-L91
128,419
influxdata/telegraf
plugins/inputs/kubernetes/kubernetes.go
Gather
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error { acc.AddError(k.gatherSummary(k.URL, acc)) return nil }
go
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error { acc.AddError(k.gatherSummary(k.URL, acc)) return nil }
[ "func", "(", "k", "*", "Kubernetes", ")", "Gather", "(", "acc", "telegraf", ".", "Accumulator", ")", "error", "{", "acc", ".", "AddError", "(", "k", ".", "gatherSummary", "(", "k", ".", "URL", ",", "acc", ")", ")", "\n", "return", "nil", "\n", "}" ...
//Gather collects kubernetes metrics from a given URL
[ "Gather", "collects", "kubernetes", "metrics", "from", "a", "given", "URL" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/kubernetes/kubernetes.go#L75-L78
128,420
influxdata/telegraf
plugins/serializers/registry.go
NewSerializer
func NewSerializer(config *Config) (Serializer, error) { var err error var serializer Serializer switch config.DataFormat { case "influx": serializer, err = NewInfluxSerializerConfig(config) case "graphite": serializer, err = NewGraphiteSerializer(config.Prefix, config.Template, config.GraphiteTagSupport) cas...
go
func NewSerializer(config *Config) (Serializer, error) { var err error var serializer Serializer switch config.DataFormat { case "influx": serializer, err = NewInfluxSerializerConfig(config) case "graphite": serializer, err = NewGraphiteSerializer(config.Prefix, config.Template, config.GraphiteTagSupport) cas...
[ "func", "NewSerializer", "(", "config", "*", "Config", ")", "(", "Serializer", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "serializer", "Serializer", "\n", "switch", "config", ".", "DataFormat", "{", "case", "\"", "\"", ":", "serializer", ...
// NewSerializer a Serializer interface based on the given config.
[ "NewSerializer", "a", "Serializer", "interface", "based", "on", "the", "given", "config", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/registry.go#L80-L102
128,421
influxdata/telegraf
plugins/serializers/influx/escape.go
escape
func escape(s string) string { if strings.ContainsAny(s, escapes) { return escaper.Replace(s) } else { return s } }
go
func escape(s string) string { if strings.ContainsAny(s, escapes) { return escaper.Replace(s) } else { return s } }
[ "func", "escape", "(", "s", "string", ")", "string", "{", "if", "strings", ".", "ContainsAny", "(", "s", ",", "escapes", ")", "{", "return", "escaper", ".", "Replace", "(", "s", ")", "\n", "}", "else", "{", "return", "s", "\n", "}", "\n", "}" ]
// Escape a tagkey, tagvalue, or fieldkey
[ "Escape", "a", "tagkey", "tagvalue", "or", "fieldkey" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/escape.go#L38-L44
128,422
influxdata/telegraf
plugins/serializers/influx/escape.go
nameEscape
func nameEscape(s string) string { if strings.ContainsAny(s, nameEscapes) { return nameEscaper.Replace(s) } else { return s } }
go
func nameEscape(s string) string { if strings.ContainsAny(s, nameEscapes) { return nameEscaper.Replace(s) } else { return s } }
[ "func", "nameEscape", "(", "s", "string", ")", "string", "{", "if", "strings", ".", "ContainsAny", "(", "s", ",", "nameEscapes", ")", "{", "return", "nameEscaper", ".", "Replace", "(", "s", ")", "\n", "}", "else", "{", "return", "s", "\n", "}", "\n",...
// Escape a measurement name
[ "Escape", "a", "measurement", "name" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/escape.go#L47-L53
128,423
influxdata/telegraf
plugins/serializers/influx/escape.go
stringFieldEscape
func stringFieldEscape(s string) string { if strings.ContainsAny(s, stringFieldEscapes) { return stringFieldEscaper.Replace(s) } else { return s } }
go
func stringFieldEscape(s string) string { if strings.ContainsAny(s, stringFieldEscapes) { return stringFieldEscaper.Replace(s) } else { return s } }
[ "func", "stringFieldEscape", "(", "s", "string", ")", "string", "{", "if", "strings", ".", "ContainsAny", "(", "s", ",", "stringFieldEscapes", ")", "{", "return", "stringFieldEscaper", ".", "Replace", "(", "s", ")", "\n", "}", "else", "{", "return", "s", ...
// Escape a string field
[ "Escape", "a", "string", "field" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/escape.go#L56-L62
128,424
influxdata/telegraf
plugins/inputs/vsphere/tscache.go
NewTSCache
func NewTSCache(ttl time.Duration) *TSCache { return &TSCache{ ttl: ttl, table: make(map[string]time.Time), done: make(chan struct{}), } }
go
func NewTSCache(ttl time.Duration) *TSCache { return &TSCache{ ttl: ttl, table: make(map[string]time.Time), done: make(chan struct{}), } }
[ "func", "NewTSCache", "(", "ttl", "time", ".", "Duration", ")", "*", "TSCache", "{", "return", "&", "TSCache", "{", "ttl", ":", "ttl", ",", "table", ":", "make", "(", "map", "[", "string", "]", "time", ".", "Time", ")", ",", "done", ":", "make", ...
// NewTSCache creates a new TSCache with a specified time-to-live after which timestamps are discarded.
[ "NewTSCache", "creates", "a", "new", "TSCache", "with", "a", "specified", "time", "-", "to", "-", "live", "after", "which", "timestamps", "are", "discarded", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/tscache.go#L18-L24
128,425
influxdata/telegraf
plugins/inputs/vsphere/tscache.go
Purge
func (t *TSCache) Purge() { t.mux.Lock() defer t.mux.Unlock() n := 0 for k, v := range t.table { if time.Now().Sub(v) > t.ttl { delete(t.table, k) n++ } } log.Printf("D! [inputs.vsphere] Purged timestamp cache. %d deleted with %d remaining", n, len(t.table)) }
go
func (t *TSCache) Purge() { t.mux.Lock() defer t.mux.Unlock() n := 0 for k, v := range t.table { if time.Now().Sub(v) > t.ttl { delete(t.table, k) n++ } } log.Printf("D! [inputs.vsphere] Purged timestamp cache. %d deleted with %d remaining", n, len(t.table)) }
[ "func", "(", "t", "*", "TSCache", ")", "Purge", "(", ")", "{", "t", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mux", ".", "Unlock", "(", ")", "\n", "n", ":=", "0", "\n", "for", "k", ",", "v", ":=", "range", "t", ".", "ta...
// Purge removes timestamps that are older than the time-to-live
[ "Purge", "removes", "timestamps", "that", "are", "older", "than", "the", "time", "-", "to", "-", "live" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/tscache.go#L27-L38
128,426
influxdata/telegraf
plugins/inputs/vsphere/tscache.go
IsNew
func (t *TSCache) IsNew(key string, tm time.Time) bool { t.mux.RLock() defer t.mux.RUnlock() v, ok := t.table[key] if !ok { return true // We've never seen this before, so consider everything a new sample } return !tm.Before(v) }
go
func (t *TSCache) IsNew(key string, tm time.Time) bool { t.mux.RLock() defer t.mux.RUnlock() v, ok := t.table[key] if !ok { return true // We've never seen this before, so consider everything a new sample } return !tm.Before(v) }
[ "func", "(", "t", "*", "TSCache", ")", "IsNew", "(", "key", "string", ",", "tm", "time", ".", "Time", ")", "bool", "{", "t", ".", "mux", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "mux", ".", "RUnlock", "(", ")", "\n", "v", ",", "ok", ...
// IsNew returns true if the supplied timestamp for the supplied key is more recent than the // timestamp we have on record.
[ "IsNew", "returns", "true", "if", "the", "supplied", "timestamp", "for", "the", "supplied", "key", "is", "more", "recent", "than", "the", "timestamp", "we", "have", "on", "record", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/tscache.go#L42-L50
128,427
influxdata/telegraf
plugins/inputs/vsphere/tscache.go
Put
func (t *TSCache) Put(key string, time time.Time) { t.mux.Lock() defer t.mux.Unlock() t.table[key] = time }
go
func (t *TSCache) Put(key string, time time.Time) { t.mux.Lock() defer t.mux.Unlock() t.table[key] = time }
[ "func", "(", "t", "*", "TSCache", ")", "Put", "(", "key", "string", ",", "time", "time", ".", "Time", ")", "{", "t", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mux", ".", "Unlock", "(", ")", "\n", "t", ".", "table", "[", "...
// Put updates the latest timestamp for the supplied key.
[ "Put", "updates", "the", "latest", "timestamp", "for", "the", "supplied", "key", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/tscache.go#L61-L65
128,428
influxdata/telegraf
plugins/outputs/librato/librato.go
Connect
func (l *Librato) Connect() error { if l.APIUser == "" || l.APIToken == "" { return fmt.Errorf( "api_user and api_token are required fields for librato output") } l.client = &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, }, Timeout: l.Timeout.Duration, } return nil }
go
func (l *Librato) Connect() error { if l.APIUser == "" || l.APIToken == "" { return fmt.Errorf( "api_user and api_token are required fields for librato output") } l.client = &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, }, Timeout: l.Timeout.Duration, } return nil }
[ "func", "(", "l", "*", "Librato", ")", "Connect", "(", ")", "error", "{", "if", "l", ".", "APIUser", "==", "\"", "\"", "||", "l", ".", "APIToken", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "...
// Connect is the default output plugin connection function who make sure it // can connect to the endpoint
[ "Connect", "is", "the", "default", "output", "plugin", "connection", "function", "who", "make", "sure", "it", "can", "connect", "to", "the", "endpoint" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/librato/librato.go#L77-L89
128,429
influxdata/telegraf
internal/templating/matcher.go
add
func (m *matcher) add(filter string, template *Template) { if filter == "" { m.defaultTemplate = template m.root.separator = template.separator return } m.root.insert(filter, template) }
go
func (m *matcher) add(filter string, template *Template) { if filter == "" { m.defaultTemplate = template m.root.separator = template.separator return } m.root.insert(filter, template) }
[ "func", "(", "m", "*", "matcher", ")", "add", "(", "filter", "string", ",", "template", "*", "Template", ")", "{", "if", "filter", "==", "\"", "\"", "{", "m", ".", "defaultTemplate", "=", "template", "\n", "m", ".", "root", ".", "separator", "=", "...
// add inserts the template in the filter tree based the given filter
[ "add", "inserts", "the", "template", "in", "the", "filter", "tree", "based", "the", "given", "filter" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/matcher.go#L41-L48
128,430
influxdata/telegraf
internal/templating/matcher.go
match
func (m *matcher) match(line string) *Template { tmpl := m.root.search(line) if tmpl != nil { return tmpl } return m.defaultTemplate }
go
func (m *matcher) match(line string) *Template { tmpl := m.root.search(line) if tmpl != nil { return tmpl } return m.defaultTemplate }
[ "func", "(", "m", "*", "matcher", ")", "match", "(", "line", "string", ")", "*", "Template", "{", "tmpl", ":=", "m", ".", "root", ".", "search", "(", "line", ")", "\n", "if", "tmpl", "!=", "nil", "{", "return", "tmpl", "\n", "}", "\n", "return", ...
// match returns the template that matches the given measurement line. // If no template matches, the default template is returned.
[ "match", "returns", "the", "template", "that", "matches", "the", "given", "measurement", "line", ".", "If", "no", "template", "matches", "the", "default", "template", "is", "returned", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/matcher.go#L52-L58
128,431
influxdata/telegraf
plugins/inputs/riak/riak.go
NewRiak
func NewRiak() *Riak { tr := &http.Transport{ResponseHeaderTimeout: time.Duration(3 * time.Second)} client := &http.Client{ Transport: tr, Timeout: time.Duration(4 * time.Second), } return &Riak{client: client} }
go
func NewRiak() *Riak { tr := &http.Transport{ResponseHeaderTimeout: time.Duration(3 * time.Second)} client := &http.Client{ Transport: tr, Timeout: time.Duration(4 * time.Second), } return &Riak{client: client} }
[ "func", "NewRiak", "(", ")", "*", "Riak", "{", "tr", ":=", "&", "http", ".", "Transport", "{", "ResponseHeaderTimeout", ":", "time", ".", "Duration", "(", "3", "*", "time", ".", "Second", ")", "}", "\n", "client", ":=", "&", "http", ".", "Client", ...
// NewRiak return a new instance of Riak with a default http client
[ "NewRiak", "return", "a", "new", "instance", "of", "Riak", "with", "a", "default", "http", "client" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/riak/riak.go#L23-L30
128,432
influxdata/telegraf
plugins/inputs/riak/riak.go
gatherServer
func (r *Riak) gatherServer(s string, acc telegraf.Accumulator) error { // Parse the given URL to extract the server tag u, err := url.Parse(s) if err != nil { return fmt.Errorf("riak unable to parse given server url %s: %s", s, err) } // Perform the GET request to the riak /stats endpoint resp, err := r.clien...
go
func (r *Riak) gatherServer(s string, acc telegraf.Accumulator) error { // Parse the given URL to extract the server tag u, err := url.Parse(s) if err != nil { return fmt.Errorf("riak unable to parse given server url %s: %s", s, err) } // Perform the GET request to the riak /stats endpoint resp, err := r.clien...
[ "func", "(", "r", "*", "Riak", ")", "gatherServer", "(", "s", "string", ",", "acc", "telegraf", ".", "Accumulator", ")", "error", "{", "// Parse the given URL to extract the server tag", "u", ",", "err", ":=", "url", ".", "Parse", "(", "s", ")", "\n", "if"...
// Gathers stats from a single server, adding them to the accumulator
[ "Gathers", "stats", "from", "a", "single", "server", "adding", "them", "to", "the", "accumulator" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/riak/riak.go#L114-L198
128,433
influxdata/telegraf
plugins/inputs/net_response/net_response.go
Gather
func (n *NetResponse) Gather(acc telegraf.Accumulator) error { // Set default values if n.Timeout.Duration == 0 { n.Timeout.Duration = time.Second } if n.ReadTimeout.Duration == 0 { n.ReadTimeout.Duration = time.Second } // Check send and expected string if n.Protocol == "udp" && n.Send == "" { return erro...
go
func (n *NetResponse) Gather(acc telegraf.Accumulator) error { // Set default values if n.Timeout.Duration == 0 { n.Timeout.Duration = time.Second } if n.ReadTimeout.Duration == 0 { n.ReadTimeout.Duration = time.Second } // Check send and expected string if n.Protocol == "udp" && n.Send == "" { return erro...
[ "func", "(", "n", "*", "NetResponse", ")", "Gather", "(", "acc", "telegraf", ".", "Accumulator", ")", "error", "{", "// Set default values", "if", "n", ".", "Timeout", ".", "Duration", "==", "0", "{", "n", ".", "Timeout", ".", "Duration", "=", "time", ...
// Gather is called by telegraf when the plugin is executed on its interval. // It will call either UDPGather or TCPGather based on the configuration and // also fill an Accumulator that is supplied.
[ "Gather", "is", "called", "by", "telegraf", "when", "the", "plugin", "is", "executed", "on", "its", "interval", ".", "It", "will", "call", "either", "UDPGather", "or", "TCPGather", "based", "on", "the", "configuration", "and", "also", "fill", "an", "Accumula...
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/net_response/net_response.go#L186-L236
128,434
influxdata/telegraf
plugins/inputs/iptables/iptables.go
Gather
func (ipt *Iptables) Gather(acc telegraf.Accumulator) error { if ipt.Table == "" || len(ipt.Chains) == 0 { return nil } // best effort : we continue through the chains even if an error is encountered, // but we keep track of the last error. for _, chain := range ipt.Chains { data, e := ipt.lister(ipt.Table, ch...
go
func (ipt *Iptables) Gather(acc telegraf.Accumulator) error { if ipt.Table == "" || len(ipt.Chains) == 0 { return nil } // best effort : we continue through the chains even if an error is encountered, // but we keep track of the last error. for _, chain := range ipt.Chains { data, e := ipt.lister(ipt.Table, ch...
[ "func", "(", "ipt", "*", "Iptables", ")", "Gather", "(", "acc", "telegraf", ".", "Accumulator", ")", "error", "{", "if", "ipt", ".", "Table", "==", "\"", "\"", "||", "len", "(", "ipt", ".", "Chains", ")", "==", "0", "{", "return", "nil", "\n", "}...
// Gather gathers iptables packets and bytes throughput from the configured tables and chains.
[ "Gather", "gathers", "iptables", "packets", "and", "bytes", "throughput", "from", "the", "configured", "tables", "and", "chains", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/iptables/iptables.go#L54-L73
128,435
influxdata/telegraf
plugins/inputs/syslog/syslog.go
getAddressParts
func getAddressParts(a string) (string, string, error) { parts := strings.SplitN(a, "://", 2) if len(parts) != 2 { return "", "", fmt.Errorf("missing protocol within address '%s'", a) } u, _ := url.Parse(a) switch u.Scheme { case "unix", "unixpacket", "unixgram": return parts[0], parts[1], nil } var host ...
go
func getAddressParts(a string) (string, string, error) { parts := strings.SplitN(a, "://", 2) if len(parts) != 2 { return "", "", fmt.Errorf("missing protocol within address '%s'", a) } u, _ := url.Parse(a) switch u.Scheme { case "unix", "unixpacket", "unixgram": return parts[0], parts[1], nil } var host ...
[ "func", "getAddressParts", "(", "a", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "parts", ":=", "strings", ".", "SplitN", "(", "a", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "...
// getAddressParts returns the address scheme and host // it also sets defaults for them when missing // when the input address does not specify the protocol it returns an error
[ "getAddressParts", "returns", "the", "address", "scheme", "and", "host", "it", "also", "sets", "defaults", "for", "them", "when", "missing", "when", "the", "input", "address", "does", "not", "specify", "the", "protocol", "it", "returns", "an", "error" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/syslog/syslog.go#L191-L215
128,436
influxdata/telegraf
plugins/outputs/amqp/client.go
Connect
func Connect(config *ClientConfig) (*client, error) { client := &client{ config: config, } p := rand.Perm(len(config.brokers)) for _, n := range p { broker := config.brokers[n] log.Printf("D! Output [amqp] connecting to %q", broker) conn, err := amqp.DialConfig( broker, amqp.Config{ TLSClientConfig:...
go
func Connect(config *ClientConfig) (*client, error) { client := &client{ config: config, } p := rand.Perm(len(config.brokers)) for _, n := range p { broker := config.brokers[n] log.Printf("D! Output [amqp] connecting to %q", broker) conn, err := amqp.DialConfig( broker, amqp.Config{ TLSClientConfig:...
[ "func", "Connect", "(", "config", "*", "ClientConfig", ")", "(", "*", "client", ",", "error", ")", "{", "client", ":=", "&", "client", "{", "config", ":", "config", ",", "}", "\n\n", "p", ":=", "rand", ".", "Perm", "(", "len", "(", "config", ".", ...
// Connect opens a connection to one of the brokers at random
[ "Connect", "opens", "a", "connection", "to", "one", "of", "the", "brokers", "at", "random" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/amqp/client.go#L36-L77
128,437
influxdata/telegraf
plugins/inputs/nsq_consumer/nsq_consumer.go
Start
func (n *NSQConsumer) Start(ac telegraf.Accumulator) error { acc := ac.WithTracking(n.MaxUndeliveredMessages) sem := make(semaphore, n.MaxUndeliveredMessages) n.messages = make(map[telegraf.TrackingID]*nsq.Message, n.MaxUndeliveredMessages) ctx, cancel := context.WithCancel(context.Background()) n.cancel = cancel...
go
func (n *NSQConsumer) Start(ac telegraf.Accumulator) error { acc := ac.WithTracking(n.MaxUndeliveredMessages) sem := make(semaphore, n.MaxUndeliveredMessages) n.messages = make(map[telegraf.TrackingID]*nsq.Message, n.MaxUndeliveredMessages) ctx, cancel := context.WithCancel(context.Background()) n.cancel = cancel...
[ "func", "(", "n", "*", "NSQConsumer", ")", "Start", "(", "ac", "telegraf", ".", "Accumulator", ")", "error", "{", "acc", ":=", "ac", ".", "WithTracking", "(", "n", ".", "MaxUndeliveredMessages", ")", "\n", "sem", ":=", "make", "(", "semaphore", ",", "n...
// Start pulls data from nsq
[ "Start", "pulls", "data", "from", "nsq" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nsq_consumer/nsq_consumer.go#L92-L141
128,438
influxdata/telegraf
plugins/inputs/nsq_consumer/nsq_consumer.go
Stop
func (n *NSQConsumer) Stop() { n.cancel() n.wg.Wait() n.consumer.Stop() <-n.consumer.StopChan }
go
func (n *NSQConsumer) Stop() { n.cancel() n.wg.Wait() n.consumer.Stop() <-n.consumer.StopChan }
[ "func", "(", "n", "*", "NSQConsumer", ")", "Stop", "(", ")", "{", "n", ".", "cancel", "(", ")", "\n", "n", ".", "wg", ".", "Wait", "(", ")", "\n", "n", ".", "consumer", ".", "Stop", "(", ")", "\n", "<-", "n", ".", "consumer", ".", "StopChan",...
// Stop processing messages
[ "Stop", "processing", "messages" ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nsq_consumer/nsq_consumer.go#L169-L174
128,439
influxdata/telegraf
plugins/outputs/socket_writer/socket_writer.go
Write
func (sw *SocketWriter) Write(metrics []telegraf.Metric) error { if sw.Conn == nil { // previous write failed with permanent error and socket was closed. if err := sw.Connect(); err != nil { return err } } for _, m := range metrics { bs, err := sw.Serialize(m) if err != nil { //TODO log & keep going...
go
func (sw *SocketWriter) Write(metrics []telegraf.Metric) error { if sw.Conn == nil { // previous write failed with permanent error and socket was closed. if err := sw.Connect(); err != nil { return err } } for _, m := range metrics { bs, err := sw.Serialize(m) if err != nil { //TODO log & keep going...
[ "func", "(", "sw", "*", "SocketWriter", ")", "Write", "(", "metrics", "[", "]", "telegraf", ".", "Metric", ")", "error", "{", "if", "sw", ".", "Conn", "==", "nil", "{", "// previous write failed with permanent error and socket was closed.", "if", "err", ":=", ...
// Write writes the given metrics to the destination. // If an error is encountered, it is up to the caller to retry the same write again later. // Not parallel safe.
[ "Write", "writes", "the", "given", "metrics", "to", "the", "destination", ".", "If", "an", "error", "is", "encountered", "it", "is", "up", "to", "the", "caller", "to", "retry", "the", "same", "write", "again", "later", ".", "Not", "parallel", "safe", "."...
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/socket_writer/socket_writer.go#L120-L147
128,440
influxdata/telegraf
plugins/outputs/socket_writer/socket_writer.go
Close
func (sw *SocketWriter) Close() error { if sw.Conn == nil { return nil } err := sw.Conn.Close() sw.Conn = nil return err }
go
func (sw *SocketWriter) Close() error { if sw.Conn == nil { return nil } err := sw.Conn.Close() sw.Conn = nil return err }
[ "func", "(", "sw", "*", "SocketWriter", ")", "Close", "(", ")", "error", "{", "if", "sw", ".", "Conn", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", ":=", "sw", ".", "Conn", ".", "Close", "(", ")", "\n", "sw", ".", "Conn", "=", "...
// Close closes the connection. Noop if already closed.
[ "Close", "closes", "the", "connection", ".", "Noop", "if", "already", "closed", "." ]
6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1
https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/socket_writer/socket_writer.go#L150-L157
128,441
sirupsen/logrus
logrus.go
String
func (level Level) String() string { if b, err := level.MarshalText(); err == nil { return string(b) } else { return "unknown" } }
go
func (level Level) String() string { if b, err := level.MarshalText(); err == nil { return string(b) } else { return "unknown" } }
[ "func", "(", "level", "Level", ")", "String", "(", ")", "string", "{", "if", "b", ",", "err", ":=", "level", ".", "MarshalText", "(", ")", ";", "err", "==", "nil", "{", "return", "string", "(", "b", ")", "\n", "}", "else", "{", "return", "\"", ...
// Convert the Level to a string. E.g. PanicLevel becomes "panic".
[ "Convert", "the", "Level", "to", "a", "string", ".", "E", ".", "g", ".", "PanicLevel", "becomes", "panic", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logrus.go#L16-L22
128,442
sirupsen/logrus
logrus.go
ParseLevel
func ParseLevel(lvl string) (Level, error) { switch strings.ToLower(lvl) { case "panic": return PanicLevel, nil case "fatal": return FatalLevel, nil case "error": return ErrorLevel, nil case "warn", "warning": return WarnLevel, nil case "info": return InfoLevel, nil case "debug": return DebugLevel, n...
go
func ParseLevel(lvl string) (Level, error) { switch strings.ToLower(lvl) { case "panic": return PanicLevel, nil case "fatal": return FatalLevel, nil case "error": return ErrorLevel, nil case "warn", "warning": return WarnLevel, nil case "info": return InfoLevel, nil case "debug": return DebugLevel, n...
[ "func", "ParseLevel", "(", "lvl", "string", ")", "(", "Level", ",", "error", ")", "{", "switch", "strings", ".", "ToLower", "(", "lvl", ")", "{", "case", "\"", "\"", ":", "return", "PanicLevel", ",", "nil", "\n", "case", "\"", "\"", ":", "return", ...
// ParseLevel takes a string level and returns the Logrus log level constant.
[ "ParseLevel", "takes", "a", "string", "level", "and", "returns", "the", "Logrus", "log", "level", "constant", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logrus.go#L25-L45
128,443
sirupsen/logrus
entry.go
String
func (entry *Entry) String() (string, error) { serialized, err := entry.Logger.Formatter.Format(entry) if err != nil { return "", err } str := string(serialized) return str, nil }
go
func (entry *Entry) String() (string, error) { serialized, err := entry.Logger.Formatter.Format(entry) if err != nil { return "", err } str := string(serialized) return str, nil }
[ "func", "(", "entry", "*", "Entry", ")", "String", "(", ")", "(", "string", ",", "error", ")", "{", "serialized", ",", "err", ":=", "entry", ".", "Logger", ".", "Formatter", ".", "Format", "(", "entry", ")", "\n", "if", "err", "!=", "nil", "{", "...
// Returns the string representation from the reader and ultimately the // formatter.
[ "Returns", "the", "string", "representation", "from", "the", "reader", "and", "ultimately", "the", "formatter", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L90-L97
128,444
sirupsen/logrus
entry.go
WithContext
func (entry *Entry) WithContext(ctx context.Context) *Entry { return &Entry{Logger: entry.Logger, Data: entry.Data, Time: entry.Time, err: entry.err, Context: ctx} }
go
func (entry *Entry) WithContext(ctx context.Context) *Entry { return &Entry{Logger: entry.Logger, Data: entry.Data, Time: entry.Time, err: entry.err, Context: ctx} }
[ "func", "(", "entry", "*", "Entry", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "Entry", "{", "return", "&", "Entry", "{", "Logger", ":", "entry", ".", "Logger", ",", "Data", ":", "entry", ".", "Data", ",", "Time", ":", "en...
// Add a context to the Entry.
[ "Add", "a", "context", "to", "the", "Entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L105-L107
128,445
sirupsen/logrus
entry.go
WithField
func (entry *Entry) WithField(key string, value interface{}) *Entry { return entry.WithFields(Fields{key: value}) }
go
func (entry *Entry) WithField(key string, value interface{}) *Entry { return entry.WithFields(Fields{key: value}) }
[ "func", "(", "entry", "*", "Entry", ")", "WithField", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "*", "Entry", "{", "return", "entry", ".", "WithFields", "(", "Fields", "{", "key", ":", "value", "}", ")", "\n", "}" ]
// Add a single field to the Entry.
[ "Add", "a", "single", "field", "to", "the", "Entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L110-L112
128,446
sirupsen/logrus
entry.go
WithFields
func (entry *Entry) WithFields(fields Fields) *Entry { data := make(Fields, len(entry.Data)+len(fields)) for k, v := range entry.Data { data[k] = v } fieldErr := entry.err for k, v := range fields { isErrField := false if t := reflect.TypeOf(v); t != nil { switch t.Kind() { case reflect.Func: isErr...
go
func (entry *Entry) WithFields(fields Fields) *Entry { data := make(Fields, len(entry.Data)+len(fields)) for k, v := range entry.Data { data[k] = v } fieldErr := entry.err for k, v := range fields { isErrField := false if t := reflect.TypeOf(v); t != nil { switch t.Kind() { case reflect.Func: isErr...
[ "func", "(", "entry", "*", "Entry", ")", "WithFields", "(", "fields", "Fields", ")", "*", "Entry", "{", "data", ":=", "make", "(", "Fields", ",", "len", "(", "entry", ".", "Data", ")", "+", "len", "(", "fields", ")", ")", "\n", "for", "k", ",", ...
// Add a map of fields to the Entry.
[ "Add", "a", "map", "of", "fields", "to", "the", "Entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L115-L143
128,447
sirupsen/logrus
entry.go
WithTime
func (entry *Entry) WithTime(t time.Time) *Entry { return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t, err: entry.err, Context: entry.Context} }
go
func (entry *Entry) WithTime(t time.Time) *Entry { return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t, err: entry.err, Context: entry.Context} }
[ "func", "(", "entry", "*", "Entry", ")", "WithTime", "(", "t", "time", ".", "Time", ")", "*", "Entry", "{", "return", "&", "Entry", "{", "Logger", ":", "entry", ".", "Logger", ",", "Data", ":", "entry", ".", "Data", ",", "Time", ":", "t", ",", ...
// Overrides the time of the Entry.
[ "Overrides", "the", "time", "of", "the", "Entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L146-L148
128,448
sirupsen/logrus
entry.go
getPackageName
func getPackageName(f string) string { for { lastPeriod := strings.LastIndex(f, ".") lastSlash := strings.LastIndex(f, "/") if lastPeriod > lastSlash { f = f[:lastPeriod] } else { break } } return f }
go
func getPackageName(f string) string { for { lastPeriod := strings.LastIndex(f, ".") lastSlash := strings.LastIndex(f, "/") if lastPeriod > lastSlash { f = f[:lastPeriod] } else { break } } return f }
[ "func", "getPackageName", "(", "f", "string", ")", "string", "{", "for", "{", "lastPeriod", ":=", "strings", ".", "LastIndex", "(", "f", ",", "\"", "\"", ")", "\n", "lastSlash", ":=", "strings", ".", "LastIndex", "(", "f", ",", "\"", "\"", ")", "\n",...
// getPackageName reduces a fully qualified function name to the package name // There really ought to be to be a better way...
[ "getPackageName", "reduces", "a", "fully", "qualified", "function", "name", "to", "the", "package", "name", "There", "really", "ought", "to", "be", "to", "be", "a", "better", "way", "..." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L152-L164
128,449
sirupsen/logrus
entry.go
getCaller
func getCaller() *runtime.Frame { // cache this package's fully-qualified name callerInitOnce.Do(func() { pcs := make([]uintptr, 2) _ = runtime.Callers(0, pcs) logrusPackage = getPackageName(runtime.FuncForPC(pcs[1]).Name()) // now that we have the cache, we can skip a minimum count of known-logrus function...
go
func getCaller() *runtime.Frame { // cache this package's fully-qualified name callerInitOnce.Do(func() { pcs := make([]uintptr, 2) _ = runtime.Callers(0, pcs) logrusPackage = getPackageName(runtime.FuncForPC(pcs[1]).Name()) // now that we have the cache, we can skip a minimum count of known-logrus function...
[ "func", "getCaller", "(", ")", "*", "runtime", ".", "Frame", "{", "// cache this package's fully-qualified name", "callerInitOnce", ".", "Do", "(", "func", "(", ")", "{", "pcs", ":=", "make", "(", "[", "]", "uintptr", ",", "2", ")", "\n", "_", "=", "runt...
// getCaller retrieves the name of the first non-logrus calling function
[ "getCaller", "retrieves", "the", "name", "of", "the", "first", "non", "-", "logrus", "calling", "function" ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L167-L196
128,450
sirupsen/logrus
entry.go
log
func (entry Entry) log(level Level, msg string) { var buffer *bytes.Buffer // Default to now, but allow users to override if they want. // // We don't have to worry about polluting future calls to Entry#log() // with this assignment because this function is declared with a // non-pointer receiver. if entry.Time...
go
func (entry Entry) log(level Level, msg string) { var buffer *bytes.Buffer // Default to now, but allow users to override if they want. // // We don't have to worry about polluting future calls to Entry#log() // with this assignment because this function is declared with a // non-pointer receiver. if entry.Time...
[ "func", "(", "entry", "Entry", ")", "log", "(", "level", "Level", ",", "msg", "string", ")", "{", "var", "buffer", "*", "bytes", ".", "Buffer", "\n\n", "// Default to now, but allow users to override if they want.", "//", "// We don't have to worry about polluting futur...
// This function is not declared with a pointer value because otherwise // race conditions will occur when using multiple goroutines
[ "This", "function", "is", "not", "declared", "with", "a", "pointer", "value", "because", "otherwise", "race", "conditions", "will", "occur", "when", "using", "multiple", "goroutines" ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L206-L241
128,451
sirupsen/logrus
entry.go
Logln
func (entry *Entry) Logln(level Level, args ...interface{}) { if entry.Logger.IsLevelEnabled(level) { entry.Log(level, entry.sprintlnn(args...)) } }
go
func (entry *Entry) Logln(level Level, args ...interface{}) { if entry.Logger.IsLevelEnabled(level) { entry.Log(level, entry.sprintlnn(args...)) } }
[ "func", "(", "entry", "*", "Entry", ")", "Logln", "(", "level", "Level", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "entry", ".", "Logger", ".", "IsLevelEnabled", "(", "level", ")", "{", "entry", ".", "Log", "(", "level", ",", "entr...
// Entry Println family functions
[ "Entry", "Println", "family", "functions" ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L357-L361
128,452
sirupsen/logrus
entry.go
sprintlnn
func (entry *Entry) sprintlnn(args ...interface{}) string { msg := fmt.Sprintln(args...) return msg[:len(msg)-1] }
go
func (entry *Entry) sprintlnn(args ...interface{}) string { msg := fmt.Sprintln(args...) return msg[:len(msg)-1] }
[ "func", "(", "entry", "*", "Entry", ")", "sprintlnn", "(", "args", "...", "interface", "{", "}", ")", "string", "{", "msg", ":=", "fmt", ".", "Sprintln", "(", "args", "...", ")", "\n", "return", "msg", "[", ":", "len", "(", "msg", ")", "-", "1", ...
// Sprintlnn => Sprint no newline. This is to get the behavior of how // fmt.Sprintln where spaces are always added between operands, regardless of // their type. Instead of vendoring the Sprintln implementation to spare a // string allocation, we do the simplest thing.
[ "Sprintlnn", "=", ">", "Sprint", "no", "newline", ".", "This", "is", "to", "get", "the", "behavior", "of", "how", "fmt", ".", "Sprintln", "where", "spaces", "are", "always", "added", "between", "operands", "regardless", "of", "their", "type", ".", "Instead...
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/entry.go#L404-L407
128,453
sirupsen/logrus
hooks.go
Fire
func (hooks LevelHooks) Fire(level Level, entry *Entry) error { for _, hook := range hooks[level] { if err := hook.Fire(entry); err != nil { return err } } return nil }
go
func (hooks LevelHooks) Fire(level Level, entry *Entry) error { for _, hook := range hooks[level] { if err := hook.Fire(entry); err != nil { return err } } return nil }
[ "func", "(", "hooks", "LevelHooks", ")", "Fire", "(", "level", "Level", ",", "entry", "*", "Entry", ")", "error", "{", "for", "_", ",", "hook", ":=", "range", "hooks", "[", "level", "]", "{", "if", "err", ":=", "hook", ".", "Fire", "(", "entry", ...
// Fire all the hooks for the passed level. Used by `entry.log` to fire // appropriate hooks for a log entry.
[ "Fire", "all", "the", "hooks", "for", "the", "passed", "level", ".", "Used", "by", "entry", ".", "log", "to", "fire", "appropriate", "hooks", "for", "a", "log", "entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/hooks.go#L26-L34
128,454
sirupsen/logrus
logger.go
WithField
func (logger *Logger) WithField(key string, value interface{}) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithField(key, value) }
go
func (logger *Logger) WithField(key string, value interface{}) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithField(key, value) }
[ "func", "(", "logger", "*", "Logger", ")", "WithField", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "*", "Entry", "{", "entry", ":=", "logger", ".", "newEntry", "(", ")", "\n", "defer", "logger", ".", "releaseEntry", "(", "entry", ...
// Adds a field to the log entry, note that it doesn't log until you call // Debug, Print, Info, Warn, Error, Fatal or Panic. It only creates a log entry. // If you want multiple fields, use `WithFields`.
[ "Adds", "a", "field", "to", "the", "log", "entry", "note", "that", "it", "doesn", "t", "log", "until", "you", "call", "Debug", "Print", "Info", "Warn", "Error", "Fatal", "or", "Panic", ".", "It", "only", "creates", "a", "log", "entry", ".", "If", "yo...
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L106-L110
128,455
sirupsen/logrus
logger.go
WithFields
func (logger *Logger) WithFields(fields Fields) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithFields(fields) }
go
func (logger *Logger) WithFields(fields Fields) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithFields(fields) }
[ "func", "(", "logger", "*", "Logger", ")", "WithFields", "(", "fields", "Fields", ")", "*", "Entry", "{", "entry", ":=", "logger", ".", "newEntry", "(", ")", "\n", "defer", "logger", ".", "releaseEntry", "(", "entry", ")", "\n", "return", "entry", ".",...
// Adds a struct of fields to the log entry. All it does is call `WithField` for // each `Field`.
[ "Adds", "a", "struct", "of", "fields", "to", "the", "log", "entry", ".", "All", "it", "does", "is", "call", "WithField", "for", "each", "Field", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L114-L118
128,456
sirupsen/logrus
logger.go
WithError
func (logger *Logger) WithError(err error) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithError(err) }
go
func (logger *Logger) WithError(err error) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithError(err) }
[ "func", "(", "logger", "*", "Logger", ")", "WithError", "(", "err", "error", ")", "*", "Entry", "{", "entry", ":=", "logger", ".", "newEntry", "(", ")", "\n", "defer", "logger", ".", "releaseEntry", "(", "entry", ")", "\n", "return", "entry", ".", "W...
// Add an error as single field to the log entry. All it does is call // `WithError` for the given `error`.
[ "Add", "an", "error", "as", "single", "field", "to", "the", "log", "entry", ".", "All", "it", "does", "is", "call", "WithError", "for", "the", "given", "error", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L122-L126
128,457
sirupsen/logrus
logger.go
WithContext
func (logger *Logger) WithContext(ctx context.Context) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithContext(ctx) }
go
func (logger *Logger) WithContext(ctx context.Context) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithContext(ctx) }
[ "func", "(", "logger", "*", "Logger", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "Entry", "{", "entry", ":=", "logger", ".", "newEntry", "(", ")", "\n", "defer", "logger", ".", "releaseEntry", "(", "entry", ")", "\n", "return"...
// Add a context to the log entry.
[ "Add", "a", "context", "to", "the", "log", "entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L129-L133
128,458
sirupsen/logrus
logger.go
WithTime
func (logger *Logger) WithTime(t time.Time) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithTime(t) }
go
func (logger *Logger) WithTime(t time.Time) *Entry { entry := logger.newEntry() defer logger.releaseEntry(entry) return entry.WithTime(t) }
[ "func", "(", "logger", "*", "Logger", ")", "WithTime", "(", "t", "time", ".", "Time", ")", "*", "Entry", "{", "entry", ":=", "logger", ".", "newEntry", "(", ")", "\n", "defer", "logger", ".", "releaseEntry", "(", "entry", ")", "\n", "return", "entry"...
// Overrides the time of the log entry.
[ "Overrides", "the", "time", "of", "the", "log", "entry", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L136-L140
128,459
sirupsen/logrus
logger.go
SetLevel
func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) }
go
func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) }
[ "func", "(", "logger", "*", "Logger", ")", "SetLevel", "(", "level", "Level", ")", "{", "atomic", ".", "StoreUint32", "(", "(", "*", "uint32", ")", "(", "&", "logger", ".", "Level", ")", ",", "uint32", "(", "level", ")", ")", "\n", "}" ]
// SetLevel sets the logger level.
[ "SetLevel", "sets", "the", "logger", "level", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L303-L305
128,460
sirupsen/logrus
logger.go
AddHook
func (logger *Logger) AddHook(hook Hook) { logger.mu.Lock() defer logger.mu.Unlock() logger.Hooks.Add(hook) }
go
func (logger *Logger) AddHook(hook Hook) { logger.mu.Lock() defer logger.mu.Unlock() logger.Hooks.Add(hook) }
[ "func", "(", "logger", "*", "Logger", ")", "AddHook", "(", "hook", "Hook", ")", "{", "logger", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "logger", ".", "mu", ".", "Unlock", "(", ")", "\n", "logger", ".", "Hooks", ".", "Add", "(", "hook", ...
// AddHook adds a hook to the logger hooks.
[ "AddHook", "adds", "a", "hook", "to", "the", "logger", "hooks", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L313-L317
128,461
sirupsen/logrus
logger.go
SetFormatter
func (logger *Logger) SetFormatter(formatter Formatter) { logger.mu.Lock() defer logger.mu.Unlock() logger.Formatter = formatter }
go
func (logger *Logger) SetFormatter(formatter Formatter) { logger.mu.Lock() defer logger.mu.Unlock() logger.Formatter = formatter }
[ "func", "(", "logger", "*", "Logger", ")", "SetFormatter", "(", "formatter", "Formatter", ")", "{", "logger", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "logger", ".", "mu", ".", "Unlock", "(", ")", "\n", "logger", ".", "Formatter", "=", "forma...
// SetFormatter sets the logger formatter.
[ "SetFormatter", "sets", "the", "logger", "formatter", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L325-L329
128,462
sirupsen/logrus
logger.go
SetOutput
func (logger *Logger) SetOutput(output io.Writer) { logger.mu.Lock() defer logger.mu.Unlock() logger.Out = output }
go
func (logger *Logger) SetOutput(output io.Writer) { logger.mu.Lock() defer logger.mu.Unlock() logger.Out = output }
[ "func", "(", "logger", "*", "Logger", ")", "SetOutput", "(", "output", "io", ".", "Writer", ")", "{", "logger", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "logger", ".", "mu", ".", "Unlock", "(", ")", "\n", "logger", ".", "Out", "=", "outpu...
// SetOutput sets the logger output.
[ "SetOutput", "sets", "the", "logger", "output", "." ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L332-L336
128,463
sirupsen/logrus
logger.go
ReplaceHooks
func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks { logger.mu.Lock() oldHooks := logger.Hooks logger.Hooks = hooks logger.mu.Unlock() return oldHooks }
go
func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks { logger.mu.Lock() oldHooks := logger.Hooks logger.Hooks = hooks logger.mu.Unlock() return oldHooks }
[ "func", "(", "logger", "*", "Logger", ")", "ReplaceHooks", "(", "hooks", "LevelHooks", ")", "LevelHooks", "{", "logger", ".", "mu", ".", "Lock", "(", ")", "\n", "oldHooks", ":=", "logger", ".", "Hooks", "\n", "logger", ".", "Hooks", "=", "hooks", "\n",...
// ReplaceHooks replaces the logger hooks and returns the old ones
[ "ReplaceHooks", "replaces", "the", "logger", "hooks", "and", "returns", "the", "old", "ones" ]
5521996833c095f5ac75d99687cef8ad344ded12
https://github.com/sirupsen/logrus/blob/5521996833c095f5ac75d99687cef8ad344ded12/logger.go#L345-L351
128,464
lightningnetwork/lnd
watchtower/wtwire/init.go
NewInitMessage
func NewInitMessage(connFeatures *lnwire.RawFeatureVector, chainHash chainhash.Hash) *Init { return &Init{ ConnFeatures: connFeatures, ChainHash: chainHash, } }
go
func NewInitMessage(connFeatures *lnwire.RawFeatureVector, chainHash chainhash.Hash) *Init { return &Init{ ConnFeatures: connFeatures, ChainHash: chainHash, } }
[ "func", "NewInitMessage", "(", "connFeatures", "*", "lnwire", ".", "RawFeatureVector", ",", "chainHash", "chainhash", ".", "Hash", ")", "*", "Init", "{", "return", "&", "Init", "{", "ConnFeatures", ":", "connFeatures", ",", "ChainHash", ":", "chainHash", ",", ...
// NewInitMessage generates a new Init message from a raw connection feature // vector and chain hash.
[ "NewInitMessage", "generates", "a", "new", "Init", "message", "from", "a", "raw", "connection", "feature", "vector", "and", "chain", "hash", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/init.go#L27-L34
128,465
lightningnetwork/lnd
watchtower/wtwire/init.go
Encode
func (msg *Init) Encode(w io.Writer, pver uint32) error { return WriteElements(w, msg.ConnFeatures, msg.ChainHash, ) }
go
func (msg *Init) Encode(w io.Writer, pver uint32) error { return WriteElements(w, msg.ConnFeatures, msg.ChainHash, ) }
[ "func", "(", "msg", "*", "Init", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "pver", "uint32", ")", "error", "{", "return", "WriteElements", "(", "w", ",", "msg", ".", "ConnFeatures", ",", "msg", ".", "ChainHash", ",", ")", "\n", "}" ]
// Encode serializes the target Init into the passed io.Writer observing the // protocol version specified. // // This is part of the wtwire.Message interface.
[ "Encode", "serializes", "the", "target", "Init", "into", "the", "passed", "io", ".", "Writer", "observing", "the", "protocol", "version", "specified", ".", "This", "is", "part", "of", "the", "wtwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/init.go#L40-L45
128,466
lightningnetwork/lnd
watchtower/wtwire/init.go
Decode
func (msg *Init) Decode(r io.Reader, pver uint32) error { return ReadElements(r, &msg.ConnFeatures, &msg.ChainHash, ) }
go
func (msg *Init) Decode(r io.Reader, pver uint32) error { return ReadElements(r, &msg.ConnFeatures, &msg.ChainHash, ) }
[ "func", "(", "msg", "*", "Init", ")", "Decode", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "error", "{", "return", "ReadElements", "(", "r", ",", "&", "msg", ".", "ConnFeatures", ",", "&", "msg", ".", "ChainHash", ",", ")", "\n", ...
// Decode deserializes a serialized Init message stored in the passed io.Reader // observing the specified protocol version. // // This is part of the wtwire.Message interface.
[ "Decode", "deserializes", "a", "serialized", "Init", "message", "stored", "in", "the", "passed", "io", ".", "Reader", "observing", "the", "specified", "protocol", "version", ".", "This", "is", "part", "of", "the", "wtwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/init.go#L51-L56
128,467
lightningnetwork/lnd
watchtower/wtwire/init.go
CheckRemoteInit
func (msg *Init) CheckRemoteInit(remoteInit *Init, featureNames map[lnwire.FeatureBit]string) error { // Check that the remote peer is on the same chain. if msg.ChainHash != remoteInit.ChainHash { return NewErrUnknownChainHash(remoteInit.ChainHash) } remoteConnFeatures := lnwire.NewFeatureVector( remoteInit....
go
func (msg *Init) CheckRemoteInit(remoteInit *Init, featureNames map[lnwire.FeatureBit]string) error { // Check that the remote peer is on the same chain. if msg.ChainHash != remoteInit.ChainHash { return NewErrUnknownChainHash(remoteInit.ChainHash) } remoteConnFeatures := lnwire.NewFeatureVector( remoteInit....
[ "func", "(", "msg", "*", "Init", ")", "CheckRemoteInit", "(", "remoteInit", "*", "Init", ",", "featureNames", "map", "[", "lnwire", ".", "FeatureBit", "]", "string", ")", "error", "{", "// Check that the remote peer is on the same chain.", "if", "msg", ".", "Cha...
// CheckRemoteInit performs basic validation of the remote party's Init message. // This method checks that the remote Init's chain hash matches our advertised // chain hash and that the remote Init does not contain any required feature // bits that we don't understand.
[ "CheckRemoteInit", "performs", "basic", "validation", "of", "the", "remote", "party", "s", "Init", "message", ".", "This", "method", "checks", "that", "the", "remote", "Init", "s", "chain", "hash", "matches", "our", "advertised", "chain", "hash", "and", "that"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/init.go#L81-L101
128,468
lightningnetwork/lnd
nat/traversal.go
isPrivateIP
func isPrivateIP(ip net.IP) bool { return private24BitBlock.Contains(ip) || private20BitBlock.Contains(ip) || private16BitBlock.Contains(ip) }
go
func isPrivateIP(ip net.IP) bool { return private24BitBlock.Contains(ip) || private20BitBlock.Contains(ip) || private16BitBlock.Contains(ip) }
[ "func", "isPrivateIP", "(", "ip", "net", ".", "IP", ")", "bool", "{", "return", "private24BitBlock", ".", "Contains", "(", "ip", ")", "||", "private20BitBlock", ".", "Contains", "(", "ip", ")", "||", "private16BitBlock", ".", "Contains", "(", "ip", ")", ...
// isPrivateIP determines if the IP is private.
[ "isPrivateIP", "determines", "if", "the", "IP", "is", "private", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/nat/traversal.go#L55-L58
128,469
lightningnetwork/lnd
autopilot/agent.go
Channels
func (c channelState) Channels() []Channel { chans := make([]Channel, 0, len(c)) for _, channel := range c { chans = append(chans, channel) } return chans }
go
func (c channelState) Channels() []Channel { chans := make([]Channel, 0, len(c)) for _, channel := range c { chans = append(chans, channel) } return chans }
[ "func", "(", "c", "channelState", ")", "Channels", "(", ")", "[", "]", "Channel", "{", "chans", ":=", "make", "(", "[", "]", "Channel", ",", "0", ",", "len", "(", "c", ")", ")", "\n", "for", "_", ",", "channel", ":=", "range", "c", "{", "chans"...
// Channels returns a slice of all the active channels.
[ "Channels", "returns", "a", "slice", "of", "all", "the", "active", "channels", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L72-L78
128,470
lightningnetwork/lnd
autopilot/agent.go
ConnectedNodes
func (c channelState) ConnectedNodes() map[NodeID]struct{} { nodes := make(map[NodeID]struct{}) for _, channels := range c { nodes[channels.Node] = struct{}{} } // TODO(roasbeef): add outgoing, nodes, allow incoming and outgoing to // per node // * only add node is chan as funding amt set return nodes }
go
func (c channelState) ConnectedNodes() map[NodeID]struct{} { nodes := make(map[NodeID]struct{}) for _, channels := range c { nodes[channels.Node] = struct{}{} } // TODO(roasbeef): add outgoing, nodes, allow incoming and outgoing to // per node // * only add node is chan as funding amt set return nodes }
[ "func", "(", "c", "channelState", ")", "ConnectedNodes", "(", ")", "map", "[", "NodeID", "]", "struct", "{", "}", "{", "nodes", ":=", "make", "(", "map", "[", "NodeID", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "channels", ":=", "range",...
// ConnectedNodes returns the set of nodes we currently have a channel with. // This information is needed as we want to avoid making repeated channels with // any node.
[ "ConnectedNodes", "returns", "the", "set", "of", "nodes", "we", "currently", "have", "a", "channel", "with", ".", "This", "information", "is", "needed", "as", "we", "want", "to", "avoid", "making", "repeated", "channels", "with", "any", "node", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L83-L94
128,471
lightningnetwork/lnd
autopilot/agent.go
New
func New(cfg Config, initialState []Channel) (*Agent, error) { a := &Agent{ cfg: cfg, chanState: make(map[lnwire.ShortChannelID]Channel), quit: make(chan struct{}), stateUpdates: make(chan interface{}), balanceUpdates: make(chan *balanceUpdate, 1), nodeUpdate...
go
func New(cfg Config, initialState []Channel) (*Agent, error) { a := &Agent{ cfg: cfg, chanState: make(map[lnwire.ShortChannelID]Channel), quit: make(chan struct{}), stateUpdates: make(chan interface{}), balanceUpdates: make(chan *balanceUpdate, 1), nodeUpdate...
[ "func", "New", "(", "cfg", "Config", ",", "initialState", "[", "]", "Channel", ")", "(", "*", "Agent", ",", "error", ")", "{", "a", ":=", "&", "Agent", "{", "cfg", ":", "cfg", ",", "chanState", ":", "make", "(", "map", "[", "lnwire", ".", "ShortC...
// New creates a new instance of the Agent instantiated using the passed // configuration and initial channel state. The initial channel state slice // should be populated with the set of Channels that are currently opened by // the backing Lightning Node.
[ "New", "creates", "a", "new", "instance", "of", "the", "Agent", "instantiated", "using", "the", "passed", "configuration", "and", "initial", "channel", "state", ".", "The", "initial", "channel", "state", "slice", "should", "be", "populated", "with", "the", "se...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L175-L195
128,472
lightningnetwork/lnd
autopilot/agent.go
Start
func (a *Agent) Start() error { if !atomic.CompareAndSwapUint32(&a.started, 0, 1) { return nil } rand.Seed(time.Now().Unix()) log.Infof("Autopilot Agent starting") a.wg.Add(1) go a.controller() return nil }
go
func (a *Agent) Start() error { if !atomic.CompareAndSwapUint32(&a.started, 0, 1) { return nil } rand.Seed(time.Now().Unix()) log.Infof("Autopilot Agent starting") a.wg.Add(1) go a.controller() return nil }
[ "func", "(", "a", "*", "Agent", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "a", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "rand", ".", "Seed", "(", "...
// Start starts the agent along with any goroutines it needs to perform its // normal duties.
[ "Start", "starts", "the", "agent", "along", "with", "any", "goroutines", "it", "needs", "to", "perform", "its", "normal", "duties", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L199-L211
128,473
lightningnetwork/lnd
autopilot/agent.go
Stop
func (a *Agent) Stop() error { if !atomic.CompareAndSwapUint32(&a.stopped, 0, 1) { return nil } log.Infof("Autopilot Agent stopping") close(a.quit) a.wg.Wait() return nil }
go
func (a *Agent) Stop() error { if !atomic.CompareAndSwapUint32(&a.stopped, 0, 1) { return nil } log.Infof("Autopilot Agent stopping") close(a.quit) a.wg.Wait() return nil }
[ "func", "(", "a", "*", "Agent", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "a", ".", "stopped", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "log", ".", "Infof", "(", "\...
// Stop signals the Agent to gracefully shutdown. This function will block // until all goroutines have exited.
[ "Stop", "signals", "the", "Agent", "to", "gracefully", "shutdown", ".", "This", "function", "will", "block", "until", "all", "goroutines", "have", "exited", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L215-L226
128,474
lightningnetwork/lnd
autopilot/agent.go
OnChannelOpen
func (a *Agent) OnChannelOpen(c Channel) { a.wg.Add(1) go func() { defer a.wg.Done() select { case a.stateUpdates <- &chanOpenUpdate{newChan: c}: case <-a.quit: } }() }
go
func (a *Agent) OnChannelOpen(c Channel) { a.wg.Add(1) go func() { defer a.wg.Done() select { case a.stateUpdates <- &chanOpenUpdate{newChan: c}: case <-a.quit: } }() }
[ "func", "(", "a", "*", "Agent", ")", "OnChannelOpen", "(", "c", "Channel", ")", "{", "a", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "a", ".", "wg", ".", "Done", "(", ")", "\n\n", "select", "{", "case", ...
// OnChannelOpen is a callback that should be executed each time a new channel // is manually opened by the user or any system outside the autopilot agent.
[ "OnChannelOpen", "is", "a", "callback", "that", "should", "be", "executed", "each", "time", "a", "new", "channel", "is", "manually", "opened", "by", "the", "user", "or", "any", "system", "outside", "the", "autopilot", "agent", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L279-L289
128,475
lightningnetwork/lnd
autopilot/agent.go
OnChannelClose
func (a *Agent) OnChannelClose(closedChans ...lnwire.ShortChannelID) { a.wg.Add(1) go func() { defer a.wg.Done() select { case a.stateUpdates <- &chanCloseUpdate{closedChans: closedChans}: case <-a.quit: } }() }
go
func (a *Agent) OnChannelClose(closedChans ...lnwire.ShortChannelID) { a.wg.Add(1) go func() { defer a.wg.Done() select { case a.stateUpdates <- &chanCloseUpdate{closedChans: closedChans}: case <-a.quit: } }() }
[ "func", "(", "a", "*", "Agent", ")", "OnChannelClose", "(", "closedChans", "...", "lnwire", ".", "ShortChannelID", ")", "{", "a", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "a", ".", "wg", ".", "Done", "(", ...
// OnChannelClose is a callback that should be executed each time a prior // channel has been closed for any reason. This includes regular // closes, force closes, and channel breaches.
[ "OnChannelClose", "is", "a", "callback", "that", "should", "be", "executed", "each", "time", "a", "prior", "channel", "has", "been", "closed", "for", "any", "reason", ".", "This", "includes", "regular", "closes", "force", "closes", "and", "channel", "breaches"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L314-L324
128,476
lightningnetwork/lnd
autopilot/agent.go
mergeNodeMaps
func mergeNodeMaps(c map[NodeID]Channel, skips ...map[NodeID]struct{}) map[NodeID]struct{} { numNodes := len(c) for _, skip := range skips { numNodes += len(skip) } res := make(map[NodeID]struct{}, len(c)+numNodes) for nodeID := range c { res[nodeID] = struct{}{} } for _, skip := range skips { for nodeI...
go
func mergeNodeMaps(c map[NodeID]Channel, skips ...map[NodeID]struct{}) map[NodeID]struct{} { numNodes := len(c) for _, skip := range skips { numNodes += len(skip) } res := make(map[NodeID]struct{}, len(c)+numNodes) for nodeID := range c { res[nodeID] = struct{}{} } for _, skip := range skips { for nodeI...
[ "func", "mergeNodeMaps", "(", "c", "map", "[", "NodeID", "]", "Channel", ",", "skips", "...", "map", "[", "NodeID", "]", "struct", "{", "}", ")", "map", "[", "NodeID", "]", "struct", "{", "}", "{", "numNodes", ":=", "len", "(", "c", ")", "\n", "f...
// mergeNodeMaps merges the Agent's set of nodes that it already has active // channels open to, with the other sets of nodes that should be removed from // consideration during heuristic selection. This ensures that the Agent doesn't // attempt to open any "duplicate" channels to the same node.
[ "mergeNodeMaps", "merges", "the", "Agent", "s", "set", "of", "nodes", "that", "it", "already", "has", "active", "channels", "open", "to", "with", "the", "other", "sets", "of", "nodes", "that", "should", "be", "removed", "from", "consideration", "during", "he...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L330-L349
128,477
lightningnetwork/lnd
autopilot/agent.go
mergeChanState
func mergeChanState(pendingChans map[NodeID]Channel, activeChans channelState) []Channel { numChans := len(pendingChans) + len(activeChans) totalChans := make([]Channel, 0, numChans) for _, activeChan := range activeChans.Channels() { totalChans = append(totalChans, activeChan) } for _, pendingChan := range p...
go
func mergeChanState(pendingChans map[NodeID]Channel, activeChans channelState) []Channel { numChans := len(pendingChans) + len(activeChans) totalChans := make([]Channel, 0, numChans) for _, activeChan := range activeChans.Channels() { totalChans = append(totalChans, activeChan) } for _, pendingChan := range p...
[ "func", "mergeChanState", "(", "pendingChans", "map", "[", "NodeID", "]", "Channel", ",", "activeChans", "channelState", ")", "[", "]", "Channel", "{", "numChans", ":=", "len", "(", "pendingChans", ")", "+", "len", "(", "activeChans", ")", "\n", "totalChans"...
// mergeChanState merges the Agent's set of active channels, with the set of // channels awaiting confirmation. This ensures that the agent doesn't go over // the prescribed channel limit or fund allocation limit.
[ "mergeChanState", "merges", "the", "Agent", "s", "set", "of", "active", "channels", "with", "the", "set", "of", "channels", "awaiting", "confirmation", ".", "This", "ensures", "that", "the", "agent", "doesn", "t", "go", "over", "the", "prescribed", "channel", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/agent.go#L354-L368
128,478
lightningnetwork/lnd
watchtower/standalone.go
New
func New(cfg *Config) (*Standalone, error) { // The tower must have listening address in order to accept new updates // from clients. if len(cfg.ListenAddrs) == 0 { return nil, ErrNoListeners } // Assign the default read timeout if none is provided. if cfg.ReadTimeout == 0 { cfg.ReadTimeout = DefaultReadTime...
go
func New(cfg *Config) (*Standalone, error) { // The tower must have listening address in order to accept new updates // from clients. if len(cfg.ListenAddrs) == 0 { return nil, ErrNoListeners } // Assign the default read timeout if none is provided. if cfg.ReadTimeout == 0 { cfg.ReadTimeout = DefaultReadTime...
[ "func", "New", "(", "cfg", "*", "Config", ")", "(", "*", "Standalone", ",", "error", ")", "{", "// The tower must have listening address in order to accept new updates", "// from clients.", "if", "len", "(", "cfg", ".", "ListenAddrs", ")", "==", "0", "{", "return"...
// New validates the passed Config and returns a fresh Standalone instance if // the tower's subsystems could be properly initialized.
[ "New", "validates", "the", "passed", "Config", "and", "returns", "a", "fresh", "Standalone", "instance", "if", "the", "tower", "s", "subsystems", "could", "be", "properly", "initialized", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/standalone.go#L35-L98
128,479
lightningnetwork/lnd
watchtower/standalone.go
Start
func (w *Standalone) Start() error { if !atomic.CompareAndSwapUint32(&w.started, 0, 1) { return nil } log.Infof("Starting watchtower") if err := w.lookout.Start(); err != nil { return err } if err := w.server.Start(); err != nil { w.lookout.Stop() return err } log.Infof("Watchtower started successful...
go
func (w *Standalone) Start() error { if !atomic.CompareAndSwapUint32(&w.started, 0, 1) { return nil } log.Infof("Starting watchtower") if err := w.lookout.Start(); err != nil { return err } if err := w.server.Start(); err != nil { w.lookout.Stop() return err } log.Infof("Watchtower started successful...
[ "func", "(", "w", "*", "Standalone", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "w", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "log", ".", "Infof", "("...
// Start idempotently starts the Standalone, an error is returned if the // subsystems could not be initialized.
[ "Start", "idempotently", "starts", "the", "Standalone", "an", "error", "is", "returned", "if", "the", "subsystems", "could", "not", "be", "initialized", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/standalone.go#L102-L120
128,480
lightningnetwork/lnd
watchtower/standalone.go
Stop
func (w *Standalone) Stop() error { if !atomic.CompareAndSwapUint32(&w.stopped, 0, 1) { return nil } log.Infof("Stopping watchtower") w.server.Stop() w.lookout.Stop() log.Infof("Watchtower stopped successfully") return nil }
go
func (w *Standalone) Stop() error { if !atomic.CompareAndSwapUint32(&w.stopped, 0, 1) { return nil } log.Infof("Stopping watchtower") w.server.Stop() w.lookout.Stop() log.Infof("Watchtower stopped successfully") return nil }
[ "func", "(", "w", "*", "Standalone", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "w", ".", "stopped", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "log", ".", "Infof", "(",...
// Stop idempotently stops the Standalone and blocks until the subsystems have // completed their shutdown.
[ "Stop", "idempotently", "stops", "the", "Standalone", "and", "blocks", "until", "the", "subsystems", "have", "completed", "their", "shutdown", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/standalone.go#L124-L137
128,481
lightningnetwork/lnd
autopilot/prefattach.go
NewNodeID
func NewNodeID(pub *btcec.PublicKey) NodeID { var n NodeID copy(n[:], pub.SerializeCompressed()) return n }
go
func NewNodeID(pub *btcec.PublicKey) NodeID { var n NodeID copy(n[:], pub.SerializeCompressed()) return n }
[ "func", "NewNodeID", "(", "pub", "*", "btcec", ".", "PublicKey", ")", "NodeID", "{", "var", "n", "NodeID", "\n", "copy", "(", "n", "[", ":", "]", ",", "pub", ".", "SerializeCompressed", "(", ")", ")", "\n", "return", "n", "\n", "}" ]
// NewNodeID creates a new nodeID from a passed public key.
[ "NewNodeID", "creates", "a", "new", "nodeID", "from", "a", "passed", "public", "key", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/prefattach.go#L46-L50
128,482
lightningnetwork/lnd
lnwire/shutdown.go
NewShutdown
func NewShutdown(cid ChannelID, addr DeliveryAddress) *Shutdown { return &Shutdown{ ChannelID: cid, Address: addr, } }
go
func NewShutdown(cid ChannelID, addr DeliveryAddress) *Shutdown { return &Shutdown{ ChannelID: cid, Address: addr, } }
[ "func", "NewShutdown", "(", "cid", "ChannelID", ",", "addr", "DeliveryAddress", ")", "*", "Shutdown", "{", "return", "&", "Shutdown", "{", "ChannelID", ":", "cid", ",", "Address", ":", "addr", ",", "}", "\n", "}" ]
// NewShutdown creates a new Shutdown message.
[ "NewShutdown", "creates", "a", "new", "Shutdown", "message", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/shutdown.go#L26-L31
128,483
lightningnetwork/lnd
lnwire/shutdown.go
Decode
func (s *Shutdown) Decode(r io.Reader, pver uint32) error { return ReadElements(r, &s.ChannelID, &s.Address) }
go
func (s *Shutdown) Decode(r io.Reader, pver uint32) error { return ReadElements(r, &s.ChannelID, &s.Address) }
[ "func", "(", "s", "*", "Shutdown", ")", "Decode", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "error", "{", "return", "ReadElements", "(", "r", ",", "&", "s", ".", "ChannelID", ",", "&", "s", ".", "Address", ")", "\n", "}" ]
// Decode deserializes a serialized Shutdown stored in the passed io.Reader // observing the specified protocol version. // // This is part of the lnwire.Message interface.
[ "Decode", "deserializes", "a", "serialized", "Shutdown", "stored", "in", "the", "passed", "io", ".", "Reader", "observing", "the", "specified", "protocol", "version", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/shutdown.go#L41-L43
128,484
lightningnetwork/lnd
lnwire/shutdown.go
Encode
func (s *Shutdown) Encode(w io.Writer, pver uint32) error { return WriteElements(w, s.ChannelID, s.Address) }
go
func (s *Shutdown) Encode(w io.Writer, pver uint32) error { return WriteElements(w, s.ChannelID, s.Address) }
[ "func", "(", "s", "*", "Shutdown", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "pver", "uint32", ")", "error", "{", "return", "WriteElements", "(", "w", ",", "s", ".", "ChannelID", ",", "s", ".", "Address", ")", "\n", "}" ]
// Encode serializes the target Shutdown into the passed io.Writer observing // the protocol version specified. // // This is part of the lnwire.Message interface.
[ "Encode", "serializes", "the", "target", "Shutdown", "into", "the", "passed", "io", ".", "Writer", "observing", "the", "protocol", "version", "specified", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/shutdown.go#L49-L51
128,485
lightningnetwork/lnd
lnwallet/errors.go
ErrChainMismatch
func ErrChainMismatch(knownChain, unknownChain *chainhash.Hash) ReservationError { return ReservationError{ fmt.Errorf("Unknown chain=%v. Supported chain=%v", unknownChain, knownChain), } }
go
func ErrChainMismatch(knownChain, unknownChain *chainhash.Hash) ReservationError { return ReservationError{ fmt.Errorf("Unknown chain=%v. Supported chain=%v", unknownChain, knownChain), } }
[ "func", "ErrChainMismatch", "(", "knownChain", ",", "unknownChain", "*", "chainhash", ".", "Hash", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "unknownChain", ",", "knownChain", ")", ",", "}", ...
// ErrChainMismatch returns an error indicating that the initiator tried to // open a channel for an unknown chain.
[ "ErrChainMismatch", "returns", "an", "error", "indicating", "that", "the", "initiator", "tried", "to", "open", "a", "channel", "for", "an", "unknown", "chain", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L34-L40
128,486
lightningnetwork/lnd
lnwallet/errors.go
ErrFunderBalanceDust
func ErrFunderBalanceDust(commitFee, funderBalance, minBalance int64) ReservationError { return ReservationError{ fmt.Errorf("Funder balance too small (%v) with fee=%v sat, "+ "minimum=%v sat required", funderBalance, commitFee, minBalance), } }
go
func ErrFunderBalanceDust(commitFee, funderBalance, minBalance int64) ReservationError { return ReservationError{ fmt.Errorf("Funder balance too small (%v) with fee=%v sat, "+ "minimum=%v sat required", funderBalance, commitFee, minBalance), } }
[ "func", "ErrFunderBalanceDust", "(", "commitFee", ",", "funderBalance", ",", "minBalance", "int64", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "funderBalance", ",", "commitFee", ...
// ErrFunderBalanceDust returns an error indicating the initial balance of the // funder is considered dust at the current commitment fee.
[ "ErrFunderBalanceDust", "returns", "an", "error", "indicating", "the", "initial", "balance", "of", "the", "funder", "is", "considered", "dust", "at", "the", "current", "commitment", "fee", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L44-L51
128,487
lightningnetwork/lnd
lnwallet/errors.go
ErrCsvDelayTooLarge
func ErrCsvDelayTooLarge(remoteDelay, maxDelay uint16) ReservationError { return ReservationError{ fmt.Errorf("CSV delay too large: %v, max is %v", remoteDelay, maxDelay), } }
go
func ErrCsvDelayTooLarge(remoteDelay, maxDelay uint16) ReservationError { return ReservationError{ fmt.Errorf("CSV delay too large: %v, max is %v", remoteDelay, maxDelay), } }
[ "func", "ErrCsvDelayTooLarge", "(", "remoteDelay", ",", "maxDelay", "uint16", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "remoteDelay", ",", "maxDelay", ")", ",", "}", "\n", "}" ]
// ErrCsvDelayTooLarge returns an error indicating that the CSV delay was to // large to be accepted, along with the current max.
[ "ErrCsvDelayTooLarge", "returns", "an", "error", "indicating", "that", "the", "CSV", "delay", "was", "to", "large", "to", "be", "accepted", "along", "with", "the", "current", "max", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L55-L60
128,488
lightningnetwork/lnd
lnwallet/errors.go
ErrChanReserveTooSmall
func ErrChanReserveTooSmall(reserve, dustLimit btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("channel reserve of %v sat is too small, min is %v "+ "sat", int64(reserve), int64(dustLimit)), } }
go
func ErrChanReserveTooSmall(reserve, dustLimit btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("channel reserve of %v sat is too small, min is %v "+ "sat", int64(reserve), int64(dustLimit)), } }
[ "func", "ErrChanReserveTooSmall", "(", "reserve", ",", "dustLimit", "btcutil", ".", "Amount", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "int64", "(", "reserve", ")", ",", "...
// ErrChanReserveTooSmall returns an error indicating that the channel reserve // the remote is requiring is too small to be accepted.
[ "ErrChanReserveTooSmall", "returns", "an", "error", "indicating", "that", "the", "channel", "reserve", "the", "remote", "is", "requiring", "is", "too", "small", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L64-L69
128,489
lightningnetwork/lnd
lnwallet/errors.go
ErrChanReserveTooLarge
func ErrChanReserveTooLarge(reserve, maxReserve btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("Channel reserve is too large: %v sat, max "+ "is %v sat", int64(reserve), int64(maxReserve)), } }
go
func ErrChanReserveTooLarge(reserve, maxReserve btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("Channel reserve is too large: %v sat, max "+ "is %v sat", int64(reserve), int64(maxReserve)), } }
[ "func", "ErrChanReserveTooLarge", "(", "reserve", ",", "maxReserve", "btcutil", ".", "Amount", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "int64", "(", "reserve", ")", ",", ...
// ErrChanReserveTooLarge returns an error indicating that the chan reserve the // remote is requiring, is too large to be accepted.
[ "ErrChanReserveTooLarge", "returns", "an", "error", "indicating", "that", "the", "chan", "reserve", "the", "remote", "is", "requiring", "is", "too", "large", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L73-L79
128,490
lightningnetwork/lnd
lnwallet/errors.go
ErrMinHtlcTooLarge
func ErrMinHtlcTooLarge(minHtlc, maxMinHtlc lnwire.MilliSatoshi) ReservationError { return ReservationError{ fmt.Errorf("Minimum HTLC value is too large: %v, max is %v", minHtlc, maxMinHtlc), } }
go
func ErrMinHtlcTooLarge(minHtlc, maxMinHtlc lnwire.MilliSatoshi) ReservationError { return ReservationError{ fmt.Errorf("Minimum HTLC value is too large: %v, max is %v", minHtlc, maxMinHtlc), } }
[ "func", "ErrMinHtlcTooLarge", "(", "minHtlc", ",", "maxMinHtlc", "lnwire", ".", "MilliSatoshi", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "minHtlc", ",", "maxMinHtlc", ")", ",", "}", "\n", "}...
// ErrMinHtlcTooLarge returns an error indicating that the MinHTLC value the // remote required is too large to be accepted.
[ "ErrMinHtlcTooLarge", "returns", "an", "error", "indicating", "that", "the", "MinHTLC", "value", "the", "remote", "required", "is", "too", "large", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L90-L96
128,491
lightningnetwork/lnd
lnwallet/errors.go
ErrMaxHtlcNumTooLarge
func ErrMaxHtlcNumTooLarge(maxHtlc, maxMaxHtlc uint16) ReservationError { return ReservationError{ fmt.Errorf("maxHtlcs is too large: %d, max is %d", maxHtlc, maxMaxHtlc), } }
go
func ErrMaxHtlcNumTooLarge(maxHtlc, maxMaxHtlc uint16) ReservationError { return ReservationError{ fmt.Errorf("maxHtlcs is too large: %d, max is %d", maxHtlc, maxMaxHtlc), } }
[ "func", "ErrMaxHtlcNumTooLarge", "(", "maxHtlc", ",", "maxMaxHtlc", "uint16", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "maxHtlc", ",", "maxMaxHtlc", ")", ",", "}", "\n", "}" ]
// ErrMaxHtlcNumTooLarge returns an error indicating that the 'max HTLCs in // flight' value the remote required is too large to be accepted.
[ "ErrMaxHtlcNumTooLarge", "returns", "an", "error", "indicating", "that", "the", "max", "HTLCs", "in", "flight", "value", "the", "remote", "required", "is", "too", "large", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L100-L105
128,492
lightningnetwork/lnd
lnwallet/errors.go
ErrMaxHtlcNumTooSmall
func ErrMaxHtlcNumTooSmall(maxHtlc, minMaxHtlc uint16) ReservationError { return ReservationError{ fmt.Errorf("maxHtlcs is too small: %d, min is %d", maxHtlc, minMaxHtlc), } }
go
func ErrMaxHtlcNumTooSmall(maxHtlc, minMaxHtlc uint16) ReservationError { return ReservationError{ fmt.Errorf("maxHtlcs is too small: %d, min is %d", maxHtlc, minMaxHtlc), } }
[ "func", "ErrMaxHtlcNumTooSmall", "(", "maxHtlc", ",", "minMaxHtlc", "uint16", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "maxHtlc", ",", "minMaxHtlc", ")", ",", "}", "\n", "}" ]
// ErrMaxHtlcNumTooSmall returns an error indicating that the 'max HTLCs in // flight' value the remote required is too small to be accepted.
[ "ErrMaxHtlcNumTooSmall", "returns", "an", "error", "indicating", "that", "the", "max", "HTLCs", "in", "flight", "value", "the", "remote", "required", "is", "too", "small", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L109-L114
128,493
lightningnetwork/lnd
lnwallet/errors.go
ErrMaxValueInFlightTooSmall
func ErrMaxValueInFlightTooSmall(maxValInFlight, minMaxValInFlight lnwire.MilliSatoshi) ReservationError { return ReservationError{ fmt.Errorf("maxValueInFlight too small: %v, min is %v", maxValInFlight, minMaxValInFlight), } }
go
func ErrMaxValueInFlightTooSmall(maxValInFlight, minMaxValInFlight lnwire.MilliSatoshi) ReservationError { return ReservationError{ fmt.Errorf("maxValueInFlight too small: %v, min is %v", maxValInFlight, minMaxValInFlight), } }
[ "func", "ErrMaxValueInFlightTooSmall", "(", "maxValInFlight", ",", "minMaxValInFlight", "lnwire", ".", "MilliSatoshi", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "maxValInFlight", ",", "minMaxValInFligh...
// ErrMaxValueInFlightTooSmall returns an error indicating that the 'max HTLC // value in flight' the remote required is too small to be accepted.
[ "ErrMaxValueInFlightTooSmall", "returns", "an", "error", "indicating", "that", "the", "max", "HTLC", "value", "in", "flight", "the", "remote", "required", "is", "too", "small", "to", "be", "accepted", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L118-L124
128,494
lightningnetwork/lnd
lnwallet/errors.go
ErrNumConfsTooLarge
func ErrNumConfsTooLarge(numConfs, maxNumConfs uint32) error { return ReservationError{ fmt.Errorf("minimum depth of %d is too large, max is %d", numConfs, maxNumConfs), } }
go
func ErrNumConfsTooLarge(numConfs, maxNumConfs uint32) error { return ReservationError{ fmt.Errorf("minimum depth of %d is too large, max is %d", numConfs, maxNumConfs), } }
[ "func", "ErrNumConfsTooLarge", "(", "numConfs", ",", "maxNumConfs", "uint32", ")", "error", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "numConfs", ",", "maxNumConfs", ")", ",", "}", "\n", "}" ]
// ErrNumConfsTooLarge returns an error indicating that the number of // confirmations required for a channel is too large.
[ "ErrNumConfsTooLarge", "returns", "an", "error", "indicating", "that", "the", "number", "of", "confirmations", "required", "for", "a", "channel", "is", "too", "large", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L128-L133
128,495
lightningnetwork/lnd
lnwallet/errors.go
ErrChanTooSmall
func ErrChanTooSmall(chanSize, minChanSize btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("chan size of %v is below min chan size of %v", chanSize, minChanSize), } }
go
func ErrChanTooSmall(chanSize, minChanSize btcutil.Amount) ReservationError { return ReservationError{ fmt.Errorf("chan size of %v is below min chan size of %v", chanSize, minChanSize), } }
[ "func", "ErrChanTooSmall", "(", "chanSize", ",", "minChanSize", "btcutil", ".", "Amount", ")", "ReservationError", "{", "return", "ReservationError", "{", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "chanSize", ",", "minChanSize", ")", ",", "}", "\n", "}" ]
// ErrChanTooSmall returns an error indicating that an incoming channel request // was too small. We'll reject any incoming channels if they're below our // configured value for the min channel size we'll accept.
[ "ErrChanTooSmall", "returns", "an", "error", "indicating", "that", "an", "incoming", "channel", "request", "was", "too", "small", ".", "We", "ll", "reject", "any", "incoming", "channels", "if", "they", "re", "below", "our", "configured", "value", "for", "the",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L138-L143
128,496
lightningnetwork/lnd
lnwallet/errors.go
Error
func (e ErrInvalidSettlePreimage) Error() string { return fmt.Sprintf("Invalid payment preimage %x for hash %x", e.preimage, e.rhash) }
go
func (e ErrInvalidSettlePreimage) Error() string { return fmt.Sprintf("Invalid payment preimage %x for hash %x", e.preimage, e.rhash) }
[ "func", "(", "e", "ErrInvalidSettlePreimage", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "preimage", ",", "e", ".", "rhash", ")", "\n", "}" ]
// Error returns an error message with the offending preimage and intended // payment hash.
[ "Error", "returns", "an", "error", "message", "with", "the", "offending", "preimage", "and", "intended", "payment", "hash", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L172-L175
128,497
lightningnetwork/lnd
lnwallet/errors.go
Error
func (e ErrUnknownHtlcIndex) Error() string { return fmt.Sprintf("No HTLC with ID %d in channel %v", e.index, e.chanID) }
go
func (e ErrUnknownHtlcIndex) Error() string { return fmt.Sprintf("No HTLC with ID %d in channel %v", e.index, e.chanID) }
[ "func", "(", "e", "ErrUnknownHtlcIndex", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "index", ",", "e", ".", "chanID", ")", "\n", "}" ]
// Error returns an error logging the channel and HTLC index that was unknown.
[ "Error", "returns", "an", "error", "logging", "the", "channel", "and", "HTLC", "index", "that", "was", "unknown", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/errors.go#L186-L189
128,498
lightningnetwork/lnd
htlcswitch/decayedlog.go
NewDecayedLog
func NewDecayedLog(dbPath string, notifier chainntnfs.ChainNotifier) *DecayedLog { // Use default path for log database if dbPath == "" { dbPath = defaultDbDirectory } return &DecayedLog{ dbPath: dbPath, notifier: notifier, quit: make(chan struct{}), } }
go
func NewDecayedLog(dbPath string, notifier chainntnfs.ChainNotifier) *DecayedLog { // Use default path for log database if dbPath == "" { dbPath = defaultDbDirectory } return &DecayedLog{ dbPath: dbPath, notifier: notifier, quit: make(chan struct{}), } }
[ "func", "NewDecayedLog", "(", "dbPath", "string", ",", "notifier", "chainntnfs", ".", "ChainNotifier", ")", "*", "DecayedLog", "{", "// Use default path for log database", "if", "dbPath", "==", "\"", "\"", "{", "dbPath", "=", "defaultDbDirectory", "\n", "}", "\n\n...
// NewDecayedLog creates a new DecayedLog, which caches recently seen hash // shared secrets. Entries are evicted as their cltv expires using block epochs // from the given notifier.
[ "NewDecayedLog", "creates", "a", "new", "DecayedLog", "which", "caches", "recently", "seen", "hash", "shared", "secrets", ".", "Entries", "are", "evicted", "as", "their", "cltv", "expires", "using", "block", "epochs", "from", "the", "given", "notifier", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/decayedlog.go#L70-L83
128,499
lightningnetwork/lnd
htlcswitch/decayedlog.go
Start
func (d *DecayedLog) Start() error { if !atomic.CompareAndSwapInt32(&d.started, 0, 1) { return nil } // Open the boltdb for use. var err error if d.db, err = bbolt.Open(d.dbPath, dbPermissions, nil); err != nil { return fmt.Errorf("Could not open boltdb: %v", err) } // Initialize the primary buckets used b...
go
func (d *DecayedLog) Start() error { if !atomic.CompareAndSwapInt32(&d.started, 0, 1) { return nil } // Open the boltdb for use. var err error if d.db, err = bbolt.Open(d.dbPath, dbPermissions, nil); err != nil { return fmt.Errorf("Could not open boltdb: %v", err) } // Initialize the primary buckets used b...
[ "func", "(", "d", "*", "DecayedLog", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "d", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "// Open the boltdb for use.", ...
// Start opens the database we will be using to store hashed shared secrets. // It also starts the garbage collector in a goroutine to remove stale // database entries.
[ "Start", "opens", "the", "database", "we", "will", "be", "using", "to", "store", "hashed", "shared", "secrets", ".", "It", "also", "starts", "the", "garbage", "collector", "in", "a", "goroutine", "to", "remove", "stale", "database", "entries", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/decayedlog.go#L88-L117