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
29,500
prometheus/procfs
proc.go
FileDescriptors
func (p Proc) FileDescriptors() ([]uintptr, error) { names, err := p.fileDescriptors() if err != nil { return nil, err } fds := make([]uintptr, len(names)) for i, n := range names { fd, err := strconv.ParseInt(n, 10, 32) if err != nil { return nil, fmt.Errorf("could not parse fd %s: %s", n, err) } fd...
go
func (p Proc) FileDescriptors() ([]uintptr, error) { names, err := p.fileDescriptors() if err != nil { return nil, err } fds := make([]uintptr, len(names)) for i, n := range names { fd, err := strconv.ParseInt(n, 10, 32) if err != nil { return nil, fmt.Errorf("could not parse fd %s: %s", n, err) } fd...
[ "func", "(", "p", "Proc", ")", "FileDescriptors", "(", ")", "(", "[", "]", "uintptr", ",", "error", ")", "{", "names", ",", "err", ":=", "p", ".", "fileDescriptors", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n"...
// FileDescriptors returns the currently open file descriptors of a process.
[ "FileDescriptors", "returns", "the", "currently", "open", "file", "descriptors", "of", "a", "process", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc.go#L180-L196
29,501
prometheus/procfs
proc.go
FileDescriptorsLen
func (p Proc) FileDescriptorsLen() (int, error) { fds, err := p.fileDescriptors() if err != nil { return 0, err } return len(fds), nil }
go
func (p Proc) FileDescriptorsLen() (int, error) { fds, err := p.fileDescriptors() if err != nil { return 0, err } return len(fds), nil }
[ "func", "(", "p", "Proc", ")", "FileDescriptorsLen", "(", ")", "(", "int", ",", "error", ")", "{", "fds", ",", "err", ":=", "p", ".", "fileDescriptors", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", ...
// FileDescriptorsLen returns the number of currently open file descriptors of // a process.
[ "FileDescriptorsLen", "returns", "the", "number", "of", "currently", "open", "file", "descriptors", "of", "a", "process", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc.go#L220-L227
29,502
prometheus/procfs
proc.go
MountStats
func (p Proc) MountStats() ([]*Mount, error) { f, err := os.Open(p.path("mountstats")) if err != nil { return nil, err } defer f.Close() return parseMountStats(f) }
go
func (p Proc) MountStats() ([]*Mount, error) { f, err := os.Open(p.path("mountstats")) if err != nil { return nil, err } defer f.Close() return parseMountStats(f) }
[ "func", "(", "p", "Proc", ")", "MountStats", "(", ")", "(", "[", "]", "*", "Mount", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "p", ".", "path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "...
// MountStats retrieves statistics and configuration for mount points in a // process's namespace.
[ "MountStats", "retrieves", "statistics", "and", "configuration", "for", "mount", "points", "in", "a", "process", "s", "namespace", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc.go#L231-L239
29,503
prometheus/procfs
proc_limits.go
NewLimits
func (p Proc) NewLimits() (ProcLimits, error) { f, err := os.Open(p.path("limits")) if err != nil { return ProcLimits{}, err } defer f.Close() var ( l = ProcLimits{} s = bufio.NewScanner(f) ) for s.Scan() { fields := limitsDelimiter.Split(s.Text(), limitsFields) if len(fields) != limitsFields { ret...
go
func (p Proc) NewLimits() (ProcLimits, error) { f, err := os.Open(p.path("limits")) if err != nil { return ProcLimits{}, err } defer f.Close() var ( l = ProcLimits{} s = bufio.NewScanner(f) ) for s.Scan() { fields := limitsDelimiter.Split(s.Text(), limitsFields) if len(fields) != limitsFields { ret...
[ "func", "(", "p", "Proc", ")", "NewLimits", "(", ")", "(", "ProcLimits", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "p", ".", "path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ProcL...
// NewLimits returns the current soft limits of the process.
[ "NewLimits", "returns", "the", "current", "soft", "limits", "of", "the", "process", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_limits.go#L81-L139
29,504
prometheus/procfs
mountstats.go
parseMountStatsNFS
func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, error) { // Field indicators for parsing specific types of data const ( fieldOpts = "opts:" fieldAge = "age:" fieldBytes = "bytes:" fieldEvents = "events:" fieldPerOpStats = "per-op" fieldTransport = "xpr...
go
func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, error) { // Field indicators for parsing specific types of data const ( fieldOpts = "opts:" fieldAge = "age:" fieldBytes = "bytes:" fieldEvents = "events:" fieldPerOpStats = "per-op" fieldTransport = "xpr...
[ "func", "parseMountStatsNFS", "(", "s", "*", "bufio", ".", "Scanner", ",", "statVersion", "string", ")", "(", "*", "MountStatsNFS", ",", "error", ")", "{", "// Field indicators for parsing specific types of data", "const", "(", "fieldOpts", "=", "\"", "\"", "\n", ...
// parseMountStatsNFS parses a MountStatsNFS by scanning additional information // related to NFS statistics.
[ "parseMountStatsNFS", "parses", "a", "MountStatsNFS", "by", "scanning", "additional", "information", "related", "to", "NFS", "statistics", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mountstats.go#L319-L408
29,505
prometheus/procfs
mountstats.go
parseNFSBytesStats
func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { if len(ss) != fieldBytesLen { return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss) } ns := make([]uint64, 0, fieldBytesLen) for _, s := range ss { n, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } ns = append(n...
go
func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { if len(ss) != fieldBytesLen { return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss) } ns := make([]uint64, 0, fieldBytesLen) for _, s := range ss { n, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } ns = append(n...
[ "func", "parseNFSBytesStats", "(", "ss", "[", "]", "string", ")", "(", "*", "NFSBytesStats", ",", "error", ")", "{", "if", "len", "(", "ss", ")", "!=", "fieldBytesLen", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ss", ")...
// parseNFSBytesStats parses a NFSBytesStats line using an input set of // integer fields.
[ "parseNFSBytesStats", "parses", "a", "NFSBytesStats", "line", "using", "an", "input", "set", "of", "integer", "fields", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mountstats.go#L412-L437
29,506
prometheus/procfs
mountstats.go
parseNFSEventsStats
func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) { if len(ss) != fieldEventsLen { return nil, fmt.Errorf("invalid NFS events stats: %v", ss) } ns := make([]uint64, 0, fieldEventsLen) for _, s := range ss { n, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } ns = app...
go
func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) { if len(ss) != fieldEventsLen { return nil, fmt.Errorf("invalid NFS events stats: %v", ss) } ns := make([]uint64, 0, fieldEventsLen) for _, s := range ss { n, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } ns = app...
[ "func", "parseNFSEventsStats", "(", "ss", "[", "]", "string", ")", "(", "*", "NFSEventsStats", ",", "error", ")", "{", "if", "len", "(", "ss", ")", "!=", "fieldEventsLen", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ss", ...
// parseNFSEventsStats parses a NFSEventsStats line using an input set of // integer fields.
[ "parseNFSEventsStats", "parses", "a", "NFSEventsStats", "line", "using", "an", "input", "set", "of", "integer", "fields", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mountstats.go#L441-L485
29,507
prometheus/procfs
mountstats.go
parseNFSOperationStats
func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { const ( // Number of expected fields in each per-operation statistics set numFields = 9 ) var ops []NFSOperationStats for s.Scan() { ss := strings.Fields(string(s.Bytes())) if len(ss) == 0 { // Must break when reading a blank ...
go
func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { const ( // Number of expected fields in each per-operation statistics set numFields = 9 ) var ops []NFSOperationStats for s.Scan() { ss := strings.Fields(string(s.Bytes())) if len(ss) == 0 { // Must break when reading a blank ...
[ "func", "parseNFSOperationStats", "(", "s", "*", "bufio", ".", "Scanner", ")", "(", "[", "]", "NFSOperationStats", ",", "error", ")", "{", "const", "(", "// Number of expected fields in each per-operation statistics set", "numFields", "=", "9", "\n", ")", "\n\n", ...
// parseNFSOperationStats parses a slice of NFSOperationStats by scanning // additional information about per-operation statistics until an empty // line is reached.
[ "parseNFSOperationStats", "parses", "a", "slice", "of", "NFSOperationStats", "by", "scanning", "additional", "information", "about", "per", "-", "operation", "statistics", "until", "an", "empty", "line", "is", "reached", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mountstats.go#L490-L535
29,508
prometheus/procfs
mountstats.go
parseNFSTransportStats
func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats, error) { // Extract the protocol field. It is the only string value in the line protocol := ss[0] ss = ss[1:] switch statVersion { case statVersion10: var expectedLength int if protocol == "tcp" { expectedLength = fieldTransp...
go
func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats, error) { // Extract the protocol field. It is the only string value in the line protocol := ss[0] ss = ss[1:] switch statVersion { case statVersion10: var expectedLength int if protocol == "tcp" { expectedLength = fieldTransp...
[ "func", "parseNFSTransportStats", "(", "ss", "[", "]", "string", ",", "statVersion", "string", ")", "(", "*", "NFSTransportStats", ",", "error", ")", "{", "// Extract the protocol field. It is the only string value in the line", "protocol", ":=", "ss", "[", "0", "]", ...
// parseNFSTransportStats parses a NFSTransportStats line using an input set of // integer fields matched to a specific stats version.
[ "parseNFSTransportStats", "parses", "a", "NFSTransportStats", "line", "using", "an", "input", "set", "of", "integer", "fields", "matched", "to", "a", "specific", "stats", "version", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mountstats.go#L539-L616
29,509
prometheus/procfs
xfrm.go
NewXfrmStat
func NewXfrmStat() (XfrmStat, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return XfrmStat{}, err } return fs.NewXfrmStat() }
go
func NewXfrmStat() (XfrmStat, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return XfrmStat{}, err } return fs.NewXfrmStat() }
[ "func", "NewXfrmStat", "(", ")", "(", "XfrmStat", ",", "error", ")", "{", "fs", ",", "err", ":=", "NewFS", "(", "DefaultMountPoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "XfrmStat", "{", "}", ",", "err", "\n", "}", "\n\n", "return", ...
// NewXfrmStat reads the xfrm_stat statistics.
[ "NewXfrmStat", "reads", "the", "xfrm_stat", "statistics", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfrm.go#L89-L96
29,510
prometheus/procfs
xfrm.go
NewXfrmStat
func (fs FS) NewXfrmStat() (XfrmStat, error) { file, err := os.Open(fs.Path("net/xfrm_stat")) if err != nil { return XfrmStat{}, err } defer file.Close() var ( x = XfrmStat{} s = bufio.NewScanner(file) ) for s.Scan() { fields := strings.Fields(s.Text()) if len(fields) != 2 { return XfrmStat{}, fm...
go
func (fs FS) NewXfrmStat() (XfrmStat, error) { file, err := os.Open(fs.Path("net/xfrm_stat")) if err != nil { return XfrmStat{}, err } defer file.Close() var ( x = XfrmStat{} s = bufio.NewScanner(file) ) for s.Scan() { fields := strings.Fields(s.Text()) if len(fields) != 2 { return XfrmStat{}, fm...
[ "func", "(", "fs", "FS", ")", "NewXfrmStat", "(", ")", "(", "XfrmStat", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "fs", ".", "Path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Xf...
// NewXfrmStat reads the xfrm_stat statistics from the 'proc' filesystem.
[ "NewXfrmStat", "reads", "the", "xfrm_stat", "statistics", "from", "the", "proc", "filesystem", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfrm.go#L99-L187
29,511
prometheus/procfs
internal/util/parse.go
ParseUint32s
func ParseUint32s(ss []string) ([]uint32, error) { us := make([]uint32, 0, len(ss)) for _, s := range ss { u, err := strconv.ParseUint(s, 10, 32) if err != nil { return nil, err } us = append(us, uint32(u)) } return us, nil }
go
func ParseUint32s(ss []string) ([]uint32, error) { us := make([]uint32, 0, len(ss)) for _, s := range ss { u, err := strconv.ParseUint(s, 10, 32) if err != nil { return nil, err } us = append(us, uint32(u)) } return us, nil }
[ "func", "ParseUint32s", "(", "ss", "[", "]", "string", ")", "(", "[", "]", "uint32", ",", "error", ")", "{", "us", ":=", "make", "(", "[", "]", "uint32", ",", "0", ",", "len", "(", "ss", ")", ")", "\n", "for", "_", ",", "s", ":=", "range", ...
// ParseUint32s parses a slice of strings into a slice of uint32s.
[ "ParseUint32s", "parses", "a", "slice", "of", "strings", "into", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/internal/util/parse.go#L23-L35
29,512
prometheus/procfs
internal/util/parse.go
ParseUint64s
func ParseUint64s(ss []string) ([]uint64, error) { us := make([]uint64, 0, len(ss)) for _, s := range ss { u, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } us = append(us, u) } return us, nil }
go
func ParseUint64s(ss []string) ([]uint64, error) { us := make([]uint64, 0, len(ss)) for _, s := range ss { u, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, err } us = append(us, u) } return us, nil }
[ "func", "ParseUint64s", "(", "ss", "[", "]", "string", ")", "(", "[", "]", "uint64", ",", "error", ")", "{", "us", ":=", "make", "(", "[", "]", "uint64", ",", "0", ",", "len", "(", "ss", ")", ")", "\n", "for", "_", ",", "s", ":=", "range", ...
// ParseUint64s parses a slice of strings into a slice of uint64s.
[ "ParseUint64s", "parses", "a", "slice", "of", "strings", "into", "a", "slice", "of", "uint64s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/internal/util/parse.go#L38-L50
29,513
prometheus/procfs
internal/util/parse.go
ReadUintFromFile
func ReadUintFromFile(path string) (uint64, error) { data, err := ioutil.ReadFile(path) if err != nil { return 0, err } return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) }
go
func ReadUintFromFile(path string) (uint64, error) { data, err := ioutil.ReadFile(path) if err != nil { return 0, err } return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) }
[ "func", "ReadUintFromFile", "(", "path", "string", ")", "(", "uint64", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", ...
// ReadUintFromFile reads a file and attempts to parse a uint64 from it.
[ "ReadUintFromFile", "reads", "a", "file", "and", "attempts", "to", "parse", "a", "uint64", "from", "it", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/internal/util/parse.go#L53-L59
29,514
prometheus/procfs
internal/util/parse.go
ParseBool
func ParseBool(b string) *bool { var truth bool switch b { case "enabled": truth = true case "disabled": truth = false default: return nil } return &truth }
go
func ParseBool(b string) *bool { var truth bool switch b { case "enabled": truth = true case "disabled": truth = false default: return nil } return &truth }
[ "func", "ParseBool", "(", "b", "string", ")", "*", "bool", "{", "var", "truth", "bool", "\n", "switch", "b", "{", "case", "\"", "\"", ":", "truth", "=", "true", "\n", "case", "\"", "\"", ":", "truth", "=", "false", "\n", "default", ":", "return", ...
// ParseBool parses a string into a boolean pointer.
[ "ParseBool", "parses", "a", "string", "into", "a", "boolean", "pointer", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/internal/util/parse.go#L62-L73
29,515
prometheus/procfs
sysfs/fs.go
Path
func (fs FS) Path(p ...string) string { return filepath.Join(append([]string{string(fs)}, p...)...) }
go
func (fs FS) Path(p ...string) string { return filepath.Join(append([]string{string(fs)}, p...)...) }
[ "func", "(", "fs", "FS", ")", "Path", "(", "p", "...", "string", ")", "string", "{", "return", "filepath", ".", "Join", "(", "append", "(", "[", "]", "string", "{", "string", "(", "fs", ")", "}", ",", "p", "...", ")", "...", ")", "\n", "}" ]
// Path returns the path of the given subsystem relative to the sys root.
[ "Path", "returns", "the", "path", "of", "the", "given", "subsystem", "relative", "to", "the", "sys", "root", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/sysfs/fs.go#L44-L46
29,516
prometheus/procfs
bcache/get.go
ReadStats
func ReadStats(sysfs string) ([]*Stats, error) { matches, err := filepath.Glob(path.Join(sysfs, "fs/bcache/*-*")) if err != nil { return nil, err } stats := make([]*Stats, 0, len(matches)) for _, uuidPath := range matches { // "*-*" in glob above indicates the name of the bcache. name := filepath.Base(uuidP...
go
func ReadStats(sysfs string) ([]*Stats, error) { matches, err := filepath.Glob(path.Join(sysfs, "fs/bcache/*-*")) if err != nil { return nil, err } stats := make([]*Stats, 0, len(matches)) for _, uuidPath := range matches { // "*-*" in glob above indicates the name of the bcache. name := filepath.Base(uuidP...
[ "func", "ReadStats", "(", "sysfs", "string", ")", "(", "[", "]", "*", "Stats", ",", "error", ")", "{", "matches", ",", "err", ":=", "filepath", ".", "Glob", "(", "path", ".", "Join", "(", "sysfs", ",", "\"", "\"", ")", ")", "\n", "if", "err", "...
// ReadStats retrieves bcache runtime statistics for each bcache.
[ "ReadStats", "retrieves", "bcache", "runtime", "statistics", "for", "each", "bcache", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/bcache/get.go#L28-L50
29,517
prometheus/procfs
bcache/get.go
parsePseudoFloat
func parsePseudoFloat(str string) (float64, error) { ss := strings.Split(str, ".") intPart, err := strconv.ParseFloat(ss[0], 64) if err != nil { return 0, err } if len(ss) == 1 { // Pure integers are fine. return intPart, nil } fracPart, err := strconv.ParseFloat(ss[1], 64) if err != nil { return 0, e...
go
func parsePseudoFloat(str string) (float64, error) { ss := strings.Split(str, ".") intPart, err := strconv.ParseFloat(ss[0], 64) if err != nil { return 0, err } if len(ss) == 1 { // Pure integers are fine. return intPart, nil } fracPart, err := strconv.ParseFloat(ss[1], 64) if err != nil { return 0, e...
[ "func", "parsePseudoFloat", "(", "str", "string", ")", "(", "float64", ",", "error", ")", "{", "ss", ":=", "strings", ".", "Split", "(", "str", ",", "\"", "\"", ")", "\n\n", "intPart", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "ss", "[", ...
// ParsePseudoFloat parses the peculiar format produced by bcache's bch_hprint.
[ "ParsePseudoFloat", "parses", "the", "peculiar", "format", "produced", "by", "bcache", "s", "bch_hprint", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/bcache/get.go#L53-L77
29,518
prometheus/procfs
bcache/get.go
dehumanize
func dehumanize(hbytes []byte) (uint64, error) { ll := len(hbytes) if ll == 0 { return 0, fmt.Errorf("zero-length reply") } lastByte := hbytes[ll-1] mul := float64(1) var ( mant float64 err error ) // If lastByte is beyond the range of ASCII digits, it must be a // multiplier. if lastByte > 57 { // R...
go
func dehumanize(hbytes []byte) (uint64, error) { ll := len(hbytes) if ll == 0 { return 0, fmt.Errorf("zero-length reply") } lastByte := hbytes[ll-1] mul := float64(1) var ( mant float64 err error ) // If lastByte is beyond the range of ASCII digits, it must be a // multiplier. if lastByte > 57 { // R...
[ "func", "dehumanize", "(", "hbytes", "[", "]", "byte", ")", "(", "uint64", ",", "error", ")", "{", "ll", ":=", "len", "(", "hbytes", ")", "\n", "if", "ll", "==", "0", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", ...
// Dehumanize converts a human-readable byte slice into a uint64.
[ "Dehumanize", "converts", "a", "human", "-", "readable", "byte", "slice", "into", "a", "uint64", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/bcache/get.go#L80-L135
29,519
prometheus/procfs
bcache/get.go
parsePriorityStats
func parsePriorityStats(line string, ps *PriorityStats) error { var ( value uint64 err error ) switch { case strings.HasPrefix(line, "Unused:"): fields := strings.Fields(line) rawValue := fields[len(fields)-1] valueStr := strings.TrimSuffix(rawValue, "%") value, err = strconv.ParseUint(valueStr, 10, 6...
go
func parsePriorityStats(line string, ps *PriorityStats) error { var ( value uint64 err error ) switch { case strings.HasPrefix(line, "Unused:"): fields := strings.Fields(line) rawValue := fields[len(fields)-1] valueStr := strings.TrimSuffix(rawValue, "%") value, err = strconv.ParseUint(valueStr, 10, 6...
[ "func", "parsePriorityStats", "(", "line", "string", ",", "ps", "*", "PriorityStats", ")", "error", "{", "var", "(", "value", "uint64", "\n", "err", "error", "\n", ")", "\n", "switch", "{", "case", "strings", ".", "HasPrefix", "(", "line", ",", "\"", "...
// ParsePriorityStats parses lines from the priority_stats file.
[ "ParsePriorityStats", "parses", "lines", "from", "the", "priority_stats", "file", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/bcache/get.go#L167-L193
29,520
prometheus/procfs
sysfs/system_cpu.go
NewSystemCpufreq
func (fs FS) NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) { var g errgroup.Group cpus, err := filepath.Glob(fs.Path("devices/system/cpu/cpu[0-9]*")) if err != nil { return nil, err } systemCpufreq := make([]SystemCPUCpufreqStats, len(cpus)) for i, cpu := range cpus { cpuName := strings.TrimPrefix(fil...
go
func (fs FS) NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) { var g errgroup.Group cpus, err := filepath.Glob(fs.Path("devices/system/cpu/cpu[0-9]*")) if err != nil { return nil, err } systemCpufreq := make([]SystemCPUCpufreqStats, len(cpus)) for i, cpu := range cpus { cpuName := strings.TrimPrefix(fil...
[ "func", "(", "fs", "FS", ")", "NewSystemCpufreq", "(", ")", "(", "[", "]", "SystemCPUCpufreqStats", ",", "error", ")", "{", "var", "g", "errgroup", ".", "Group", "\n\n", "cpus", ",", "err", ":=", "filepath", ".", "Glob", "(", "fs", ".", "Path", "(", ...
// NewSystemCpufreq returns CPU frequency metrics for all CPUs.
[ "NewSystemCpufreq", "returns", "CPU", "frequency", "metrics", "for", "all", "CPUs", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/sysfs/system_cpu.go#L60-L99
29,521
prometheus/procfs
xfs/parse.go
extentAllocationStats
func extentAllocationStats(us []uint32) (ExtentAllocationStats, error) { if l := len(us); l != 4 { return ExtentAllocationStats{}, fmt.Errorf("incorrect number of values for XFS extent allocation stats: %d", l) } return ExtentAllocationStats{ ExtentsAllocated: us[0], BlocksAllocated: us[1], ExtentsFreed: ...
go
func extentAllocationStats(us []uint32) (ExtentAllocationStats, error) { if l := len(us); l != 4 { return ExtentAllocationStats{}, fmt.Errorf("incorrect number of values for XFS extent allocation stats: %d", l) } return ExtentAllocationStats{ ExtentsAllocated: us[0], BlocksAllocated: us[1], ExtentsFreed: ...
[ "func", "extentAllocationStats", "(", "us", "[", "]", "uint32", ")", "(", "ExtentAllocationStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "4", "{", "return", "ExtentAllocationStats", "{", "}", ",", "fmt", ".", ...
// extentAllocationStats builds an ExtentAllocationStats from a slice of uint32s.
[ "extentAllocationStats", "builds", "an", "ExtentAllocationStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L128-L139
29,522
prometheus/procfs
xfs/parse.go
btreeStats
func btreeStats(us []uint32) (BTreeStats, error) { if l := len(us); l != 4 { return BTreeStats{}, fmt.Errorf("incorrect number of values for XFS btree stats: %d", l) } return BTreeStats{ Lookups: us[0], Compares: us[1], RecordsInserted: us[2], RecordsDeleted: us[3], }, nil }
go
func btreeStats(us []uint32) (BTreeStats, error) { if l := len(us); l != 4 { return BTreeStats{}, fmt.Errorf("incorrect number of values for XFS btree stats: %d", l) } return BTreeStats{ Lookups: us[0], Compares: us[1], RecordsInserted: us[2], RecordsDeleted: us[3], }, nil }
[ "func", "btreeStats", "(", "us", "[", "]", "uint32", ")", "(", "BTreeStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "4", "{", "return", "BTreeStats", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"",...
// btreeStats builds a BTreeStats from a slice of uint32s.
[ "btreeStats", "builds", "a", "BTreeStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L142-L153
29,523
prometheus/procfs
xfs/parse.go
blockMappingStats
func blockMappingStats(us []uint32) (BlockMappingStats, error) { if l := len(us); l != 7 { return BlockMappingStats{}, fmt.Errorf("incorrect number of values for XFS block mapping stats: %d", l) } return BlockMappingStats{ Reads: us[0], Writes: us[1], Unmaps: us[2]...
go
func blockMappingStats(us []uint32) (BlockMappingStats, error) { if l := len(us); l != 7 { return BlockMappingStats{}, fmt.Errorf("incorrect number of values for XFS block mapping stats: %d", l) } return BlockMappingStats{ Reads: us[0], Writes: us[1], Unmaps: us[2]...
[ "func", "blockMappingStats", "(", "us", "[", "]", "uint32", ")", "(", "BlockMappingStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "7", "{", "return", "BlockMappingStats", "{", "}", ",", "fmt", ".", "Errorf", ...
// BlockMappingStat builds a BlockMappingStats from a slice of uint32s.
[ "BlockMappingStat", "builds", "a", "BlockMappingStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L156-L170
29,524
prometheus/procfs
xfs/parse.go
directoryOperationStats
func directoryOperationStats(us []uint32) (DirectoryOperationStats, error) { if l := len(us); l != 4 { return DirectoryOperationStats{}, fmt.Errorf("incorrect number of values for XFS directory operation stats: %d", l) } return DirectoryOperationStats{ Lookups: us[0], Creates: us[1], Removes: us[2], Ge...
go
func directoryOperationStats(us []uint32) (DirectoryOperationStats, error) { if l := len(us); l != 4 { return DirectoryOperationStats{}, fmt.Errorf("incorrect number of values for XFS directory operation stats: %d", l) } return DirectoryOperationStats{ Lookups: us[0], Creates: us[1], Removes: us[2], Ge...
[ "func", "directoryOperationStats", "(", "us", "[", "]", "uint32", ")", "(", "DirectoryOperationStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "4", "{", "return", "DirectoryOperationStats", "{", "}", ",", "fmt", ...
// DirectoryOperationStats builds a DirectoryOperationStats from a slice of uint32s.
[ "DirectoryOperationStats", "builds", "a", "DirectoryOperationStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L173-L184
29,525
prometheus/procfs
xfs/parse.go
transactionStats
func transactionStats(us []uint32) (TransactionStats, error) { if l := len(us); l != 3 { return TransactionStats{}, fmt.Errorf("incorrect number of values for XFS transaction stats: %d", l) } return TransactionStats{ Sync: us[0], Async: us[1], Empty: us[2], }, nil }
go
func transactionStats(us []uint32) (TransactionStats, error) { if l := len(us); l != 3 { return TransactionStats{}, fmt.Errorf("incorrect number of values for XFS transaction stats: %d", l) } return TransactionStats{ Sync: us[0], Async: us[1], Empty: us[2], }, nil }
[ "func", "transactionStats", "(", "us", "[", "]", "uint32", ")", "(", "TransactionStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "3", "{", "return", "TransactionStats", "{", "}", ",", "fmt", ".", "Errorf", "(...
// TransactionStats builds a TransactionStats from a slice of uint32s.
[ "TransactionStats", "builds", "a", "TransactionStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L187-L197
29,526
prometheus/procfs
xfs/parse.go
inodeOperationStats
func inodeOperationStats(us []uint32) (InodeOperationStats, error) { if l := len(us); l != 7 { return InodeOperationStats{}, fmt.Errorf("incorrect number of values for XFS inode operation stats: %d", l) } return InodeOperationStats{ Attempts: us[0], Found: us[1], Recycle: us[2], M...
go
func inodeOperationStats(us []uint32) (InodeOperationStats, error) { if l := len(us); l != 7 { return InodeOperationStats{}, fmt.Errorf("incorrect number of values for XFS inode operation stats: %d", l) } return InodeOperationStats{ Attempts: us[0], Found: us[1], Recycle: us[2], M...
[ "func", "inodeOperationStats", "(", "us", "[", "]", "uint32", ")", "(", "InodeOperationStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "7", "{", "return", "InodeOperationStats", "{", "}", ",", "fmt", ".", "Erro...
// InodeOperationStats builds an InodeOperationStats from a slice of uint32s.
[ "InodeOperationStats", "builds", "an", "InodeOperationStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L200-L214
29,527
prometheus/procfs
xfs/parse.go
logOperationStats
func logOperationStats(us []uint32) (LogOperationStats, error) { if l := len(us); l != 5 { return LogOperationStats{}, fmt.Errorf("incorrect number of values for XFS log operation stats: %d", l) } return LogOperationStats{ Writes: us[0], Blocks: us[1], NoInternalBuffers: us[2], Force...
go
func logOperationStats(us []uint32) (LogOperationStats, error) { if l := len(us); l != 5 { return LogOperationStats{}, fmt.Errorf("incorrect number of values for XFS log operation stats: %d", l) } return LogOperationStats{ Writes: us[0], Blocks: us[1], NoInternalBuffers: us[2], Force...
[ "func", "logOperationStats", "(", "us", "[", "]", "uint32", ")", "(", "LogOperationStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "5", "{", "return", "LogOperationStats", "{", "}", ",", "fmt", ".", "Errorf", ...
// LogOperationStats builds a LogOperationStats from a slice of uint32s.
[ "LogOperationStats", "builds", "a", "LogOperationStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L217-L229
29,528
prometheus/procfs
xfs/parse.go
readWriteStats
func readWriteStats(us []uint32) (ReadWriteStats, error) { if l := len(us); l != 2 { return ReadWriteStats{}, fmt.Errorf("incorrect number of values for XFS read write stats: %d", l) } return ReadWriteStats{ Read: us[0], Write: us[1], }, nil }
go
func readWriteStats(us []uint32) (ReadWriteStats, error) { if l := len(us); l != 2 { return ReadWriteStats{}, fmt.Errorf("incorrect number of values for XFS read write stats: %d", l) } return ReadWriteStats{ Read: us[0], Write: us[1], }, nil }
[ "func", "readWriteStats", "(", "us", "[", "]", "uint32", ")", "(", "ReadWriteStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "2", "{", "return", "ReadWriteStats", "{", "}", ",", "fmt", ".", "Errorf", "(", "...
// ReadWriteStats builds a ReadWriteStats from a slice of uint32s.
[ "ReadWriteStats", "builds", "a", "ReadWriteStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L232-L241
29,529
prometheus/procfs
xfs/parse.go
attributeOperationStats
func attributeOperationStats(us []uint32) (AttributeOperationStats, error) { if l := len(us); l != 4 { return AttributeOperationStats{}, fmt.Errorf("incorrect number of values for XFS attribute operation stats: %d", l) } return AttributeOperationStats{ Get: us[0], Set: us[1], Remove: us[2], List: ...
go
func attributeOperationStats(us []uint32) (AttributeOperationStats, error) { if l := len(us); l != 4 { return AttributeOperationStats{}, fmt.Errorf("incorrect number of values for XFS attribute operation stats: %d", l) } return AttributeOperationStats{ Get: us[0], Set: us[1], Remove: us[2], List: ...
[ "func", "attributeOperationStats", "(", "us", "[", "]", "uint32", ")", "(", "AttributeOperationStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "4", "{", "return", "AttributeOperationStats", "{", "}", ",", "fmt", ...
// AttributeOperationStats builds an AttributeOperationStats from a slice of uint32s.
[ "AttributeOperationStats", "builds", "an", "AttributeOperationStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L244-L255
29,530
prometheus/procfs
xfs/parse.go
inodeClusteringStats
func inodeClusteringStats(us []uint32) (InodeClusteringStats, error) { if l := len(us); l != 3 { return InodeClusteringStats{}, fmt.Errorf("incorrect number of values for XFS inode clustering stats: %d", l) } return InodeClusteringStats{ Iflush: us[0], Flush: us[1], FlushInode: us[2], }, nil }
go
func inodeClusteringStats(us []uint32) (InodeClusteringStats, error) { if l := len(us); l != 3 { return InodeClusteringStats{}, fmt.Errorf("incorrect number of values for XFS inode clustering stats: %d", l) } return InodeClusteringStats{ Iflush: us[0], Flush: us[1], FlushInode: us[2], }, nil }
[ "func", "inodeClusteringStats", "(", "us", "[", "]", "uint32", ")", "(", "InodeClusteringStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "3", "{", "return", "InodeClusteringStats", "{", "}", ",", "fmt", ".", "E...
// InodeClusteringStats builds an InodeClusteringStats from a slice of uint32s.
[ "InodeClusteringStats", "builds", "an", "InodeClusteringStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L258-L268
29,531
prometheus/procfs
xfs/parse.go
vnodeStats
func vnodeStats(us []uint32) (VnodeStats, error) { // The attribute "Free" appears to not be available on older XFS // stats versions. Therefore, 7 or 8 elements may appear in // this slice. l := len(us) if l != 7 && l != 8 { return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", ...
go
func vnodeStats(us []uint32) (VnodeStats, error) { // The attribute "Free" appears to not be available on older XFS // stats versions. Therefore, 7 or 8 elements may appear in // this slice. l := len(us) if l != 7 && l != 8 { return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", ...
[ "func", "vnodeStats", "(", "us", "[", "]", "uint32", ")", "(", "VnodeStats", ",", "error", ")", "{", "// The attribute \"Free\" appears to not be available on older XFS", "// stats versions. Therefore, 7 or 8 elements may appear in", "// this slice.", "l", ":=", "len", "(", ...
// VnodeStats builds a VnodeStats from a slice of uint32s.
[ "VnodeStats", "builds", "a", "VnodeStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L271-L298
29,532
prometheus/procfs
xfs/parse.go
bufferStats
func bufferStats(us []uint32) (BufferStats, error) { if l := len(us); l != 9 { return BufferStats{}, fmt.Errorf("incorrect number of values for XFS buffer stats: %d", l) } return BufferStats{ Get: us[0], Create: us[1], GetLocked: us[2], GetLockedWaited: us[3], BusyLocked: ...
go
func bufferStats(us []uint32) (BufferStats, error) { if l := len(us); l != 9 { return BufferStats{}, fmt.Errorf("incorrect number of values for XFS buffer stats: %d", l) } return BufferStats{ Get: us[0], Create: us[1], GetLocked: us[2], GetLockedWaited: us[3], BusyLocked: ...
[ "func", "bufferStats", "(", "us", "[", "]", "uint32", ")", "(", "BufferStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "9", "{", "return", "BufferStats", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\...
// BufferStats builds a BufferStats from a slice of uint32s.
[ "BufferStats", "builds", "a", "BufferStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L301-L317
29,533
prometheus/procfs
xfs/parse.go
extendedPrecisionStats
func extendedPrecisionStats(us []uint64) (ExtendedPrecisionStats, error) { if l := len(us); l != 3 { return ExtendedPrecisionStats{}, fmt.Errorf("incorrect number of values for XFS extended precision stats: %d", l) } return ExtendedPrecisionStats{ FlushBytes: us[0], WriteBytes: us[1], ReadBytes: us[2], },...
go
func extendedPrecisionStats(us []uint64) (ExtendedPrecisionStats, error) { if l := len(us); l != 3 { return ExtendedPrecisionStats{}, fmt.Errorf("incorrect number of values for XFS extended precision stats: %d", l) } return ExtendedPrecisionStats{ FlushBytes: us[0], WriteBytes: us[1], ReadBytes: us[2], },...
[ "func", "extendedPrecisionStats", "(", "us", "[", "]", "uint64", ")", "(", "ExtendedPrecisionStats", ",", "error", ")", "{", "if", "l", ":=", "len", "(", "us", ")", ";", "l", "!=", "3", "{", "return", "ExtendedPrecisionStats", "{", "}", ",", "fmt", "."...
// ExtendedPrecisionStats builds an ExtendedPrecisionStats from a slice of uint32s.
[ "ExtendedPrecisionStats", "builds", "an", "ExtendedPrecisionStats", "from", "a", "slice", "of", "uint32s", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/xfs/parse.go#L320-L330
29,534
prometheus/procfs
fs.go
Path
func (fs FS) Path(p ...string) string { return path.Join(append([]string{string(fs)}, p...)...) }
go
func (fs FS) Path(p ...string) string { return path.Join(append([]string{string(fs)}, p...)...) }
[ "func", "(", "fs", "FS", ")", "Path", "(", "p", "...", "string", ")", "string", "{", "return", "path", ".", "Join", "(", "append", "(", "[", "]", "string", "{", "string", "(", "fs", ")", "}", ",", "p", "...", ")", "...", ")", "\n", "}" ]
// Path returns the path of the given subsystem relative to the procfs root.
[ "Path", "returns", "the", "path", "of", "the", "given", "subsystem", "relative", "to", "the", "procfs", "root", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/fs.go#L44-L46
29,535
prometheus/procfs
sysfs/class_thermal.go
NewClassThermalZoneStats
func (fs FS) NewClassThermalZoneStats() ([]ClassThermalZoneStats, error) { zones, err := filepath.Glob(fs.Path("class/thermal/thermal_zone[0-9]*")) if err != nil { return []ClassThermalZoneStats{}, err } var zoneStats = ClassThermalZoneStats{} stats := make([]ClassThermalZoneStats, len(zones)) for i, zone := r...
go
func (fs FS) NewClassThermalZoneStats() ([]ClassThermalZoneStats, error) { zones, err := filepath.Glob(fs.Path("class/thermal/thermal_zone[0-9]*")) if err != nil { return []ClassThermalZoneStats{}, err } var zoneStats = ClassThermalZoneStats{} stats := make([]ClassThermalZoneStats, len(zones)) for i, zone := r...
[ "func", "(", "fs", "FS", ")", "NewClassThermalZoneStats", "(", ")", "(", "[", "]", "ClassThermalZoneStats", ",", "error", ")", "{", "zones", ",", "err", ":=", "filepath", ".", "Glob", "(", "fs", ".", "Path", "(", "\"", "\"", ")", ")", "\n", "if", "...
// NewClassThermalZoneStats returns Thermal Zone metrics for all zones.
[ "NewClassThermalZoneStats", "returns", "Thermal", "Zone", "metrics", "for", "all", "zones", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/sysfs/class_thermal.go#L39-L58
29,536
prometheus/procfs
mdstat.go
ParseMDStat
func (fs FS) ParseMDStat() (mdstates []MDStat, err error) { mdStatusFilePath := fs.Path("mdstat") content, err := ioutil.ReadFile(mdStatusFilePath) if err != nil { return []MDStat{}, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err) } mdStates := []MDStat{} lines := strings.Split(string(content), "\n")...
go
func (fs FS) ParseMDStat() (mdstates []MDStat, err error) { mdStatusFilePath := fs.Path("mdstat") content, err := ioutil.ReadFile(mdStatusFilePath) if err != nil { return []MDStat{}, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err) } mdStates := []MDStat{} lines := strings.Split(string(content), "\n")...
[ "func", "(", "fs", "FS", ")", "ParseMDStat", "(", ")", "(", "mdstates", "[", "]", "MDStat", ",", "err", "error", ")", "{", "mdStatusFilePath", ":=", "fs", ".", "Path", "(", "\"", "\"", ")", "\n", "content", ",", "err", ":=", "ioutil", ".", "ReadFil...
// ParseMDStat parses an mdstat-file and returns a struct with the relevant infos.
[ "ParseMDStat", "parses", "an", "mdstat", "-", "file", "and", "returns", "a", "struct", "with", "the", "relevant", "infos", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/mdstat.go#L46-L113
29,537
prometheus/procfs
stat.go
parseSoftIRQStat
func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { softIRQStat := SoftIRQStat{} var total uint64 var prefix string _, err := fmt.Sscanf(line, "%s %d %d %d %d %d %d %d %d %d %d %d", &prefix, &total, &softIRQStat.Hi, &softIRQStat.Timer, &softIRQStat.NetTx, &softIRQStat.NetRx, &softIRQStat.Block,...
go
func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { softIRQStat := SoftIRQStat{} var total uint64 var prefix string _, err := fmt.Sscanf(line, "%s %d %d %d %d %d %d %d %d %d %d %d", &prefix, &total, &softIRQStat.Hi, &softIRQStat.Timer, &softIRQStat.NetTx, &softIRQStat.NetRx, &softIRQStat.Block,...
[ "func", "parseSoftIRQStat", "(", "line", "string", ")", "(", "SoftIRQStat", ",", "uint64", ",", "error", ")", "{", "softIRQStat", ":=", "SoftIRQStat", "{", "}", "\n", "var", "total", "uint64", "\n", "var", "prefix", "string", "\n\n", "_", ",", "err", ":=...
// Parse a softirq line.
[ "Parse", "a", "softirq", "line", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/stat.go#L133-L150
29,538
prometheus/procfs
ipvs.go
NewIPVSStats
func NewIPVSStats() (IPVSStats, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return IPVSStats{}, err } return fs.NewIPVSStats() }
go
func NewIPVSStats() (IPVSStats, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return IPVSStats{}, err } return fs.NewIPVSStats() }
[ "func", "NewIPVSStats", "(", ")", "(", "IPVSStats", ",", "error", ")", "{", "fs", ",", "err", ":=", "NewFS", "(", "DefaultMountPoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IPVSStats", "{", "}", ",", "err", "\n", "}", "\n\n", "return",...
// NewIPVSStats reads the IPVS statistics.
[ "NewIPVSStats", "reads", "the", "IPVS", "statistics", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/ipvs.go#L66-L73
29,539
prometheus/procfs
ipvs.go
NewIPVSStats
func (fs FS) NewIPVSStats() (IPVSStats, error) { file, err := os.Open(fs.Path("net/ip_vs_stats")) if err != nil { return IPVSStats{}, err } defer file.Close() return parseIPVSStats(file) }
go
func (fs FS) NewIPVSStats() (IPVSStats, error) { file, err := os.Open(fs.Path("net/ip_vs_stats")) if err != nil { return IPVSStats{}, err } defer file.Close() return parseIPVSStats(file) }
[ "func", "(", "fs", "FS", ")", "NewIPVSStats", "(", ")", "(", "IPVSStats", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "fs", ".", "Path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "...
// NewIPVSStats reads the IPVS statistics from the specified `proc` filesystem.
[ "NewIPVSStats", "reads", "the", "IPVS", "statistics", "from", "the", "specified", "proc", "filesystem", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/ipvs.go#L76-L84
29,540
prometheus/procfs
ipvs.go
parseIPVSStats
func parseIPVSStats(file io.Reader) (IPVSStats, error) { var ( statContent []byte statLines []string statFields []string stats IPVSStats ) statContent, err := ioutil.ReadAll(file) if err != nil { return IPVSStats{}, err } statLines = strings.SplitN(string(statContent), "\n", 4) if len(statLi...
go
func parseIPVSStats(file io.Reader) (IPVSStats, error) { var ( statContent []byte statLines []string statFields []string stats IPVSStats ) statContent, err := ioutil.ReadAll(file) if err != nil { return IPVSStats{}, err } statLines = strings.SplitN(string(statContent), "\n", 4) if len(statLi...
[ "func", "parseIPVSStats", "(", "file", "io", ".", "Reader", ")", "(", "IPVSStats", ",", "error", ")", "{", "var", "(", "statContent", "[", "]", "byte", "\n", "statLines", "[", "]", "string", "\n", "statFields", "[", "]", "string", "\n", "stats", "IPVSS...
// parseIPVSStats performs the actual parsing of `ip_vs_stats`.
[ "parseIPVSStats", "performs", "the", "actual", "parsing", "of", "ip_vs_stats", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/ipvs.go#L87-L132
29,541
prometheus/procfs
net_dev.go
newNetDev
func newNetDev(file string) (NetDev, error) { f, err := os.Open(file) if err != nil { return NetDev{}, err } defer f.Close() nd := NetDev{} s := bufio.NewScanner(f) for n := 0; s.Scan(); n++ { // Skip the 2 header lines. if n < 2 { continue } line, err := nd.parseLine(s.Text()) if err != nil { ...
go
func newNetDev(file string) (NetDev, error) { f, err := os.Open(file) if err != nil { return NetDev{}, err } defer f.Close() nd := NetDev{} s := bufio.NewScanner(f) for n := 0; s.Scan(); n++ { // Skip the 2 header lines. if n < 2 { continue } line, err := nd.parseLine(s.Text()) if err != nil { ...
[ "func", "newNetDev", "(", "file", "string", ")", "(", "NetDev", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NetDev", "{", "}", ",", "err", "\n", "}", "\n", ...
// newNetDev creates a new NetDev from the contents of the given file.
[ "newNetDev", "creates", "a", "new", "NetDev", "from", "the", "contents", "of", "the", "given", "file", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/net_dev.go#L71-L95
29,542
prometheus/procfs
net_dev.go
Total
func (nd NetDev) Total() NetDevLine { total := NetDevLine{} names := make([]string, 0, len(nd)) for _, ifc := range nd { names = append(names, ifc.Name) total.RxBytes += ifc.RxBytes total.RxPackets += ifc.RxPackets total.RxPackets += ifc.RxPackets total.RxErrors += ifc.RxErrors total.RxDropped += ifc.Rx...
go
func (nd NetDev) Total() NetDevLine { total := NetDevLine{} names := make([]string, 0, len(nd)) for _, ifc := range nd { names = append(names, ifc.Name) total.RxBytes += ifc.RxBytes total.RxPackets += ifc.RxPackets total.RxPackets += ifc.RxPackets total.RxErrors += ifc.RxErrors total.RxDropped += ifc.Rx...
[ "func", "(", "nd", "NetDev", ")", "Total", "(", ")", "NetDevLine", "{", "total", ":=", "NetDevLine", "{", "}", "\n\n", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "nd", ")", ")", "\n", "for", "_", ",", "ifc", ":="...
// Total aggregates the values across interfaces and returns a new NetDevLine. // The Name field will be a sorted comma separated list of interface names.
[ "Total", "aggregates", "the", "values", "across", "interfaces", "and", "returns", "a", "new", "NetDevLine", ".", "The", "Name", "field", "will", "be", "a", "sorted", "comma", "separated", "list", "of", "interface", "names", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/net_dev.go#L188-L216
29,543
prometheus/procfs
proc_psi.go
NewPSIStatsForResource
func NewPSIStatsForResource(resource string) (PSIStats, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return PSIStats{}, err } return fs.NewPSIStatsForResource(resource) }
go
func NewPSIStatsForResource(resource string) (PSIStats, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return PSIStats{}, err } return fs.NewPSIStatsForResource(resource) }
[ "func", "NewPSIStatsForResource", "(", "resource", "string", ")", "(", "PSIStats", ",", "error", ")", "{", "fs", ",", "err", ":=", "NewFS", "(", "DefaultMountPoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "PSIStats", "{", "}", ",", "err", ...
// NewPSIStatsForResource reads pressure stall information for the specified // resource. At time of writing this can be either "cpu", "memory" or "io".
[ "NewPSIStatsForResource", "reads", "pressure", "stall", "information", "for", "the", "specified", "resource", ".", "At", "time", "of", "writing", "this", "can", "be", "either", "cpu", "memory", "or", "io", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_psi.go#L56-L63
29,544
prometheus/procfs
proc_psi.go
parsePSIStats
func parsePSIStats(resource string, file io.Reader) (PSIStats, error) { psiStats := PSIStats{} stats, err := ioutil.ReadAll(file) if err != nil { return psiStats, fmt.Errorf("psi_stats: unable to read data for %s", resource) } for _, l := range strings.Split(string(stats), "\n") { prefix := strings.Split(l, "...
go
func parsePSIStats(resource string, file io.Reader) (PSIStats, error) { psiStats := PSIStats{} stats, err := ioutil.ReadAll(file) if err != nil { return psiStats, fmt.Errorf("psi_stats: unable to read data for %s", resource) } for _, l := range strings.Split(string(stats), "\n") { prefix := strings.Split(l, "...
[ "func", "parsePSIStats", "(", "resource", "string", ",", "file", "io", ".", "Reader", ")", "(", "PSIStats", ",", "error", ")", "{", "psiStats", ":=", "PSIStats", "{", "}", "\n", "stats", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "file", ")", "...
// parsePSIStats parses the specified file for pressure stall information
[ "parsePSIStats", "parses", "the", "specified", "file", "for", "pressure", "stall", "information" ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_psi.go#L77-L110
29,545
prometheus/procfs
buddyinfo.go
NewBuddyInfo
func NewBuddyInfo() ([]BuddyInfo, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return nil, err } return fs.NewBuddyInfo() }
go
func NewBuddyInfo() ([]BuddyInfo, error) { fs, err := NewFS(DefaultMountPoint) if err != nil { return nil, err } return fs.NewBuddyInfo() }
[ "func", "NewBuddyInfo", "(", ")", "(", "[", "]", "BuddyInfo", ",", "error", ")", "{", "fs", ",", "err", ":=", "NewFS", "(", "DefaultMountPoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "fs...
// NewBuddyInfo reads the buddyinfo statistics.
[ "NewBuddyInfo", "reads", "the", "buddyinfo", "statistics", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/buddyinfo.go#L35-L42
29,546
prometheus/procfs
buddyinfo.go
NewBuddyInfo
func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) { file, err := os.Open(fs.Path("buddyinfo")) if err != nil { return nil, err } defer file.Close() return parseBuddyInfo(file) }
go
func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) { file, err := os.Open(fs.Path("buddyinfo")) if err != nil { return nil, err } defer file.Close() return parseBuddyInfo(file) }
[ "func", "(", "fs", "FS", ")", "NewBuddyInfo", "(", ")", "(", "[", "]", "BuddyInfo", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "fs", ".", "Path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", ...
// NewBuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem.
[ "NewBuddyInfo", "reads", "the", "buddyinfo", "statistics", "from", "the", "specified", "proc", "filesystem", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/buddyinfo.go#L45-L53
29,547
prometheus/procfs
proc_stat.go
NewStat
func (p Proc) NewStat() (ProcStat, error) { f, err := os.Open(p.path("stat")) if err != nil { return ProcStat{}, err } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return ProcStat{}, err } var ( ignore int s = ProcStat{PID: p.PID, fs: p.fs} l = bytes.Index(data, []byte("(")) r =...
go
func (p Proc) NewStat() (ProcStat, error) { f, err := os.Open(p.path("stat")) if err != nil { return ProcStat{}, err } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return ProcStat{}, err } var ( ignore int s = ProcStat{PID: p.PID, fs: p.fs} l = bytes.Index(data, []byte("(")) r =...
[ "func", "(", "p", "Proc", ")", "NewStat", "(", ")", "(", "ProcStat", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "p", ".", "path", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ProcStat"...
// NewStat returns the current status information of the process.
[ "NewStat", "returns", "the", "current", "status", "information", "of", "the", "process", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_stat.go#L106-L164
29,548
prometheus/procfs
proc_stat.go
StartTime
func (s ProcStat) StartTime() (float64, error) { stat, err := s.fs.NewStat() if err != nil { return 0, err } return float64(stat.BootTime) + (float64(s.Starttime) / userHZ), nil }
go
func (s ProcStat) StartTime() (float64, error) { stat, err := s.fs.NewStat() if err != nil { return 0, err } return float64(stat.BootTime) + (float64(s.Starttime) / userHZ), nil }
[ "func", "(", "s", "ProcStat", ")", "StartTime", "(", ")", "(", "float64", ",", "error", ")", "{", "stat", ",", "err", ":=", "s", ".", "fs", ".", "NewStat", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "...
// StartTime returns the unix timestamp of the process in seconds.
[ "StartTime", "returns", "the", "unix", "timestamp", "of", "the", "process", "in", "seconds", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_stat.go#L177-L183
29,549
prometheus/procfs
proc_stat.go
CPUTime
func (s ProcStat) CPUTime() float64 { return float64(s.UTime+s.STime) / userHZ }
go
func (s ProcStat) CPUTime() float64 { return float64(s.UTime+s.STime) / userHZ }
[ "func", "(", "s", "ProcStat", ")", "CPUTime", "(", ")", "float64", "{", "return", "float64", "(", "s", ".", "UTime", "+", "s", ".", "STime", ")", "/", "userHZ", "\n", "}" ]
// CPUTime returns the total CPU user and system time in seconds.
[ "CPUTime", "returns", "the", "total", "CPU", "user", "and", "system", "time", "in", "seconds", "." ]
87a4384529e0652f5035fb5cc8095faf73ea9b0b
https://github.com/prometheus/procfs/blob/87a4384529e0652f5035fb5cc8095faf73ea9b0b/proc_stat.go#L186-L188
29,550
nats-io/go-nats-streaming
stan.go
ConnectWait
func ConnectWait(t time.Duration) Option { return func(o *Options) error { o.ConnectTimeout = t return nil } }
go
func ConnectWait(t time.Duration) Option { return func(o *Options) error { o.ConnectTimeout = t return nil } }
[ "func", "ConnectWait", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "ConnectTimeout", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ConnectWait is an Option to set the timeout for establishing a connection.
[ "ConnectWait", "is", "an", "Option", "to", "set", "the", "timeout", "for", "establishing", "a", "connection", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L198-L203
29,551
nats-io/go-nats-streaming
stan.go
PubAckWait
func PubAckWait(t time.Duration) Option { return func(o *Options) error { o.AckTimeout = t return nil } }
go
func PubAckWait(t time.Duration) Option { return func(o *Options) error { o.AckTimeout = t return nil } }
[ "func", "PubAckWait", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "AckTimeout", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// PubAckWait is an Option to set the timeout for waiting for an ACK for a // published message.
[ "PubAckWait", "is", "an", "Option", "to", "set", "the", "timeout", "for", "waiting", "for", "an", "ACK", "for", "a", "published", "message", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L207-L212
29,552
nats-io/go-nats-streaming
stan.go
MaxPubAcksInflight
func MaxPubAcksInflight(max int) Option { return func(o *Options) error { o.MaxPubAcksInflight = max return nil } }
go
func MaxPubAcksInflight(max int) Option { return func(o *Options) error { o.MaxPubAcksInflight = max return nil } }
[ "func", "MaxPubAcksInflight", "(", "max", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "MaxPubAcksInflight", "=", "max", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// MaxPubAcksInflight is an Option to set the maximum number of published // messages without outstanding ACKs from the server.
[ "MaxPubAcksInflight", "is", "an", "Option", "to", "set", "the", "maximum", "number", "of", "published", "messages", "without", "outstanding", "ACKs", "from", "the", "server", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L216-L221
29,553
nats-io/go-nats-streaming
stan.go
NatsConn
func NatsConn(nc *nats.Conn) Option { return func(o *Options) error { o.NatsConn = nc return nil } }
go
func NatsConn(nc *nats.Conn) Option { return func(o *Options) error { o.NatsConn = nc return nil } }
[ "func", "NatsConn", "(", "nc", "*", "nats", ".", "Conn", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "NatsConn", "=", "nc", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// NatsConn is an Option to set the underlying NATS connection to be used // by a streaming connection object. When such option is set, closing the // streaming connection does not close the provided NATS connection.
[ "NatsConn", "is", "an", "Option", "to", "set", "the", "underlying", "NATS", "connection", "to", "be", "used", "by", "a", "streaming", "connection", "object", ".", "When", "such", "option", "is", "set", "closing", "the", "streaming", "connection", "does", "no...
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L226-L231
29,554
nats-io/go-nats-streaming
stan.go
Pings
func Pings(interval, maxOut int) Option { return func(o *Options) error { // For tests, we may pass negative value that will be interpreted // by the library as milliseconds. If this test boolean is set, // do not check values. if !testAllowMillisecInPings { if interval < 1 || maxOut <= 2 { return fmt.E...
go
func Pings(interval, maxOut int) Option { return func(o *Options) error { // For tests, we may pass negative value that will be interpreted // by the library as milliseconds. If this test boolean is set, // do not check values. if !testAllowMillisecInPings { if interval < 1 || maxOut <= 2 { return fmt.E...
[ "func", "Pings", "(", "interval", ",", "maxOut", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "// For tests, we may pass negative value that will be interpreted", "// by the library as milliseconds. If this test boolean is set,", ...
// Pings is an Option to set the ping interval and max out values. // The interval needs to be at least 1 and represents the number // of seconds. // The maxOut needs to be at least 2, since the count of sent PINGs // increase whenever a PING is sent and reset to 0 when a response // is received. Setting to 1 would cau...
[ "Pings", "is", "an", "Option", "to", "set", "the", "ping", "interval", "and", "max", "out", "values", ".", "The", "interval", "needs", "to", "be", "at", "least", "1", "and", "represents", "the", "number", "of", "seconds", ".", "The", "maxOut", "needs", ...
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L240-L254
29,555
nats-io/go-nats-streaming
stan.go
failConnect
func (sc *conn) failConnect(err error) { sc.cleanupOnClose(err) if sc.nc != nil && sc.ncOwned { sc.nc.Close() } }
go
func (sc *conn) failConnect(err error) { sc.cleanupOnClose(err) if sc.nc != nil && sc.ncOwned { sc.nc.Close() } }
[ "func", "(", "sc", "*", "conn", ")", "failConnect", "(", "err", "error", ")", "{", "sc", ".", "cleanupOnClose", "(", "err", ")", "\n", "if", "sc", ".", "nc", "!=", "nil", "&&", "sc", ".", "ncOwned", "{", "sc", ".", "nc", ".", "Close", "(", ")",...
// Invoked on a failed connect. // Perform appropriate cleanup operations but do not attempt to send // a close request.
[ "Invoked", "on", "a", "failed", "connect", ".", "Perform", "appropriate", "cleanup", "operations", "but", "do", "not", "attempt", "to", "send", "a", "close", "request", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L460-L465
29,556
nats-io/go-nats-streaming
stan.go
closeDueToPing
func (sc *conn) closeDueToPing(err error) { sc.Lock() if sc.nc == nil { sc.Unlock() return } // Stop timer, unsubscribe, fail the pubs, etc.. sc.cleanupOnClose(err) // No need to send Close protocol, so simply close the underlying // NATS connection (if we own it, and if not already closed) if sc.ncOwned &&...
go
func (sc *conn) closeDueToPing(err error) { sc.Lock() if sc.nc == nil { sc.Unlock() return } // Stop timer, unsubscribe, fail the pubs, etc.. sc.cleanupOnClose(err) // No need to send Close protocol, so simply close the underlying // NATS connection (if we own it, and if not already closed) if sc.ncOwned &&...
[ "func", "(", "sc", "*", "conn", ")", "closeDueToPing", "(", "err", "error", ")", "{", "sc", ".", "Lock", "(", ")", "\n", "if", "sc", ".", "nc", "==", "nil", "{", "sc", ".", "Unlock", "(", ")", "\n", "return", "\n", "}", "\n", "// Stop timer, unsu...
// Closes a connection and invoke the connection error callback if one // was registered when the connection was created.
[ "Closes", "a", "connection", "and", "invoke", "the", "connection", "error", "callback", "if", "one", "was", "registered", "when", "the", "connection", "was", "created", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L523-L547
29,557
nats-io/go-nats-streaming
stan.go
cleanupOnClose
func (sc *conn) cleanupOnClose(err error) { sc.pingMu.Lock() if sc.pingTimer != nil { sc.pingTimer.Stop() sc.pingTimer = nil } sc.pingMu.Unlock() // Unsubscribe only if the NATS connection is not already closed // and we don't own it (otherwise connection is going to be closed // so no need for explicit uns...
go
func (sc *conn) cleanupOnClose(err error) { sc.pingMu.Lock() if sc.pingTimer != nil { sc.pingTimer.Stop() sc.pingTimer = nil } sc.pingMu.Unlock() // Unsubscribe only if the NATS connection is not already closed // and we don't own it (otherwise connection is going to be closed // so no need for explicit uns...
[ "func", "(", "sc", "*", "conn", ")", "cleanupOnClose", "(", "err", "error", ")", "{", "sc", ".", "pingMu", ".", "Lock", "(", ")", "\n", "if", "sc", ".", "pingTimer", "!=", "nil", "{", "sc", ".", "pingTimer", ".", "Stop", "(", ")", "\n", "sc", "...
// Do some cleanup when connection is lost or closed. // Connection lock is held on entry, and sc.nc is guaranteed not to be nil.
[ "Do", "some", "cleanup", "when", "connection", "is", "lost", "or", "closed", ".", "Connection", "lock", "is", "held", "on", "entry", "and", "sc", ".", "nc", "is", "guaranteed", "not", "to", "be", "nil", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L551-L588
29,558
nats-io/go-nats-streaming
stan.go
Close
func (sc *conn) Close() error { sc.Lock() defer sc.Unlock() if sc.nc == nil { // We are already closed. return nil } // Capture for NATS calls below. nc := sc.nc if sc.ncOwned { defer nc.Close() } // Now close ourselves. sc.cleanupOnClose(ErrConnectionClosed) // Signals we are closed. // Do this a...
go
func (sc *conn) Close() error { sc.Lock() defer sc.Unlock() if sc.nc == nil { // We are already closed. return nil } // Capture for NATS calls below. nc := sc.nc if sc.ncOwned { defer nc.Close() } // Now close ourselves. sc.cleanupOnClose(ErrConnectionClosed) // Signals we are closed. // Do this a...
[ "func", "(", "sc", "*", "conn", ")", "Close", "(", ")", "error", "{", "sc", ".", "Lock", "(", ")", "\n", "defer", "sc", ".", "Unlock", "(", ")", "\n\n", "if", "sc", ".", "nc", "==", "nil", "{", "// We are already closed.", "return", "nil", "\n", ...
// Close a connection to the stan system.
[ "Close", "a", "connection", "to", "the", "stan", "system", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L591-L634
29,559
nats-io/go-nats-streaming
stan.go
NatsConn
func (sc *conn) NatsConn() *nats.Conn { sc.RLock() nc := sc.nc sc.RUnlock() return nc }
go
func (sc *conn) NatsConn() *nats.Conn { sc.RLock() nc := sc.nc sc.RUnlock() return nc }
[ "func", "(", "sc", "*", "conn", ")", "NatsConn", "(", ")", "*", "nats", ".", "Conn", "{", "sc", ".", "RLock", "(", ")", "\n", "nc", ":=", "sc", ".", "nc", "\n", "sc", ".", "RUnlock", "(", ")", "\n", "return", "nc", "\n", "}" ]
// NatsConn returns the underlying NATS conn. Use this with care. For example, // closing the wrapped NATS conn will put the NATS Streaming Conn in an invalid // state.
[ "NatsConn", "returns", "the", "underlying", "NATS", "conn", ".", "Use", "this", "with", "care", ".", "For", "example", "closing", "the", "wrapped", "NATS", "conn", "will", "put", "the", "NATS", "Streaming", "Conn", "in", "an", "invalid", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L639-L644
29,560
nats-io/go-nats-streaming
stan.go
processHeartBeat
func (sc *conn) processHeartBeat(m *nats.Msg) { // No payload assumed, just reply. sc.RLock() nc := sc.nc sc.RUnlock() if nc != nil { nc.Publish(m.Reply, nil) } }
go
func (sc *conn) processHeartBeat(m *nats.Msg) { // No payload assumed, just reply. sc.RLock() nc := sc.nc sc.RUnlock() if nc != nil { nc.Publish(m.Reply, nil) } }
[ "func", "(", "sc", "*", "conn", ")", "processHeartBeat", "(", "m", "*", "nats", ".", "Msg", ")", "{", "// No payload assumed, just reply.", "sc", ".", "RLock", "(", ")", "\n", "nc", ":=", "sc", ".", "nc", "\n", "sc", ".", "RUnlock", "(", ")", "\n", ...
// Process a heartbeat from the NATS Streaming cluster
[ "Process", "a", "heartbeat", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L647-L655
29,561
nats-io/go-nats-streaming
stan.go
processAck
func (sc *conn) processAck(m *nats.Msg) { pa := &pb.PubAck{} err := pa.Unmarshal(m.Data) if err != nil { panic(fmt.Errorf("error during ack unmarshal: %v", err)) } // Remove a := sc.removeAck(pa.Guid) if a != nil { // Capture error if it exists. if pa.Error != "" { err = errors.New(pa.Error) } if a...
go
func (sc *conn) processAck(m *nats.Msg) { pa := &pb.PubAck{} err := pa.Unmarshal(m.Data) if err != nil { panic(fmt.Errorf("error during ack unmarshal: %v", err)) } // Remove a := sc.removeAck(pa.Guid) if a != nil { // Capture error if it exists. if pa.Error != "" { err = errors.New(pa.Error) } if a...
[ "func", "(", "sc", "*", "conn", ")", "processAck", "(", "m", "*", "nats", ".", "Msg", ")", "{", "pa", ":=", "&", "pb", ".", "PubAck", "{", "}", "\n", "err", ":=", "pa", ".", "Unmarshal", "(", "m", ".", "Data", ")", "\n", "if", "err", "!=", ...
// Process an ack from the NATS Streaming cluster
[ "Process", "an", "ack", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L658-L680
29,562
nats-io/go-nats-streaming
stan.go
Publish
func (sc *conn) Publish(subject string, data []byte) error { // Need to make this a buffered channel of 1 in case // a publish call is blocked in pubAckChan but cleanupOnClose() // is trying to push the error to this channel. ch := make(chan error, 1) _, err := sc.publishAsync(subject, data, nil, ch) if err == ni...
go
func (sc *conn) Publish(subject string, data []byte) error { // Need to make this a buffered channel of 1 in case // a publish call is blocked in pubAckChan but cleanupOnClose() // is trying to push the error to this channel. ch := make(chan error, 1) _, err := sc.publishAsync(subject, data, nil, ch) if err == ni...
[ "func", "(", "sc", "*", "conn", ")", "Publish", "(", "subject", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "// Need to make this a buffered channel of 1 in case", "// a publish call is blocked in pubAckChan but cleanupOnClose()", "// is trying to push the err...
// Publish will publish to the cluster and wait for an ACK.
[ "Publish", "will", "publish", "to", "the", "cluster", "and", "wait", "for", "an", "ACK", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L683-L693
29,563
nats-io/go-nats-streaming
stan.go
PublishAsync
func (sc *conn) PublishAsync(subject string, data []byte, ah AckHandler) (string, error) { return sc.publishAsync(subject, data, ah, nil) }
go
func (sc *conn) PublishAsync(subject string, data []byte, ah AckHandler) (string, error) { return sc.publishAsync(subject, data, ah, nil) }
[ "func", "(", "sc", "*", "conn", ")", "PublishAsync", "(", "subject", "string", ",", "data", "[", "]", "byte", ",", "ah", "AckHandler", ")", "(", "string", ",", "error", ")", "{", "return", "sc", ".", "publishAsync", "(", "subject", ",", "data", ",", ...
// PublishAsync will publish to the cluster on pubPrefix+subject and asynchronously // process the ACK or error state. It will return the GUID for the message being sent.
[ "PublishAsync", "will", "publish", "to", "the", "cluster", "on", "pubPrefix", "+", "subject", "and", "asynchronously", "process", "the", "ACK", "or", "error", "state", ".", "It", "will", "return", "the", "GUID", "for", "the", "message", "being", "sent", "." ...
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L697-L699
29,564
nats-io/go-nats-streaming
stan.go
processMsg
func (sc *conn) processMsg(raw *nats.Msg) { msg := &Msg{} err := msg.Unmarshal(raw.Data) if err != nil { panic(fmt.Errorf("error processing unmarshal for msg: %v", err)) } // Lookup the subscription sc.RLock() nc := sc.nc isClosed := nc == nil sub := sc.subMap[raw.Subject] sc.RUnlock() // Check if sub is ...
go
func (sc *conn) processMsg(raw *nats.Msg) { msg := &Msg{} err := msg.Unmarshal(raw.Data) if err != nil { panic(fmt.Errorf("error processing unmarshal for msg: %v", err)) } // Lookup the subscription sc.RLock() nc := sc.nc isClosed := nc == nil sub := sc.subMap[raw.Subject] sc.RUnlock() // Check if sub is ...
[ "func", "(", "sc", "*", "conn", ")", "processMsg", "(", "raw", "*", "nats", ".", "Msg", ")", "{", "msg", ":=", "&", "Msg", "{", "}", "\n", "err", ":=", "msg", ".", "Unmarshal", "(", "raw", ".", "Data", ")", "\n", "if", "err", "!=", "nil", "{"...
// Process an msg from the NATS Streaming cluster
[ "Process", "an", "msg", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L794-L834
29,565
nats-io/go-nats-streaming
sub.go
MaxInflight
func MaxInflight(m int) SubscriptionOption { return func(o *SubscriptionOptions) error { o.MaxInflight = m return nil } }
go
func MaxInflight(m int) SubscriptionOption { return func(o *SubscriptionOptions) error { o.MaxInflight = m return nil } }
[ "func", "MaxInflight", "(", "m", "int", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "MaxInflight", "=", "m", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// MaxInflight is an Option to set the maximum number of messages the cluster will send // without an ACK.
[ "MaxInflight", "is", "an", "Option", "to", "set", "the", "maximum", "number", "of", "messages", "the", "cluster", "will", "send", "without", "an", "ACK", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L139-L144
29,566
nats-io/go-nats-streaming
sub.go
AckWait
func AckWait(t time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.AckWait = t return nil } }
go
func AckWait(t time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.AckWait = t return nil } }
[ "func", "AckWait", "(", "t", "time", ".", "Duration", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "AckWait", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// AckWait is an Option to set the timeout for waiting for an ACK from the cluster's // point of view for delivered messages.
[ "AckWait", "is", "an", "Option", "to", "set", "the", "timeout", "for", "waiting", "for", "an", "ACK", "from", "the", "cluster", "s", "point", "of", "view", "for", "delivered", "messages", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L148-L153
29,567
nats-io/go-nats-streaming
sub.go
StartAt
func StartAt(sp pb.StartPosition) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = sp return nil } }
go
func StartAt(sp pb.StartPosition) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = sp return nil } }
[ "func", "StartAt", "(", "sp", "pb", ".", "StartPosition", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "sp", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// StartAt sets the desired start position for the message stream.
[ "StartAt", "sets", "the", "desired", "start", "position", "for", "the", "message", "stream", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L156-L161
29,568
nats-io/go-nats-streaming
sub.go
StartAtSequence
func StartAtSequence(seq uint64) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_SequenceStart o.StartSequence = seq return nil } }
go
func StartAtSequence(seq uint64) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_SequenceStart o.StartSequence = seq return nil } }
[ "func", "StartAtSequence", "(", "seq", "uint64", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_SequenceStart", "\n", "o", ".", "StartSequence", "="...
// StartAtSequence sets the desired start sequence position and state.
[ "StartAtSequence", "sets", "the", "desired", "start", "sequence", "position", "and", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L164-L170
29,569
nats-io/go-nats-streaming
sub.go
StartAtTime
func StartAtTime(start time.Time) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = start return nil } }
go
func StartAtTime(start time.Time) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = start return nil } }
[ "func", "StartAtTime", "(", "start", "time", ".", "Time", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_TimeDeltaStart", "\n", "o", ".", "StartTi...
// StartAtTime sets the desired start time position and state.
[ "StartAtTime", "sets", "the", "desired", "start", "time", "position", "and", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L173-L179
29,570
nats-io/go-nats-streaming
sub.go
StartAtTimeDelta
func StartAtTimeDelta(ago time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = time.Now().Add(-ago) return nil } }
go
func StartAtTimeDelta(ago time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = time.Now().Add(-ago) return nil } }
[ "func", "StartAtTimeDelta", "(", "ago", "time", ".", "Duration", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_TimeDeltaStart", "\n", "o", ".", "...
// StartAtTimeDelta sets the desired start time position and state using the delta.
[ "StartAtTimeDelta", "sets", "the", "desired", "start", "time", "position", "and", "state", "using", "the", "delta", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L182-L188
29,571
nats-io/go-nats-streaming
sub.go
StartWithLastReceived
func StartWithLastReceived() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_LastReceived return nil } }
go
func StartWithLastReceived() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_LastReceived return nil } }
[ "func", "StartWithLastReceived", "(", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_LastReceived", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// StartWithLastReceived is a helper function to set start position to last received.
[ "StartWithLastReceived", "is", "a", "helper", "function", "to", "set", "start", "position", "to", "last", "received", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L191-L196
29,572
nats-io/go-nats-streaming
sub.go
DeliverAllAvailable
func DeliverAllAvailable() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_First return nil } }
go
func DeliverAllAvailable() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_First return nil } }
[ "func", "DeliverAllAvailable", "(", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_First", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DeliverAllAvailable will deliver all messages available.
[ "DeliverAllAvailable", "will", "deliver", "all", "messages", "available", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L199-L204
29,573
nats-io/go-nats-streaming
sub.go
DurableName
func DurableName(name string) SubscriptionOption { return func(o *SubscriptionOptions) error { o.DurableName = name return nil } }
go
func DurableName(name string) SubscriptionOption { return func(o *SubscriptionOptions) error { o.DurableName = name return nil } }
[ "func", "DurableName", "(", "name", "string", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "DurableName", "=", "name", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DurableName sets the DurableName for the subscriber.
[ "DurableName", "sets", "the", "DurableName", "for", "the", "subscriber", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L215-L220
29,574
nats-io/go-nats-streaming
sub.go
Subscribe
func (sc *conn) Subscribe(subject string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, "", cb, options...) }
go
func (sc *conn) Subscribe(subject string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, "", cb, options...) }
[ "func", "(", "sc", "*", "conn", ")", "Subscribe", "(", "subject", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "return", "sc", ".", "subscribe", "(", "subject", ",", "\"...
// Subscribe will perform a subscription with the given options to the NATS Streaming cluster.
[ "Subscribe", "will", "perform", "a", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L223-L225
29,575
nats-io/go-nats-streaming
sub.go
QueueSubscribe
func (sc *conn) QueueSubscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, qgroup, cb, options...) }
go
func (sc *conn) QueueSubscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, qgroup, cb, options...) }
[ "func", "(", "sc", "*", "conn", ")", "QueueSubscribe", "(", "subject", ",", "qgroup", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "return", "sc", ".", "subscribe", "(", ...
// QueueSubscribe will perform a queue subscription with the given options to the NATS Streaming cluster.
[ "QueueSubscribe", "will", "perform", "a", "queue", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L228-L230
29,576
nats-io/go-nats-streaming
sub.go
subscribe
func (sc *conn) subscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { sub := &subscription{subject: subject, qgroup: qgroup, inbox: nats.NewInbox(), cb: cb, sc: sc, opts: DefaultSubscriptionOptions} for _, opt := range options { if err := opt(&sub.opts); err != nil ...
go
func (sc *conn) subscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { sub := &subscription{subject: subject, qgroup: qgroup, inbox: nats.NewInbox(), cb: cb, sc: sc, opts: DefaultSubscriptionOptions} for _, opt := range options { if err := opt(&sub.opts); err != nil ...
[ "func", "(", "sc", "*", "conn", ")", "subscribe", "(", "subject", ",", "qgroup", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "sub", ":=", "&", "subscription", "{", "sub...
// subscribe will perform a subscription with the given options to the NATS Streaming cluster.
[ "subscribe", "will", "perform", "a", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L233-L304
29,577
nats-io/go-nats-streaming
sub.go
closeOrUnsubscribe
func (sub *subscription) closeOrUnsubscribe(doClose bool) error { sub.Lock() sc := sub.sc if sc == nil { // Already closed. sub.Unlock() return ErrBadSubscription } sub.sc = nil sub.inboxSub.Unsubscribe() sub.inboxSub = nil sub.Unlock() sc.Lock() if sc.nc == nil { sc.Unlock() return ErrConnectionCl...
go
func (sub *subscription) closeOrUnsubscribe(doClose bool) error { sub.Lock() sc := sub.sc if sc == nil { // Already closed. sub.Unlock() return ErrBadSubscription } sub.sc = nil sub.inboxSub.Unsubscribe() sub.inboxSub = nil sub.Unlock() sc.Lock() if sc.nc == nil { sc.Unlock() return ErrConnectionCl...
[ "func", "(", "sub", "*", "subscription", ")", "closeOrUnsubscribe", "(", "doClose", "bool", ")", "error", "{", "sub", ".", "Lock", "(", ")", "\n", "sc", ":=", "sub", ".", "sc", "\n", "if", "sc", "==", "nil", "{", "// Already closed.", "sub", ".", "Un...
// closeOrUnsubscribe performs either close or unsubsribe based on // given boolean.
[ "closeOrUnsubscribe", "performs", "either", "close", "or", "unsubsribe", "based", "on", "given", "boolean", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L396-L455
29,578
twpayne/go-geom
xyz/xyz.go
Distance
func Distance(point1, point2 geom.Coord) float64 { // default to 2D distance if either Z is not set if math.IsNaN(point1[2]) || math.IsNaN(point2[2]) { return xy.Distance(point1, point2) } dx := point1[0] - point2[0] dy := point1[1] - point2[1] dz := point1[2] - point2[2] return math.Sqrt(dx*dx + dy*dy + dz*d...
go
func Distance(point1, point2 geom.Coord) float64 { // default to 2D distance if either Z is not set if math.IsNaN(point1[2]) || math.IsNaN(point2[2]) { return xy.Distance(point1, point2) } dx := point1[0] - point2[0] dy := point1[1] - point2[1] dz := point1[2] - point2[2] return math.Sqrt(dx*dx + dy*dy + dz*d...
[ "func", "Distance", "(", "point1", ",", "point2", "geom", ".", "Coord", ")", "float64", "{", "// default to 2D distance if either Z is not set", "if", "math", ".", "IsNaN", "(", "point1", "[", "2", "]", ")", "||", "math", ".", "IsNaN", "(", "point2", "[", ...
// Distance calculates the distance between the two coordinates in 3d space.
[ "Distance", "calculates", "the", "distance", "between", "the", "two", "coordinates", "in", "3d", "space", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L14-L24
29,579
twpayne/go-geom
xyz/xyz.go
DistancePointToLine
func DistancePointToLine(point, lineStart, lineEnd geom.Coord) float64 { // if start = end, then just compute distance to one of the endpoints if Equals(lineStart, lineEnd) { return Distance(point, lineStart) } // otherwise use comp.graphics.algorithms Frequently Asked Questions method /* * (1) r = AC dot AB ...
go
func DistancePointToLine(point, lineStart, lineEnd geom.Coord) float64 { // if start = end, then just compute distance to one of the endpoints if Equals(lineStart, lineEnd) { return Distance(point, lineStart) } // otherwise use comp.graphics.algorithms Frequently Asked Questions method /* * (1) r = AC dot AB ...
[ "func", "DistancePointToLine", "(", "point", ",", "lineStart", ",", "lineEnd", "geom", ".", "Coord", ")", "float64", "{", "// if start = end, then just compute distance to one of the endpoints", "if", "Equals", "(", "lineStart", ",", "lineEnd", ")", "{", "return", "Di...
// DistancePointToLine calculates the distance from point to a point on the line
[ "DistancePointToLine", "calculates", "the", "distance", "from", "point", "to", "a", "point", "on", "the", "line" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L27-L69
29,580
twpayne/go-geom
xyz/xyz.go
Equals
func Equals(point1, other geom.Coord) bool { return (point1[0] == other[0]) && (point1[1] == other[1]) && ((point1[2] == other[2]) || (math.IsNaN(point1[2]) && math.IsNaN(other[2]))) }
go
func Equals(point1, other geom.Coord) bool { return (point1[0] == other[0]) && (point1[1] == other[1]) && ((point1[2] == other[2]) || (math.IsNaN(point1[2]) && math.IsNaN(other[2]))) }
[ "func", "Equals", "(", "point1", ",", "other", "geom", ".", "Coord", ")", "bool", "{", "return", "(", "point1", "[", "0", "]", "==", "other", "[", "0", "]", ")", "&&", "(", "point1", "[", "1", "]", "==", "other", "[", "1", "]", ")", "&&", "("...
// Equals determines if the two coordinates have equal in 3d space
[ "Equals", "determines", "if", "the", "two", "coordinates", "have", "equal", "in", "3d", "space" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L72-L76
29,581
twpayne/go-geom
xyz/xyz.go
DistanceLineToLine
func DistanceLineToLine(line1Start, line1End, line2Start, line2End geom.Coord) float64 { /** * This calculation is susceptible to roundoff errors when * passed large ordinate values. * It may be possible to improve this by using {@link DD} arithmetic. */ if Equals(line1Start, line1End) { return DistancePoin...
go
func DistanceLineToLine(line1Start, line1End, line2Start, line2End geom.Coord) float64 { /** * This calculation is susceptible to roundoff errors when * passed large ordinate values. * It may be possible to improve this by using {@link DD} arithmetic. */ if Equals(line1Start, line1End) { return DistancePoin...
[ "func", "DistanceLineToLine", "(", "line1Start", ",", "line1End", ",", "line2Start", ",", "line2End", "geom", ".", "Coord", ")", "float64", "{", "/**\n\t * This calculation is susceptible to roundoff errors when\n\t * passed large ordinate values.\n\t * It may be possible to improve ...
// DistanceLineToLine computes the distance between two 3D segments
[ "DistanceLineToLine", "computes", "the", "distance", "between", "two", "3D", "segments" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L79-L147
29,582
twpayne/go-geom
xy/angle.go
AngleBetween
func AngleBetween(tip1, tail, tip2 geom.Coord) float64 { a1 := Angle(tail, tip1) a2 := Angle(tail, tip2) return Diff(a1, a2) }
go
func AngleBetween(tip1, tail, tip2 geom.Coord) float64 { a1 := Angle(tail, tip1) a2 := Angle(tail, tip2) return Diff(a1, a2) }
[ "func", "AngleBetween", "(", "tip1", ",", "tail", ",", "tip2", "geom", ".", "Coord", ")", "float64", "{", "a1", ":=", "Angle", "(", "tail", ",", "tip1", ")", "\n", "a2", ":=", "Angle", "(", "tail", ",", "tip2", ")", "\n\n", "return", "Diff", "(", ...
// AngleBetween calculates the un-oriented smallest angle between two vectors. // The computed angle will be in the range [0, Pi). // // Param tip1 - the tip of one vector // param tail - the tail of each vector // param tip2 - the tip of the other vector
[ "AngleBetween", "calculates", "the", "un", "-", "oriented", "smallest", "angle", "between", "two", "vectors", ".", "The", "computed", "angle", "will", "be", "in", "the", "range", "[", "0", "Pi", ")", ".", "Param", "tip1", "-", "the", "tip", "of", "one", ...
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L62-L67
29,583
twpayne/go-geom
xy/angle.go
AngleOrientation
func AngleOrientation(ang1, ang2 float64) orientation.Type { crossproduct := math.Sin(ang2 - ang1) switch { case crossproduct > 0: return orientation.CounterClockwise case crossproduct < 0: return orientation.Clockwise default: return orientation.Collinear } }
go
func AngleOrientation(ang1, ang2 float64) orientation.Type { crossproduct := math.Sin(ang2 - ang1) switch { case crossproduct > 0: return orientation.CounterClockwise case crossproduct < 0: return orientation.Clockwise default: return orientation.Collinear } }
[ "func", "AngleOrientation", "(", "ang1", ",", "ang2", "float64", ")", "orientation", ".", "Type", "{", "crossproduct", ":=", "math", ".", "Sin", "(", "ang2", "-", "ang1", ")", "\n\n", "switch", "{", "case", "crossproduct", ">", "0", ":", "return", "orien...
// AngleOrientation returns whether an angle must turn clockwise or counterclockwise // overlap another angle.
[ "AngleOrientation", "returns", "whether", "an", "angle", "must", "turn", "clockwise", "or", "counterclockwise", "overlap", "another", "angle", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L93-L104
29,584
twpayne/go-geom
xy/angle.go
Normalize
func Normalize(angle float64) float64 { for angle > math.Pi { angle -= piTimes2 } for angle <= -math.Pi { angle += piTimes2 } return angle }
go
func Normalize(angle float64) float64 { for angle > math.Pi { angle -= piTimes2 } for angle <= -math.Pi { angle += piTimes2 } return angle }
[ "func", "Normalize", "(", "angle", "float64", ")", "float64", "{", "for", "angle", ">", "math", ".", "Pi", "{", "angle", "-=", "piTimes2", "\n", "}", "\n", "for", "angle", "<=", "-", "math", ".", "Pi", "{", "angle", "+=", "piTimes2", "\n", "}", "\n...
// Normalize computes the normalized value of an angle, which is the // equivalent angle in the range ( -Pi, Pi ].
[ "Normalize", "computes", "the", "normalized", "value", "of", "an", "angle", "which", "is", "the", "equivalent", "angle", "in", "the", "range", "(", "-", "Pi", "Pi", "]", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L108-L116
29,585
twpayne/go-geom
geom.go
MIndex
func (l Layout) MIndex() int { switch l { case NoLayout, XY, XYZ: return -1 case XYM: return 2 case XYZM: return 3 default: return 3 } }
go
func (l Layout) MIndex() int { switch l { case NoLayout, XY, XYZ: return -1 case XYM: return 2 case XYZM: return 3 default: return 3 } }
[ "func", "(", "l", "Layout", ")", "MIndex", "(", ")", "int", "{", "switch", "l", "{", "case", "NoLayout", ",", "XY", ",", "XYZ", ":", "return", "-", "1", "\n", "case", "XYM", ":", "return", "2", "\n", "case", "XYZM", ":", "return", "3", "\n", "d...
// MIndex returns the index of the M dimension, or -1 if the l does not have an // M dimension.
[ "MIndex", "returns", "the", "index", "of", "the", "M", "dimension", "or", "-", "1", "if", "the", "l", "does", "not", "have", "an", "M", "dimension", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L135-L146
29,586
twpayne/go-geom
geom.go
Stride
func (l Layout) Stride() int { switch l { case NoLayout: return 0 case XY: return 2 case XYZ: return 3 case XYM: return 3 case XYZM: return 4 default: return int(l) } }
go
func (l Layout) Stride() int { switch l { case NoLayout: return 0 case XY: return 2 case XYZ: return 3 case XYM: return 3 case XYZM: return 4 default: return int(l) } }
[ "func", "(", "l", "Layout", ")", "Stride", "(", ")", "int", "{", "switch", "l", "{", "case", "NoLayout", ":", "return", "0", "\n", "case", "XY", ":", "return", "2", "\n", "case", "XYZ", ":", "return", "3", "\n", "case", "XYM", ":", "return", "3",...
// Stride returns l's number of dimensions.
[ "Stride", "returns", "l", "s", "number", "of", "dimensions", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L149-L164
29,587
twpayne/go-geom
geom.go
String
func (l Layout) String() string { switch l { case NoLayout: return "NoLayout" case XY: return "XY" case XYZ: return "XYZ" case XYM: return "XYM" case XYZM: return "XYZM" default: return fmt.Sprintf("Layout(%d)", int(l)) } }
go
func (l Layout) String() string { switch l { case NoLayout: return "NoLayout" case XY: return "XY" case XYZ: return "XYZ" case XYM: return "XYM" case XYZM: return "XYZM" default: return fmt.Sprintf("Layout(%d)", int(l)) } }
[ "func", "(", "l", "Layout", ")", "String", "(", ")", "string", "{", "switch", "l", "{", "case", "NoLayout", ":", "return", "\"", "\"", "\n", "case", "XY", ":", "return", "\"", "\"", "\n", "case", "XYZ", ":", "return", "\"", "\"", "\n", "case", "X...
// String returns a human-readable string representing l.
[ "String", "returns", "a", "human", "-", "readable", "string", "representing", "l", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L167-L182
29,588
twpayne/go-geom
geom.go
Must
func Must(g T, err error) T { if err != nil { panic(err) } return g }
go
func Must(g T, err error) T { if err != nil { panic(err) } return g }
[ "func", "Must", "(", "g", "T", ",", "err", "error", ")", "T", "{", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "g", "\n", "}" ]
// Must panics if err is not nil, otherwise it returns g.
[ "Must", "panics", "if", "err", "is", "not", "nil", "otherwise", "it", "returns", "g", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L196-L201
29,589
twpayne/go-geom
xy/lineintersection/line_on_line_intersection.go
NewResult
func NewResult(intersectionType Type, intersection []geom.Coord) Result { return Result{ intersectionType: intersectionType, intersection: intersection, } }
go
func NewResult(intersectionType Type, intersection []geom.Coord) Result { return Result{ intersectionType: intersectionType, intersection: intersection, } }
[ "func", "NewResult", "(", "intersectionType", "Type", ",", "intersection", "[", "]", "geom", ".", "Coord", ")", "Result", "{", "return", "Result", "{", "intersectionType", ":", "intersectionType", ",", "intersection", ":", "intersection", ",", "}", "\n", "}" ]
// NewResult create a new result object
[ "NewResult", "create", "a", "new", "result", "object" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/lineintersection/line_on_line_intersection.go#L32-L37
29,590
twpayne/go-geom
xy/internal/numbers.go
IsSameSignAndNonZero
func IsSameSignAndNonZero(a, b float64) bool { if a == 0 || b == 0 { return false } return (a < 0 && b < 0) || (a > 0 && b > 0) }
go
func IsSameSignAndNonZero(a, b float64) bool { if a == 0 || b == 0 { return false } return (a < 0 && b < 0) || (a > 0 && b > 0) }
[ "func", "IsSameSignAndNonZero", "(", "a", ",", "b", "float64", ")", "bool", "{", "if", "a", "==", "0", "||", "b", "==", "0", "{", "return", "false", "\n", "}", "\n", "return", "(", "a", "<", "0", "&&", "b", "<", "0", ")", "||", "(", "a", ">",...
// IsSameSignAndNonZero checks if both a and b are positive or negative.
[ "IsSameSignAndNonZero", "checks", "if", "both", "a", "and", "b", "are", "positive", "or", "negative", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L4-L9
29,591
twpayne/go-geom
xy/internal/numbers.go
Min
func Min(v1, v2, v3, v4 float64) float64 { min := v1 if v2 < min { min = v2 } if v3 < min { min = v3 } if v4 < min { min = v4 } return min }
go
func Min(v1, v2, v3, v4 float64) float64 { min := v1 if v2 < min { min = v2 } if v3 < min { min = v3 } if v4 < min { min = v4 } return min }
[ "func", "Min", "(", "v1", ",", "v2", ",", "v3", ",", "v4", "float64", ")", "float64", "{", "min", ":=", "v1", "\n", "if", "v2", "<", "min", "{", "min", "=", "v2", "\n", "}", "\n", "if", "v3", "<", "min", "{", "min", "=", "v3", "\n", "}", ...
// Min finds the minimum of the 4 parameters
[ "Min", "finds", "the", "minimum", "of", "the", "4", "parameters" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L12-L24
29,592
twpayne/go-geom
encoding/wkbhex/wkbhex.go
Encode
func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) { wkb, err := wkb.Marshal(g, byteOrder) if err != nil { return "", err } return hex.EncodeToString(wkb), nil }
go
func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) { wkb, err := wkb.Marshal(g, byteOrder) if err != nil { return "", err } return hex.EncodeToString(wkb), nil }
[ "func", "Encode", "(", "g", "geom", ".", "T", ",", "byteOrder", "binary", ".", "ByteOrder", ")", "(", "string", ",", "error", ")", "{", "wkb", ",", "err", ":=", "wkb", ".", "Marshal", "(", "g", ",", "byteOrder", ")", "\n", "if", "err", "!=", "nil...
// Encode encodes an arbitrary geometry to a string.
[ "Encode", "encodes", "an", "arbitrary", "geometry", "to", "a", "string", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L21-L27
29,593
twpayne/go-geom
encoding/wkbhex/wkbhex.go
Decode
func Decode(s string) (geom.T, error) { data, err := hex.DecodeString(s) if err != nil { return nil, err } return wkb.Unmarshal(data) }
go
func Decode(s string) (geom.T, error) { data, err := hex.DecodeString(s) if err != nil { return nil, err } return wkb.Unmarshal(data) }
[ "func", "Decode", "(", "s", "string", ")", "(", "geom", ".", "T", ",", "error", ")", "{", "data", ",", "err", ":=", "hex", ".", "DecodeString", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", ...
// Decode decodes an arbitrary geometry from a string.
[ "Decode", "decodes", "an", "arbitrary", "geometry", "from", "a", "string", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L30-L36
29,594
twpayne/go-geom
polygon.go
NewPolygonFlat
func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon { g := new(Polygon) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords g.ends = ends return g }
go
func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon { g := new(Polygon) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords g.ends = ends return g }
[ "func", "NewPolygonFlat", "(", "layout", "Layout", ",", "flatCoords", "[", "]", "float64", ",", "ends", "[", "]", "int", ")", "*", "Polygon", "{", "g", ":=", "new", "(", "Polygon", ")", "\n", "g", ".", "layout", "=", "layout", "\n", "g", ".", "stri...
// NewPolygonFlat returns a new Polygon with the given flat coordinates.
[ "NewPolygonFlat", "returns", "a", "new", "Polygon", "with", "the", "given", "flat", "coordinates", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L16-L23
29,595
twpayne/go-geom
polygon.go
Area
func (g *Polygon) Area() float64 { return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2 }
go
func (g *Polygon) Area() float64 { return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2 }
[ "func", "(", "g", "*", "Polygon", ")", "Area", "(", ")", "float64", "{", "return", "doubleArea2", "(", "g", ".", "flatCoords", ",", "0", ",", "g", ".", "ends", ",", "g", ".", "stride", ")", "/", "2", "\n", "}" ]
// Area returns the area.
[ "Area", "returns", "the", "area", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L26-L28
29,596
twpayne/go-geom
polygon.go
Length
func (g *Polygon) Length() float64 { return length2(g.flatCoords, 0, g.ends, g.stride) }
go
func (g *Polygon) Length() float64 { return length2(g.flatCoords, 0, g.ends, g.stride) }
[ "func", "(", "g", "*", "Polygon", ")", "Length", "(", ")", "float64", "{", "return", "length2", "(", "g", ".", "flatCoords", ",", "0", ",", "g", ".", "ends", ",", "g", ".", "stride", ")", "\n", "}" ]
// Length returns the perimter.
[ "Length", "returns", "the", "perimter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L41-L43
29,597
twpayne/go-geom
polygon.go
LinearRing
func (g *Polygon) LinearRing(i int) *LinearRing { offset := 0 if i > 0 { offset = g.ends[i-1] } return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]]) }
go
func (g *Polygon) LinearRing(i int) *LinearRing { offset := 0 if i > 0 { offset = g.ends[i-1] } return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]]) }
[ "func", "(", "g", "*", "Polygon", ")", "LinearRing", "(", "i", "int", ")", "*", "LinearRing", "{", "offset", ":=", "0", "\n", "if", "i", ">", "0", "{", "offset", "=", "g", ".", "ends", "[", "i", "-", "1", "]", "\n", "}", "\n", "return", "NewL...
// LinearRing returns the ith LinearRing.
[ "LinearRing", "returns", "the", "ith", "LinearRing", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L46-L52
29,598
twpayne/go-geom
polygon.go
Push
func (g *Polygon) Push(lr *LinearRing) error { if lr.layout != g.layout { return ErrLayoutMismatch{Got: lr.layout, Want: g.layout} } g.flatCoords = append(g.flatCoords, lr.flatCoords...) g.ends = append(g.ends, len(g.flatCoords)) return nil }
go
func (g *Polygon) Push(lr *LinearRing) error { if lr.layout != g.layout { return ErrLayoutMismatch{Got: lr.layout, Want: g.layout} } g.flatCoords = append(g.flatCoords, lr.flatCoords...) g.ends = append(g.ends, len(g.flatCoords)) return nil }
[ "func", "(", "g", "*", "Polygon", ")", "Push", "(", "lr", "*", "LinearRing", ")", "error", "{", "if", "lr", ".", "layout", "!=", "g", ".", "layout", "{", "return", "ErrLayoutMismatch", "{", "Got", ":", "lr", ".", "layout", ",", "Want", ":", "g", ...
// Push appends a LinearRing.
[ "Push", "appends", "a", "LinearRing", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L66-L73
29,599
twpayne/go-geom
encoding/wkt/wkt.go
Marshal
func Marshal(g geom.T) (string, error) { b := &bytes.Buffer{} if err := write(b, g); err != nil { return "", err } return b.String(), nil }
go
func Marshal(g geom.T) (string, error) { b := &bytes.Buffer{} if err := write(b, g); err != nil { return "", err } return b.String(), nil }
[ "func", "Marshal", "(", "g", "geom", ".", "T", ")", "(", "string", ",", "error", ")", "{", "b", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "write", "(", "b", ",", "g", ")", ";", "err", "!=", "nil", "{", "return", ...
// Marshal marshals an arbitrary geometry.
[ "Marshal", "marshals", "an", "arbitrary", "geometry", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkt/wkt.go#L11-L17