id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
128,000 | apache/thrift | lib/go/thrift/compact_protocol.go | WriteString | func (p *TCompactProtocol) WriteString(value string) error {
_, e := p.writeVarint32(int32(len(value)))
if e != nil {
return NewTProtocolException(e)
}
if len(value) > 0 {
}
_, e = p.trans.WriteString(value)
return e
} | go | func (p *TCompactProtocol) WriteString(value string) error {
_, e := p.writeVarint32(int32(len(value)))
if e != nil {
return NewTProtocolException(e)
}
if len(value) > 0 {
}
_, e = p.trans.WriteString(value)
return e
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"WriteString",
"(",
"value",
"string",
")",
"error",
"{",
"_",
",",
"e",
":=",
"p",
".",
"writeVarint32",
"(",
"int32",
"(",
"len",
"(",
"value",
")",
")",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"r... | // Write a string to the wire with a varint size preceding. | [
"Write",
"a",
"string",
"to",
"the",
"wire",
"with",
"a",
"varint",
"size",
"preceding",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L303-L312 |
128,001 | apache/thrift | lib/go/thrift/compact_protocol.go | WriteBinary | func (p *TCompactProtocol) WriteBinary(bin []byte) error {
_, e := p.writeVarint32(int32(len(bin)))
if e != nil {
return NewTProtocolException(e)
}
if len(bin) > 0 {
_, e = p.trans.Write(bin)
return NewTProtocolException(e)
}
return nil
} | go | func (p *TCompactProtocol) WriteBinary(bin []byte) error {
_, e := p.writeVarint32(int32(len(bin)))
if e != nil {
return NewTProtocolException(e)
}
if len(bin) > 0 {
_, e = p.trans.Write(bin)
return NewTProtocolException(e)
}
return nil
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"WriteBinary",
"(",
"bin",
"[",
"]",
"byte",
")",
"error",
"{",
"_",
",",
"e",
":=",
"p",
".",
"writeVarint32",
"(",
"int32",
"(",
"len",
"(",
"bin",
")",
")",
")",
"\n",
"if",
"e",
"!=",
"nil",
"... | // Write a byte array, using a varint for the size. | [
"Write",
"a",
"byte",
"array",
"using",
"a",
"varint",
"for",
"the",
"size",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L315-L325 |
128,002 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadMessageBegin | func (p *TCompactProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) {
protocolId, err := p.readByteDirect()
if err != nil {
return
}
if protocolId != COMPACT_PROTOCOL_ID {
e := fmt.Errorf("Expected protocol id %02x but got %02x", COMPACT_PROTOCOL_ID, protocolId)
return "... | go | func (p *TCompactProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) {
protocolId, err := p.readByteDirect()
if err != nil {
return
}
if protocolId != COMPACT_PROTOCOL_ID {
e := fmt.Errorf("Expected protocol id %02x but got %02x", COMPACT_PROTOCOL_ID, protocolId)
return "... | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadMessageBegin",
"(",
")",
"(",
"name",
"string",
",",
"typeId",
"TMessageType",
",",
"seqId",
"int32",
",",
"err",
"error",
")",
"{",
"protocolId",
",",
"err",
":=",
"p",
".",
"readByteDirect",
"(",
")"... | //
// Reading methods.
//
// Read a message header. | [
"Reading",
"methods",
".",
"Read",
"a",
"message",
"header",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L332-L363 |
128,003 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadStructBegin | func (p *TCompactProtocol) ReadStructBegin() (name string, err error) {
p.lastField = append(p.lastField, p.lastFieldId)
p.lastFieldId = 0
return
} | go | func (p *TCompactProtocol) ReadStructBegin() (name string, err error) {
p.lastField = append(p.lastField, p.lastFieldId)
p.lastFieldId = 0
return
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadStructBegin",
"(",
")",
"(",
"name",
"string",
",",
"err",
"error",
")",
"{",
"p",
".",
"lastField",
"=",
"append",
"(",
"p",
".",
"lastField",
",",
"p",
".",
"lastFieldId",
")",
"\n",
"p",
".",
... | // Read a struct begin. There's nothing on the wire for this, but it is our
// opportunity to push a new struct begin marker onto the field stack. | [
"Read",
"a",
"struct",
"begin",
".",
"There",
"s",
"nothing",
"on",
"the",
"wire",
"for",
"this",
"but",
"it",
"is",
"our",
"opportunity",
"to",
"push",
"a",
"new",
"struct",
"begin",
"marker",
"onto",
"the",
"field",
"stack",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L369-L373 |
128,004 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadFieldBegin | func (p *TCompactProtocol) ReadFieldBegin() (name string, typeId TType, id int16, err error) {
t, err := p.readByteDirect()
if err != nil {
return
}
// if it's a stop, then we can return immediately, as the struct is over.
if (t & 0x0f) == STOP {
return "", STOP, 0, nil
}
// mask off the 4 MSB of the type ... | go | func (p *TCompactProtocol) ReadFieldBegin() (name string, typeId TType, id int16, err error) {
t, err := p.readByteDirect()
if err != nil {
return
}
// if it's a stop, then we can return immediately, as the struct is over.
if (t & 0x0f) == STOP {
return "", STOP, 0, nil
}
// mask off the 4 MSB of the type ... | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadFieldBegin",
"(",
")",
"(",
"name",
"string",
",",
"typeId",
"TType",
",",
"id",
"int16",
",",
"err",
"error",
")",
"{",
"t",
",",
"err",
":=",
"p",
".",
"readByteDirect",
"(",
")",
"\n",
"if",
"... | // Read a field header off the wire. | [
"Read",
"a",
"field",
"header",
"off",
"the",
"wire",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L385-L424 |
128,005 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadSetBegin | func (p *TCompactProtocol) ReadSetBegin() (elemType TType, size int, err error) {
return p.ReadListBegin()
} | go | func (p *TCompactProtocol) ReadSetBegin() (elemType TType, size int, err error) {
return p.ReadListBegin()
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadSetBegin",
"(",
")",
"(",
"elemType",
"TType",
",",
"size",
"int",
",",
"err",
"error",
")",
"{",
"return",
"p",
".",
"ReadListBegin",
"(",
")",
"\n",
"}"
] | // Read a set header off the wire. If the set size is 0-14, the size will
// be packed into the element type header. If it's a longer set, the 4 MSB
// of the element type header will be 0xF, and a varint will follow with the
// true size. | [
"Read",
"a",
"set",
"header",
"off",
"the",
"wire",
".",
"If",
"the",
"set",
"size",
"is",
"0",
"-",
"14",
"the",
"size",
"will",
"be",
"packed",
"into",
"the",
"element",
"type",
"header",
".",
"If",
"it",
"s",
"a",
"longer",
"set",
"the",
"4",
... | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L493-L495 |
128,006 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadBool | func (p *TCompactProtocol) ReadBool() (value bool, err error) {
if p.boolValueIsNotNull {
p.boolValueIsNotNull = false
return p.boolValue, nil
}
v, err := p.readByteDirect()
return v == COMPACT_BOOLEAN_TRUE, err
} | go | func (p *TCompactProtocol) ReadBool() (value bool, err error) {
if p.boolValueIsNotNull {
p.boolValueIsNotNull = false
return p.boolValue, nil
}
v, err := p.readByteDirect()
return v == COMPACT_BOOLEAN_TRUE, err
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadBool",
"(",
")",
"(",
"value",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"p",
".",
"boolValueIsNotNull",
"{",
"p",
".",
"boolValueIsNotNull",
"=",
"false",
"\n",
"return",
"p",
".",
"boolValue",
"... | // Read a boolean off the wire. If this is a boolean field, the value should
// already have been read during readFieldBegin, so we'll just consume the
// pre-stored value. Otherwise, read a byte. | [
"Read",
"a",
"boolean",
"off",
"the",
"wire",
".",
"If",
"this",
"is",
"a",
"boolean",
"field",
"the",
"value",
"should",
"already",
"have",
"been",
"read",
"during",
"readFieldBegin",
"so",
"we",
"ll",
"just",
"consume",
"the",
"pre",
"-",
"stored",
"va... | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L502-L509 |
128,007 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadI16 | func (p *TCompactProtocol) ReadI16() (value int16, err error) {
v, err := p.ReadI32()
return int16(v), err
} | go | func (p *TCompactProtocol) ReadI16() (value int16, err error) {
v, err := p.ReadI32()
return int16(v), err
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadI16",
"(",
")",
"(",
"value",
"int16",
",",
"err",
"error",
")",
"{",
"v",
",",
"err",
":=",
"p",
".",
"ReadI32",
"(",
")",
"\n",
"return",
"int16",
"(",
"v",
")",
",",
"err",
"\n",
"}"
] | // Read an i16 from the wire as a zigzag varint. | [
"Read",
"an",
"i16",
"from",
"the",
"wire",
"as",
"a",
"zigzag",
"varint",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L521-L524 |
128,008 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadI32 | func (p *TCompactProtocol) ReadI32() (value int32, err error) {
v, e := p.readVarint32()
if e != nil {
return 0, NewTProtocolException(e)
}
value = p.zigzagToInt32(v)
return value, nil
} | go | func (p *TCompactProtocol) ReadI32() (value int32, err error) {
v, e := p.readVarint32()
if e != nil {
return 0, NewTProtocolException(e)
}
value = p.zigzagToInt32(v)
return value, nil
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadI32",
"(",
")",
"(",
"value",
"int32",
",",
"err",
"error",
")",
"{",
"v",
",",
"e",
":=",
"p",
".",
"readVarint32",
"(",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"return",
"0",
",",
"NewTProtoc... | // Read an i32 from the wire as a zigzag varint. | [
"Read",
"an",
"i32",
"from",
"the",
"wire",
"as",
"a",
"zigzag",
"varint",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L527-L534 |
128,009 | apache/thrift | lib/go/thrift/compact_protocol.go | ReadI64 | func (p *TCompactProtocol) ReadI64() (value int64, err error) {
v, e := p.readVarint64()
if e != nil {
return 0, NewTProtocolException(e)
}
value = p.zigzagToInt64(v)
return value, nil
} | go | func (p *TCompactProtocol) ReadI64() (value int64, err error) {
v, e := p.readVarint64()
if e != nil {
return 0, NewTProtocolException(e)
}
value = p.zigzagToInt64(v)
return value, nil
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"ReadI64",
"(",
")",
"(",
"value",
"int64",
",",
"err",
"error",
")",
"{",
"v",
",",
"e",
":=",
"p",
".",
"readVarint64",
"(",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"return",
"0",
",",
"NewTProtoc... | // Read an i64 from the wire as a zigzag varint. | [
"Read",
"an",
"i64",
"from",
"the",
"wire",
"as",
"a",
"zigzag",
"varint",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L537-L544 |
128,010 | apache/thrift | lib/go/thrift/compact_protocol.go | writeByteDirect | func (p *TCompactProtocol) writeByteDirect(b byte) error {
return p.trans.WriteByte(b)
} | go | func (p *TCompactProtocol) writeByteDirect(b byte) error {
return p.trans.WriteByte(b)
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"writeByteDirect",
"(",
"b",
"byte",
")",
"error",
"{",
"return",
"p",
".",
"trans",
".",
"WriteByte",
"(",
"b",
")",
"\n",
"}"
] | // Writes a byte without any possibility of all that field header nonsense.
// Used internally by other writing methods that know they need to write a byte. | [
"Writes",
"a",
"byte",
"without",
"any",
"possibility",
"of",
"all",
"that",
"field",
"header",
"nonsense",
".",
"Used",
"internally",
"by",
"other",
"writing",
"methods",
"that",
"know",
"they",
"need",
"to",
"write",
"a",
"byte",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L691-L693 |
128,011 | apache/thrift | lib/go/thrift/compact_protocol.go | writeIntAsByteDirect | func (p *TCompactProtocol) writeIntAsByteDirect(n int) (int, error) {
return 1, p.writeByteDirect(byte(n))
} | go | func (p *TCompactProtocol) writeIntAsByteDirect(n int) (int, error) {
return 1, p.writeByteDirect(byte(n))
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"writeIntAsByteDirect",
"(",
"n",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"1",
",",
"p",
".",
"writeByteDirect",
"(",
"byte",
"(",
"n",
")",
")",
"\n",
"}"
] | // Writes a byte without any possibility of all that field header nonsense. | [
"Writes",
"a",
"byte",
"without",
"any",
"possibility",
"of",
"all",
"that",
"field",
"header",
"nonsense",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L696-L698 |
128,012 | apache/thrift | lib/go/thrift/compact_protocol.go | readVarint32 | func (p *TCompactProtocol) readVarint32() (int32, error) {
// if the wire contains the right stuff, this will just truncate the i64 we
// read and get us the right sign.
v, err := p.readVarint64()
return int32(v), err
} | go | func (p *TCompactProtocol) readVarint32() (int32, error) {
// if the wire contains the right stuff, this will just truncate the i64 we
// read and get us the right sign.
v, err := p.readVarint64()
return int32(v), err
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"readVarint32",
"(",
")",
"(",
"int32",
",",
"error",
")",
"{",
"// if the wire contains the right stuff, this will just truncate the i64 we",
"// read and get us the right sign.",
"v",
",",
"err",
":=",
"p",
".",
"readVar... | //
// Internal reading methods
//
// Read an i32 from the wire as a varint. The MSB of each byte is set
// if there is another byte to follow. This can read up to 5 bytes. | [
"Internal",
"reading",
"methods",
"Read",
"an",
"i32",
"from",
"the",
"wire",
"as",
"a",
"varint",
".",
"The",
"MSB",
"of",
"each",
"byte",
"is",
"set",
"if",
"there",
"is",
"another",
"byte",
"to",
"follow",
".",
"This",
"can",
"read",
"up",
"to",
"... | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L706-L711 |
128,013 | apache/thrift | lib/go/thrift/compact_protocol.go | zigzagToInt32 | func (p *TCompactProtocol) zigzagToInt32(n int32) int32 {
u := uint32(n)
return int32(u>>1) ^ -(n & 1)
} | go | func (p *TCompactProtocol) zigzagToInt32(n int32) int32 {
u := uint32(n)
return int32(u>>1) ^ -(n & 1)
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"zigzagToInt32",
"(",
"n",
"int32",
")",
"int32",
"{",
"u",
":=",
"uint32",
"(",
"n",
")",
"\n",
"return",
"int32",
"(",
"u",
">>",
"1",
")",
"^",
"-",
"(",
"n",
"&",
"1",
")",
"\n",
"}"
] | //
// encoding helpers
//
// Convert from zigzag int to int. | [
"encoding",
"helpers",
"Convert",
"from",
"zigzag",
"int",
"to",
"int",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L742-L745 |
128,014 | apache/thrift | lib/go/thrift/compact_protocol.go | zigzagToInt64 | func (p *TCompactProtocol) zigzagToInt64(n int64) int64 {
u := uint64(n)
return int64(u>>1) ^ -(n & 1)
} | go | func (p *TCompactProtocol) zigzagToInt64(n int64) int64 {
u := uint64(n)
return int64(u>>1) ^ -(n & 1)
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"zigzagToInt64",
"(",
"n",
"int64",
")",
"int64",
"{",
"u",
":=",
"uint64",
"(",
"n",
")",
"\n",
"return",
"int64",
"(",
"u",
">>",
"1",
")",
"^",
"-",
"(",
"n",
"&",
"1",
")",
"\n",
"}"
] | // Convert from zigzag long to long. | [
"Convert",
"from",
"zigzag",
"long",
"to",
"long",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L748-L751 |
128,015 | apache/thrift | lib/go/thrift/compact_protocol.go | isBoolType | func (p *TCompactProtocol) isBoolType(b byte) bool {
return (b&0x0f) == COMPACT_BOOLEAN_TRUE || (b&0x0f) == COMPACT_BOOLEAN_FALSE
} | go | func (p *TCompactProtocol) isBoolType(b byte) bool {
return (b&0x0f) == COMPACT_BOOLEAN_TRUE || (b&0x0f) == COMPACT_BOOLEAN_FALSE
} | [
"func",
"(",
"p",
"*",
"TCompactProtocol",
")",
"isBoolType",
"(",
"b",
"byte",
")",
"bool",
"{",
"return",
"(",
"b",
"&",
"0x0f",
")",
"==",
"COMPACT_BOOLEAN_TRUE",
"||",
"(",
"b",
"&",
"0x0f",
")",
"==",
"COMPACT_BOOLEAN_FALSE",
"\n",
"}"
] | //
// type testing and converting
// | [
"type",
"testing",
"and",
"converting"
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/compact_protocol.go#L771-L773 |
128,016 | apache/thrift | lib/go/thrift/zlib_transport.go | GetTransport | func (p *TZlibTransportFactory) GetTransport(trans TTransport) (TTransport, error) {
if p.factory != nil {
// wrap other factory
var err error
trans, err = p.factory.GetTransport(trans)
if err != nil {
return nil, err
}
}
return NewTZlibTransport(trans, p.level)
} | go | func (p *TZlibTransportFactory) GetTransport(trans TTransport) (TTransport, error) {
if p.factory != nil {
// wrap other factory
var err error
trans, err = p.factory.GetTransport(trans)
if err != nil {
return nil, err
}
}
return NewTZlibTransport(trans, p.level)
} | [
"func",
"(",
"p",
"*",
"TZlibTransportFactory",
")",
"GetTransport",
"(",
"trans",
"TTransport",
")",
"(",
"TTransport",
",",
"error",
")",
"{",
"if",
"p",
".",
"factory",
"!=",
"nil",
"{",
"// wrap other factory",
"var",
"err",
"error",
"\n",
"trans",
","... | // GetTransport constructs a new instance of NewTZlibTransport | [
"GetTransport",
"constructs",
"a",
"new",
"instance",
"of",
"NewTZlibTransport"
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/zlib_transport.go#L43-L53 |
128,017 | apache/thrift | lib/go/thrift/zlib_transport.go | NewTZlibTransportFactoryWithFactory | func NewTZlibTransportFactoryWithFactory(level int, factory TTransportFactory) *TZlibTransportFactory {
return &TZlibTransportFactory{level: level, factory: factory}
} | go | func NewTZlibTransportFactoryWithFactory(level int, factory TTransportFactory) *TZlibTransportFactory {
return &TZlibTransportFactory{level: level, factory: factory}
} | [
"func",
"NewTZlibTransportFactoryWithFactory",
"(",
"level",
"int",
",",
"factory",
"TTransportFactory",
")",
"*",
"TZlibTransportFactory",
"{",
"return",
"&",
"TZlibTransportFactory",
"{",
"level",
":",
"level",
",",
"factory",
":",
"factory",
"}",
"\n",
"}"
] | // NewTZlibTransportFactory constructs a new instance of TZlibTransportFactory
// as a wrapper over existing transport factory | [
"NewTZlibTransportFactory",
"constructs",
"a",
"new",
"instance",
"of",
"TZlibTransportFactory",
"as",
"a",
"wrapper",
"over",
"existing",
"transport",
"factory"
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/zlib_transport.go#L62-L64 |
128,018 | apache/thrift | lib/go/thrift/zlib_transport.go | NewTZlibTransport | func NewTZlibTransport(trans TTransport, level int) (*TZlibTransport, error) {
w, err := zlib.NewWriterLevel(trans, level)
if err != nil {
log.Println(err)
return nil, err
}
return &TZlibTransport{
writer: w,
transport: trans,
}, nil
} | go | func NewTZlibTransport(trans TTransport, level int) (*TZlibTransport, error) {
w, err := zlib.NewWriterLevel(trans, level)
if err != nil {
log.Println(err)
return nil, err
}
return &TZlibTransport{
writer: w,
transport: trans,
}, nil
} | [
"func",
"NewTZlibTransport",
"(",
"trans",
"TTransport",
",",
"level",
"int",
")",
"(",
"*",
"TZlibTransport",
",",
"error",
")",
"{",
"w",
",",
"err",
":=",
"zlib",
".",
"NewWriterLevel",
"(",
"trans",
",",
"level",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // NewTZlibTransport constructs a new instance of TZlibTransport | [
"NewTZlibTransport",
"constructs",
"a",
"new",
"instance",
"of",
"TZlibTransport"
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/zlib_transport.go#L67-L78 |
128,019 | apache/thrift | lib/go/thrift/zlib_transport.go | Flush | func (z *TZlibTransport) Flush(ctx context.Context) error {
if err := z.writer.Flush(); err != nil {
return err
}
return z.transport.Flush(ctx)
} | go | func (z *TZlibTransport) Flush(ctx context.Context) error {
if err := z.writer.Flush(); err != nil {
return err
}
return z.transport.Flush(ctx)
} | [
"func",
"(",
"z",
"*",
"TZlibTransport",
")",
"Flush",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"z",
".",
"writer",
".",
"Flush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"retur... | // Flush flushes the writer and its underlying transport. | [
"Flush",
"flushes",
"the",
"writer",
"and",
"its",
"underlying",
"transport",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/zlib_transport.go#L95-L100 |
128,020 | apache/thrift | lib/go/thrift/client.go | NewTStandardClient | func NewTStandardClient(inputProtocol, outputProtocol TProtocol) *TStandardClient {
return &TStandardClient{
iprot: inputProtocol,
oprot: outputProtocol,
}
} | go | func NewTStandardClient(inputProtocol, outputProtocol TProtocol) *TStandardClient {
return &TStandardClient{
iprot: inputProtocol,
oprot: outputProtocol,
}
} | [
"func",
"NewTStandardClient",
"(",
"inputProtocol",
",",
"outputProtocol",
"TProtocol",
")",
"*",
"TStandardClient",
"{",
"return",
"&",
"TStandardClient",
"{",
"iprot",
":",
"inputProtocol",
",",
"oprot",
":",
"outputProtocol",
",",
"}",
"\n",
"}"
] | // TStandardClient implements TClient, and uses the standard message format for Thrift.
// It is not safe for concurrent use. | [
"TStandardClient",
"implements",
"TClient",
"and",
"uses",
"the",
"standard",
"message",
"format",
"for",
"Thrift",
".",
"It",
"is",
"not",
"safe",
"for",
"concurrent",
"use",
"."
] | 366cc3dee0f279b652644ae96b05fabd6fae2e06 | https://github.com/apache/thrift/blob/366cc3dee0f279b652644ae96b05fabd6fae2e06/lib/go/thrift/client.go#L19-L24 |
128,021 | gorilla/websocket | client.go | Dial | func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
return d.DialContext(context.Background(), urlStr, requestHeader)
} | go | func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
return d.DialContext(context.Background(), urlStr, requestHeader)
} | [
"func",
"(",
"d",
"*",
"Dialer",
")",
"Dial",
"(",
"urlStr",
"string",
",",
"requestHeader",
"http",
".",
"Header",
")",
"(",
"*",
"Conn",
",",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"d",
".",
"DialContext",
"(",
"context",
... | // Dial creates a new client connection by calling DialContext with a background context. | [
"Dial",
"creates",
"a",
"new",
"client",
"connection",
"by",
"calling",
"DialContext",
"with",
"a",
"background",
"context",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/client.go#L105-L107 |
128,022 | gorilla/websocket | join.go | JoinMessages | func JoinMessages(c *Conn, term string) io.Reader {
return &joinReader{c: c, term: term}
} | go | func JoinMessages(c *Conn, term string) io.Reader {
return &joinReader{c: c, term: term}
} | [
"func",
"JoinMessages",
"(",
"c",
"*",
"Conn",
",",
"term",
"string",
")",
"io",
".",
"Reader",
"{",
"return",
"&",
"joinReader",
"{",
"c",
":",
"c",
",",
"term",
":",
"term",
"}",
"\n",
"}"
] | // JoinMessages concatenates received messages to create a single io.Reader.
// The string term is appended to each message. The returned reader does not
// support concurrent calls to the Read method. | [
"JoinMessages",
"concatenates",
"received",
"messages",
"to",
"create",
"a",
"single",
"io",
".",
"Reader",
".",
"The",
"string",
"term",
"is",
"appended",
"to",
"each",
"message",
".",
"The",
"returned",
"reader",
"does",
"not",
"support",
"concurrent",
"call... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/join.go#L15-L17 |
128,023 | gorilla/websocket | prepared.go | NewPreparedMessage | func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
pm := &PreparedMessage{
messageType: messageType,
frames: make(map[prepareKey]*preparedFrame),
data: data,
}
// Prepare a plain server frame.
_, frameData, err := pm.frame(prepareKey{isServer: true, compress: false}... | go | func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
pm := &PreparedMessage{
messageType: messageType,
frames: make(map[prepareKey]*preparedFrame),
data: data,
}
// Prepare a plain server frame.
_, frameData, err := pm.frame(prepareKey{isServer: true, compress: false}... | [
"func",
"NewPreparedMessage",
"(",
"messageType",
"int",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"PreparedMessage",
",",
"error",
")",
"{",
"pm",
":=",
"&",
"PreparedMessage",
"{",
"messageType",
":",
"messageType",
",",
"frames",
":",
"make",
"(",
... | // NewPreparedMessage returns an initialized PreparedMessage. You can then send
// it to connection using WritePreparedMessage method. Valid wire
// representation will be calculated lazily only once for a set of current
// connection options. | [
"NewPreparedMessage",
"returns",
"an",
"initialized",
"PreparedMessage",
".",
"You",
"can",
"then",
"send",
"it",
"to",
"connection",
"using",
"WritePreparedMessage",
"method",
".",
"Valid",
"wire",
"representation",
"will",
"be",
"calculated",
"lazily",
"only",
"on... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/prepared.go#L43-L60 |
128,024 | gorilla/websocket | examples/chat/client.go | readPump | func (c *Client) readPump() {
defer func() {
c.hub.unregister <- c
c.conn.Close()
}()
c.conn.SetReadLimit(maxMessageSize)
c.conn.SetReadDeadline(time.Now().Add(pongWait))
c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
for {
_, message, err := c.con... | go | func (c *Client) readPump() {
defer func() {
c.hub.unregister <- c
c.conn.Close()
}()
c.conn.SetReadLimit(maxMessageSize)
c.conn.SetReadDeadline(time.Now().Add(pongWait))
c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
for {
_, message, err := c.con... | [
"func",
"(",
"c",
"*",
"Client",
")",
"readPump",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"c",
".",
"hub",
".",
"unregister",
"<-",
"c",
"\n",
"c",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"c",
".",
"conn",
"."... | // readPump pumps messages from the websocket connection to the hub.
//
// The application runs readPump in a per-connection goroutine. The application
// ensures that there is at most one reader on a connection by executing all
// reads from this goroutine. | [
"readPump",
"pumps",
"messages",
"from",
"the",
"websocket",
"connection",
"to",
"the",
"hub",
".",
"The",
"application",
"runs",
"readPump",
"in",
"a",
"per",
"-",
"connection",
"goroutine",
".",
"The",
"application",
"ensures",
"that",
"there",
"is",
"at",
... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/examples/chat/client.go#L56-L75 |
128,025 | gorilla/websocket | examples/chat/client.go | writePump | func (c *Client) writePump() {
ticker := time.NewTicker(pingPeriod)
defer func() {
ticker.Stop()
c.conn.Close()
}()
for {
select {
case message, ok := <-c.send:
c.conn.SetWriteDeadline(time.Now().Add(writeWait))
if !ok {
// The hub closed the channel.
c.conn.WriteMessage(websocket.CloseMessage... | go | func (c *Client) writePump() {
ticker := time.NewTicker(pingPeriod)
defer func() {
ticker.Stop()
c.conn.Close()
}()
for {
select {
case message, ok := <-c.send:
c.conn.SetWriteDeadline(time.Now().Add(writeWait))
if !ok {
// The hub closed the channel.
c.conn.WriteMessage(websocket.CloseMessage... | [
"func",
"(",
"c",
"*",
"Client",
")",
"writePump",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"pingPeriod",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"ticker",
".",
"Stop",
"(",
")",
"\n",
"c",
".",
"conn",
".",
"Close",
"(",
... | // writePump pumps messages from the hub to the websocket connection.
//
// A goroutine running writePump is started for each connection. The
// application ensures that there is at most one writer to a connection by
// executing all writes from this goroutine. | [
"writePump",
"pumps",
"messages",
"from",
"the",
"hub",
"to",
"the",
"websocket",
"connection",
".",
"A",
"goroutine",
"running",
"writePump",
"is",
"started",
"for",
"each",
"connection",
".",
"The",
"application",
"ensures",
"that",
"there",
"is",
"at",
"mos... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/examples/chat/client.go#L82-L121 |
128,026 | gorilla/websocket | examples/chat/client.go | serveWs | func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println(err)
return
}
client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)}
client.hub.register <- client
// Allow collection of memory referenced by the caller by doi... | go | func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println(err)
return
}
client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)}
client.hub.register <- client
// Allow collection of memory referenced by the caller by doi... | [
"func",
"serveWs",
"(",
"hub",
"*",
"Hub",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"conn",
",",
"err",
":=",
"upgrader",
".",
"Upgrade",
"(",
"w",
",",
"r",
",",
"nil",
")",
"\n",
"if",
"err",
"... | // serveWs handles websocket requests from the peer. | [
"serveWs",
"handles",
"websocket",
"requests",
"from",
"the",
"peer",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/examples/chat/client.go#L124-L137 |
128,027 | gorilla/websocket | examples/autobahn/server.go | echoCopy | func echoCopy(w http.ResponseWriter, r *http.Request, writerOnly bool) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println("Upgrade:", err)
return
}
defer conn.Close()
for {
mt, r, err := conn.NextReader()
if err != nil {
if err != io.EOF {
log.Println("NextReader:", err)
}
... | go | func echoCopy(w http.ResponseWriter, r *http.Request, writerOnly bool) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println("Upgrade:", err)
return
}
defer conn.Close()
for {
mt, r, err := conn.NextReader()
if err != nil {
if err != io.EOF {
log.Println("NextReader:", err)
}
... | [
"func",
"echoCopy",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"writerOnly",
"bool",
")",
"{",
"conn",
",",
"err",
":=",
"upgrader",
".",
"Upgrade",
"(",
"w",
",",
"r",
",",
"nil",
")",
"\n",
"if",
"err",
... | // echoCopy echoes messages from the client using io.Copy. | [
"echoCopy",
"echoes",
"messages",
"from",
"the",
"client",
"using",
"io",
".",
"Copy",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/examples/autobahn/server.go#L30-L76 |
128,028 | gorilla/websocket | examples/autobahn/server.go | echoReadAll | func echoReadAll(w http.ResponseWriter, r *http.Request, writeMessage, writePrepared bool) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println("Upgrade:", err)
return
}
defer conn.Close()
for {
mt, b, err := conn.ReadMessage()
if err != nil {
if err != io.EOF {
log.Println("NextRe... | go | func echoReadAll(w http.ResponseWriter, r *http.Request, writeMessage, writePrepared bool) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println("Upgrade:", err)
return
}
defer conn.Close()
for {
mt, b, err := conn.ReadMessage()
if err != nil {
if err != io.EOF {
log.Println("NextRe... | [
"func",
"echoReadAll",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"writeMessage",
",",
"writePrepared",
"bool",
")",
"{",
"conn",
",",
"err",
":=",
"upgrader",
".",
"Upgrade",
"(",
"w",
",",
"r",
",",
"nil",
... | // echoReadAll echoes messages from the client by reading the entire message
// with ioutil.ReadAll. | [
"echoReadAll",
"echoes",
"messages",
"from",
"the",
"client",
"by",
"reading",
"the",
"entire",
"message",
"with",
"ioutil",
".",
"ReadAll",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/examples/autobahn/server.go#L88-L144 |
128,029 | gorilla/websocket | x_net_proxy.go | proxy_SOCKS5 | func proxy_SOCKS5(network, addr string, auth *proxy_Auth, forward proxy_Dialer) (proxy_Dialer, error) {
s := &proxy_socks5{
network: network,
addr: addr,
forward: forward,
}
if auth != nil {
s.user = auth.User
s.password = auth.Password
}
return s, nil
} | go | func proxy_SOCKS5(network, addr string, auth *proxy_Auth, forward proxy_Dialer) (proxy_Dialer, error) {
s := &proxy_socks5{
network: network,
addr: addr,
forward: forward,
}
if auth != nil {
s.user = auth.User
s.password = auth.Password
}
return s, nil
} | [
"func",
"proxy_SOCKS5",
"(",
"network",
",",
"addr",
"string",
",",
"auth",
"*",
"proxy_Auth",
",",
"forward",
"proxy_Dialer",
")",
"(",
"proxy_Dialer",
",",
"error",
")",
"{",
"s",
":=",
"&",
"proxy_socks5",
"{",
"network",
":",
"network",
",",
"addr",
... | // SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address
// with an optional username and password. See RFC 1928 and RFC 1929. | [
"SOCKS5",
"returns",
"a",
"Dialer",
"that",
"makes",
"SOCKSv5",
"connections",
"to",
"the",
"given",
"address",
"with",
"an",
"optional",
"username",
"and",
"password",
".",
"See",
"RFC",
"1928",
"and",
"RFC",
"1929",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/x_net_proxy.go#L275-L287 |
128,030 | gorilla/websocket | x_net_proxy.go | Dial | func (s *proxy_socks5) Dial(network, addr string) (net.Conn, error) {
switch network {
case "tcp", "tcp6", "tcp4":
default:
return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network)
}
conn, err := s.forward.Dial(s.network, s.addr)
if err != nil {
return nil, err
}
if err :... | go | func (s *proxy_socks5) Dial(network, addr string) (net.Conn, error) {
switch network {
case "tcp", "tcp6", "tcp4":
default:
return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network)
}
conn, err := s.forward.Dial(s.network, s.addr)
if err != nil {
return nil, err
}
if err :... | [
"func",
"(",
"s",
"*",
"proxy_socks5",
")",
"Dial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"switch",
"network",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"default",
":",
... | // Dial connects to the address addr on the given network via the SOCKS5 proxy. | [
"Dial",
"connects",
"to",
"the",
"address",
"addr",
"on",
"the",
"given",
"network",
"via",
"the",
"SOCKS5",
"proxy",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/x_net_proxy.go#L323-L339 |
128,031 | gorilla/websocket | util.go | skipSpace | func skipSpace(s string) (rest string) {
i := 0
for ; i < len(s); i++ {
if b := s[i]; b != ' ' && b != '\t' {
break
}
}
return s[i:]
} | go | func skipSpace(s string) (rest string) {
i := 0
for ; i < len(s); i++ {
if b := s[i]; b != ' ' && b != '\t' {
break
}
}
return s[i:]
} | [
"func",
"skipSpace",
"(",
"s",
"string",
")",
"(",
"rest",
"string",
")",
"{",
"i",
":=",
"0",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"++",
"{",
"if",
"b",
":=",
"s",
"[",
"i",
"]",
";",
"b",
"!=",
"' '",
"&&",
"b",
... | // skipSpace returns a slice of the string s with all leading RFC 2616 linear
// whitespace removed. | [
"skipSpace",
"returns",
"a",
"slice",
"of",
"the",
"string",
"s",
"with",
"all",
"leading",
"RFC",
"2616",
"linear",
"whitespace",
"removed",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/util.go#L117-L125 |
128,032 | gorilla/websocket | util.go | nextToken | func nextToken(s string) (token, rest string) {
i := 0
for ; i < len(s); i++ {
if !isTokenOctet[s[i]] {
break
}
}
return s[:i], s[i:]
} | go | func nextToken(s string) (token, rest string) {
i := 0
for ; i < len(s); i++ {
if !isTokenOctet[s[i]] {
break
}
}
return s[:i], s[i:]
} | [
"func",
"nextToken",
"(",
"s",
"string",
")",
"(",
"token",
",",
"rest",
"string",
")",
"{",
"i",
":=",
"0",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"++",
"{",
"if",
"!",
"isTokenOctet",
"[",
"s",
"[",
"i",
"]",
"]",
"{"... | // nextToken returns the leading RFC 2616 token of s and the string following
// the token. | [
"nextToken",
"returns",
"the",
"leading",
"RFC",
"2616",
"token",
"of",
"s",
"and",
"the",
"string",
"following",
"the",
"token",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/util.go#L129-L137 |
128,033 | gorilla/websocket | util.go | equalASCIIFold | func equalASCIIFold(s, t string) bool {
for s != "" && t != "" {
sr, size := utf8.DecodeRuneInString(s)
s = s[size:]
tr, size := utf8.DecodeRuneInString(t)
t = t[size:]
if sr == tr {
continue
}
if 'A' <= sr && sr <= 'Z' {
sr = sr + 'a' - 'A'
}
if 'A' <= tr && tr <= 'Z' {
tr = tr + 'a' - 'A'
... | go | func equalASCIIFold(s, t string) bool {
for s != "" && t != "" {
sr, size := utf8.DecodeRuneInString(s)
s = s[size:]
tr, size := utf8.DecodeRuneInString(t)
t = t[size:]
if sr == tr {
continue
}
if 'A' <= sr && sr <= 'Z' {
sr = sr + 'a' - 'A'
}
if 'A' <= tr && tr <= 'Z' {
tr = tr + 'a' - 'A'
... | [
"func",
"equalASCIIFold",
"(",
"s",
",",
"t",
"string",
")",
"bool",
"{",
"for",
"s",
"!=",
"\"",
"\"",
"&&",
"t",
"!=",
"\"",
"\"",
"{",
"sr",
",",
"size",
":=",
"utf8",
".",
"DecodeRuneInString",
"(",
"s",
")",
"\n",
"s",
"=",
"s",
"[",
"size... | // equalASCIIFold returns true if s is equal to t with ASCII case folding as
// defined in RFC 4790. | [
"equalASCIIFold",
"returns",
"true",
"if",
"s",
"is",
"equal",
"to",
"t",
"with",
"ASCII",
"case",
"folding",
"as",
"defined",
"in",
"RFC",
"4790",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/util.go#L178-L198 |
128,034 | gorilla/websocket | util.go | parseExtensions | func parseExtensions(header http.Header) []map[string]string {
// From RFC 6455:
//
// Sec-WebSocket-Extensions = extension-list
// extension-list = 1#extension
// extension = extension-token *( ";" extension-param )
// extension-token = registered-token
// registered-token = token
// extension-param = to... | go | func parseExtensions(header http.Header) []map[string]string {
// From RFC 6455:
//
// Sec-WebSocket-Extensions = extension-list
// extension-list = 1#extension
// extension = extension-token *( ";" extension-param )
// extension-token = registered-token
// registered-token = token
// extension-param = to... | [
"func",
"parseExtensions",
"(",
"header",
"http",
".",
"Header",
")",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
"{",
"// From RFC 6455:",
"//",
"// Sec-WebSocket-Extensions = extension-list",
"// extension-list = 1#extension",
"// extension = extension-token *( \";\" ... | // parseExtensions parses WebSocket extensions from a header. | [
"parseExtensions",
"parses",
"WebSocket",
"extensions",
"from",
"a",
"header",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/util.go#L228-L283 |
128,035 | gorilla/websocket | server.go | Subprotocols | func Subprotocols(r *http.Request) []string {
h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
if h == "" {
return nil
}
protocols := strings.Split(h, ",")
for i := range protocols {
protocols[i] = strings.TrimSpace(protocols[i])
}
return protocols
} | go | func Subprotocols(r *http.Request) []string {
h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
if h == "" {
return nil
}
protocols := strings.Split(h, ",")
for i := range protocols {
protocols[i] = strings.TrimSpace(protocols[i])
}
return protocols
} | [
"func",
"Subprotocols",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"[",
"]",
"string",
"{",
"h",
":=",
"strings",
".",
"TrimSpace",
"(",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"h",
"==",
"\"",
"\"",
"{",
"return... | // Subprotocols returns the subprotocols requested by the client in the
// Sec-Websocket-Protocol header. | [
"Subprotocols",
"returns",
"the",
"subprotocols",
"requested",
"by",
"the",
"client",
"in",
"the",
"Sec",
"-",
"Websocket",
"-",
"Protocol",
"header",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/server.go#L309-L319 |
128,036 | gorilla/websocket | server.go | IsWebSocketUpgrade | func IsWebSocketUpgrade(r *http.Request) bool {
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
tokenListContainsValue(r.Header, "Upgrade", "websocket")
} | go | func IsWebSocketUpgrade(r *http.Request) bool {
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
tokenListContainsValue(r.Header, "Upgrade", "websocket")
} | [
"func",
"IsWebSocketUpgrade",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"return",
"tokenListContainsValue",
"(",
"r",
".",
"Header",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"&&",
"tokenListContainsValue",
"(",
"r",
".",
"Header",
",",
"\"",... | // IsWebSocketUpgrade returns true if the client requested upgrade to the
// WebSocket protocol. | [
"IsWebSocketUpgrade",
"returns",
"true",
"if",
"the",
"client",
"requested",
"upgrade",
"to",
"the",
"WebSocket",
"protocol",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/server.go#L323-L326 |
128,037 | gorilla/websocket | server.go | bufioReaderSize | func bufioReaderSize(originalReader io.Reader, br *bufio.Reader) int {
// This code assumes that peek on a reset reader returns
// bufio.Reader.buf[:0].
// TODO: Use bufio.Reader.Size() after Go 1.10
br.Reset(originalReader)
if p, err := br.Peek(0); err == nil {
return cap(p)
}
return 0
} | go | func bufioReaderSize(originalReader io.Reader, br *bufio.Reader) int {
// This code assumes that peek on a reset reader returns
// bufio.Reader.buf[:0].
// TODO: Use bufio.Reader.Size() after Go 1.10
br.Reset(originalReader)
if p, err := br.Peek(0); err == nil {
return cap(p)
}
return 0
} | [
"func",
"bufioReaderSize",
"(",
"originalReader",
"io",
".",
"Reader",
",",
"br",
"*",
"bufio",
".",
"Reader",
")",
"int",
"{",
"// This code assumes that peek on a reset reader returns",
"// bufio.Reader.buf[:0].",
"// TODO: Use bufio.Reader.Size() after Go 1.10",
"br",
".",... | // bufioReaderSize size returns the size of a bufio.Reader. | [
"bufioReaderSize",
"size",
"returns",
"the",
"size",
"of",
"a",
"bufio",
".",
"Reader",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/server.go#L329-L338 |
128,038 | gorilla/websocket | server.go | bufioWriterBuffer | func bufioWriterBuffer(originalWriter io.Writer, bw *bufio.Writer) []byte {
// This code assumes that bufio.Writer.buf[:1] is passed to the
// bufio.Writer's underlying writer.
var wh writeHook
bw.Reset(&wh)
bw.WriteByte(0)
bw.Flush()
bw.Reset(originalWriter)
return wh.p[:cap(wh.p)]
} | go | func bufioWriterBuffer(originalWriter io.Writer, bw *bufio.Writer) []byte {
// This code assumes that bufio.Writer.buf[:1] is passed to the
// bufio.Writer's underlying writer.
var wh writeHook
bw.Reset(&wh)
bw.WriteByte(0)
bw.Flush()
bw.Reset(originalWriter)
return wh.p[:cap(wh.p)]
} | [
"func",
"bufioWriterBuffer",
"(",
"originalWriter",
"io",
".",
"Writer",
",",
"bw",
"*",
"bufio",
".",
"Writer",
")",
"[",
"]",
"byte",
"{",
"// This code assumes that bufio.Writer.buf[:1] is passed to the",
"// bufio.Writer's underlying writer.",
"var",
"wh",
"writeHook"... | // bufioWriterBuffer grabs the buffer from a bufio.Writer. | [
"bufioWriterBuffer",
"grabs",
"the",
"buffer",
"from",
"a",
"bufio",
".",
"Writer",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/server.go#L352-L363 |
128,039 | gorilla/websocket | conn.go | WriteControl | func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error {
if !isControl(messageType) {
return errBadWriteOpCode
}
if len(data) > maxControlFramePayloadSize {
return errInvalidControlFrame
}
b0 := byte(messageType) | finalBit
b1 := byte(len(data))
if !c.isServer {
b1 |= maskBit
... | go | func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error {
if !isControl(messageType) {
return errBadWriteOpCode
}
if len(data) > maxControlFramePayloadSize {
return errInvalidControlFrame
}
b0 := byte(messageType) | finalBit
b1 := byte(len(data))
if !c.isServer {
b1 |= maskBit
... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WriteControl",
"(",
"messageType",
"int",
",",
"data",
"[",
"]",
"byte",
",",
"deadline",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"!",
"isControl",
"(",
"messageType",
")",
"{",
"return",
"errBadWriteOpCode",
... | // WriteControl writes a control message with the given deadline. The allowed
// message types are CloseMessage, PingMessage and PongMessage. | [
"WriteControl",
"writes",
"a",
"control",
"message",
"with",
"the",
"given",
"deadline",
".",
"The",
"allowed",
"message",
"types",
"are",
"CloseMessage",
"PingMessage",
"and",
"PongMessage",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L393-L452 |
128,040 | gorilla/websocket | conn.go | beginMessage | func (c *Conn) beginMessage(mw *messageWriter, messageType int) error {
// Close previous writer if not already closed by the application. It's
// probably better to return an error in this situation, but we cannot
// change this without breaking existing applications.
if c.writer != nil {
c.writer.Close()
c.wr... | go | func (c *Conn) beginMessage(mw *messageWriter, messageType int) error {
// Close previous writer if not already closed by the application. It's
// probably better to return an error in this situation, but we cannot
// change this without breaking existing applications.
if c.writer != nil {
c.writer.Close()
c.wr... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"beginMessage",
"(",
"mw",
"*",
"messageWriter",
",",
"messageType",
"int",
")",
"error",
"{",
"// Close previous writer if not already closed by the application. It's",
"// probably better to return an error in this situation, but we cannot",
... | // beginMessage prepares a connection and message writer for a new message. | [
"beginMessage",
"prepares",
"a",
"connection",
"and",
"message",
"writer",
"for",
"a",
"new",
"message",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L455-L488 |
128,041 | gorilla/websocket | conn.go | flushFrame | func (w *messageWriter) flushFrame(final bool, extra []byte) error {
c := w.c
length := w.pos - maxFrameHeaderSize + len(extra)
// Check for invalid control frames.
if isControl(w.frameType) &&
(!final || length > maxControlFramePayloadSize) {
return w.endMessage(errInvalidControlFrame)
}
b0 := byte(w.frame... | go | func (w *messageWriter) flushFrame(final bool, extra []byte) error {
c := w.c
length := w.pos - maxFrameHeaderSize + len(extra)
// Check for invalid control frames.
if isControl(w.frameType) &&
(!final || length > maxControlFramePayloadSize) {
return w.endMessage(errInvalidControlFrame)
}
b0 := byte(w.frame... | [
"func",
"(",
"w",
"*",
"messageWriter",
")",
"flushFrame",
"(",
"final",
"bool",
",",
"extra",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
":=",
"w",
".",
"c",
"\n",
"length",
":=",
"w",
".",
"pos",
"-",
"maxFrameHeaderSize",
"+",
"len",
"(",
"extra"... | // flushFrame writes buffered data and extra as a frame to the network. The
// final argument indicates that this is the last frame in the message. | [
"flushFrame",
"writes",
"buffered",
"data",
"and",
"extra",
"as",
"a",
"frame",
"to",
"the",
"network",
".",
"The",
"final",
"argument",
"indicates",
"that",
"this",
"is",
"the",
"last",
"frame",
"in",
"the",
"message",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L536-L621 |
128,042 | gorilla/websocket | conn.go | WritePreparedMessage | func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
frameType, frameData, err := pm.frame(prepareKey{
isServer: c.isServer,
compress: c.newCompressionWriter != nil && c.enableWriteCompression && isData(pm.messageType),
compressionLevel: c.compressionLevel,
})
if err != nil {
retu... | go | func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
frameType, frameData, err := pm.frame(prepareKey{
isServer: c.isServer,
compress: c.newCompressionWriter != nil && c.enableWriteCompression && isData(pm.messageType),
compressionLevel: c.compressionLevel,
})
if err != nil {
retu... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WritePreparedMessage",
"(",
"pm",
"*",
"PreparedMessage",
")",
"error",
"{",
"frameType",
",",
"frameData",
",",
"err",
":=",
"pm",
".",
"frame",
"(",
"prepareKey",
"{",
"isServer",
":",
"c",
".",
"isServer",
",",
"... | // WritePreparedMessage writes prepared message into connection. | [
"WritePreparedMessage",
"writes",
"prepared",
"message",
"into",
"connection",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L715-L734 |
128,043 | gorilla/websocket | conn.go | WriteMessage | func (c *Conn) WriteMessage(messageType int, data []byte) error {
if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
// Fast path with no allocations and single frame.
var mw messageWriter
if err := c.beginMessage(&mw, messageType); err != nil {
return err
}
n := copy(c.writ... | go | func (c *Conn) WriteMessage(messageType int, data []byte) error {
if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
// Fast path with no allocations and single frame.
var mw messageWriter
if err := c.beginMessage(&mw, messageType); err != nil {
return err
}
n := copy(c.writ... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WriteMessage",
"(",
"messageType",
"int",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"c",
".",
"isServer",
"&&",
"(",
"c",
".",
"newCompressionWriter",
"==",
"nil",
"||",
"!",
"c",
".",
"enableWriteCo... | // WriteMessage is a helper method for getting a writer using NextWriter,
// writing the message and closing the writer. | [
"WriteMessage",
"is",
"a",
"helper",
"method",
"for",
"getting",
"a",
"writer",
"using",
"NextWriter",
"writing",
"the",
"message",
"and",
"closing",
"the",
"writer",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L738-L761 |
128,044 | gorilla/websocket | conn.go | SetWriteDeadline | func (c *Conn) SetWriteDeadline(t time.Time) error {
c.writeDeadline = t
return nil
} | go | func (c *Conn) SetWriteDeadline(t time.Time) error {
c.writeDeadline = t
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetWriteDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"c",
".",
"writeDeadline",
"=",
"t",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetWriteDeadline sets the write deadline on the underlying network
// connection. After a write has timed out, the websocket state is corrupt and
// all future writes will return an error. A zero value for t means writes will
// not time out. | [
"SetWriteDeadline",
"sets",
"the",
"write",
"deadline",
"on",
"the",
"underlying",
"network",
"connection",
".",
"After",
"a",
"write",
"has",
"timed",
"out",
"the",
"websocket",
"state",
"is",
"corrupt",
"and",
"all",
"future",
"writes",
"will",
"return",
"an... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L767-L770 |
128,045 | gorilla/websocket | conn.go | NextReader | func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
// Close previous reader, only relevant for decompression.
if c.reader != nil {
c.reader.Close()
c.reader = nil
}
c.messageReader = nil
c.readLength = 0
for c.readErr == nil {
frameType, err := c.advanceFrame()
if err != nil {
c.... | go | func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
// Close previous reader, only relevant for decompression.
if c.reader != nil {
c.reader.Close()
c.reader = nil
}
c.messageReader = nil
c.readLength = 0
for c.readErr == nil {
frameType, err := c.advanceFrame()
if err != nil {
c.... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"NextReader",
"(",
")",
"(",
"messageType",
"int",
",",
"r",
"io",
".",
"Reader",
",",
"err",
"error",
")",
"{",
"// Close previous reader, only relevant for decompression.",
"if",
"c",
".",
"reader",
"!=",
"nil",
"{",
"... | // NextReader returns the next data message received from the peer. The
// returned messageType is either TextMessage or BinaryMessage.
//
// There can be at most one open reader on a connection. NextReader discards
// the previous message if the application has not already consumed it.
//
// Applications must break ou... | [
"NextReader",
"returns",
"the",
"next",
"data",
"message",
"received",
"from",
"the",
"peer",
".",
"The",
"returned",
"messageType",
"is",
"either",
"TextMessage",
"or",
"BinaryMessage",
".",
"There",
"can",
"be",
"at",
"most",
"one",
"open",
"reader",
"on",
... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L934-L969 |
128,046 | gorilla/websocket | conn.go | ReadMessage | func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
var r io.Reader
messageType, r, err = c.NextReader()
if err != nil {
return messageType, nil, err
}
p, err = ioutil.ReadAll(r)
return messageType, p, err
} | go | func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
var r io.Reader
messageType, r, err = c.NextReader()
if err != nil {
return messageType, nil, err
}
p, err = ioutil.ReadAll(r)
return messageType, p, err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ReadMessage",
"(",
")",
"(",
"messageType",
"int",
",",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"r",
"io",
".",
"Reader",
"\n",
"messageType",
",",
"r",
",",
"err",
"=",
"c",
".",
"NextR... | // ReadMessage is a helper method for getting a reader using NextReader and
// reading from that reader to a buffer. | [
"ReadMessage",
"is",
"a",
"helper",
"method",
"for",
"getting",
"a",
"reader",
"using",
"NextReader",
"and",
"reading",
"from",
"that",
"reader",
"to",
"a",
"buffer",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1024-L1032 |
128,047 | gorilla/websocket | conn.go | CloseHandler | func (c *Conn) CloseHandler() func(code int, text string) error {
return c.handleClose
} | go | func (c *Conn) CloseHandler() func(code int, text string) error {
return c.handleClose
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"CloseHandler",
"(",
")",
"func",
"(",
"code",
"int",
",",
"text",
"string",
")",
"error",
"{",
"return",
"c",
".",
"handleClose",
"\n",
"}"
] | // CloseHandler returns the current close handler | [
"CloseHandler",
"returns",
"the",
"current",
"close",
"handler"
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1050-L1052 |
128,048 | gorilla/websocket | conn.go | SetCloseHandler | func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
if h == nil {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
return nil
}
}
c.handleClose = h
} | go | func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
if h == nil {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
return nil
}
}
c.handleClose = h
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetCloseHandler",
"(",
"h",
"func",
"(",
"code",
"int",
",",
"text",
"string",
")",
"error",
")",
"{",
"if",
"h",
"==",
"nil",
"{",
"h",
"=",
"func",
"(",
"code",
"int",
",",
"text",
"string",
")",
"error",
... | // SetCloseHandler sets the handler for close messages received from the peer.
// The code argument to h is the received close code or CloseNoStatusReceived
// if the close message is empty. The default close handler sends a close
// message back to the peer.
//
// The handler function is called from the NextReader, Re... | [
"SetCloseHandler",
"sets",
"the",
"handler",
"for",
"close",
"messages",
"received",
"from",
"the",
"peer",
".",
"The",
"code",
"argument",
"to",
"h",
"is",
"the",
"received",
"close",
"code",
"or",
"CloseNoStatusReceived",
"if",
"the",
"close",
"message",
"is... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1068-L1077 |
128,049 | gorilla/websocket | conn.go | SetPingHandler | func (c *Conn) SetPingHandler(h func(appData string) error) {
if h == nil {
h = func(message string) error {
err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
if err == ErrCloseSent {
return nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
return nil
}
... | go | func (c *Conn) SetPingHandler(h func(appData string) error) {
if h == nil {
h = func(message string) error {
err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
if err == ErrCloseSent {
return nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
return nil
}
... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetPingHandler",
"(",
"h",
"func",
"(",
"appData",
"string",
")",
"error",
")",
"{",
"if",
"h",
"==",
"nil",
"{",
"h",
"=",
"func",
"(",
"message",
"string",
")",
"error",
"{",
"err",
":=",
"c",
".",
"WriteCon... | // SetPingHandler sets the handler for ping messages received from the peer.
// The appData argument to h is the PING message application data. The default
// ping handler sends a pong to the peer.
//
// The handler function is called from the NextReader, ReadMessage and message
// reader Read methods. The application ... | [
"SetPingHandler",
"sets",
"the",
"handler",
"for",
"ping",
"messages",
"received",
"from",
"the",
"peer",
".",
"The",
"appData",
"argument",
"to",
"h",
"is",
"the",
"PING",
"message",
"application",
"data",
".",
"The",
"default",
"ping",
"handler",
"sends",
... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1091-L1104 |
128,050 | gorilla/websocket | conn.go | SetPongHandler | func (c *Conn) SetPongHandler(h func(appData string) error) {
if h == nil {
h = func(string) error { return nil }
}
c.handlePong = h
} | go | func (c *Conn) SetPongHandler(h func(appData string) error) {
if h == nil {
h = func(string) error { return nil }
}
c.handlePong = h
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetPongHandler",
"(",
"h",
"func",
"(",
"appData",
"string",
")",
"error",
")",
"{",
"if",
"h",
"==",
"nil",
"{",
"h",
"=",
"func",
"(",
"string",
")",
"error",
"{",
"return",
"nil",
"}",
"\n",
"}",
"\n",
"c... | // SetPongHandler sets the handler for pong messages received from the peer.
// The appData argument to h is the PONG message application data. The default
// pong handler does nothing.
//
// The handler function is called from the NextReader, ReadMessage and message
// reader Read methods. The application must read th... | [
"SetPongHandler",
"sets",
"the",
"handler",
"for",
"pong",
"messages",
"received",
"from",
"the",
"peer",
".",
"The",
"appData",
"argument",
"to",
"h",
"is",
"the",
"PONG",
"message",
"application",
"data",
".",
"The",
"default",
"pong",
"handler",
"does",
"... | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1118-L1123 |
128,051 | gorilla/websocket | conn.go | FormatCloseMessage | func FormatCloseMessage(closeCode int, text string) []byte {
if closeCode == CloseNoStatusReceived {
// Return empty message because it's illegal to send
// CloseNoStatusReceived. Return non-nil value in case application
// checks for nil.
return []byte{}
}
buf := make([]byte, 2+len(text))
binary.BigEndian.... | go | func FormatCloseMessage(closeCode int, text string) []byte {
if closeCode == CloseNoStatusReceived {
// Return empty message because it's illegal to send
// CloseNoStatusReceived. Return non-nil value in case application
// checks for nil.
return []byte{}
}
buf := make([]byte, 2+len(text))
binary.BigEndian.... | [
"func",
"FormatCloseMessage",
"(",
"closeCode",
"int",
",",
"text",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"closeCode",
"==",
"CloseNoStatusReceived",
"{",
"// Return empty message because it's illegal to send",
"// CloseNoStatusReceived. Return non-nil value in case appli... | // FormatCloseMessage formats closeCode and text as a WebSocket close message.
// An empty message is returned for code CloseNoStatusReceived. | [
"FormatCloseMessage",
"formats",
"closeCode",
"and",
"text",
"as",
"a",
"WebSocket",
"close",
"message",
".",
"An",
"empty",
"message",
"is",
"returned",
"for",
"code",
"CloseNoStatusReceived",
"."
] | 80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6 | https://github.com/gorilla/websocket/blob/80c2d40e9b91f2ef7a9c1a403aeec64d1b89a9a6/conn.go#L1152-L1163 |
128,052 | influxdata/telegraf | plugins/inputs/tcp_listener/tcp_listener.go | Start | func (t *TcpListener) Start(acc telegraf.Accumulator) error {
t.Lock()
defer t.Unlock()
log.Println("W! DEPRECATED: the TCP listener plugin has been deprecated " +
"in favor of the socket_listener plugin " +
"(https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener)")
tags := map[str... | go | func (t *TcpListener) Start(acc telegraf.Accumulator) error {
t.Lock()
defer t.Unlock()
log.Println("W! DEPRECATED: the TCP listener plugin has been deprecated " +
"in favor of the socket_listener plugin " +
"(https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener)")
tags := map[str... | [
"func",
"(",
"t",
"*",
"TcpListener",
")",
"Start",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"Unlock",
"(",
")",
"\n\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
"+",
"\"",... | // Start starts the tcp listener service. | [
"Start",
"starts",
"the",
"tcp",
"listener",
"service",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/tcp_listener/tcp_listener.go#L85-L128 |
128,053 | influxdata/telegraf | plugins/inputs/tcp_listener/tcp_listener.go | tcpListen | func (t *TcpListener) tcpListen() error {
defer t.wg.Done()
for {
select {
case <-t.done:
return nil
default:
// Accept connection:
conn, err := t.listener.AcceptTCP()
if err != nil {
return err
}
select {
case <-t.accept:
// not over connection limit, handle the connection proper... | go | func (t *TcpListener) tcpListen() error {
defer t.wg.Done()
for {
select {
case <-t.done:
return nil
default:
// Accept connection:
conn, err := t.listener.AcceptTCP()
if err != nil {
return err
}
select {
case <-t.accept:
// not over connection limit, handle the connection proper... | [
"func",
"(",
"t",
"*",
"TcpListener",
")",
"tcpListen",
"(",
")",
"error",
"{",
"defer",
"t",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"t",
".",
"done",
":",
"return",
"nil",
"\n",
"default",
":",
"// Acc... | // tcpListen listens for incoming TCP connections. | [
"tcpListen",
"listens",
"for",
"incoming",
"TCP",
"connections",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/tcp_listener/tcp_listener.go#L157-L185 |
128,054 | influxdata/telegraf | plugins/inputs/tcp_listener/tcp_listener.go | tcpParser | func (t *TcpListener) tcpParser() error {
defer t.wg.Done()
var packet []byte
var metrics []telegraf.Metric
var err error
for {
select {
case <-t.done:
// drain input packets before finishing:
if len(t.in) == 0 {
return nil
}
case packet = <-t.in:
if len(packet) == 0 {
continue
}
m... | go | func (t *TcpListener) tcpParser() error {
defer t.wg.Done()
var packet []byte
var metrics []telegraf.Metric
var err error
for {
select {
case <-t.done:
// drain input packets before finishing:
if len(t.in) == 0 {
return nil
}
case packet = <-t.in:
if len(packet) == 0 {
continue
}
m... | [
"func",
"(",
"t",
"*",
"TcpListener",
")",
"tcpParser",
"(",
")",
"error",
"{",
"defer",
"t",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"var",
"packet",
"[",
"]",
"byte",
"\n",
"var",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
"\n",
"var",
"... | // tcpParser parses the incoming tcp byte packets | [
"tcpParser",
"parses",
"the",
"incoming",
"tcp",
"byte",
"packets"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/tcp_listener/tcp_listener.go#L246-L276 |
128,055 | influxdata/telegraf | internal/limiter/limiter.go | NewRateLimiter | func NewRateLimiter(n int, rate time.Duration) *rateLimiter {
r := &rateLimiter{
C: make(chan bool),
rate: rate,
n: n,
shutdown: make(chan bool),
}
r.wg.Add(1)
go r.limiter()
return r
} | go | func NewRateLimiter(n int, rate time.Duration) *rateLimiter {
r := &rateLimiter{
C: make(chan bool),
rate: rate,
n: n,
shutdown: make(chan bool),
}
r.wg.Add(1)
go r.limiter()
return r
} | [
"func",
"NewRateLimiter",
"(",
"n",
"int",
",",
"rate",
"time",
".",
"Duration",
")",
"*",
"rateLimiter",
"{",
"r",
":=",
"&",
"rateLimiter",
"{",
"C",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"rate",
":",
"rate",
",",
"n",
":",
"n",
",",
"shu... | // NewRateLimiter returns a rate limiter that will will emit from the C
// channel only 'n' times every 'rate' seconds. | [
"NewRateLimiter",
"returns",
"a",
"rate",
"limiter",
"that",
"will",
"will",
"emit",
"from",
"the",
"C",
"channel",
"only",
"n",
"times",
"every",
"rate",
"seconds",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/limiter/limiter.go#L10-L20 |
128,056 | influxdata/telegraf | plugins/inputs/elasticsearch/elasticsearch.go | NewElasticsearch | func NewElasticsearch() *Elasticsearch {
return &Elasticsearch{
HttpTimeout: internal.Duration{Duration: time.Second * 5},
ClusterStatsOnlyFromMaster: true,
ClusterHealthLevel: "indices",
}
} | go | func NewElasticsearch() *Elasticsearch {
return &Elasticsearch{
HttpTimeout: internal.Duration{Duration: time.Second * 5},
ClusterStatsOnlyFromMaster: true,
ClusterHealthLevel: "indices",
}
} | [
"func",
"NewElasticsearch",
"(",
")",
"*",
"Elasticsearch",
"{",
"return",
"&",
"Elasticsearch",
"{",
"HttpTimeout",
":",
"internal",
".",
"Duration",
"{",
"Duration",
":",
"time",
".",
"Second",
"*",
"5",
"}",
",",
"ClusterStatsOnlyFromMaster",
":",
"true",
... | // NewElasticsearch return a new instance of Elasticsearch | [
"NewElasticsearch",
"return",
"a",
"new",
"instance",
"of",
"Elasticsearch"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/elasticsearch/elasticsearch.go#L145-L151 |
128,057 | influxdata/telegraf | plugins/inputs/elasticsearch/elasticsearch.go | Gather | func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
if e.client == nil {
client, err := e.createHttpClient()
if err != nil {
return err
}
e.client = client
}
var wg sync.WaitGroup
wg.Add(len(e.Servers))
for _, serv := range e.Servers {
go func(s string, acc telegraf.Accumulator) {
d... | go | func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
if e.client == nil {
client, err := e.createHttpClient()
if err != nil {
return err
}
e.client = client
}
var wg sync.WaitGroup
wg.Add(len(e.Servers))
for _, serv := range e.Servers {
go func(s string, acc telegraf.Accumulator) {
d... | [
"func",
"(",
"e",
"*",
"Elasticsearch",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"e",
".",
"client",
"==",
"nil",
"{",
"client",
",",
"err",
":=",
"e",
".",
"createHttpClient",
"(",
")",
"\n\n",
"if",
"err",... | // Gather reads the stats from Elasticsearch and writes it to the
// Accumulator. | [
"Gather",
"reads",
"the",
"stats",
"from",
"Elasticsearch",
"and",
"writes",
"it",
"to",
"the",
"Accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/elasticsearch/elasticsearch.go#L178-L234 |
128,058 | influxdata/telegraf | plugins/inputs/procstat/native_finder_notwindows.go | FullPattern | func (pg *NativeFinder) FullPattern(pattern string) ([]PID, error) {
var pids []PID
regxPattern, err := regexp.Compile(pattern)
if err != nil {
return pids, err
}
procs, err := process.Processes()
if err != nil {
return pids, err
}
for _, p := range procs {
cmd, err := p.Cmdline()
if err != nil {
//s... | go | func (pg *NativeFinder) FullPattern(pattern string) ([]PID, error) {
var pids []PID
regxPattern, err := regexp.Compile(pattern)
if err != nil {
return pids, err
}
procs, err := process.Processes()
if err != nil {
return pids, err
}
for _, p := range procs {
cmd, err := p.Cmdline()
if err != nil {
//s... | [
"func",
"(",
"pg",
"*",
"NativeFinder",
")",
"FullPattern",
"(",
"pattern",
"string",
")",
"(",
"[",
"]",
"PID",
",",
"error",
")",
"{",
"var",
"pids",
"[",
"]",
"PID",
"\n",
"regxPattern",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"pattern",
... | //FullPattern matches on the command line when the process was executed | [
"FullPattern",
"matches",
"on",
"the",
"command",
"line",
"when",
"the",
"process",
"was",
"executed"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder_notwindows.go#L37-L59 |
128,059 | influxdata/telegraf | plugins/inputs/postgresql/service.go | Start | func (p *Service) Start(telegraf.Accumulator) (err error) {
const localhost = "host=localhost sslmode=disable"
if p.Address == "" || p.Address == "localhost" {
p.Address = localhost
}
connectionString := p.Address
// Specific support to make it work with PgBouncer too
// See https://github.com/influxdata/tel... | go | func (p *Service) Start(telegraf.Accumulator) (err error) {
const localhost = "host=localhost sslmode=disable"
if p.Address == "" || p.Address == "localhost" {
p.Address = localhost
}
connectionString := p.Address
// Specific support to make it work with PgBouncer too
// See https://github.com/influxdata/tel... | [
"func",
"(",
"p",
"*",
"Service",
")",
"Start",
"(",
"telegraf",
".",
"Accumulator",
")",
"(",
"err",
"error",
")",
"{",
"const",
"localhost",
"=",
"\"",
"\"",
"\n\n",
"if",
"p",
".",
"Address",
"==",
"\"",
"\"",
"||",
"p",
".",
"Address",
"==",
... | // Start starts the ServiceInput's service, whatever that may be | [
"Start",
"starts",
"the",
"ServiceInput",
"s",
"service",
"whatever",
"that",
"may",
"be"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/postgresql/service.go#L100-L143 |
128,060 | influxdata/telegraf | plugins/inputs/postgresql/service.go | SanitizedAddress | func (p *Service) SanitizedAddress() (sanitizedAddress string, err error) {
var (
canonicalizedAddress string
)
if p.Outputaddress != "" {
return p.Outputaddress, nil
}
if strings.HasPrefix(p.Address, "postgres://") || strings.HasPrefix(p.Address, "postgresql://") {
if canonicalizedAddress, err = parseURL(... | go | func (p *Service) SanitizedAddress() (sanitizedAddress string, err error) {
var (
canonicalizedAddress string
)
if p.Outputaddress != "" {
return p.Outputaddress, nil
}
if strings.HasPrefix(p.Address, "postgres://") || strings.HasPrefix(p.Address, "postgresql://") {
if canonicalizedAddress, err = parseURL(... | [
"func",
"(",
"p",
"*",
"Service",
")",
"SanitizedAddress",
"(",
")",
"(",
"sanitizedAddress",
"string",
",",
"err",
"error",
")",
"{",
"var",
"(",
"canonicalizedAddress",
"string",
"\n",
")",
"\n\n",
"if",
"p",
".",
"Outputaddress",
"!=",
"\"",
"\"",
"{"... | // SanitizedAddress utility function to strip sensitive information from the connection string. | [
"SanitizedAddress",
"utility",
"function",
"to",
"strip",
"sensitive",
"information",
"from",
"the",
"connection",
"string",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/postgresql/service.go#L153-L173 |
128,061 | influxdata/telegraf | plugins/inputs/openldap/openldap.go | NewOpenldap | func NewOpenldap() *Openldap {
return &Openldap{
Host: "localhost",
Port: 389,
SSL: "",
TLS: "",
InsecureSkipVerify: false,
SSLCA: "",
TLSCA: "",
BindDn: "",
BindPassword: "",
ReverseMetricNames: f... | go | func NewOpenldap() *Openldap {
return &Openldap{
Host: "localhost",
Port: 389,
SSL: "",
TLS: "",
InsecureSkipVerify: false,
SSLCA: "",
TLSCA: "",
BindDn: "",
BindPassword: "",
ReverseMetricNames: f... | [
"func",
"NewOpenldap",
"(",
")",
"*",
"Openldap",
"{",
"return",
"&",
"Openldap",
"{",
"Host",
":",
"\"",
"\"",
",",
"Port",
":",
"389",
",",
"SSL",
":",
"\"",
"\"",
",",
"TLS",
":",
"\"",
"\"",
",",
"InsecureSkipVerify",
":",
"false",
",",
"SSLCA"... | // return an initialized Openldap | [
"return",
"an",
"initialized",
"Openldap"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/openldap/openldap.go#L71-L84 |
128,062 | influxdata/telegraf | plugins/inputs/openldap/openldap.go | dnToMetric | func dnToMetric(dn string, o *Openldap) string {
if o.ReverseMetricNames {
var metricParts []string
dn = strings.Trim(dn, " ")
dn = strings.Replace(dn, " ", "_", -1)
dn = strings.Replace(dn, "cn=", "", -1)
dn = strings.ToLower(dn)
metricParts = strings.Split(dn, ",")
for i, j := 0, len(metricParts)-1; i... | go | func dnToMetric(dn string, o *Openldap) string {
if o.ReverseMetricNames {
var metricParts []string
dn = strings.Trim(dn, " ")
dn = strings.Replace(dn, " ", "_", -1)
dn = strings.Replace(dn, "cn=", "", -1)
dn = strings.ToLower(dn)
metricParts = strings.Split(dn, ",")
for i, j := 0, len(metricParts)-1; i... | [
"func",
"dnToMetric",
"(",
"dn",
"string",
",",
"o",
"*",
"Openldap",
")",
"string",
"{",
"if",
"o",
".",
"ReverseMetricNames",
"{",
"var",
"metricParts",
"[",
"]",
"string",
"\n\n",
"dn",
"=",
"strings",
".",
"Trim",
"(",
"dn",
",",
"\"",
"\"",
")",... | // Convert a DN to metric name, eg cn=Read,cn=Waiters,cn=Monitor becomes waiters_read
// Assumes the last part of the DN is cn=Monitor and we want to drop it | [
"Convert",
"a",
"DN",
"to",
"metric",
"name",
"eg",
"cn",
"=",
"Read",
"cn",
"=",
"Waiters",
"cn",
"=",
"Monitor",
"becomes",
"waiters_read",
"Assumes",
"the",
"last",
"part",
"of",
"the",
"DN",
"is",
"cn",
"=",
"Monitor",
"and",
"we",
"want",
"to",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/openldap/openldap.go#L189-L211 |
128,063 | influxdata/telegraf | plugins/inputs/smart/smart.go | sudo | func sudo(sudo bool, command string, args ...string) *exec.Cmd {
if sudo {
return execCommand("sudo", append([]string{"-n", command}, args...)...)
}
return execCommand(command, args...)
} | go | func sudo(sudo bool, command string, args ...string) *exec.Cmd {
if sudo {
return execCommand("sudo", append([]string{"-n", command}, args...)...)
}
return execCommand(command, args...)
} | [
"func",
"sudo",
"(",
"sudo",
"bool",
",",
"command",
"string",
",",
"args",
"...",
"string",
")",
"*",
"exec",
".",
"Cmd",
"{",
"if",
"sudo",
"{",
"return",
"execCommand",
"(",
"\"",
"\"",
",",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
... | // Wrap with sudo | [
"Wrap",
"with",
"sudo"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/smart/smart.go#L120-L126 |
128,064 | influxdata/telegraf | plugins/inputs/smart/smart.go | scan | func (m *Smart) scan() ([]string, error) {
cmd := sudo(m.UseSudo, m.Path, "--scan")
out, err := internal.CombinedOutputTimeout(cmd, time.Second*5)
if err != nil {
return []string{}, fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
}
devices := []string{}
for _, li... | go | func (m *Smart) scan() ([]string, error) {
cmd := sudo(m.UseSudo, m.Path, "--scan")
out, err := internal.CombinedOutputTimeout(cmd, time.Second*5)
if err != nil {
return []string{}, fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
}
devices := []string{}
for _, li... | [
"func",
"(",
"m",
"*",
"Smart",
")",
"scan",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"cmd",
":=",
"sudo",
"(",
"m",
".",
"UseSudo",
",",
"m",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"out",
",",
"err",
":=",
"internal",
"... | // Scan for S.M.A.R.T. devices | [
"Scan",
"for",
"S",
".",
"M",
".",
"A",
".",
"R",
".",
"T",
".",
"devices"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/smart/smart.go#L129-L145 |
128,065 | influxdata/telegraf | plugins/inputs/smart/smart.go | getAttributes | func (m *Smart) getAttributes(acc telegraf.Accumulator, devices []string) {
var wg sync.WaitGroup
wg.Add(len(devices))
for _, device := range devices {
go gatherDisk(acc, m.UseSudo, m.Attributes, m.Path, m.Nocheck, device, &wg)
}
wg.Wait()
} | go | func (m *Smart) getAttributes(acc telegraf.Accumulator, devices []string) {
var wg sync.WaitGroup
wg.Add(len(devices))
for _, device := range devices {
go gatherDisk(acc, m.UseSudo, m.Attributes, m.Path, m.Nocheck, device, &wg)
}
wg.Wait()
} | [
"func",
"(",
"m",
"*",
"Smart",
")",
"getAttributes",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"devices",
"[",
"]",
"string",
")",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"wg",
".",
"Add",
"(",
"len",
"(",
"devices",
")",
")",
"\n... | // Get info and attributes for each S.M.A.R.T. device | [
"Get",
"info",
"and",
"attributes",
"for",
"each",
"S",
".",
"M",
".",
"A",
".",
"R",
".",
"T",
".",
"device"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/smart/smart.go#L160-L170 |
128,066 | influxdata/telegraf | plugins/inputs/solr/solr.go | Gather | func (s *Solr) Gather(acc telegraf.Accumulator) error {
if s.client == nil {
client := s.createHTTPClient()
s.client = client
}
var wg sync.WaitGroup
wg.Add(len(s.Servers))
for _, serv := range s.Servers {
go func(serv string, acc telegraf.Accumulator) {
defer wg.Done()
acc.AddError(s.gatherServerMet... | go | func (s *Solr) Gather(acc telegraf.Accumulator) error {
if s.client == nil {
client := s.createHTTPClient()
s.client = client
}
var wg sync.WaitGroup
wg.Add(len(s.Servers))
for _, serv := range s.Servers {
go func(serv string, acc telegraf.Accumulator) {
defer wg.Done()
acc.AddError(s.gatherServerMet... | [
"func",
"(",
"s",
"*",
"Solr",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"s",
".",
"client",
"==",
"nil",
"{",
"client",
":=",
"s",
".",
"createHTTPClient",
"(",
")",
"\n",
"s",
".",
"client",
"=",
"client"... | // Gather reads the stats from Solr and writes it to the
// Accumulator. | [
"Gather",
"reads",
"the",
"stats",
"from",
"Solr",
"and",
"writes",
"it",
"to",
"the",
"Accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L138-L155 |
128,067 | influxdata/telegraf | plugins/inputs/solr/solr.go | gatherServerMetrics | func (s *Solr) gatherServerMetrics(server string, acc telegraf.Accumulator) error {
measurementTime := time.Now()
adminCoresStatus := &AdminCoresStatus{}
if err := s.gatherData(s.adminURL(server), adminCoresStatus); err != nil {
return err
}
addAdminCoresStatusToAcc(acc, adminCoresStatus, measurementTime)
cores... | go | func (s *Solr) gatherServerMetrics(server string, acc telegraf.Accumulator) error {
measurementTime := time.Now()
adminCoresStatus := &AdminCoresStatus{}
if err := s.gatherData(s.adminURL(server), adminCoresStatus); err != nil {
return err
}
addAdminCoresStatusToAcc(acc, adminCoresStatus, measurementTime)
cores... | [
"func",
"(",
"s",
"*",
"Solr",
")",
"gatherServerMetrics",
"(",
"server",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"measurementTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"adminCoresStatus",
":=",
"&",
"AdminCoresStatus",... | // Gather all metrics from server | [
"Gather",
"all",
"metrics",
"from",
"server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L158-L181 |
128,068 | influxdata/telegraf | plugins/inputs/solr/solr.go | filterCores | func (s *Solr) filterCores(serverCores []string) []string {
if len(s.Cores) == 0 {
return serverCores
}
return s.Cores
} | go | func (s *Solr) filterCores(serverCores []string) []string {
if len(s.Cores) == 0 {
return serverCores
}
return s.Cores
} | [
"func",
"(",
"s",
"*",
"Solr",
")",
"filterCores",
"(",
"serverCores",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"Cores",
")",
"==",
"0",
"{",
"return",
"serverCores",
"\n",
"}",
"\n",
"return",
"s",
".",
"Core... | // Use cores from configuration if exists, else use cores from server | [
"Use",
"cores",
"from",
"configuration",
"if",
"exists",
"else",
"use",
"cores",
"from",
"server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L184-L189 |
128,069 | influxdata/telegraf | plugins/inputs/solr/solr.go | getCoresFromStatus | func getCoresFromStatus(adminCoresStatus *AdminCoresStatus) []string {
serverCores := []string{}
for coreName := range adminCoresStatus.Status {
serverCores = append(serverCores, coreName)
}
return serverCores
} | go | func getCoresFromStatus(adminCoresStatus *AdminCoresStatus) []string {
serverCores := []string{}
for coreName := range adminCoresStatus.Status {
serverCores = append(serverCores, coreName)
}
return serverCores
} | [
"func",
"getCoresFromStatus",
"(",
"adminCoresStatus",
"*",
"AdminCoresStatus",
")",
"[",
"]",
"string",
"{",
"serverCores",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"coreName",
":=",
"range",
"adminCoresStatus",
".",
"Status",
"{",
"serverCores",
"=",... | // Return list of cores from solr server | [
"Return",
"list",
"of",
"cores",
"from",
"solr",
"server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L192-L198 |
128,070 | influxdata/telegraf | plugins/inputs/solr/solr.go | addCoreMetricsToAcc | func addCoreMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var coreMetrics map[string]Core
if len(mBeansData.SolrMbeans) < 2 {
return fmt.Errorf("no core metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans[1], &coreMetrics); err != nil ... | go | func addCoreMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var coreMetrics map[string]Core
if len(mBeansData.SolrMbeans) < 2 {
return fmt.Errorf("no core metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans[1], &coreMetrics); err != nil ... | [
"func",
"addCoreMetricsToAcc",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"core",
"string",
",",
"mBeansData",
"*",
"MBeansData",
",",
"time",
"time",
".",
"Time",
")",
"error",
"{",
"var",
"coreMetrics",
"map",
"[",
"string",
"]",
"Core",
"\n",
"if"... | // Add core metrics section to accumulator | [
"Add",
"core",
"metrics",
"section",
"to",
"accumulator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L220-L247 |
128,071 | influxdata/telegraf | plugins/inputs/solr/solr.go | addQueryHandlerMetricsToAcc | func addQueryHandlerMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var queryMetrics map[string]QueryHandler
if len(mBeansData.SolrMbeans) < 4 {
return fmt.Errorf("no query handler metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans[3]... | go | func addQueryHandlerMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var queryMetrics map[string]QueryHandler
if len(mBeansData.SolrMbeans) < 4 {
return fmt.Errorf("no query handler metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans[3]... | [
"func",
"addQueryHandlerMetricsToAcc",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"core",
"string",
",",
"mBeansData",
"*",
"MBeansData",
",",
"time",
"time",
".",
"Time",
")",
"error",
"{",
"var",
"queryMetrics",
"map",
"[",
"string",
"]",
"QueryHandler... | // Add query metrics section to accumulator | [
"Add",
"query",
"metrics",
"section",
"to",
"accumulator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L250-L289 |
128,072 | influxdata/telegraf | plugins/inputs/solr/solr.go | addUpdateHandlerMetricsToAcc | func addUpdateHandlerMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var updateMetrics map[string]UpdateHandler
if len(mBeansData.SolrMbeans) < 6 {
return fmt.Errorf("no update handler metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans... | go | func addUpdateHandlerMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
var updateMetrics map[string]UpdateHandler
if len(mBeansData.SolrMbeans) < 6 {
return fmt.Errorf("no update handler metric data to unmarshall")
}
if err := json.Unmarshal(mBeansData.SolrMbeans... | [
"func",
"addUpdateHandlerMetricsToAcc",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"core",
"string",
",",
"mBeansData",
"*",
"MBeansData",
",",
"time",
"time",
".",
"Time",
")",
"error",
"{",
"var",
"updateMetrics",
"map",
"[",
"string",
"]",
"UpdateHand... | // Add update metrics section to accumulator | [
"Add",
"update",
"metrics",
"section",
"to",
"accumulator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L325-L368 |
128,073 | influxdata/telegraf | plugins/inputs/solr/solr.go | getFloat | func getFloat(unk interface{}) float64 {
switch i := unk.(type) {
case float64:
return i
case string:
f, err := strconv.ParseFloat(i, 64)
if err != nil || math.IsNaN(f) {
return float64(0)
}
return f
default:
return float64(0)
}
} | go | func getFloat(unk interface{}) float64 {
switch i := unk.(type) {
case float64:
return i
case string:
f, err := strconv.ParseFloat(i, 64)
if err != nil || math.IsNaN(f) {
return float64(0)
}
return f
default:
return float64(0)
}
} | [
"func",
"getFloat",
"(",
"unk",
"interface",
"{",
"}",
")",
"float64",
"{",
"switch",
"i",
":=",
"unk",
".",
"(",
"type",
")",
"{",
"case",
"float64",
":",
"return",
"i",
"\n",
"case",
"string",
":",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFlo... | // Get float64 from interface | [
"Get",
"float64",
"from",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L371-L384 |
128,074 | influxdata/telegraf | plugins/inputs/solr/solr.go | getInt | func getInt(unk interface{}) int64 {
switch i := unk.(type) {
case int64:
return i
case float64:
return int64(i)
case string:
v, err := strconv.ParseInt(i, 10, 64)
if err != nil {
return int64(0)
}
return v
default:
return int64(0)
}
} | go | func getInt(unk interface{}) int64 {
switch i := unk.(type) {
case int64:
return i
case float64:
return int64(i)
case string:
v, err := strconv.ParseInt(i, 10, 64)
if err != nil {
return int64(0)
}
return v
default:
return int64(0)
}
} | [
"func",
"getInt",
"(",
"unk",
"interface",
"{",
"}",
")",
"int64",
"{",
"switch",
"i",
":=",
"unk",
".",
"(",
"type",
")",
"{",
"case",
"int64",
":",
"return",
"i",
"\n",
"case",
"float64",
":",
"return",
"int64",
"(",
"i",
")",
"\n",
"case",
"st... | // Get int64 from interface | [
"Get",
"int64",
"from",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L387-L402 |
128,075 | influxdata/telegraf | plugins/inputs/solr/solr.go | addCacheMetricsToAcc | func addCacheMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
if len(mBeansData.SolrMbeans) < 8 {
return fmt.Errorf("no cache metric data to unmarshall")
}
var cacheMetrics map[string]Cache
if err := json.Unmarshal(mBeansData.SolrMbeans[7], &cacheMetrics); err !=... | go | func addCacheMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBeansData, time time.Time) error {
if len(mBeansData.SolrMbeans) < 8 {
return fmt.Errorf("no cache metric data to unmarshall")
}
var cacheMetrics map[string]Cache
if err := json.Unmarshal(mBeansData.SolrMbeans[7], &cacheMetrics); err !=... | [
"func",
"addCacheMetricsToAcc",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"core",
"string",
",",
"mBeansData",
"*",
"MBeansData",
",",
"time",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"len",
"(",
"mBeansData",
".",
"SolrMbeans",
")",
"<",
"8",
... | // Add cache metrics section to accumulator | [
"Add",
"cache",
"metrics",
"section",
"to",
"accumulator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L405-L449 |
128,076 | influxdata/telegraf | plugins/inputs/solr/solr.go | adminURL | func (s *Solr) adminURL(server string) string {
return fmt.Sprintf("%s%s", server, adminCoresPath)
} | go | func (s *Solr) adminURL(server string) string {
return fmt.Sprintf("%s%s", server, adminCoresPath)
} | [
"func",
"(",
"s",
"*",
"Solr",
")",
"adminURL",
"(",
"server",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"server",
",",
"adminCoresPath",
")",
"\n",
"}"
] | // Provide admin url | [
"Provide",
"admin",
"url"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L452-L454 |
128,077 | influxdata/telegraf | plugins/inputs/solr/solr.go | mbeansURL | func (s *Solr) mbeansURL(server string, core string) string {
return fmt.Sprintf("%s/solr/%s%s", server, core, mbeansPath)
} | go | func (s *Solr) mbeansURL(server string, core string) string {
return fmt.Sprintf("%s/solr/%s%s", server, core, mbeansPath)
} | [
"func",
"(",
"s",
"*",
"Solr",
")",
"mbeansURL",
"(",
"server",
"string",
",",
"core",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"server",
",",
"core",
",",
"mbeansPath",
")",
"\n",
"}"
] | // Provide mbeans url | [
"Provide",
"mbeans",
"url"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/solr/solr.go#L457-L459 |
128,078 | influxdata/telegraf | plugins/inputs/nstat/nstat.go | loadPaths | func (ns *Nstat) loadPaths() {
if ns.ProcNetNetstat == "" {
ns.ProcNetNetstat = proc(ENV_NETSTAT, NET_NETSTAT)
}
if ns.ProcNetSNMP == "" {
ns.ProcNetSNMP = proc(ENV_SNMP, NET_SNMP)
}
if ns.ProcNetSNMP6 == "" {
ns.ProcNetSNMP6 = proc(ENV_SNMP6, NET_SNMP6)
}
} | go | func (ns *Nstat) loadPaths() {
if ns.ProcNetNetstat == "" {
ns.ProcNetNetstat = proc(ENV_NETSTAT, NET_NETSTAT)
}
if ns.ProcNetSNMP == "" {
ns.ProcNetSNMP = proc(ENV_SNMP, NET_SNMP)
}
if ns.ProcNetSNMP6 == "" {
ns.ProcNetSNMP6 = proc(ENV_SNMP6, NET_SNMP6)
}
} | [
"func",
"(",
"ns",
"*",
"Nstat",
")",
"loadPaths",
"(",
")",
"{",
"if",
"ns",
".",
"ProcNetNetstat",
"==",
"\"",
"\"",
"{",
"ns",
".",
"ProcNetNetstat",
"=",
"proc",
"(",
"ENV_NETSTAT",
",",
"NET_NETSTAT",
")",
"\n",
"}",
"\n",
"if",
"ns",
".",
"Pr... | // loadPaths can be used to read paths firstly from config
// if it is empty then try read from env variables | [
"loadPaths",
"can",
"be",
"used",
"to",
"read",
"paths",
"firstly",
"from",
"config",
"if",
"it",
"is",
"empty",
"then",
"try",
"read",
"from",
"env",
"variables"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nstat/nstat.go#L137-L147 |
128,079 | influxdata/telegraf | plugins/inputs/nstat/nstat.go | loadGoodTable | func loadGoodTable(table []byte, dumpZeros bool) (map[string]interface{}, error) {
entries := map[string]interface{}{}
fields := bytes.Fields(table)
var value int64
var err error
// iterate over two values each time
// first value is header, second is value
for i := 0; i < len(fields); i = i + 2 {
// counter i... | go | func loadGoodTable(table []byte, dumpZeros bool) (map[string]interface{}, error) {
entries := map[string]interface{}{}
fields := bytes.Fields(table)
var value int64
var err error
// iterate over two values each time
// first value is header, second is value
for i := 0; i < len(fields); i = i + 2 {
// counter i... | [
"func",
"loadGoodTable",
"(",
"table",
"[",
"]",
"byte",
",",
"dumpZeros",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"entries",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n"... | // loadGoodTable can be used to parse string heap that
// headers and values are arranged in right order | [
"loadGoodTable",
"can",
"be",
"used",
"to",
"parse",
"string",
"heap",
"that",
"headers",
"and",
"values",
"are",
"arranged",
"in",
"right",
"order"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nstat/nstat.go#L151-L175 |
128,080 | influxdata/telegraf | plugins/inputs/nstat/nstat.go | loadUglyTable | func loadUglyTable(table []byte, dumpZeros bool) (map[string]interface{}, error) {
entries := map[string]interface{}{}
// split the lines by newline
lines := bytes.Split(table, newLineByte)
var value int64
var err error
// iterate over lines, take 2 lines each time
// first line contains header names
// second ... | go | func loadUglyTable(table []byte, dumpZeros bool) (map[string]interface{}, error) {
entries := map[string]interface{}{}
// split the lines by newline
lines := bytes.Split(table, newLineByte)
var value int64
var err error
// iterate over lines, take 2 lines each time
// first line contains header names
// second ... | [
"func",
"loadUglyTable",
"(",
"table",
"[",
"]",
"byte",
",",
"dumpZeros",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"entries",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n"... | // loadUglyTable can be used to parse string heap that
// the headers and values are splitted with a newline | [
"loadUglyTable",
"can",
"be",
"used",
"to",
"parse",
"string",
"heap",
"that",
"the",
"headers",
"and",
"values",
"are",
"splitted",
"with",
"a",
"newline"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nstat/nstat.go#L179-L214 |
128,081 | influxdata/telegraf | plugins/inputs/jenkins/jenkins.go | initialize | func (j *Jenkins) initialize(client *http.Client) error {
var err error
// init job filter
j.jobFilter, err = filter.Compile(j.JobExclude)
if err != nil {
return fmt.Errorf("error compile job filters[%s]: %v", j.URL, err)
}
// init node filter
j.nodeFilter, err = filter.Compile(j.NodeExclude)
if err != nil ... | go | func (j *Jenkins) initialize(client *http.Client) error {
var err error
// init job filter
j.jobFilter, err = filter.Compile(j.JobExclude)
if err != nil {
return fmt.Errorf("error compile job filters[%s]: %v", j.URL, err)
}
// init node filter
j.nodeFilter, err = filter.Compile(j.NodeExclude)
if err != nil ... | [
"func",
"(",
"j",
"*",
"Jenkins",
")",
"initialize",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// init job filter",
"j",
".",
"jobFilter",
",",
"err",
"=",
"filter",
".",
"Compile",
"(",
"j",
".",
"... | // seperate the client as dependency to use httptest Client for mocking | [
"seperate",
"the",
"client",
"as",
"dependency",
"to",
"use",
"httptest",
"Client",
"for",
"mocking"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jenkins/jenkins.go#L137-L167 |
128,082 | influxdata/telegraf | plugins/inputs/jenkins/jenkins.go | doGet | func (j *Jenkins) doGet(tcp func() error) error {
j.semaphore <- struct{}{}
if err := tcp(); err != nil {
<-j.semaphore
return err
}
<-j.semaphore
return nil
} | go | func (j *Jenkins) doGet(tcp func() error) error {
j.semaphore <- struct{}{}
if err := tcp(); err != nil {
<-j.semaphore
return err
}
<-j.semaphore
return nil
} | [
"func",
"(",
"j",
"*",
"Jenkins",
")",
"doGet",
"(",
"tcp",
"func",
"(",
")",
"error",
")",
"error",
"{",
"j",
".",
"semaphore",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"if",
"err",
":=",
"tcp",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"<-",... | // wrap the tcp request with doGet
// block tcp request if buffered channel is full | [
"wrap",
"the",
"tcp",
"request",
"with",
"doGet",
"block",
"tcp",
"request",
"if",
"buffered",
"channel",
"is",
"full"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jenkins/jenkins.go#L251-L259 |
128,083 | influxdata/telegraf | agent/agent.go | NewAgent | func NewAgent(config *config.Config) (*Agent, error) {
a := &Agent{
Config: config,
}
return a, nil
} | go | func NewAgent(config *config.Config) (*Agent, error) {
a := &Agent{
Config: config,
}
return a, nil
} | [
"func",
"NewAgent",
"(",
"config",
"*",
"config",
".",
"Config",
")",
"(",
"*",
"Agent",
",",
"error",
")",
"{",
"a",
":=",
"&",
"Agent",
"{",
"Config",
":",
"config",
",",
"}",
"\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] | // NewAgent returns an Agent for the given Config. | [
"NewAgent",
"returns",
"an",
"Agent",
"for",
"the",
"given",
"Config",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L24-L29 |
128,084 | influxdata/telegraf | agent/agent.go | runInputs | func (a *Agent) runInputs(
ctx context.Context,
startTime time.Time,
dst chan<- telegraf.Metric,
) error {
var wg sync.WaitGroup
for _, input := range a.Config.Inputs {
interval := a.Config.Agent.Interval.Duration
jitter := a.Config.Agent.CollectionJitter.Duration
// Overwrite agent interval if this plugin ... | go | func (a *Agent) runInputs(
ctx context.Context,
startTime time.Time,
dst chan<- telegraf.Metric,
) error {
var wg sync.WaitGroup
for _, input := range a.Config.Inputs {
interval := a.Config.Agent.Interval.Duration
jitter := a.Config.Agent.CollectionJitter.Duration
// Overwrite agent interval if this plugin ... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"runInputs",
"(",
"ctx",
"context",
".",
"Context",
",",
"startTime",
"time",
".",
"Time",
",",
"dst",
"chan",
"<-",
"telegraf",
".",
"Metric",
",",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
... | // runInputs starts and triggers the periodic gather for Inputs.
//
// When the context is done the timers are stopped and this function returns
// after all ongoing Gather calls complete. | [
"runInputs",
"starts",
"and",
"triggers",
"the",
"periodic",
"gather",
"for",
"Inputs",
".",
"When",
"the",
"context",
"is",
"done",
"the",
"timers",
"are",
"stopped",
"and",
"this",
"function",
"returns",
"after",
"all",
"ongoing",
"Gather",
"calls",
"complet... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L215-L251 |
128,085 | influxdata/telegraf | agent/agent.go | gatherOnInterval | func (a *Agent) gatherOnInterval(
ctx context.Context,
acc telegraf.Accumulator,
input *models.RunningInput,
interval time.Duration,
jitter time.Duration,
) {
defer panicRecover(input)
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
err := internal.SleepContext(ctx, internal.RandomDuration(jit... | go | func (a *Agent) gatherOnInterval(
ctx context.Context,
acc telegraf.Accumulator,
input *models.RunningInput,
interval time.Duration,
jitter time.Duration,
) {
defer panicRecover(input)
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
err := internal.SleepContext(ctx, internal.RandomDuration(jit... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"gatherOnInterval",
"(",
"ctx",
"context",
".",
"Context",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
"input",
"*",
"models",
".",
"RunningInput",
",",
"interval",
"time",
".",
"Duration",
",",
"jitter",
"time",
... | // gather runs an input's gather function periodically until the context is
// done. | [
"gather",
"runs",
"an",
"input",
"s",
"gather",
"function",
"periodically",
"until",
"the",
"context",
"is",
"done",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L255-L285 |
128,086 | influxdata/telegraf | agent/agent.go | gatherOnce | func (a *Agent) gatherOnce(
acc telegraf.Accumulator,
input *models.RunningInput,
timeout time.Duration,
) error {
ticker := time.NewTicker(timeout)
defer ticker.Stop()
done := make(chan error)
go func() {
done <- input.Gather(acc)
}()
for {
select {
case err := <-done:
return err
case <-ticker.C:... | go | func (a *Agent) gatherOnce(
acc telegraf.Accumulator,
input *models.RunningInput,
timeout time.Duration,
) error {
ticker := time.NewTicker(timeout)
defer ticker.Stop()
done := make(chan error)
go func() {
done <- input.Gather(acc)
}()
for {
select {
case err := <-done:
return err
case <-ticker.C:... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"gatherOnce",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"input",
"*",
"models",
".",
"RunningInput",
",",
"timeout",
"time",
".",
"Duration",
",",
")",
"error",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
... | // gatherOnce runs the input's Gather function once, logging a warning each
// interval it fails to complete before. | [
"gatherOnce",
"runs",
"the",
"input",
"s",
"Gather",
"function",
"once",
"logging",
"a",
"warning",
"each",
"interval",
"it",
"fails",
"to",
"complete",
"before",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L289-L311 |
128,087 | influxdata/telegraf | agent/agent.go | runProcessors | func (a *Agent) runProcessors(
src <-chan telegraf.Metric,
agg chan<- telegraf.Metric,
) error {
for metric := range src {
metrics := a.applyProcessors(metric)
for _, metric := range metrics {
agg <- metric
}
}
return nil
} | go | func (a *Agent) runProcessors(
src <-chan telegraf.Metric,
agg chan<- telegraf.Metric,
) error {
for metric := range src {
metrics := a.applyProcessors(metric)
for _, metric := range metrics {
agg <- metric
}
}
return nil
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"runProcessors",
"(",
"src",
"<-",
"chan",
"telegraf",
".",
"Metric",
",",
"agg",
"chan",
"<-",
"telegraf",
".",
"Metric",
",",
")",
"error",
"{",
"for",
"metric",
":=",
"range",
"src",
"{",
"metrics",
":=",
"a",
... | // runProcessors applies processors to metrics. | [
"runProcessors",
"applies",
"processors",
"to",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L314-L327 |
128,088 | influxdata/telegraf | agent/agent.go | applyProcessors | func (a *Agent) applyProcessors(m telegraf.Metric) []telegraf.Metric {
metrics := []telegraf.Metric{m}
for _, processor := range a.Config.Processors {
metrics = processor.Apply(metrics...)
}
return metrics
} | go | func (a *Agent) applyProcessors(m telegraf.Metric) []telegraf.Metric {
metrics := []telegraf.Metric{m}
for _, processor := range a.Config.Processors {
metrics = processor.Apply(metrics...)
}
return metrics
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"applyProcessors",
"(",
"m",
"telegraf",
".",
"Metric",
")",
"[",
"]",
"telegraf",
".",
"Metric",
"{",
"metrics",
":=",
"[",
"]",
"telegraf",
".",
"Metric",
"{",
"m",
"}",
"\n",
"for",
"_",
",",
"processor",
":=... | // applyProcessors applies all processors to a metric. | [
"applyProcessors",
"applies",
"all",
"processors",
"to",
"a",
"metric",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L330-L337 |
128,089 | influxdata/telegraf | agent/agent.go | runAggregators | func (a *Agent) runAggregators(
startTime time.Time,
src <-chan telegraf.Metric,
dst chan<- telegraf.Metric,
) error {
ctx, cancel := context.WithCancel(context.Background())
// Before calling Add, initialize the aggregation window. This ensures
// that any metric created after start time will be aggregated.
f... | go | func (a *Agent) runAggregators(
startTime time.Time,
src <-chan telegraf.Metric,
dst chan<- telegraf.Metric,
) error {
ctx, cancel := context.WithCancel(context.Background())
// Before calling Add, initialize the aggregation window. This ensures
// that any metric created after start time will be aggregated.
f... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"runAggregators",
"(",
"startTime",
"time",
".",
"Time",
",",
"src",
"<-",
"chan",
"telegraf",
".",
"Metric",
",",
"dst",
"chan",
"<-",
"telegraf",
".",
"Metric",
",",
")",
"error",
"{",
"ctx",
",",
"cancel",
":="... | // runAggregators adds metrics to the aggregators and triggers their periodic
// push call.
//
// Runs until src is closed and all metrics have been processed. Will call
// push one final time before returning. | [
"runAggregators",
"adds",
"metrics",
"to",
"the",
"aggregators",
"and",
"triggers",
"their",
"periodic",
"push",
"call",
".",
"Runs",
"until",
"src",
"is",
"closed",
"and",
"all",
"metrics",
"have",
"been",
"processed",
".",
"Will",
"call",
"push",
"one",
"f... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L360-L425 |
128,090 | influxdata/telegraf | agent/agent.go | push | func (a *Agent) push(
ctx context.Context,
aggregator *models.RunningAggregator,
acc telegraf.Accumulator,
) {
for {
// Ensures that Push will be called for each period, even if it has
// already elapsed before this function is called. This is guaranteed
// because so long as only Push updates the EndPeriod.... | go | func (a *Agent) push(
ctx context.Context,
aggregator *models.RunningAggregator,
acc telegraf.Accumulator,
) {
for {
// Ensures that Push will be called for each period, even if it has
// already elapsed before this function is called. This is guaranteed
// because so long as only Push updates the EndPeriod.... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"push",
"(",
"ctx",
"context",
".",
"Context",
",",
"aggregator",
"*",
"models",
".",
"RunningAggregator",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
")",
"{",
"for",
"{",
"// Ensures that Push will be called for each... | // push runs the push for a single aggregator every period. | [
"push",
"runs",
"the",
"push",
"for",
"a",
"single",
"aggregator",
"every",
"period",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L428-L449 |
128,091 | influxdata/telegraf | agent/agent.go | runOutputs | func (a *Agent) runOutputs(
startTime time.Time,
src <-chan telegraf.Metric,
) error {
interval := a.Config.Agent.FlushInterval.Duration
jitter := a.Config.Agent.FlushJitter.Duration
ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
for _, output := range a.Config.Outputs {
interv... | go | func (a *Agent) runOutputs(
startTime time.Time,
src <-chan telegraf.Metric,
) error {
interval := a.Config.Agent.FlushInterval.Duration
jitter := a.Config.Agent.FlushJitter.Duration
ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
for _, output := range a.Config.Outputs {
interv... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"runOutputs",
"(",
"startTime",
"time",
".",
"Time",
",",
"src",
"<-",
"chan",
"telegraf",
".",
"Metric",
",",
")",
"error",
"{",
"interval",
":=",
"a",
".",
"Config",
".",
"Agent",
".",
"FlushInterval",
".",
"Dur... | // runOutputs triggers the periodic write for Outputs.
//
// Runs until src is closed and all metrics have been processed. Will call
// Write one final time before returning. | [
"runOutputs",
"triggers",
"the",
"periodic",
"write",
"for",
"Outputs",
".",
"Runs",
"until",
"src",
"is",
"closed",
"and",
"all",
"metrics",
"have",
"been",
"processed",
".",
"Will",
"call",
"Write",
"one",
"final",
"time",
"before",
"returning",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L456-L504 |
128,092 | influxdata/telegraf | agent/agent.go | flush | func (a *Agent) flush(
ctx context.Context,
output *models.RunningOutput,
interval time.Duration,
jitter time.Duration,
) {
// since we are watching two channels we need a ticker with the jitter
// integrated.
ticker := NewTicker(interval, jitter)
defer ticker.Stop()
logError := func(err error) {
if err != ... | go | func (a *Agent) flush(
ctx context.Context,
output *models.RunningOutput,
interval time.Duration,
jitter time.Duration,
) {
// since we are watching two channels we need a ticker with the jitter
// integrated.
ticker := NewTicker(interval, jitter)
defer ticker.Stop()
logError := func(err error) {
if err != ... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"flush",
"(",
"ctx",
"context",
".",
"Context",
",",
"output",
"*",
"models",
".",
"RunningOutput",
",",
"interval",
"time",
".",
"Duration",
",",
"jitter",
"time",
".",
"Duration",
",",
")",
"{",
"// since we are wat... | // flush runs an output's flush function periodically until the context is
// done. | [
"flush",
"runs",
"an",
"output",
"s",
"flush",
"function",
"periodically",
"until",
"the",
"context",
"is",
"done",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L508-L550 |
128,093 | influxdata/telegraf | agent/agent.go | flushOnce | func (a *Agent) flushOnce(
output *models.RunningOutput,
timeout time.Duration,
writeFunc func() error,
) error {
ticker := time.NewTicker(timeout)
defer ticker.Stop()
done := make(chan error)
go func() {
done <- writeFunc()
}()
for {
select {
case err := <-done:
output.LogBufferStatus()
return e... | go | func (a *Agent) flushOnce(
output *models.RunningOutput,
timeout time.Duration,
writeFunc func() error,
) error {
ticker := time.NewTicker(timeout)
defer ticker.Stop()
done := make(chan error)
go func() {
done <- writeFunc()
}()
for {
select {
case err := <-done:
output.LogBufferStatus()
return e... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"flushOnce",
"(",
"output",
"*",
"models",
".",
"RunningOutput",
",",
"timeout",
"time",
".",
"Duration",
",",
"writeFunc",
"func",
"(",
")",
"error",
",",
")",
"error",
"{",
"ticker",
":=",
"time",
".",
"NewTicker"... | // flushOnce runs the output's Write function once, logging a warning each
// interval it fails to complete before. | [
"flushOnce",
"runs",
"the",
"output",
"s",
"Write",
"function",
"once",
"logging",
"a",
"warning",
"each",
"interval",
"it",
"fails",
"to",
"complete",
"before",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L554-L579 |
128,094 | influxdata/telegraf | agent/agent.go | connectOutputs | func (a *Agent) connectOutputs(ctx context.Context) error {
for _, output := range a.Config.Outputs {
log.Printf("D! [agent] Attempting connection to output: %s\n", output.Name)
err := output.Output.Connect()
if err != nil {
log.Printf("E! [agent] Failed to connect to output %s, retrying in 15s, "+
"error... | go | func (a *Agent) connectOutputs(ctx context.Context) error {
for _, output := range a.Config.Outputs {
log.Printf("D! [agent] Attempting connection to output: %s\n", output.Name)
err := output.Output.Connect()
if err != nil {
log.Printf("E! [agent] Failed to connect to output %s, retrying in 15s, "+
"error... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"connectOutputs",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"for",
"_",
",",
"output",
":=",
"range",
"a",
".",
"Config",
".",
"Outputs",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
... | // connectOutputs connects to all outputs. | [
"connectOutputs",
"connects",
"to",
"all",
"outputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L582-L603 |
128,095 | influxdata/telegraf | agent/agent.go | closeOutputs | func (a *Agent) closeOutputs() {
for _, output := range a.Config.Outputs {
output.Close()
}
} | go | func (a *Agent) closeOutputs() {
for _, output := range a.Config.Outputs {
output.Close()
}
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"closeOutputs",
"(",
")",
"{",
"for",
"_",
",",
"output",
":=",
"range",
"a",
".",
"Config",
".",
"Outputs",
"{",
"output",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // closeOutputs closes all outputs. | [
"closeOutputs",
"closes",
"all",
"outputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L606-L610 |
128,096 | influxdata/telegraf | agent/agent.go | startServiceInputs | func (a *Agent) startServiceInputs(
ctx context.Context,
dst chan<- telegraf.Metric,
) error {
started := []telegraf.ServiceInput{}
for _, input := range a.Config.Inputs {
if si, ok := input.Input.(telegraf.ServiceInput); ok {
// Service input plugins are not subject to timestamp rounding.
// This only app... | go | func (a *Agent) startServiceInputs(
ctx context.Context,
dst chan<- telegraf.Metric,
) error {
started := []telegraf.ServiceInput{}
for _, input := range a.Config.Inputs {
if si, ok := input.Input.(telegraf.ServiceInput); ok {
// Service input plugins are not subject to timestamp rounding.
// This only app... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"startServiceInputs",
"(",
"ctx",
"context",
".",
"Context",
",",
"dst",
"chan",
"<-",
"telegraf",
".",
"Metric",
",",
")",
"error",
"{",
"started",
":=",
"[",
"]",
"telegraf",
".",
"ServiceInput",
"{",
"}",
"\n\n",... | // startServiceInputs starts all service inputs. | [
"startServiceInputs",
"starts",
"all",
"service",
"inputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L613-L645 |
128,097 | influxdata/telegraf | agent/agent.go | stopServiceInputs | func (a *Agent) stopServiceInputs() {
for _, input := range a.Config.Inputs {
if si, ok := input.Input.(telegraf.ServiceInput); ok {
si.Stop()
}
}
} | go | func (a *Agent) stopServiceInputs() {
for _, input := range a.Config.Inputs {
if si, ok := input.Input.(telegraf.ServiceInput); ok {
si.Stop()
}
}
} | [
"func",
"(",
"a",
"*",
"Agent",
")",
"stopServiceInputs",
"(",
")",
"{",
"for",
"_",
",",
"input",
":=",
"range",
"a",
".",
"Config",
".",
"Inputs",
"{",
"if",
"si",
",",
"ok",
":=",
"input",
".",
"Input",
".",
"(",
"telegraf",
".",
"ServiceInput",... | // stopServiceInputs stops all service inputs. | [
"stopServiceInputs",
"stops",
"all",
"service",
"inputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L648-L654 |
128,098 | influxdata/telegraf | agent/agent.go | Precision | func (a *Agent) Precision() time.Duration {
precision := a.Config.Agent.Precision.Duration
interval := a.Config.Agent.Interval.Duration
if precision > 0 {
return precision
}
switch {
case interval >= time.Second:
return time.Second
case interval >= time.Millisecond:
return time.Millisecond
case interval... | go | func (a *Agent) Precision() time.Duration {
precision := a.Config.Agent.Precision.Duration
interval := a.Config.Agent.Interval.Duration
if precision > 0 {
return precision
}
switch {
case interval >= time.Second:
return time.Second
case interval >= time.Millisecond:
return time.Millisecond
case interval... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"Precision",
"(",
")",
"time",
".",
"Duration",
"{",
"precision",
":=",
"a",
".",
"Config",
".",
"Agent",
".",
"Precision",
".",
"Duration",
"\n",
"interval",
":=",
"a",
".",
"Config",
".",
"Agent",
".",
"Interval... | // Returns the rounding precision for metrics. | [
"Returns",
"the",
"rounding",
"precision",
"for",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L657-L675 |
128,099 | influxdata/telegraf | agent/agent.go | panicRecover | func panicRecover(input *models.RunningInput) {
if err := recover(); err != nil {
trace := make([]byte, 2048)
runtime.Stack(trace, true)
log.Printf("E! FATAL: Input [%s] panicked: %s, Stack:\n%s\n",
input.Name(), err, trace)
log.Println("E! PLEASE REPORT THIS PANIC ON GITHUB with " +
"stack trace, config... | go | func panicRecover(input *models.RunningInput) {
if err := recover(); err != nil {
trace := make([]byte, 2048)
runtime.Stack(trace, true)
log.Printf("E! FATAL: Input [%s] panicked: %s, Stack:\n%s\n",
input.Name(), err, trace)
log.Println("E! PLEASE REPORT THIS PANIC ON GITHUB with " +
"stack trace, config... | [
"func",
"panicRecover",
"(",
"input",
"*",
"models",
".",
"RunningInput",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"trace",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"2048",
")",
"\n",
"runtime",
".",
"Stack",... | // panicRecover displays an error if an input panics. | [
"panicRecover",
"displays",
"an",
"error",
"if",
"an",
"input",
"panics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/agent.go#L678-L688 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.