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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,300 | optiopay/kafka | broker.go | Producer | func (b *Broker) Producer(conf ProducerConf) Producer {
if conf.Logger == nil {
conf.Logger = b.conf.Logger
}
return &producer{
conf: conf,
broker: b,
}
} | go | func (b *Broker) Producer(conf ProducerConf) Producer {
if conf.Logger == nil {
conf.Logger = b.conf.Logger
}
return &producer{
conf: conf,
broker: b,
}
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"Producer",
"(",
"conf",
"ProducerConf",
")",
"Producer",
"{",
"if",
"conf",
".",
"Logger",
"==",
"nil",
"{",
"conf",
".",
"Logger",
"=",
"b",
".",
"conf",
".",
"Logger",
"\n",
"}",
"\n",
"return",
"&",
"produc... | // Producer returns new producer instance, bound to the broker. | [
"Producer",
"returns",
"new",
"producer",
"instance",
"bound",
"to",
"the",
"broker",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L904-L912 |
133,301 | optiopay/kafka | broker.go | Produce | func (p *producer) Produce(topic string, partition int32, messages ...*proto.Message) (offset int64, err error) {
for retry := 0; retry < p.conf.RetryLimit; retry++ {
if retry != 0 {
time.Sleep(p.conf.RetryWait)
}
offset, err = p.produce(topic, partition, messages...)
switch err {
case nil:
for i, ms... | go | func (p *producer) Produce(topic string, partition int32, messages ...*proto.Message) (offset int64, err error) {
for retry := 0; retry < p.conf.RetryLimit; retry++ {
if retry != 0 {
time.Sleep(p.conf.RetryWait)
}
offset, err = p.produce(topic, partition, messages...)
switch err {
case nil:
for i, ms... | [
"func",
"(",
"p",
"*",
"producer",
")",
"Produce",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"messages",
"...",
"*",
"proto",
".",
"Message",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"for",
"retry",
":=",
"0",
";",
... | // Produce writes messages to the given destination. Writes within the call are
// atomic, meaning either all or none of them are written to kafka. Produce
// has a configurable amount of retries which may be attempted when common
// errors are encountered. This behaviour can be configured with the
// RetryLimit and ... | [
"Produce",
"writes",
"messages",
"to",
"the",
"given",
"destination",
".",
"Writes",
"within",
"the",
"call",
"are",
"atomic",
"meaning",
"either",
"all",
"or",
"none",
"of",
"them",
"are",
"written",
"to",
"kafka",
".",
"Produce",
"has",
"a",
"configurable"... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L921-L962 |
133,302 | optiopay/kafka | broker.go | produce | func (p *producer) produce(topic string, partition int32, messages ...*proto.Message) (offset int64, err error) {
conn, err := p.broker.muLeaderConnection(topic, partition)
if err != nil {
return 0, err
}
req := proto.ProduceReq{
RequestHeader: proto.RequestHeader{ClientID: p.broker.conf.ClientID},
Compressi... | go | func (p *producer) produce(topic string, partition int32, messages ...*proto.Message) (offset int64, err error) {
conn, err := p.broker.muLeaderConnection(topic, partition)
if err != nil {
return 0, err
}
req := proto.ProduceReq{
RequestHeader: proto.RequestHeader{ClientID: p.broker.conf.ClientID},
Compressi... | [
"func",
"(",
"p",
"*",
"producer",
")",
"produce",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"messages",
"...",
"*",
"proto",
".",
"Message",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"p",
"... | // produce send produce request to leader for given destination. | [
"produce",
"send",
"produce",
"request",
"to",
"leader",
"for",
"given",
"destination",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L965-L1035 |
133,303 | optiopay/kafka | broker.go | NewConsumerConf | func NewConsumerConf(topic string, partition int32) ConsumerConf {
return ConsumerConf{
Topic: topic,
Partition: partition,
RequestTimeout: time.Millisecond * 50,
RetryLimit: -1,
RetryWait: time.Millisecond * 50,
RetryErrLimit: 10,
RetryErrWait: time.Millisecond * 500,
MinFetc... | go | func NewConsumerConf(topic string, partition int32) ConsumerConf {
return ConsumerConf{
Topic: topic,
Partition: partition,
RequestTimeout: time.Millisecond * 50,
RetryLimit: -1,
RetryWait: time.Millisecond * 50,
RetryErrLimit: 10,
RetryErrWait: time.Millisecond * 500,
MinFetc... | [
"func",
"NewConsumerConf",
"(",
"topic",
"string",
",",
"partition",
"int32",
")",
"ConsumerConf",
"{",
"return",
"ConsumerConf",
"{",
"Topic",
":",
"topic",
",",
"Partition",
":",
"partition",
",",
"RequestTimeout",
":",
"time",
".",
"Millisecond",
"*",
"50",... | // NewConsumerConf returns the default consumer configuration. | [
"NewConsumerConf",
"returns",
"the",
"default",
"consumer",
"configuration",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1099-L1113 |
133,304 | optiopay/kafka | broker.go | Consumer | func (b *Broker) Consumer(conf ConsumerConf) (Consumer, error) {
return b.consumer(conf)
} | go | func (b *Broker) Consumer(conf ConsumerConf) (Consumer, error) {
return b.consumer(conf)
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"Consumer",
"(",
"conf",
"ConsumerConf",
")",
"(",
"Consumer",
",",
"error",
")",
"{",
"return",
"b",
".",
"consumer",
"(",
"conf",
")",
"\n",
"}"
] | // Consumer creates a new consumer instance, bound to the broker. | [
"Consumer",
"creates",
"a",
"new",
"consumer",
"instance",
"bound",
"to",
"the",
"broker",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1128-L1130 |
133,305 | optiopay/kafka | broker.go | BatchConsumer | func (b *Broker) BatchConsumer(conf ConsumerConf) (BatchConsumer, error) {
return b.consumer(conf)
} | go | func (b *Broker) BatchConsumer(conf ConsumerConf) (BatchConsumer, error) {
return b.consumer(conf)
} | [
"func",
"(",
"b",
"*",
"Broker",
")",
"BatchConsumer",
"(",
"conf",
"ConsumerConf",
")",
"(",
"BatchConsumer",
",",
"error",
")",
"{",
"return",
"b",
".",
"consumer",
"(",
"conf",
")",
"\n",
"}"
] | // BatchConsumer creates a new BatchConsumer instance, bound to the broker. | [
"BatchConsumer",
"creates",
"a",
"new",
"BatchConsumer",
"instance",
"bound",
"to",
"the",
"broker",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1133-L1135 |
133,306 | optiopay/kafka | broker.go | consume | func (c *consumer) consume() ([]*proto.Message, error) {
var msgbuf []*proto.Message
var retry int
for len(msgbuf) == 0 {
var err error
msgbuf, err = c.fetch()
if err != nil {
return nil, err
}
if len(msgbuf) == 0 {
if c.conf.RetryWait > 0 {
time.Sleep(c.conf.RetryWait)
}
retry++
if c.co... | go | func (c *consumer) consume() ([]*proto.Message, error) {
var msgbuf []*proto.Message
var retry int
for len(msgbuf) == 0 {
var err error
msgbuf, err = c.fetch()
if err != nil {
return nil, err
}
if len(msgbuf) == 0 {
if c.conf.RetryWait > 0 {
time.Sleep(c.conf.RetryWait)
}
retry++
if c.co... | [
"func",
"(",
"c",
"*",
"consumer",
")",
"consume",
"(",
")",
"(",
"[",
"]",
"*",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"var",
"msgbuf",
"[",
"]",
"*",
"proto",
".",
"Message",
"\n",
"var",
"retry",
"int",
"\n",
"for",
"len",
"(",
"ms... | // consume is returning a batch of messages from consumed partition.
// Consumer can retry fetching messages even if responses return no new
// data. Retry behaviour can be configured through RetryLimit and RetryWait
// consumer parameters.
//
// consume can retry sending request on common errors. This behaviour can
//... | [
"consume",
"is",
"returning",
"a",
"batch",
"of",
"messages",
"from",
"consumed",
"partition",
".",
"Consumer",
"can",
"retry",
"fetching",
"messages",
"even",
"if",
"responses",
"return",
"no",
"new",
"data",
".",
"Retry",
"behaviour",
"can",
"be",
"configure... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1182-L1203 |
133,307 | optiopay/kafka | broker.go | NewOffsetCoordinatorConf | func NewOffsetCoordinatorConf(consumerGroup string) OffsetCoordinatorConf {
return OffsetCoordinatorConf{
ConsumerGroup: consumerGroup,
RetryErrLimit: 10,
RetryErrWait: time.Millisecond * 500,
Logger: nil,
}
} | go | func NewOffsetCoordinatorConf(consumerGroup string) OffsetCoordinatorConf {
return OffsetCoordinatorConf{
ConsumerGroup: consumerGroup,
RetryErrLimit: 10,
RetryErrWait: time.Millisecond * 500,
Logger: nil,
}
} | [
"func",
"NewOffsetCoordinatorConf",
"(",
"consumerGroup",
"string",
")",
"OffsetCoordinatorConf",
"{",
"return",
"OffsetCoordinatorConf",
"{",
"ConsumerGroup",
":",
"consumerGroup",
",",
"RetryErrLimit",
":",
"10",
",",
"RetryErrWait",
":",
"time",
".",
"Millisecond",
... | // NewOffsetCoordinatorConf returns default OffsetCoordinator configuration. | [
"NewOffsetCoordinatorConf",
"returns",
"default",
"OffsetCoordinator",
"configuration",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1379-L1386 |
133,308 | optiopay/kafka | broker.go | OffsetCoordinator | func (b *Broker) OffsetCoordinator(conf OffsetCoordinatorConf) (OffsetCoordinator, error) {
conn, err := b.muCoordinatorConnection(conf.ConsumerGroup)
if err != nil {
return nil, err
}
if conf.Logger == nil {
conf.Logger = b.conf.Logger
}
c := &offsetCoordinator{
broker: b,
conf: conf,
conn: conn,
... | go | func (b *Broker) OffsetCoordinator(conf OffsetCoordinatorConf) (OffsetCoordinator, error) {
conn, err := b.muCoordinatorConnection(conf.ConsumerGroup)
if err != nil {
return nil, err
}
if conf.Logger == nil {
conf.Logger = b.conf.Logger
}
c := &offsetCoordinator{
broker: b,
conf: conf,
conn: conn,
... | [
"func",
"(",
"b",
"*",
"Broker",
")",
"OffsetCoordinator",
"(",
"conf",
"OffsetCoordinatorConf",
")",
"(",
"OffsetCoordinator",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"b",
".",
"muCoordinatorConnection",
"(",
"conf",
".",
"ConsumerGroup",
")",
"\n... | // OffsetCoordinator returns offset management coordinator for single consumer
// group, bound to broker. | [
"OffsetCoordinator",
"returns",
"offset",
"management",
"coordinator",
"for",
"single",
"consumer",
"group",
"bound",
"to",
"broker",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1398-L1412 |
133,309 | optiopay/kafka | broker.go | Commit | func (c *offsetCoordinator) Commit(topic string, partition int32, offset int64) error {
return c.commit(topic, partition, offset, "")
} | go | func (c *offsetCoordinator) Commit(topic string, partition int32, offset int64) error {
return c.commit(topic, partition, offset, "")
} | [
"func",
"(",
"c",
"*",
"offsetCoordinator",
")",
"Commit",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"offset",
"int64",
")",
"error",
"{",
"return",
"c",
".",
"commit",
"(",
"topic",
",",
"partition",
",",
"offset",
",",
"\"",
"\"",
")",
... | // Commit is saving offset information for given topic and partition.
//
// Commit can retry saving offset information on common errors. This behaviour
// can be configured with with RetryErrLimit and RetryErrWait coordinator
// configuration attributes. | [
"Commit",
"is",
"saving",
"offset",
"information",
"for",
"given",
"topic",
"and",
"partition",
".",
"Commit",
"can",
"retry",
"saving",
"offset",
"information",
"on",
"common",
"errors",
".",
"This",
"behaviour",
"can",
"be",
"configured",
"with",
"with",
"Re... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1419-L1421 |
133,310 | optiopay/kafka | broker.go | CommitFull | func (c *offsetCoordinator) CommitFull(topic string, partition int32, offset int64, metadata string) error {
return c.commit(topic, partition, offset, metadata)
} | go | func (c *offsetCoordinator) CommitFull(topic string, partition int32, offset int64, metadata string) error {
return c.commit(topic, partition, offset, metadata)
} | [
"func",
"(",
"c",
"*",
"offsetCoordinator",
")",
"CommitFull",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"offset",
"int64",
",",
"metadata",
"string",
")",
"error",
"{",
"return",
"c",
".",
"commit",
"(",
"topic",
",",
"partition",
",",
"of... | // Commit works exactly like Commit method, but store extra metadata string
// together with offset information. | [
"Commit",
"works",
"exactly",
"like",
"Commit",
"method",
"but",
"store",
"extra",
"metadata",
"string",
"together",
"with",
"offset",
"information",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1425-L1427 |
133,311 | optiopay/kafka | broker.go | commit | func (c *offsetCoordinator) commit(topic string, partition int32, offset int64, metadata string) (resErr error) {
c.mu.Lock()
defer c.mu.Unlock()
for retry := 0; retry < c.conf.RetryErrLimit; retry++ {
if retry != 0 {
c.mu.Unlock()
time.Sleep(c.conf.RetryErrWait)
c.mu.Lock()
}
// connection can be s... | go | func (c *offsetCoordinator) commit(topic string, partition int32, offset int64, metadata string) (resErr error) {
c.mu.Lock()
defer c.mu.Unlock()
for retry := 0; retry < c.conf.RetryErrLimit; retry++ {
if retry != 0 {
c.mu.Unlock()
time.Sleep(c.conf.RetryErrWait)
c.mu.Lock()
}
// connection can be s... | [
"func",
"(",
"c",
"*",
"offsetCoordinator",
")",
"commit",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"offset",
"int64",
",",
"metadata",
"string",
")",
"(",
"resErr",
"error",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defe... | // commit is saving offset and metadata information. Provides limited error
// handling configurable through OffsetCoordinatorConf. | [
"commit",
"is",
"saving",
"offset",
"and",
"metadata",
"information",
".",
"Provides",
"limited",
"error",
"handling",
"configurable",
"through",
"OffsetCoordinatorConf",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1431-L1500 |
133,312 | optiopay/kafka | broker.go | Offset | func (c *offsetCoordinator) Offset(topic string, partition int32) (offset int64, metadata string, resErr error) {
c.mu.Lock()
defer c.mu.Unlock()
for retry := 0; retry < c.conf.RetryErrLimit; retry++ {
if retry != 0 {
c.mu.Unlock()
time.Sleep(c.conf.RetryErrWait)
c.mu.Lock()
}
// connection can be s... | go | func (c *offsetCoordinator) Offset(topic string, partition int32) (offset int64, metadata string, resErr error) {
c.mu.Lock()
defer c.mu.Unlock()
for retry := 0; retry < c.conf.RetryErrLimit; retry++ {
if retry != 0 {
c.mu.Unlock()
time.Sleep(c.conf.RetryErrWait)
c.mu.Lock()
}
// connection can be s... | [
"func",
"(",
"c",
"*",
"offsetCoordinator",
")",
"Offset",
"(",
"topic",
"string",
",",
"partition",
"int32",
")",
"(",
"offset",
"int64",
",",
"metadata",
"string",
",",
"resErr",
"error",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defe... | // Offset is returning last offset and metadata information committed for given
// topic and partition.
// Offset can retry sending request on common errors. This behaviour can be
// configured with with RetryErrLimit and RetryErrWait coordinator
// configuration attributes. | [
"Offset",
"is",
"returning",
"last",
"offset",
"and",
"metadata",
"information",
"committed",
"for",
"given",
"topic",
"and",
"partition",
".",
"Offset",
"can",
"retry",
"sending",
"request",
"on",
"common",
"errors",
".",
"This",
"behaviour",
"can",
"be",
"co... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/broker.go#L1507-L1576 |
133,313 | optiopay/kafka | connection.go | newTCPConnection | func newTCPConnection(address string, timeout, readTimeout time.Duration) (*connection, error) {
var fetchVersions = true
for {
dialer := net.Dialer{
Timeout: timeout,
KeepAlive: 30 * time.Second,
}
conn, err := dialer.Dial("tcp", address)
if err != nil {
return nil, err
}
c := &connection{
... | go | func newTCPConnection(address string, timeout, readTimeout time.Duration) (*connection, error) {
var fetchVersions = true
for {
dialer := net.Dialer{
Timeout: timeout,
KeepAlive: 30 * time.Second,
}
conn, err := dialer.Dial("tcp", address)
if err != nil {
return nil, err
}
c := &connection{
... | [
"func",
"newTCPConnection",
"(",
"address",
"string",
",",
"timeout",
",",
"readTimeout",
"time",
".",
"Duration",
")",
"(",
"*",
"connection",
",",
"error",
")",
"{",
"var",
"fetchVersions",
"=",
"true",
"\n",
"for",
"{",
"dialer",
":=",
"net",
".",
"Di... | // newConnection returns new, initialized connection or error | [
"newConnection",
"returns",
"new",
"initialized",
"connection",
"or",
"error"
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L87-L121 |
133,314 | optiopay/kafka | connection.go | getBestVersion | func (c *connection) getBestVersion(apiKey int16) int16 {
if requested, ok := c.apiVersions[apiKey]; ok {
supported := proto.SupportedByDriver[apiKey]
if min(supported.MaxVersion, requested.MaxVersion) >= max(supported.MinVersion, requested.MinVersion) {
return min(supported.MaxVersion, requested.MaxVersion)
... | go | func (c *connection) getBestVersion(apiKey int16) int16 {
if requested, ok := c.apiVersions[apiKey]; ok {
supported := proto.SupportedByDriver[apiKey]
if min(supported.MaxVersion, requested.MaxVersion) >= max(supported.MinVersion, requested.MinVersion) {
return min(supported.MaxVersion, requested.MaxVersion)
... | [
"func",
"(",
"c",
"*",
"connection",
")",
"getBestVersion",
"(",
"apiKey",
"int16",
")",
"int16",
"{",
"if",
"requested",
",",
"ok",
":=",
"c",
".",
"apiVersions",
"[",
"apiKey",
"]",
";",
"ok",
"{",
"supported",
":=",
"proto",
".",
"SupportedByDriver",
... | //getBestVersion returns version for passed apiKey which best fit server and client requirements | [
"getBestVersion",
"returns",
"version",
"for",
"passed",
"apiKey",
"which",
"best",
"fit",
"server",
"and",
"client",
"requirements"
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L137-L145 |
133,315 | optiopay/kafka | connection.go | nextIDLoop | func (c *connection) nextIDLoop() {
var id int32 = 1
for {
select {
case <-c.stop:
close(c.nextID)
return
case c.nextID <- id:
id++
if id == math.MaxInt32 {
id = 1
}
}
}
} | go | func (c *connection) nextIDLoop() {
var id int32 = 1
for {
select {
case <-c.stop:
close(c.nextID)
return
case c.nextID <- id:
id++
if id == math.MaxInt32 {
id = 1
}
}
}
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"nextIDLoop",
"(",
")",
"{",
"var",
"id",
"int32",
"=",
"1",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"c",
".",
"stop",
":",
"close",
"(",
"c",
".",
"nextID",
")",
"\n",
"return",
"\n",
"case",
"c... | // nextIDLoop generates correlation IDs, making sure they are always in order
// and within the scope of request-response mapping array. | [
"nextIDLoop",
"generates",
"correlation",
"IDs",
"making",
"sure",
"they",
"are",
"always",
"in",
"order",
"and",
"within",
"the",
"scope",
"of",
"request",
"-",
"response",
"mapping",
"array",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L163-L177 |
133,316 | optiopay/kafka | connection.go | readRespLoop | func (c *connection) readRespLoop() {
defer func() {
c.mu.Lock()
for _, cc := range c.respc {
close(cc)
}
c.respc = make(map[int32]chan []byte)
c.mu.Unlock()
}()
rd := bufio.NewReader(c.rw)
for {
if c.readTimeout > 0 {
err := c.rw.SetReadDeadline(time.Now().Add(c.readTimeout))
if err != nil {
... | go | func (c *connection) readRespLoop() {
defer func() {
c.mu.Lock()
for _, cc := range c.respc {
close(cc)
}
c.respc = make(map[int32]chan []byte)
c.mu.Unlock()
}()
rd := bufio.NewReader(c.rw)
for {
if c.readTimeout > 0 {
err := c.rw.SetReadDeadline(time.Now().Add(c.readTimeout))
if err != nil {
... | [
"func",
"(",
"c",
"*",
"connection",
")",
"readRespLoop",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"cc",
":=",
"range",
"c",
".",
"respc",
"{",
"close",
"(",
"cc",
")",
"\n",... | // readRespLoop constantly reading response messages from the socket and after
// partial parsing, sends byte representation of the whole message to request
// sending process. | [
"readRespLoop",
"constantly",
"reading",
"response",
"messages",
"from",
"the",
"socket",
"and",
"after",
"partial",
"parsing",
"sends",
"byte",
"representation",
"of",
"the",
"whole",
"message",
"to",
"request",
"sending",
"process",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L182-L234 |
133,317 | optiopay/kafka | connection.go | respWaiter | func (c *connection) respWaiter(correlationID int32) (respc chan []byte, err error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.stopErr != nil {
return nil, c.stopErr
}
if _, ok := c.respc[correlationID]; ok {
c.logger.Error("msg", "correlation conflict", "correlationID", correlationID)
return nil, fmt.Errorf("c... | go | func (c *connection) respWaiter(correlationID int32) (respc chan []byte, err error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.stopErr != nil {
return nil, c.stopErr
}
if _, ok := c.respc[correlationID]; ok {
c.logger.Error("msg", "correlation conflict", "correlationID", correlationID)
return nil, fmt.Errorf("c... | [
"func",
"(",
"c",
"*",
"connection",
")",
"respWaiter",
"(",
"correlationID",
"int32",
")",
"(",
"respc",
"chan",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock"... | // respWaiter register listener to response message with given correlationID
// and return channel that single response message will be pushed to once it
// will arrive.
// After pushing response message, channel is closed.
//
// Upon connection close, all unconsumed channels are closed. | [
"respWaiter",
"register",
"listener",
"to",
"response",
"message",
"with",
"given",
"correlationID",
"and",
"return",
"channel",
"that",
"single",
"response",
"message",
"will",
"be",
"pushed",
"to",
"once",
"it",
"will",
"arrive",
".",
"After",
"pushing",
"resp... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L242-L256 |
133,318 | optiopay/kafka | connection.go | releaseWaiter | func (c *connection) releaseWaiter(correlationID int32) {
c.mu.Lock()
rc, ok := c.respc[correlationID]
if ok {
delete(c.respc, correlationID)
close(rc)
}
c.mu.Unlock()
} | go | func (c *connection) releaseWaiter(correlationID int32) {
c.mu.Lock()
rc, ok := c.respc[correlationID]
if ok {
delete(c.respc, correlationID)
close(rc)
}
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"releaseWaiter",
"(",
"correlationID",
"int32",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"rc",
",",
"ok",
":=",
"c",
".",
"respc",
"[",
"correlationID",
"]",
"\n",
"if",
"ok",
"{",
"delete",
... | // releaseWaiter removes response channel from waiters pool and close it.
// Calling this method for unknown correlationID has no effect. | [
"releaseWaiter",
"removes",
"response",
"channel",
"from",
"waiters",
"pool",
"and",
"close",
"it",
".",
"Calling",
"this",
"method",
"for",
"unknown",
"correlationID",
"has",
"no",
"effect",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L260-L268 |
133,319 | optiopay/kafka | connection.go | Close | func (c *connection) Close() error {
c.mu.Lock()
if c.stopErr == nil {
c.stopErr = ErrClosed
close(c.stop)
}
c.mu.Unlock()
return c.rw.Close()
} | go | func (c *connection) Close() error {
c.mu.Lock()
if c.stopErr == nil {
c.stopErr = ErrClosed
close(c.stop)
}
c.mu.Unlock()
return c.rw.Close()
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"Close",
"(",
")",
"error",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"c",
".",
"stopErr",
"==",
"nil",
"{",
"c",
".",
"stopErr",
"=",
"ErrClosed",
"\n",
"close",
"(",
"c",
".",
"stop",
... | // Close close underlying transport connection and cancel all pending response
// waiters. | [
"Close",
"close",
"underlying",
"transport",
"connection",
"and",
"cancel",
"all",
"pending",
"response",
"waiters",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L272-L280 |
133,320 | optiopay/kafka | connection.go | APIVersions | func (c *connection) APIVersions(req *proto.APIVersionsReq) (*proto.APIVersionsResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedAPIVersionsResp(bytes.NewReader(b), req.GetVersion())
} | go | func (c *connection) APIVersions(req *proto.APIVersionsReq) (*proto.APIVersionsResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedAPIVersionsResp(bytes.NewReader(b), req.GetVersion())
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"APIVersions",
"(",
"req",
"*",
"proto",
".",
"APIVersionsReq",
")",
"(",
"*",
"proto",
".",
"APIVersionsResp",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"req",
")",
"\n",
... | // APIVersions sends a request to fetch the supported versions for each API.
// Versioning is only supported in Kafka versions above 0.10.0.0 | [
"APIVersions",
"sends",
"a",
"request",
"to",
"fetch",
"the",
"supported",
"versions",
"for",
"each",
"API",
".",
"Versioning",
"is",
"only",
"supported",
"in",
"Kafka",
"versions",
"above",
"0",
".",
"10",
".",
"0",
".",
"0"
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L325-L331 |
133,321 | optiopay/kafka | connection.go | Metadata | func (c *connection) Metadata(req *proto.MetadataReq) (*proto.MetadataResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedMetadataResp(bytes.NewReader(b), req.GetVersion())
} | go | func (c *connection) Metadata(req *proto.MetadataReq) (*proto.MetadataResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedMetadataResp(bytes.NewReader(b), req.GetVersion())
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"Metadata",
"(",
"req",
"*",
"proto",
".",
"MetadataReq",
")",
"(",
"*",
"proto",
".",
"MetadataResp",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"req",
")",
"\n",
"if",
... | // Metadata sends given metadata request to kafka node and returns related
// metadata response.
// Calling this method on closed connection will always return ErrClosed. | [
"Metadata",
"sends",
"given",
"metadata",
"request",
"to",
"kafka",
"node",
"and",
"returns",
"related",
"metadata",
"response",
".",
"Calling",
"this",
"method",
"on",
"closed",
"connection",
"will",
"always",
"return",
"ErrClosed",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L336-L342 |
133,322 | optiopay/kafka | connection.go | CreateTopic | func (c *connection) CreateTopic(req *proto.CreateTopicsReq) (*proto.CreateTopicsResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadCreateTopicsResp(bytes.NewReader(b))
} | go | func (c *connection) CreateTopic(req *proto.CreateTopicsReq) (*proto.CreateTopicsResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadCreateTopicsResp(bytes.NewReader(b))
} | [
"func",
"(",
"c",
"*",
"connection",
")",
"CreateTopic",
"(",
"req",
"*",
"proto",
".",
"CreateTopicsReq",
")",
"(",
"*",
"proto",
".",
"CreateTopicsResp",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"req",
")",
"\n",... | // CreateTopic sends given createTopic request to kafka node and returns related
// response.
// Calling this method on closed connection will always return ErrClosed. | [
"CreateTopic",
"sends",
"given",
"createTopic",
"request",
"to",
"kafka",
"node",
"and",
"returns",
"related",
"response",
".",
"Calling",
"this",
"method",
"on",
"closed",
"connection",
"will",
"always",
"return",
"ErrClosed",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L347-L353 |
133,323 | optiopay/kafka | connection.go | Produce | func (c *connection) Produce(req *proto.ProduceReq) (*proto.ProduceResp, error) {
if req.RequiredAcks == proto.RequiredAcksNone {
return nil, c.sendRequestWithoutAcks(req)
}
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedProduceResp(bytes.NewReader(b), req.GetVersi... | go | func (c *connection) Produce(req *proto.ProduceReq) (*proto.ProduceResp, error) {
if req.RequiredAcks == proto.RequiredAcksNone {
return nil, c.sendRequestWithoutAcks(req)
}
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedProduceResp(bytes.NewReader(b), req.GetVersi... | [
"func",
"(",
"c",
"*",
"connection",
")",
"Produce",
"(",
"req",
"*",
"proto",
".",
"ProduceReq",
")",
"(",
"*",
"proto",
".",
"ProduceResp",
",",
"error",
")",
"{",
"if",
"req",
".",
"RequiredAcks",
"==",
"proto",
".",
"RequiredAcksNone",
"{",
"return... | // Produce sends given produce request to kafka node and returns related
// response. Sending request with no ACKs flag will result with returning nil
// right after sending request, without waiting for response.
// Calling this method on closed connection will always return ErrClosed. | [
"Produce",
"sends",
"given",
"produce",
"request",
"to",
"kafka",
"node",
"and",
"returns",
"related",
"response",
".",
"Sending",
"request",
"with",
"no",
"ACKs",
"flag",
"will",
"result",
"with",
"returning",
"nil",
"right",
"after",
"sending",
"request",
"w... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L359-L371 |
133,324 | optiopay/kafka | connection.go | Fetch | func (c *connection) Fetch(req *proto.FetchReq) (*proto.FetchResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
resp, err := proto.ReadVersionedFetchResp(bytes.NewReader(b), req.GetVersion())
if err != nil {
return nil, err
}
// Compressed messages are returned in full batches fo... | go | func (c *connection) Fetch(req *proto.FetchReq) (*proto.FetchResp, error) {
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
resp, err := proto.ReadVersionedFetchResp(bytes.NewReader(b), req.GetVersion())
if err != nil {
return nil, err
}
// Compressed messages are returned in full batches fo... | [
"func",
"(",
"c",
"*",
"connection",
")",
"Fetch",
"(",
"req",
"*",
"proto",
".",
"FetchReq",
")",
"(",
"*",
"proto",
".",
"FetchResp",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"c",
".",
"sendRequest",
"(",
"req",
")",
"\n",
"if",
"err",
... | // Fetch sends given fetch request to kafka node and returns related response.
// Calling this method on closed connection will always return ErrClosed. | [
"Fetch",
"sends",
"given",
"fetch",
"request",
"to",
"kafka",
"node",
"and",
"returns",
"related",
"response",
".",
"Calling",
"this",
"method",
"on",
"closed",
"connection",
"will",
"always",
"return",
"ErrClosed",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L375-L418 |
133,325 | optiopay/kafka | connection.go | Offset | func (c *connection) Offset(req *proto.OffsetReq) (*proto.OffsetResp, error) {
// TODO(husio) documentation is not mentioning this directly, but I assume
// -1 is for non node clients
req.ReplicaID = -1
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedOffsetResp(bytes.N... | go | func (c *connection) Offset(req *proto.OffsetReq) (*proto.OffsetResp, error) {
// TODO(husio) documentation is not mentioning this directly, but I assume
// -1 is for non node clients
req.ReplicaID = -1
b, err := c.sendRequest(req)
if err != nil {
return nil, err
}
return proto.ReadVersionedOffsetResp(bytes.N... | [
"func",
"(",
"c",
"*",
"connection",
")",
"Offset",
"(",
"req",
"*",
"proto",
".",
"OffsetReq",
")",
"(",
"*",
"proto",
".",
"OffsetResp",
",",
"error",
")",
"{",
"// TODO(husio) documentation is not mentioning this directly, but I assume",
"// -1 is for non node clie... | // Offset sends given offset request to kafka node and returns related response.
// Calling this method on closed connection will always return ErrClosed. | [
"Offset",
"sends",
"given",
"offset",
"request",
"to",
"kafka",
"node",
"and",
"returns",
"related",
"response",
".",
"Calling",
"this",
"method",
"on",
"closed",
"connection",
"will",
"always",
"return",
"ErrClosed",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/connection.go#L422-L432 |
133,326 | optiopay/kafka | multiplexer.go | Merge | func Merge(consumers ...Consumer) *Mx {
p := &Mx{
errc: make(chan error),
msgc: make(chan *proto.Message),
stop: make(chan struct{}),
workers: len(consumers),
}
for _, consumer := range consumers {
go func(c Consumer) {
defer func() {
p.mu.Lock()
p.workers--
if p.workers == 0 && !p... | go | func Merge(consumers ...Consumer) *Mx {
p := &Mx{
errc: make(chan error),
msgc: make(chan *proto.Message),
stop: make(chan struct{}),
workers: len(consumers),
}
for _, consumer := range consumers {
go func(c Consumer) {
defer func() {
p.mu.Lock()
p.workers--
if p.workers == 0 && !p... | [
"func",
"Merge",
"(",
"consumers",
"...",
"Consumer",
")",
"*",
"Mx",
"{",
"p",
":=",
"&",
"Mx",
"{",
"errc",
":",
"make",
"(",
"chan",
"error",
")",
",",
"msgc",
":",
"make",
"(",
"chan",
"*",
"proto",
".",
"Message",
")",
",",
"stop",
":",
"m... | // Merge is merging consume result of any number of consumers into single stream
// and expose them through returned multiplexer. | [
"Merge",
"is",
"merging",
"consume",
"result",
"of",
"any",
"number",
"of",
"consumers",
"into",
"single",
"stream",
"and",
"expose",
"them",
"through",
"returned",
"multiplexer",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/multiplexer.go#L40-L83 |
133,327 | optiopay/kafka | multiplexer.go | Workers | func (p *Mx) Workers() int {
p.mu.Lock()
defer p.mu.Unlock()
return p.workers
} | go | func (p *Mx) Workers() int {
p.mu.Lock()
defer p.mu.Unlock()
return p.workers
} | [
"func",
"(",
"p",
"*",
"Mx",
")",
"Workers",
"(",
")",
"int",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"workers",
"\n",
"}"
] | // Workers return number of active consumer workers that are pushing messages
// to multiplexer conumer queue. | [
"Workers",
"return",
"number",
"of",
"active",
"consumer",
"workers",
"that",
"are",
"pushing",
"messages",
"to",
"multiplexer",
"conumer",
"queue",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/multiplexer.go#L87-L91 |
133,328 | optiopay/kafka | multiplexer.go | Close | func (p *Mx) Close() {
p.mu.Lock()
defer p.mu.Unlock()
if !p.closed {
p.closed = true
close(p.stop)
}
} | go | func (p *Mx) Close() {
p.mu.Lock()
defer p.mu.Unlock()
if !p.closed {
p.closed = true
close(p.stop)
}
} | [
"func",
"(",
"p",
"*",
"Mx",
")",
"Close",
"(",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"p",
".",
"closed",
"{",
"p",
".",
"closed",
"=",
"true",
"\n",
"c... | // Close is closing multiplexer and stopping all underlying workers.
//
// Closing multiplexer will stop all workers as soon as possible, but any
// consume-in-progress action performed by worker has to be finished first. Any
// consumption result received after closing multiplexer is ignored.
//
// Close is returning ... | [
"Close",
"is",
"closing",
"multiplexer",
"and",
"stopping",
"all",
"underlying",
"workers",
".",
"Closing",
"multiplexer",
"will",
"stop",
"all",
"workers",
"as",
"soon",
"as",
"possible",
"but",
"any",
"consume",
"-",
"in",
"-",
"progress",
"action",
"perform... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/multiplexer.go#L102-L110 |
133,329 | optiopay/kafka | multiplexer.go | Consume | func (p *Mx) Consume() (*proto.Message, error) {
select {
case <-p.stop:
return nil, ErrMxClosed
case msg := <-p.msgc:
return msg, nil
case err := <-p.errc:
return nil, err
}
} | go | func (p *Mx) Consume() (*proto.Message, error) {
select {
case <-p.stop:
return nil, ErrMxClosed
case msg := <-p.msgc:
return msg, nil
case err := <-p.errc:
return nil, err
}
} | [
"func",
"(",
"p",
"*",
"Mx",
")",
"Consume",
"(",
")",
"(",
"*",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"select",
"{",
"case",
"<-",
"p",
".",
"stop",
":",
"return",
"nil",
",",
"ErrMxClosed",
"\n",
"case",
"msg",
":=",
"<-",
"p",
"."... | // Consume returns Consume result from any of the merged consumer. | [
"Consume",
"returns",
"Consume",
"result",
"from",
"any",
"of",
"the",
"merged",
"consumer",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/multiplexer.go#L113-L122 |
133,330 | optiopay/kafka | proto/utils.go | allocParseBuf | func allocParseBuf(size int) ([]byte, error) {
if size < 0 || size > maxParseBufSize {
return nil, messageSizeError(size)
}
return make([]byte, size), nil
} | go | func allocParseBuf(size int) ([]byte, error) {
if size < 0 || size > maxParseBufSize {
return nil, messageSizeError(size)
}
return make([]byte, size), nil
} | [
"func",
"allocParseBuf",
"(",
"size",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"size",
"<",
"0",
"||",
"size",
">",
"maxParseBufSize",
"{",
"return",
"nil",
",",
"messageSizeError",
"(",
"size",
")",
"\n",
"}",
"\n\n",
"return... | // allocParseBuf is used to allocate buffers used for parsing | [
"allocParseBuf",
"is",
"used",
"to",
"allocate",
"buffers",
"used",
"for",
"parsing"
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/proto/utils.go#L17-L23 |
133,331 | optiopay/kafka | proto/messages.go | ReadReq | func ReadReq(r io.Reader) (requestKind int16, b []byte, err error) {
dec := NewDecoder(r)
msgSize := dec.DecodeInt32()
requestKind = dec.DecodeInt16()
if err := dec.Err(); err != nil {
return 0, nil, err
}
// size of the message + size of the message itself
b, err = allocParseBuf(int(msgSize + 4))
if err != n... | go | func ReadReq(r io.Reader) (requestKind int16, b []byte, err error) {
dec := NewDecoder(r)
msgSize := dec.DecodeInt32()
requestKind = dec.DecodeInt16()
if err := dec.Err(); err != nil {
return 0, nil, err
}
// size of the message + size of the message itself
b, err = allocParseBuf(int(msgSize + 4))
if err != n... | [
"func",
"ReadReq",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"requestKind",
"int16",
",",
"b",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"dec",
":=",
"NewDecoder",
"(",
"r",
")",
"\n",
"msgSize",
":=",
"dec",
".",
"DecodeInt32",
"(",
")",
"... | // ReadReq returns request kind ID and byte representation of the whole message
// in wire protocol format. | [
"ReadReq",
"returns",
"request",
"kind",
"ID",
"and",
"byte",
"representation",
"of",
"the",
"whole",
"message",
"in",
"wire",
"protocol",
"format",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/proto/messages.go#L175-L203 |
133,332 | optiopay/kafka | proto/messages.go | ReadResp | func ReadResp(r io.Reader) (correlationID int32, b []byte, err error) {
dec := NewDecoder(r)
msgSize := dec.DecodeInt32()
correlationID = dec.DecodeInt32()
if err := dec.Err(); err != nil {
return 0, nil, err
}
// size of the message + size of the message itself
b, err = allocParseBuf(int(msgSize + 4))
if err... | go | func ReadResp(r io.Reader) (correlationID int32, b []byte, err error) {
dec := NewDecoder(r)
msgSize := dec.DecodeInt32()
correlationID = dec.DecodeInt32()
if err := dec.Err(); err != nil {
return 0, nil, err
}
// size of the message + size of the message itself
b, err = allocParseBuf(int(msgSize + 4))
if err... | [
"func",
"ReadResp",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"correlationID",
"int32",
",",
"b",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"dec",
":=",
"NewDecoder",
"(",
"r",
")",
"\n",
"msgSize",
":=",
"dec",
".",
"DecodeInt32",
"(",
")",
... | // ReadResp returns message correlation ID and byte representation of the whole
// message in wire protocol that is returned when reading from given stream,
// including 4 bytes of message size itself.
// Byte representation returned by ReadResp can be parsed by all response
// reeaders to transform it into specialized... | [
"ReadResp",
"returns",
"message",
"correlation",
"ID",
"and",
"byte",
"representation",
"of",
"the",
"whole",
"message",
"in",
"wire",
"protocol",
"that",
"is",
"returned",
"when",
"reading",
"from",
"given",
"stream",
"including",
"4",
"bytes",
"of",
"message",... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/proto/messages.go#L210-L227 |
133,333 | optiopay/kafka | proto/messages.go | ComputeCrc | func ComputeCrc(m *Message, compression Compression) uint32 {
var buf bytes.Buffer
enc := NewEncoder(&buf)
enc.EncodeInt8(0) // magic byte is always 0
enc.EncodeInt8(int8(compression))
enc.EncodeBytes(m.Key)
enc.EncodeBytes(m.Value)
return crc32.ChecksumIEEE(buf.Bytes())
} | go | func ComputeCrc(m *Message, compression Compression) uint32 {
var buf bytes.Buffer
enc := NewEncoder(&buf)
enc.EncodeInt8(0) // magic byte is always 0
enc.EncodeInt8(int8(compression))
enc.EncodeBytes(m.Key)
enc.EncodeBytes(m.Value)
return crc32.ChecksumIEEE(buf.Bytes())
} | [
"func",
"ComputeCrc",
"(",
"m",
"*",
"Message",
",",
"compression",
"Compression",
")",
"uint32",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"enc",
":=",
"NewEncoder",
"(",
"&",
"buf",
")",
"\n",
"enc",
".",
"EncodeInt8",
"(",
"0",
")",
"// magic... | // ComputeCrc returns crc32 hash for given message content. | [
"ComputeCrc",
"returns",
"crc32",
"hash",
"for",
"given",
"message",
"content",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/proto/messages.go#L241-L249 |
133,334 | optiopay/kafka | proto/messages.go | writeMessageSet | func writeMessageSet(w io.Writer, messages []*Message, compression Compression) (int, error) {
if len(messages) == 0 {
return 0, nil
}
// NOTE(caleb): it doesn't appear to be documented, but I observed that the
// Java client sets the offset of the synthesized message set for a group of
// compressed messages to... | go | func writeMessageSet(w io.Writer, messages []*Message, compression Compression) (int, error) {
if len(messages) == 0 {
return 0, nil
}
// NOTE(caleb): it doesn't appear to be documented, but I observed that the
// Java client sets the offset of the synthesized message set for a group of
// compressed messages to... | [
"func",
"writeMessageSet",
"(",
"w",
"io",
".",
"Writer",
",",
"messages",
"[",
"]",
"*",
"Message",
",",
"compression",
"Compression",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"len",
"(",
"messages",
")",
"==",
"0",
"{",
"return",
"0",
",",
... | // writeMessageSet writes a Message Set into w.
// It returns the number of bytes written and any error. | [
"writeMessageSet",
"writes",
"a",
"Message",
"Set",
"into",
"w",
".",
"It",
"returns",
"the",
"number",
"of",
"bytes",
"written",
"and",
"any",
"error",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/proto/messages.go#L253-L328 |
133,335 | optiopay/kafka | integration/cluster.go | Start | func (cluster *KafkaCluster) Start() error {
cluster.mu.Lock()
defer cluster.mu.Unlock()
// ensure cluster is not running
if err := cluster.Stop(); err != nil {
return fmt.Errorf("cannot ensure stop cluster: %s", err)
}
if err := cluster.removeStoppedContainers(); err != nil {
return fmt.Errorf("cannot clea... | go | func (cluster *KafkaCluster) Start() error {
cluster.mu.Lock()
defer cluster.mu.Unlock()
// ensure cluster is not running
if err := cluster.Stop(); err != nil {
return fmt.Errorf("cannot ensure stop cluster: %s", err)
}
if err := cluster.removeStoppedContainers(); err != nil {
return fmt.Errorf("cannot clea... | [
"func",
"(",
"cluster",
"*",
"KafkaCluster",
")",
"Start",
"(",
")",
"error",
"{",
"cluster",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cluster",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// ensure cluster is not running",
"if",
"err",
":=",
... | // Start start zookeeper and kafka nodes using docker-compose command. Upon
// successful process spawn, cluster is scaled to required amount of nodes. | [
"Start",
"start",
"zookeeper",
"and",
"kafka",
"nodes",
"using",
"docker",
"-",
"compose",
"command",
".",
"Upon",
"successful",
"process",
"spawn",
"cluster",
"is",
"scaled",
"to",
"required",
"amount",
"of",
"nodes",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/integration/cluster.go#L64-L90 |
133,336 | optiopay/kafka | integration/cluster.go | Containers | func (cluster *KafkaCluster) Containers() ([]*Container, error) {
psCmd, stdout, stderr := cluster.cmd("docker-compose", "ps", "-q")
err := psCmd.Run()
if err != nil {
return nil, fmt.Errorf("Cannot list processes: %s, %s", err, stderr.String())
}
containerIDs := stdout.String()
var containers []*Container
... | go | func (cluster *KafkaCluster) Containers() ([]*Container, error) {
psCmd, stdout, stderr := cluster.cmd("docker-compose", "ps", "-q")
err := psCmd.Run()
if err != nil {
return nil, fmt.Errorf("Cannot list processes: %s, %s", err, stderr.String())
}
containerIDs := stdout.String()
var containers []*Container
... | [
"func",
"(",
"cluster",
"*",
"KafkaCluster",
")",
"Containers",
"(",
")",
"(",
"[",
"]",
"*",
"Container",
",",
"error",
")",
"{",
"psCmd",
",",
"stdout",
",",
"stderr",
":=",
"cluster",
".",
"cmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\... | // Containers inspect all containers running within cluster and return
// information about them. | [
"Containers",
"inspect",
"all",
"containers",
"running",
"within",
"cluster",
"and",
"return",
"information",
"about",
"them",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/integration/cluster.go#L119-L147 |
133,337 | optiopay/kafka | distributing_producer.go | NewRandomProducer | func NewRandomProducer(p Producer, numPartitions int32) DistributingProducer {
return &randomProducer{
rand: saferand{r: rand.New(rand.NewSource(time.Now().UnixNano()))},
producer: p,
partitions: numPartitions,
}
} | go | func NewRandomProducer(p Producer, numPartitions int32) DistributingProducer {
return &randomProducer{
rand: saferand{r: rand.New(rand.NewSource(time.Now().UnixNano()))},
producer: p,
partitions: numPartitions,
}
} | [
"func",
"NewRandomProducer",
"(",
"p",
"Producer",
",",
"numPartitions",
"int32",
")",
"DistributingProducer",
"{",
"return",
"&",
"randomProducer",
"{",
"rand",
":",
"saferand",
"{",
"r",
":",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"time",
... | // NewRandomProducer wraps given producer and return DistributingProducer that
// publish messages to kafka, randomly picking partition number from range
// [0, numPartitions) | [
"NewRandomProducer",
"wraps",
"given",
"producer",
"and",
"return",
"DistributingProducer",
"that",
"publish",
"messages",
"to",
"kafka",
"randomly",
"picking",
"partition",
"number",
"from",
"range",
"[",
"0",
"numPartitions",
")"
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L47-L53 |
133,338 | optiopay/kafka | distributing_producer.go | Distribute | func (p *randomProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
// In the case there are no partitions, which may happen for new topics
// when AllowTopicCreation is passed, we will write to partition 0
// since rand.Intn panics with 0
part := 0
if p.partitions > 0 {
par... | go | func (p *randomProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
// In the case there are no partitions, which may happen for new topics
// when AllowTopicCreation is passed, we will write to partition 0
// since rand.Intn panics with 0
part := 0
if p.partitions > 0 {
par... | [
"func",
"(",
"p",
"*",
"randomProducer",
")",
"Distribute",
"(",
"topic",
"string",
",",
"messages",
"...",
"*",
"proto",
".",
"Message",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"// In the case there are no partitions, which may happen for new ... | // Distribute write messages to given kafka topic, randomly destination choosing
// partition. All messages written within single Produce call are atomically
// written to the same destination. | [
"Distribute",
"write",
"messages",
"to",
"given",
"kafka",
"topic",
"randomly",
"destination",
"choosing",
"partition",
".",
"All",
"messages",
"written",
"within",
"single",
"Produce",
"call",
"are",
"atomically",
"written",
"to",
"the",
"same",
"destination",
".... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L58-L67 |
133,339 | optiopay/kafka | distributing_producer.go | NewRoundRobinProducer | func NewRoundRobinProducer(p Producer, numPartitions int32) DistributingProducer {
return &roundRobinProducer{
producer: p,
partitions: numPartitions,
next: 0,
}
} | go | func NewRoundRobinProducer(p Producer, numPartitions int32) DistributingProducer {
return &roundRobinProducer{
producer: p,
partitions: numPartitions,
next: 0,
}
} | [
"func",
"NewRoundRobinProducer",
"(",
"p",
"Producer",
",",
"numPartitions",
"int32",
")",
"DistributingProducer",
"{",
"return",
"&",
"roundRobinProducer",
"{",
"producer",
":",
"p",
",",
"partitions",
":",
"numPartitions",
",",
"next",
":",
"0",
",",
"}",
"\... | // NewRoundRobinProducer wraps given producer and return DistributingProducer
// that publish messages to kafka, choosing destination partition from cycle
// build from [0, numPartitions) range. | [
"NewRoundRobinProducer",
"wraps",
"given",
"producer",
"and",
"return",
"DistributingProducer",
"that",
"publish",
"messages",
"to",
"kafka",
"choosing",
"destination",
"partition",
"from",
"cycle",
"build",
"from",
"[",
"0",
"numPartitions",
")",
"range",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L79-L85 |
133,340 | optiopay/kafka | distributing_producer.go | Distribute | func (p *roundRobinProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
p.mu.Lock()
part := p.next
p.next++
if p.next >= p.partitions {
p.next = 0
}
p.mu.Unlock()
return p.producer.Produce(topic, int32(part), messages...)
} | go | func (p *roundRobinProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
p.mu.Lock()
part := p.next
p.next++
if p.next >= p.partitions {
p.next = 0
}
p.mu.Unlock()
return p.producer.Produce(topic, int32(part), messages...)
} | [
"func",
"(",
"p",
"*",
"roundRobinProducer",
")",
"Distribute",
"(",
"topic",
"string",
",",
"messages",
"...",
"*",
"proto",
".",
"Message",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"... | // Distribute write messages to given kafka topic, choosing next destination
// partition from internal cycle. All messages written within single Produce
// call are atomically written to the same destination. | [
"Distribute",
"write",
"messages",
"to",
"given",
"kafka",
"topic",
"choosing",
"next",
"destination",
"partition",
"from",
"internal",
"cycle",
".",
"All",
"messages",
"written",
"within",
"single",
"Produce",
"call",
"are",
"atomically",
"written",
"to",
"the",
... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L90-L100 |
133,341 | optiopay/kafka | distributing_producer.go | NewHashProducer | func NewHashProducer(p Producer, numPartitions int32) DistributingProducer {
return &hashProducer{
producer: p,
partitions: numPartitions,
}
} | go | func NewHashProducer(p Producer, numPartitions int32) DistributingProducer {
return &hashProducer{
producer: p,
partitions: numPartitions,
}
} | [
"func",
"NewHashProducer",
"(",
"p",
"Producer",
",",
"numPartitions",
"int32",
")",
"DistributingProducer",
"{",
"return",
"&",
"hashProducer",
"{",
"producer",
":",
"p",
",",
"partitions",
":",
"numPartitions",
",",
"}",
"\n",
"}"
] | // NewHashProducer wraps given producer and return DistributingProducer that
// publish messages to kafka, computing partition number from message key hash,
// using fnv hash and [0, numPartitions) range. | [
"NewHashProducer",
"wraps",
"given",
"producer",
"and",
"return",
"DistributingProducer",
"that",
"publish",
"messages",
"to",
"kafka",
"computing",
"partition",
"number",
"from",
"message",
"key",
"hash",
"using",
"fnv",
"hash",
"and",
"[",
"0",
"numPartitions",
... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L110-L115 |
133,342 | optiopay/kafka | distributing_producer.go | Distribute | func (p *hashProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
if len(messages) == 0 {
return 0, errors.New("no messages")
}
part, err := messageHashPartition(messages[0].Key, p.partitions)
if err != nil {
return 0, fmt.Errorf("cannot hash message: %s", err)
}
// make ... | go | func (p *hashProducer) Distribute(topic string, messages ...*proto.Message) (offset int64, err error) {
if len(messages) == 0 {
return 0, errors.New("no messages")
}
part, err := messageHashPartition(messages[0].Key, p.partitions)
if err != nil {
return 0, fmt.Errorf("cannot hash message: %s", err)
}
// make ... | [
"func",
"(",
"p",
"*",
"hashProducer",
")",
"Distribute",
"(",
"topic",
"string",
",",
"messages",
"...",
"*",
"proto",
".",
"Message",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"messages",
")",
"==",
"0",
"{",
"... | // Distribute write messages to given kafka topic, computing partition number from
// the message key value. Message key must be not nil and all messages written
// within single Produce call are atomically written to the same destination.
//
// All messages passed within single Produce call must hash to the same
// de... | [
"Distribute",
"write",
"messages",
"to",
"given",
"kafka",
"topic",
"computing",
"partition",
"number",
"from",
"the",
"message",
"key",
"value",
".",
"Message",
"key",
"must",
"be",
"not",
"nil",
"and",
"all",
"messages",
"written",
"within",
"single",
"Produ... | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L123-L143 |
133,343 | optiopay/kafka | distributing_producer.go | messageHashPartition | func messageHashPartition(key []byte, partitions int32) (int32, error) {
if key == nil {
return 0, errors.New("no key")
}
hasher := fnv.New32a()
if _, err := hasher.Write(key); err != nil {
return 0, fmt.Errorf("cannot hash key: %s", err)
}
sum := int32(hasher.Sum32())
if sum < 0 {
sum = -sum
}
return su... | go | func messageHashPartition(key []byte, partitions int32) (int32, error) {
if key == nil {
return 0, errors.New("no key")
}
hasher := fnv.New32a()
if _, err := hasher.Write(key); err != nil {
return 0, fmt.Errorf("cannot hash key: %s", err)
}
sum := int32(hasher.Sum32())
if sum < 0 {
sum = -sum
}
return su... | [
"func",
"messageHashPartition",
"(",
"key",
"[",
"]",
"byte",
",",
"partitions",
"int32",
")",
"(",
"int32",
",",
"error",
")",
"{",
"if",
"key",
"==",
"nil",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"... | // messageHashPartition compute destination partition number for given key
// value and total number of partitions. | [
"messageHashPartition",
"compute",
"destination",
"partition",
"number",
"for",
"given",
"key",
"value",
"and",
"total",
"number",
"of",
"partitions",
"."
] | 6c126522640ec5e8e232d0e219160b30a92814f8 | https://github.com/optiopay/kafka/blob/6c126522640ec5e8e232d0e219160b30a92814f8/distributing_producer.go#L147-L160 |
133,344 | starkandwayne/shield | tui/form.go | NewField | func (f *Form) NewField(label string, name string, value interface{}, showas string, fn FieldProcessor) (*Field, error) {
tmpField := Field{
Label: label,
Name: name,
ShowAs: showas,
Value: value,
Processor: fn,
Hidden: false,
}
f.Fields = append(f.Fields, &tmpField)
return &tmpField,... | go | func (f *Form) NewField(label string, name string, value interface{}, showas string, fn FieldProcessor) (*Field, error) {
tmpField := Field{
Label: label,
Name: name,
ShowAs: showas,
Value: value,
Processor: fn,
Hidden: false,
}
f.Fields = append(f.Fields, &tmpField)
return &tmpField,... | [
"func",
"(",
"f",
"*",
"Form",
")",
"NewField",
"(",
"label",
"string",
",",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
",",
"showas",
"string",
",",
"fn",
"FieldProcessor",
")",
"(",
"*",
"Field",
",",
"error",
")",
"{",
"tmpField",
":="... | // NewField appends a new Field to the Form. | [
"NewField",
"appends",
"a",
"new",
"Field",
"to",
"the",
"Form",
"."
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/tui/form.go#L50-L61 |
133,345 | starkandwayne/shield | tui/form.go | GetField | func (f *Form) GetField(name string) *Field {
for _, field := range f.Fields {
if field.Name == name {
return field
}
}
return nil
} | go | func (f *Form) GetField(name string) *Field {
for _, field := range f.Fields {
if field.Name == name {
return field
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"Form",
")",
"GetField",
"(",
"name",
"string",
")",
"*",
"Field",
"{",
"for",
"_",
",",
"field",
":=",
"range",
"f",
".",
"Fields",
"{",
"if",
"field",
".",
"Name",
"==",
"name",
"{",
"return",
"field",
"\n",
"}",
"\n",
... | //GetField retrieves the reference to the Field with the Name attribute given
//to this function. Returns nil if no such Field was found. | [
"GetField",
"retrieves",
"the",
"reference",
"to",
"the",
"Field",
"with",
"the",
"Name",
"attribute",
"given",
"to",
"this",
"function",
".",
"Returns",
"nil",
"if",
"no",
"such",
"Field",
"was",
"found",
"."
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/tui/form.go#L65-L72 |
133,346 | starkandwayne/shield | plugin/cassandra/plugin.go | hardLinkAll | func hardLinkAll(src_dir string, dst_dir string) (err error) {
dir, err := os.Open(src_dir)
if err != nil {
return err
}
defer func() {
dir.Close()
}()
entries, err := dir.Readdir(-1)
if err != nil {
return err
}
for _, tableDirInfo := range entries {
if tableDirInfo.IsDir() {
continue
}
src ... | go | func hardLinkAll(src_dir string, dst_dir string) (err error) {
dir, err := os.Open(src_dir)
if err != nil {
return err
}
defer func() {
dir.Close()
}()
entries, err := dir.Readdir(-1)
if err != nil {
return err
}
for _, tableDirInfo := range entries {
if tableDirInfo.IsDir() {
continue
}
src ... | [
"func",
"hardLinkAll",
"(",
"src_dir",
"string",
",",
"dst_dir",
"string",
")",
"(",
"err",
"error",
")",
"{",
"dir",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"src_dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
... | // Hard-link all files from 'src_dir' to the 'dst_dir' | [
"Hard",
"-",
"link",
"all",
"files",
"from",
"src_dir",
"to",
"the",
"dst_dir"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/cassandra/plugin.go#L458-L486 |
133,347 | starkandwayne/shield | plugin/cassandra/plugin.go | Restore | func (p CassandraPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
cassandra, err := cassandraInfo(endpoint)
if err != nil {
return err
}
plugin.DEBUG("Creating directory '%s' with 0755 permissions", "/var/vcap/store/shield/cassandra")
err = os.MkdirAll("/var/vcap/store/shield/cassandra", 0755)
if err !=... | go | func (p CassandraPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
cassandra, err := cassandraInfo(endpoint)
if err != nil {
return err
}
plugin.DEBUG("Creating directory '%s' with 0755 permissions", "/var/vcap/store/shield/cassandra")
err = os.MkdirAll("/var/vcap/store/shield/cassandra", 0755)
if err !=... | [
"func",
"(",
"p",
"CassandraPlugin",
")",
"Restore",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"cassandra",
",",
"err",
":=",
"cassandraInfo",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}... | // Restore one cassandra keyspace | [
"Restore",
"one",
"cassandra",
"keyspace"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/cassandra/plugin.go#L489-L568 |
133,348 | starkandwayne/shield | db/db.go | Connect | func Connect(file string) (*DB, error) {
db := &DB{
Driver: "sqlite3",
DSN: file,
}
connection, err := sqlx.Open(db.Driver, db.DSN)
if err != nil {
return nil, err
}
db.connection = connection
if db.cache == nil {
db.cache = make(map[string]*sql.Stmt)
}
return db, nil
} | go | func Connect(file string) (*DB, error) {
db := &DB{
Driver: "sqlite3",
DSN: file,
}
connection, err := sqlx.Open(db.Driver, db.DSN)
if err != nil {
return nil, err
}
db.connection = connection
if db.cache == nil {
db.cache = make(map[string]*sql.Stmt)
}
return db, nil
} | [
"func",
"Connect",
"(",
"file",
"string",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"db",
":=",
"&",
"DB",
"{",
"Driver",
":",
"\"",
"\"",
",",
"DSN",
":",
"file",
",",
"}",
"\n\n",
"connection",
",",
"err",
":=",
"sqlx",
".",
"Open",
"(",
... | // Connect to the backend database | [
"Connect",
"to",
"the",
"backend",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/db/db.go#L28-L45 |
133,349 | starkandwayne/shield | db/db.go | Disconnect | func (db *DB) Disconnect() error {
if db.connection != nil {
if err := db.connection.Close(); err != nil {
return err
}
db.connection = nil
db.cache = make(map[string]*sql.Stmt)
}
return nil
} | go | func (db *DB) Disconnect() error {
if db.connection != nil {
if err := db.connection.Close(); err != nil {
return err
}
db.connection = nil
db.cache = make(map[string]*sql.Stmt)
}
return nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Disconnect",
"(",
")",
"error",
"{",
"if",
"db",
".",
"connection",
"!=",
"nil",
"{",
"if",
"err",
":=",
"db",
".",
"connection",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"... | // Disconnect from the backend database | [
"Disconnect",
"from",
"the",
"backend",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/db/db.go#L53-L62 |
133,350 | starkandwayne/shield | db/db.go | statement | func (db *DB) statement(sql string) (*sql.Stmt, error) {
if db.connection == nil {
return nil, fmt.Errorf("Not connected to database")
}
sql = db.connection.Rebind(sql)
if _, ok := db.cache[sql]; !ok {
stmt, err := db.connection.Prepare(sql)
if err != nil {
return nil, err
}
db.cache[sql] = stmt
}
... | go | func (db *DB) statement(sql string) (*sql.Stmt, error) {
if db.connection == nil {
return nil, fmt.Errorf("Not connected to database")
}
sql = db.connection.Rebind(sql)
if _, ok := db.cache[sql]; !ok {
stmt, err := db.connection.Prepare(sql)
if err != nil {
return nil, err
}
db.cache[sql] = stmt
}
... | [
"func",
"(",
"db",
"*",
"DB",
")",
"statement",
"(",
"sql",
"string",
")",
"(",
"*",
"sql",
".",
"Stmt",
",",
"error",
")",
"{",
"if",
"db",
".",
"connection",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
... | // Return the prepared statement for a given SQL query | [
"Return",
"the",
"prepared",
"statement",
"for",
"a",
"given",
"SQL",
"query"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/db/db.go#L124-L143 |
133,351 | starkandwayne/shield | db/memberships.go | GetTenantsForUser | func (db *DB) GetTenantsForUser(user string) ([]*Tenant, error) {
r, err := db.Query(`
SELECT t.uuid, t.name
FROM tenants t INNER JOIN memberships m ON m.tenant_uuid = t.uuid
WHERE m.user_uuid = ?`, user)
if err != nil {
return nil, err
}
defer r.Close()
l := make([]*Tenant, 0)
for r.Next() {... | go | func (db *DB) GetTenantsForUser(user string) ([]*Tenant, error) {
r, err := db.Query(`
SELECT t.uuid, t.name
FROM tenants t INNER JOIN memberships m ON m.tenant_uuid = t.uuid
WHERE m.user_uuid = ?`, user)
if err != nil {
return nil, err
}
defer r.Close()
l := make([]*Tenant, 0)
for r.Next() {... | [
"func",
"(",
"db",
"*",
"DB",
")",
"GetTenantsForUser",
"(",
"user",
"string",
")",
"(",
"[",
"]",
"*",
"Tenant",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"`\n\t SELECT t.uuid, t.name\n\t FROM tenants t INNER JOIN members... | //GetTenantsForUser given a user's uuid returns a slice of Tenants that the user has membership with | [
"GetTenantsForUser",
"given",
"a",
"user",
"s",
"uuid",
"returns",
"a",
"slice",
"of",
"Tenants",
"that",
"the",
"user",
"has",
"membership",
"with"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/db/memberships.go#L87-L109 |
133,352 | starkandwayne/shield | plugin/mysql/plugin.go | Backup | func (p MySQLPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
mysql, err := mysqlConnectionInfo(endpoint)
if err != nil {
return err
}
if mysql.Replica != "" {
mysql.Host = mysql.Replica
}
cmd := fmt.Sprintf("%s/mysqldump %s %s", mysql.Bin, mysql.Options, connectionString(mysql, true))
plugin.DEBUG("... | go | func (p MySQLPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
mysql, err := mysqlConnectionInfo(endpoint)
if err != nil {
return err
}
if mysql.Replica != "" {
mysql.Host = mysql.Replica
}
cmd := fmt.Sprintf("%s/mysqldump %s %s", mysql.Bin, mysql.Options, connectionString(mysql, true))
plugin.DEBUG("... | [
"func",
"(",
"p",
"MySQLPlugin",
")",
"Backup",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"mysql",
",",
"err",
":=",
"mysqlConnectionInfo",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // Backup mysql database | [
"Backup",
"mysql",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/mysql/plugin.go#L215-L229 |
133,353 | starkandwayne/shield | plugin/mysql/plugin.go | Restore | func (p MySQLPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
mysql, err := mysqlConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mysql %s", mysql.Bin, connectionString(mysql, false))
dbname, err := endpoint.StringValueDefault("mysql_database", "")
if err != nil {
return err... | go | func (p MySQLPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
mysql, err := mysqlConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mysql %s", mysql.Bin, connectionString(mysql, false))
dbname, err := endpoint.StringValueDefault("mysql_database", "")
if err != nil {
return err... | [
"func",
"(",
"p",
"MySQLPlugin",
")",
"Restore",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"mysql",
",",
"err",
":=",
"mysqlConnectionInfo",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // Restore mysql database | [
"Restore",
"mysql",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/mysql/plugin.go#L232-L249 |
133,354 | starkandwayne/shield | plugin/mongo/plugin.go | Backup | func (p MongoPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
mongo, err := mongoConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mongodump %s", mongo.Bin, connectionString(mongo, true))
plugin.DEBUG("Executing: `%s`", cmd)
return plugin.Exec(cmd, plugin.STDOUT)
} | go | func (p MongoPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
mongo, err := mongoConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mongodump %s", mongo.Bin, connectionString(mongo, true))
plugin.DEBUG("Executing: `%s`", cmd)
return plugin.Exec(cmd, plugin.STDOUT)
} | [
"func",
"(",
"p",
"MongoPlugin",
")",
"Backup",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"mongo",
",",
"err",
":=",
"mongoConnectionInfo",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // Backup mongo database | [
"Backup",
"mongo",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/mongo/plugin.go#L174-L183 |
133,355 | starkandwayne/shield | plugin/mongo/plugin.go | Restore | func (p MongoPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
mongo, err := mongoConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mongorestore %s", mongo.Bin, connectionString(mongo, false))
plugin.DEBUG("Exec: %s", cmd)
return plugin.Exec(cmd, plugin.STDIN)
} | go | func (p MongoPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
mongo, err := mongoConnectionInfo(endpoint)
if err != nil {
return err
}
cmd := fmt.Sprintf("%s/mongorestore %s", mongo.Bin, connectionString(mongo, false))
plugin.DEBUG("Exec: %s", cmd)
return plugin.Exec(cmd, plugin.STDIN)
} | [
"func",
"(",
"p",
"MongoPlugin",
")",
"Restore",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"mongo",
",",
"err",
":=",
"mongoConnectionInfo",
"(",
"endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // Restore mongo database | [
"Restore",
"mongo",
"database"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/mongo/plugin.go#L186-L195 |
133,356 | starkandwayne/shield | plugin/dummy/dummy.go | Backup | func (p DummyPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
data, err := endpoint.StringValue("data")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/echo %s", data), plugin.STDOUT)
} | go | func (p DummyPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
data, err := endpoint.StringValue("data")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/echo %s", data), plugin.STDOUT)
} | [
"func",
"(",
"p",
"DummyPlugin",
")",
"Backup",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"data",
",",
"err",
":=",
"endpoint",
".",
"StringValue",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // Called when you want to back data up. Examine the ShieldEndpoint passed in, and perform actions accordingly | [
"Called",
"when",
"you",
"want",
"to",
"back",
"data",
"up",
".",
"Examine",
"the",
"ShieldEndpoint",
"passed",
"in",
"and",
"perform",
"actions",
"accordingly"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/dummy/dummy.go#L71-L78 |
133,357 | starkandwayne/shield | plugin/dummy/dummy.go | Restore | func (p DummyPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
file, err := endpoint.StringValue("file")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s\"", file), plugin.STDIN)
} | go | func (p DummyPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
file, err := endpoint.StringValue("file")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s\"", file), plugin.STDIN)
} | [
"func",
"(",
"p",
"DummyPlugin",
")",
"Restore",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"error",
"{",
"file",
",",
"err",
":=",
"endpoint",
".",
"StringValue",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // Called when you want to restore data Examine the ShieldEndpoint passed in, and perform actions accordingly | [
"Called",
"when",
"you",
"want",
"to",
"restore",
"data",
"Examine",
"the",
"ShieldEndpoint",
"passed",
"in",
"and",
"perform",
"actions",
"accordingly"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/dummy/dummy.go#L81-L88 |
133,358 | starkandwayne/shield | plugin/dummy/dummy.go | Store | func (p DummyPlugin) Store(endpoint plugin.ShieldEndpoint) (string, int64, error) {
directory, err := endpoint.StringValue("directory")
if err != nil {
return "", 0, err
}
file := plugin.GenUUID()
err = plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s/%s\"", directory, file), plugin.STDIN)
info, e := os.St... | go | func (p DummyPlugin) Store(endpoint plugin.ShieldEndpoint) (string, int64, error) {
directory, err := endpoint.StringValue("directory")
if err != nil {
return "", 0, err
}
file := plugin.GenUUID()
err = plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s/%s\"", directory, file), plugin.STDIN)
info, e := os.St... | [
"func",
"(",
"p",
"DummyPlugin",
")",
"Store",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
")",
"(",
"string",
",",
"int64",
",",
"error",
")",
"{",
"directory",
",",
"err",
":=",
"endpoint",
".",
"StringValue",
"(",
"\"",
"\"",
")",
"\n",
"if",
... | // Called when you want to store backup data. Examine the ShieldEndpoint passed in, and perform actions accordingly | [
"Called",
"when",
"you",
"want",
"to",
"store",
"backup",
"data",
".",
"Examine",
"the",
"ShieldEndpoint",
"passed",
"in",
"and",
"perform",
"actions",
"accordingly"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/dummy/dummy.go#L91-L106 |
133,359 | starkandwayne/shield | plugin/dummy/dummy.go | Retrieve | func (p DummyPlugin) Retrieve(endpoint plugin.ShieldEndpoint, file string) error {
directory, err := endpoint.StringValue("directory")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/cat %s/%s", directory, file), plugin.STDOUT)
} | go | func (p DummyPlugin) Retrieve(endpoint plugin.ShieldEndpoint, file string) error {
directory, err := endpoint.StringValue("directory")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/cat %s/%s", directory, file), plugin.STDOUT)
} | [
"func",
"(",
"p",
"DummyPlugin",
")",
"Retrieve",
"(",
"endpoint",
"plugin",
".",
"ShieldEndpoint",
",",
"file",
"string",
")",
"error",
"{",
"directory",
",",
"err",
":=",
"endpoint",
".",
"StringValue",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
... | // Called when you want to retreive backup data. Examine the ShieldEndpoint passed in, and perform actions accordingly | [
"Called",
"when",
"you",
"want",
"to",
"retreive",
"backup",
"data",
".",
"Examine",
"the",
"ShieldEndpoint",
"passed",
"in",
"and",
"perform",
"actions",
"accordingly"
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/plugin/dummy/dummy.go#L109-L116 |
133,360 | starkandwayne/shield | route/request.go | NewRequest | func NewRequest(w http.ResponseWriter, r *http.Request, debug bool) *Request {
return &Request{
Req: r,
w: w,
debug: debug,
}
} | go | func NewRequest(w http.ResponseWriter, r *http.Request, debug bool) *Request {
return &Request{
Req: r,
w: w,
debug: debug,
}
} | [
"func",
"NewRequest",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"debug",
"bool",
")",
"*",
"Request",
"{",
"return",
"&",
"Request",
"{",
"Req",
":",
"r",
",",
"w",
":",
"w",
",",
"debug",
":",
"debug",
... | //NewRequest initializes and returns a new request object. Setting debug to
// true will cause errors to be logged. | [
"NewRequest",
"initializes",
"and",
"returns",
"a",
"new",
"request",
"object",
".",
"Setting",
"debug",
"to",
"true",
"will",
"cause",
"errors",
"to",
"be",
"logged",
"."
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/route/request.go#L30-L36 |
133,361 | starkandwayne/shield | route/request.go | Payload | func (r *Request) Payload(v interface{}) bool {
if r.Req.Body == nil {
r.Fail(Bad(nil, "no JSON input payload present in request"))
return false
}
if err := json.NewDecoder(r.Req.Body).Decode(v); err != nil && err != io.EOF {
r.Fail(Bad(err, "invalid JSON input payload present in request"))
return false
}
... | go | func (r *Request) Payload(v interface{}) bool {
if r.Req.Body == nil {
r.Fail(Bad(nil, "no JSON input payload present in request"))
return false
}
if err := json.NewDecoder(r.Req.Body).Decode(v); err != nil && err != io.EOF {
r.Fail(Bad(err, "invalid JSON input payload present in request"))
return false
}
... | [
"func",
"(",
"r",
"*",
"Request",
")",
"Payload",
"(",
"v",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"r",
".",
"Req",
".",
"Body",
"==",
"nil",
"{",
"r",
".",
"Fail",
"(",
"Bad",
"(",
"nil",
",",
"\"",
"\"",
")",
")",
"\n",
"return",
... | //Payload unmarshals the JSON body of this request into the given interface.
// Returns true if successful and false otherwise. | [
"Payload",
"unmarshals",
"the",
"JSON",
"body",
"of",
"this",
"request",
"into",
"the",
"given",
"interface",
".",
"Returns",
"true",
"if",
"successful",
"and",
"false",
"otherwise",
"."
] | db2b428270a4dd1a9999dc1f3589ce0eef407bb2 | https://github.com/starkandwayne/shield/blob/db2b428270a4dd1a9999dc1f3589ce0eef407bb2/route/request.go#L133-L145 |
133,362 | benbjohnson/ego | parse.go | ParseFile | func ParseFile(path string) (*Template, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Parse(f, path)
} | go | func ParseFile(path string) (*Template, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Parse(f, path)
} | [
"func",
"ParseFile",
"(",
"path",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer... | // ParseFile parses an Ego template from a file. | [
"ParseFile",
"parses",
"an",
"Ego",
"template",
"from",
"a",
"file",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/parse.go#L9-L16 |
133,363 | benbjohnson/ego | parse.go | Parse | func Parse(r io.Reader, path string) (*Template, error) {
s := NewScanner(r, path)
t := &Template{Path: path}
for {
blk, err := s.Scan()
if err == io.EOF {
break
} else if err != nil {
return nil, err
}
switch blk := blk.(type) {
case *ComponentStartBlock:
if err := parseComponentBlock(s, blk);... | go | func Parse(r io.Reader, path string) (*Template, error) {
s := NewScanner(r, path)
t := &Template{Path: path}
for {
blk, err := s.Scan()
if err == io.EOF {
break
} else if err != nil {
return nil, err
}
switch blk := blk.(type) {
case *ComponentStartBlock:
if err := parseComponentBlock(s, blk);... | [
"func",
"Parse",
"(",
"r",
"io",
".",
"Reader",
",",
"path",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"s",
":=",
"NewScanner",
"(",
"r",
",",
"path",
")",
"\n",
"t",
":=",
"&",
"Template",
"{",
"Path",
":",
"path",
"}",
"\n"... | // Parse parses an Ego template from a reader.
// The path specifies the path name used in the compiled template's pragmas. | [
"Parse",
"parses",
"an",
"Ego",
"template",
"from",
"a",
"reader",
".",
"The",
"path",
"specifies",
"the",
"path",
"name",
"used",
"in",
"the",
"compiled",
"template",
"s",
"pragmas",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/parse.go#L20-L48 |
133,364 | benbjohnson/ego | scanner.go | NewScanner | func NewScanner(r io.Reader, path string) *Scanner {
return &Scanner{
r: r,
pos: Pos{
Path: path,
LineNo: 1,
},
}
} | go | func NewScanner(r io.Reader, path string) *Scanner {
return &Scanner{
r: r,
pos: Pos{
Path: path,
LineNo: 1,
},
}
} | [
"func",
"NewScanner",
"(",
"r",
"io",
".",
"Reader",
",",
"path",
"string",
")",
"*",
"Scanner",
"{",
"return",
"&",
"Scanner",
"{",
"r",
":",
"r",
",",
"pos",
":",
"Pos",
"{",
"Path",
":",
"path",
",",
"LineNo",
":",
"1",
",",
"}",
",",
"}",
... | // NewScanner initializes a new scanner with a given reader. | [
"NewScanner",
"initializes",
"a",
"new",
"scanner",
"with",
"a",
"given",
"reader",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L26-L34 |
133,365 | benbjohnson/ego | scanner.go | Scan | func (s *Scanner) Scan() (Block, error) {
if err := s.init(); err != nil {
return nil, err
}
switch s.peek() {
case '<':
// Special handling for component/attr blocks.
if s.peekComponentStartBlock() {
return s.scanComponentStartBlock()
} else if s.peekComponentEndBlock() {
return s.scanComponentEndBl... | go | func (s *Scanner) Scan() (Block, error) {
if err := s.init(); err != nil {
return nil, err
}
switch s.peek() {
case '<':
// Special handling for component/attr blocks.
if s.peekComponentStartBlock() {
return s.scanComponentStartBlock()
} else if s.peekComponentEndBlock() {
return s.scanComponentEndBl... | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"Scan",
"(",
")",
"(",
"Block",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".",
"init",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"switch",
"s",
".",
... | // Scan returns the next block from the reader. | [
"Scan",
"returns",
"the",
"next",
"block",
"from",
"the",
"reader",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L37-L68 |
133,366 | benbjohnson/ego | scanner.go | scanContent | func (s *Scanner) scanContent() (string, error) {
var buf bytes.Buffer
for {
ch := s.read()
if ch == eof {
return "", &SyntaxError{Message: "Expected close tag, found EOF", Pos: s.pos}
} else if ch == '%' {
ch := s.read()
if ch == eof {
return "", &SyntaxError{Message: "Expected close tag, found EO... | go | func (s *Scanner) scanContent() (string, error) {
var buf bytes.Buffer
for {
ch := s.read()
if ch == eof {
return "", &SyntaxError{Message: "Expected close tag, found EOF", Pos: s.pos}
} else if ch == '%' {
ch := s.read()
if ch == eof {
return "", &SyntaxError{Message: "Expected close tag, found EO... | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"scanContent",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"{",
"ch",
":=",
"s",
".",
"read",
"(",
")",
"\n",
"if",
"ch",
"==",
"eof",
"{",
"return",... | // scans the reader until %> is reached. | [
"scans",
"the",
"reader",
"until",
"%",
">",
"is",
"reached",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L328-L349 |
133,367 | benbjohnson/ego | scanner.go | init | func (s *Scanner) init() (err error) {
if s.b != nil {
return nil
}
s.b, err = ioutil.ReadAll(s.r)
return err
} | go | func (s *Scanner) init() (err error) {
if s.b != nil {
return nil
}
s.b, err = ioutil.ReadAll(s.r)
return err
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"init",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"s",
".",
"b",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"s",
".",
"b",
",",
"err",
"=",
"ioutil",
".",
"ReadAll",
"(",
"s",
".",
"r",
... | // init slurps the reader on first scan. | [
"init",
"slurps",
"the",
"reader",
"on",
"first",
"scan",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L513-L519 |
133,368 | benbjohnson/ego | scanner.go | read | func (s *Scanner) read() rune {
if s.i >= len(s.b) {
return eof
}
ch, n := utf8.DecodeRune(s.b[s.i:])
s.i += n
if ch == '\n' {
s.pos.LineNo++
}
return ch
} | go | func (s *Scanner) read() rune {
if s.i >= len(s.b) {
return eof
}
ch, n := utf8.DecodeRune(s.b[s.i:])
s.i += n
if ch == '\n' {
s.pos.LineNo++
}
return ch
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"read",
"(",
")",
"rune",
"{",
"if",
"s",
".",
"i",
">=",
"len",
"(",
"s",
".",
"b",
")",
"{",
"return",
"eof",
"\n",
"}",
"\n\n",
"ch",
",",
"n",
":=",
"utf8",
".",
"DecodeRune",
"(",
"s",
".",
"b",
... | // read reads the next rune and moves the position forward. | [
"read",
"reads",
"the",
"next",
"rune",
"and",
"moves",
"the",
"position",
"forward",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L522-L534 |
133,369 | benbjohnson/ego | scanner.go | readN | func (s *Scanner) readN(n int) string {
var buf bytes.Buffer
for i := 0; i < n; i++ {
ch := s.read()
if ch == eof {
break
}
buf.WriteRune(ch)
}
return buf.String()
} | go | func (s *Scanner) readN(n int) string {
var buf bytes.Buffer
for i := 0; i < n; i++ {
ch := s.read()
if ch == eof {
break
}
buf.WriteRune(ch)
}
return buf.String()
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"readN",
"(",
"n",
"int",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"ch",
":=",
"s",
".",
"read",
"(",
")",
"\n",
... | // readN reads the next n characters and moves the position forward. | [
"readN",
"reads",
"the",
"next",
"n",
"characters",
"and",
"moves",
"the",
"position",
"forward",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L537-L547 |
133,370 | benbjohnson/ego | scanner.go | peek | func (s *Scanner) peek() rune {
if s.i >= len(s.b) {
return eof
}
ch, _ := utf8.DecodeRune(s.b[s.i:])
return ch
} | go | func (s *Scanner) peek() rune {
if s.i >= len(s.b) {
return eof
}
ch, _ := utf8.DecodeRune(s.b[s.i:])
return ch
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"peek",
"(",
")",
"rune",
"{",
"if",
"s",
".",
"i",
">=",
"len",
"(",
"s",
".",
"b",
")",
"{",
"return",
"eof",
"\n",
"}",
"\n",
"ch",
",",
"_",
":=",
"utf8",
".",
"DecodeRune",
"(",
"s",
".",
"b",
"... | // peek reads the next rune but does not move the position forward. | [
"peek",
"reads",
"the",
"next",
"rune",
"but",
"does",
"not",
"move",
"the",
"position",
"forward",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L550-L556 |
133,371 | benbjohnson/ego | scanner.go | peekN | func (s *Scanner) peekN(n int) string {
if s.i >= len(s.b) {
return ""
}
b := s.b[s.i:]
var buf bytes.Buffer
for i := 0; i < n && len(b) > 0; i++ {
ch, sz := utf8.DecodeRune(b)
b = b[sz:]
buf.WriteRune(ch)
}
return buf.String()
} | go | func (s *Scanner) peekN(n int) string {
if s.i >= len(s.b) {
return ""
}
b := s.b[s.i:]
var buf bytes.Buffer
for i := 0; i < n && len(b) > 0; i++ {
ch, sz := utf8.DecodeRune(b)
b = b[sz:]
buf.WriteRune(ch)
}
return buf.String()
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"peekN",
"(",
"n",
"int",
")",
"string",
"{",
"if",
"s",
".",
"i",
">=",
"len",
"(",
"s",
".",
"b",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"b",
":=",
"s",
".",
"b",
"[",
"s",
".",
"i",
":... | // peekN reads the next n runes but does not move the position forward. | [
"peekN",
"reads",
"the",
"next",
"n",
"runes",
"but",
"does",
"not",
"move",
"the",
"position",
"forward",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L559-L572 |
133,372 | benbjohnson/ego | scanner.go | peekIgnoreWhitespace | func (s *Scanner) peekIgnoreWhitespace() rune {
var b []byte
if s.i < len(s.b) {
b = s.b[s.i:]
}
for i := 0; ; i++ {
if len(b) == 0 {
return eof
}
ch, sz := utf8.DecodeRune(b)
if !isWhitespace(ch) {
return ch
}
b = b[sz:]
}
} | go | func (s *Scanner) peekIgnoreWhitespace() rune {
var b []byte
if s.i < len(s.b) {
b = s.b[s.i:]
}
for i := 0; ; i++ {
if len(b) == 0 {
return eof
}
ch, sz := utf8.DecodeRune(b)
if !isWhitespace(ch) {
return ch
}
b = b[sz:]
}
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"peekIgnoreWhitespace",
"(",
")",
"rune",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"if",
"s",
".",
"i",
"<",
"len",
"(",
"s",
".",
"b",
")",
"{",
"b",
"=",
"s",
".",
"b",
"[",
"s",
".",
"i",
":",
"]"... | // peekIgnoreWhitespace reads the non-whitespace rune. | [
"peekIgnoreWhitespace",
"reads",
"the",
"non",
"-",
"whitespace",
"rune",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/scanner.go#L575-L593 |
133,373 | benbjohnson/ego | ego.go | WriteTo | func (t *Template) WriteTo(w io.Writer) (n int64, err error) {
var buf bytes.Buffer
// Write "generated" header comment.
buf.WriteString("// Generated by ego.\n")
buf.WriteString("// DO NOT EDIT\n\n")
// Write blocks.
writeBlocksTo(&buf, t.Blocks)
// Parse buffer as a Go file.
fset := token.NewFileSet()
f, ... | go | func (t *Template) WriteTo(w io.Writer) (n int64, err error) {
var buf bytes.Buffer
// Write "generated" header comment.
buf.WriteString("// Generated by ego.\n")
buf.WriteString("// DO NOT EDIT\n\n")
// Write blocks.
writeBlocksTo(&buf, t.Blocks)
// Parse buffer as a Go file.
fset := token.NewFileSet()
f, ... | [
"func",
"(",
"t",
"*",
"Template",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n\n",
"// Write \"generated\" header comment.",
"buf",
".",
"WriteString",
"(... | // WriteTo writes the template to a writer. | [
"WriteTo",
"writes",
"the",
"template",
"to",
"a",
"writer",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/ego.go#L24-L54 |
133,374 | benbjohnson/ego | ego.go | normalizeBlocks | func normalizeBlocks(a []Block) []Block {
a = joinAdjacentTextBlocks(a)
a = trimTrailingEmptyTextBlocks(a)
return a
} | go | func normalizeBlocks(a []Block) []Block {
a = joinAdjacentTextBlocks(a)
a = trimTrailingEmptyTextBlocks(a)
return a
} | [
"func",
"normalizeBlocks",
"(",
"a",
"[",
"]",
"Block",
")",
"[",
"]",
"Block",
"{",
"a",
"=",
"joinAdjacentTextBlocks",
"(",
"a",
")",
"\n",
"a",
"=",
"trimTrailingEmptyTextBlocks",
"(",
"a",
")",
"\n",
"return",
"a",
"\n",
"}"
] | // Normalize joins together adjacent text blocks. | [
"Normalize",
"joins",
"together",
"adjacent",
"text",
"blocks",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/ego.go#L114-L118 |
133,375 | benbjohnson/ego | ego.go | Position | func Position(blk Block) Pos {
switch blk := blk.(type) {
case *TextBlock:
return blk.Pos
case *CodeBlock:
return blk.Pos
case *PrintBlock:
return blk.Pos
case *RawPrintBlock:
return blk.Pos
case *ComponentStartBlock:
return blk.Pos
case *ComponentEndBlock:
return blk.Pos
case *AttrStartBlock:
ret... | go | func Position(blk Block) Pos {
switch blk := blk.(type) {
case *TextBlock:
return blk.Pos
case *CodeBlock:
return blk.Pos
case *PrintBlock:
return blk.Pos
case *RawPrintBlock:
return blk.Pos
case *ComponentStartBlock:
return blk.Pos
case *ComponentEndBlock:
return blk.Pos
case *AttrStartBlock:
ret... | [
"func",
"Position",
"(",
"blk",
"Block",
")",
"Pos",
"{",
"switch",
"blk",
":=",
"blk",
".",
"(",
"type",
")",
"{",
"case",
"*",
"TextBlock",
":",
"return",
"blk",
".",
"Pos",
"\n",
"case",
"*",
"CodeBlock",
":",
"return",
"blk",
".",
"Pos",
"\n",
... | // Position returns the position of the block. | [
"Position",
"returns",
"the",
"position",
"of",
"the",
"block",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/ego.go#L370-L391 |
133,376 | benbjohnson/ego | ego.go | AttrNames | func AttrNames(attrs map[string]interface{}) []string {
a := make([]string, 0, len(attrs))
for k := range attrs {
a = append(a, k)
}
sort.Strings(a)
return a
} | go | func AttrNames(attrs map[string]interface{}) []string {
a := make([]string, 0, len(attrs))
for k := range attrs {
a = append(a, k)
}
sort.Strings(a)
return a
} | [
"func",
"AttrNames",
"(",
"attrs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"a",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"attrs",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"attrs... | // AttrNames returns a sorted list of names for an attribute set. | [
"AttrNames",
"returns",
"a",
"sorted",
"list",
"of",
"names",
"for",
"an",
"attribute",
"set",
"."
] | 02c2902eb0157c2ffab350390e373ca00e4e84a1 | https://github.com/benbjohnson/ego/blob/02c2902eb0157c2ffab350390e373ca00e4e84a1/ego.go#L414-L421 |
133,377 | codahale/hdrhistogram | window.go | NewWindowed | func NewWindowed(n int, minValue, maxValue int64, sigfigs int) *WindowedHistogram {
w := WindowedHistogram{
idx: -1,
h: make([]Histogram, n),
m: New(minValue, maxValue, sigfigs),
}
for i := range w.h {
w.h[i] = *New(minValue, maxValue, sigfigs)
}
w.Rotate()
return &w
} | go | func NewWindowed(n int, minValue, maxValue int64, sigfigs int) *WindowedHistogram {
w := WindowedHistogram{
idx: -1,
h: make([]Histogram, n),
m: New(minValue, maxValue, sigfigs),
}
for i := range w.h {
w.h[i] = *New(minValue, maxValue, sigfigs)
}
w.Rotate()
return &w
} | [
"func",
"NewWindowed",
"(",
"n",
"int",
",",
"minValue",
",",
"maxValue",
"int64",
",",
"sigfigs",
"int",
")",
"*",
"WindowedHistogram",
"{",
"w",
":=",
"WindowedHistogram",
"{",
"idx",
":",
"-",
"1",
",",
"h",
":",
"make",
"(",
"[",
"]",
"Histogram",
... | // NewWindowed creates a new WindowedHistogram with N underlying histograms with
// the given parameters. | [
"NewWindowed",
"creates",
"a",
"new",
"WindowedHistogram",
"with",
"N",
"underlying",
"histograms",
"with",
"the",
"given",
"parameters",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/window.go#L14-L27 |
133,378 | codahale/hdrhistogram | window.go | Merge | func (w *WindowedHistogram) Merge() *Histogram {
w.m.Reset()
for _, h := range w.h {
w.m.Merge(&h)
}
return w.m
} | go | func (w *WindowedHistogram) Merge() *Histogram {
w.m.Reset()
for _, h := range w.h {
w.m.Merge(&h)
}
return w.m
} | [
"func",
"(",
"w",
"*",
"WindowedHistogram",
")",
"Merge",
"(",
")",
"*",
"Histogram",
"{",
"w",
".",
"m",
".",
"Reset",
"(",
")",
"\n",
"for",
"_",
",",
"h",
":=",
"range",
"w",
".",
"h",
"{",
"w",
".",
"m",
".",
"Merge",
"(",
"&",
"h",
")"... | // Merge returns a histogram which includes the recorded values from all the
// sections of the window. | [
"Merge",
"returns",
"a",
"histogram",
"which",
"includes",
"the",
"recorded",
"values",
"from",
"all",
"the",
"sections",
"of",
"the",
"window",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/window.go#L31-L37 |
133,379 | codahale/hdrhistogram | window.go | Rotate | func (w *WindowedHistogram) Rotate() {
w.idx++
w.Current = &w.h[w.idx%len(w.h)]
w.Current.Reset()
} | go | func (w *WindowedHistogram) Rotate() {
w.idx++
w.Current = &w.h[w.idx%len(w.h)]
w.Current.Reset()
} | [
"func",
"(",
"w",
"*",
"WindowedHistogram",
")",
"Rotate",
"(",
")",
"{",
"w",
".",
"idx",
"++",
"\n",
"w",
".",
"Current",
"=",
"&",
"w",
".",
"h",
"[",
"w",
".",
"idx",
"%",
"len",
"(",
"w",
".",
"h",
")",
"]",
"\n",
"w",
".",
"Current",
... | // Rotate resets the oldest histogram and rotates it to be used as the current
// histogram. | [
"Rotate",
"resets",
"the",
"oldest",
"histogram",
"and",
"rotates",
"it",
"to",
"be",
"used",
"as",
"the",
"current",
"histogram",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/window.go#L41-L45 |
133,380 | codahale/hdrhistogram | hdr.go | New | func New(minValue, maxValue int64, sigfigs int) *Histogram {
if sigfigs < 1 || 5 < sigfigs {
panic(fmt.Errorf("sigfigs must be [1,5] (was %d)", sigfigs))
}
largestValueWithSingleUnitResolution := 2 * math.Pow10(sigfigs)
subBucketCountMagnitude := int32(math.Ceil(math.Log2(float64(largestValueWithSingleUnitResolu... | go | func New(minValue, maxValue int64, sigfigs int) *Histogram {
if sigfigs < 1 || 5 < sigfigs {
panic(fmt.Errorf("sigfigs must be [1,5] (was %d)", sigfigs))
}
largestValueWithSingleUnitResolution := 2 * math.Pow10(sigfigs)
subBucketCountMagnitude := int32(math.Ceil(math.Log2(float64(largestValueWithSingleUnitResolu... | [
"func",
"New",
"(",
"minValue",
",",
"maxValue",
"int64",
",",
"sigfigs",
"int",
")",
"*",
"Histogram",
"{",
"if",
"sigfigs",
"<",
"1",
"||",
"5",
"<",
"sigfigs",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sigfigs",
")",
")",
... | // New returns a new Histogram instance capable of tracking values in the given
// range and with the given amount of precision. | [
"New",
"returns",
"a",
"new",
"Histogram",
"instance",
"capable",
"of",
"tracking",
"values",
"in",
"the",
"given",
"range",
"and",
"with",
"the",
"given",
"amount",
"of",
"precision",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L46-L96 |
133,381 | codahale/hdrhistogram | hdr.go | Merge | func (h *Histogram) Merge(from *Histogram) (dropped int64) {
i := from.rIterator()
for i.next() {
v := i.valueFromIdx
c := i.countAtIdx
if h.RecordValues(v, c) != nil {
dropped += c
}
}
return
} | go | func (h *Histogram) Merge(from *Histogram) (dropped int64) {
i := from.rIterator()
for i.next() {
v := i.valueFromIdx
c := i.countAtIdx
if h.RecordValues(v, c) != nil {
dropped += c
}
}
return
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Merge",
"(",
"from",
"*",
"Histogram",
")",
"(",
"dropped",
"int64",
")",
"{",
"i",
":=",
"from",
".",
"rIterator",
"(",
")",
"\n",
"for",
"i",
".",
"next",
"(",
")",
"{",
"v",
":=",
"i",
".",
"valueFro... | // Merge merges the data stored in the given histogram with the receiver,
// returning the number of recorded values which had to be dropped. | [
"Merge",
"merges",
"the",
"data",
"stored",
"in",
"the",
"given",
"histogram",
"with",
"the",
"receiver",
"returning",
"the",
"number",
"of",
"recorded",
"values",
"which",
"had",
"to",
"be",
"dropped",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L109-L121 |
133,382 | codahale/hdrhistogram | hdr.go | Max | func (h *Histogram) Max() int64 {
var max int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
max = i.highestEquivalentValue
}
}
return h.highestEquivalentValue(max)
} | go | func (h *Histogram) Max() int64 {
var max int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
max = i.highestEquivalentValue
}
}
return h.highestEquivalentValue(max)
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Max",
"(",
")",
"int64",
"{",
"var",
"max",
"int64",
"\n",
"i",
":=",
"h",
".",
"iterator",
"(",
")",
"\n",
"for",
"i",
".",
"next",
"(",
")",
"{",
"if",
"i",
".",
"countAtIdx",
"!=",
"0",
"{",
"max",... | // Max returns the approximate maximum recorded value. | [
"Max",
"returns",
"the",
"approximate",
"maximum",
"recorded",
"value",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L129-L138 |
133,383 | codahale/hdrhistogram | hdr.go | Min | func (h *Histogram) Min() int64 {
var min int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 && min == 0 {
min = i.highestEquivalentValue
break
}
}
return h.lowestEquivalentValue(min)
} | go | func (h *Histogram) Min() int64 {
var min int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 && min == 0 {
min = i.highestEquivalentValue
break
}
}
return h.lowestEquivalentValue(min)
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Min",
"(",
")",
"int64",
"{",
"var",
"min",
"int64",
"\n",
"i",
":=",
"h",
".",
"iterator",
"(",
")",
"\n",
"for",
"i",
".",
"next",
"(",
")",
"{",
"if",
"i",
".",
"countAtIdx",
"!=",
"0",
"&&",
"min"... | // Min returns the approximate minimum recorded value. | [
"Min",
"returns",
"the",
"approximate",
"minimum",
"recorded",
"value",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L141-L151 |
133,384 | codahale/hdrhistogram | hdr.go | Mean | func (h *Histogram) Mean() float64 {
if h.totalCount == 0 {
return 0
}
var total int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
total += i.countAtIdx * h.medianEquivalentValue(i.valueFromIdx)
}
}
return float64(total) / float64(h.totalCount)
} | go | func (h *Histogram) Mean() float64 {
if h.totalCount == 0 {
return 0
}
var total int64
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
total += i.countAtIdx * h.medianEquivalentValue(i.valueFromIdx)
}
}
return float64(total) / float64(h.totalCount)
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Mean",
"(",
")",
"float64",
"{",
"if",
"h",
".",
"totalCount",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"var",
"total",
"int64",
"\n",
"i",
":=",
"h",
".",
"iterator",
"(",
")",
"\n",
"for",
"i",... | // Mean returns the approximate arithmetic mean of the recorded values. | [
"Mean",
"returns",
"the",
"approximate",
"arithmetic",
"mean",
"of",
"the",
"recorded",
"values",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L154-L166 |
133,385 | codahale/hdrhistogram | hdr.go | StdDev | func (h *Histogram) StdDev() float64 {
if h.totalCount == 0 {
return 0
}
mean := h.Mean()
geometricDevTotal := 0.0
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
dev := float64(h.medianEquivalentValue(i.valueFromIdx)) - mean
geometricDevTotal += (dev * dev) * float64(i.countAtIdx)
}
}
re... | go | func (h *Histogram) StdDev() float64 {
if h.totalCount == 0 {
return 0
}
mean := h.Mean()
geometricDevTotal := 0.0
i := h.iterator()
for i.next() {
if i.countAtIdx != 0 {
dev := float64(h.medianEquivalentValue(i.valueFromIdx)) - mean
geometricDevTotal += (dev * dev) * float64(i.countAtIdx)
}
}
re... | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"StdDev",
"(",
")",
"float64",
"{",
"if",
"h",
".",
"totalCount",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"mean",
":=",
"h",
".",
"Mean",
"(",
")",
"\n",
"geometricDevTotal",
":=",
"0.0",
"\n\n",
... | // StdDev returns the approximate standard deviation of the recorded values. | [
"StdDev",
"returns",
"the",
"approximate",
"standard",
"deviation",
"of",
"the",
"recorded",
"values",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L169-L186 |
133,386 | codahale/hdrhistogram | hdr.go | Reset | func (h *Histogram) Reset() {
h.totalCount = 0
for i := range h.counts {
h.counts[i] = 0
}
} | go | func (h *Histogram) Reset() {
h.totalCount = 0
for i := range h.counts {
h.counts[i] = 0
}
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Reset",
"(",
")",
"{",
"h",
".",
"totalCount",
"=",
"0",
"\n",
"for",
"i",
":=",
"range",
"h",
".",
"counts",
"{",
"h",
".",
"counts",
"[",
"i",
"]",
"=",
"0",
"\n",
"}",
"\n",
"}"
] | // Reset deletes all recorded values and restores the histogram to its original
// state. | [
"Reset",
"deletes",
"all",
"recorded",
"values",
"and",
"restores",
"the",
"histogram",
"to",
"its",
"original",
"state",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L190-L195 |
133,387 | codahale/hdrhistogram | hdr.go | CumulativeDistribution | func (h *Histogram) CumulativeDistribution() []Bracket {
var result []Bracket
i := h.pIterator(1)
for i.next() {
result = append(result, Bracket{
Quantile: i.percentile,
Count: i.countToIdx,
ValueAt: i.highestEquivalentValue,
})
}
return result
} | go | func (h *Histogram) CumulativeDistribution() []Bracket {
var result []Bracket
i := h.pIterator(1)
for i.next() {
result = append(result, Bracket{
Quantile: i.percentile,
Count: i.countToIdx,
ValueAt: i.highestEquivalentValue,
})
}
return result
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"CumulativeDistribution",
"(",
")",
"[",
"]",
"Bracket",
"{",
"var",
"result",
"[",
"]",
"Bracket",
"\n\n",
"i",
":=",
"h",
".",
"pIterator",
"(",
"1",
")",
"\n",
"for",
"i",
".",
"next",
"(",
")",
"{",
"r... | // CumulativeDistribution returns an ordered list of brackets of the
// distribution of recorded values. | [
"CumulativeDistribution",
"returns",
"an",
"ordered",
"list",
"of",
"brackets",
"of",
"the",
"distribution",
"of",
"recorded",
"values",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L263-L276 |
133,388 | codahale/hdrhistogram | hdr.go | String | func (b Bar) String() string {
return fmt.Sprintf("%v, %v, %v\n", b.From, b.To, b.Count)
} | go | func (b Bar) String() string {
return fmt.Sprintf("%v, %v, %v\n", b.From, b.To, b.Count)
} | [
"func",
"(",
"b",
"Bar",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"b",
".",
"From",
",",
"b",
".",
"To",
",",
"b",
".",
"Count",
")",
"\n",
"}"
] | // Pretty print as csv for easy plotting | [
"Pretty",
"print",
"as",
"csv",
"for",
"easy",
"plotting"
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L302-L304 |
133,389 | codahale/hdrhistogram | hdr.go | Distribution | func (h *Histogram) Distribution() (result []Bar) {
i := h.iterator()
for i.next() {
result = append(result, Bar{
Count: i.countAtIdx,
From: h.lowestEquivalentValue(i.valueFromIdx),
To: i.highestEquivalentValue,
})
}
return result
} | go | func (h *Histogram) Distribution() (result []Bar) {
i := h.iterator()
for i.next() {
result = append(result, Bar{
Count: i.countAtIdx,
From: h.lowestEquivalentValue(i.valueFromIdx),
To: i.highestEquivalentValue,
})
}
return result
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Distribution",
"(",
")",
"(",
"result",
"[",
"]",
"Bar",
")",
"{",
"i",
":=",
"h",
".",
"iterator",
"(",
")",
"\n",
"for",
"i",
".",
"next",
"(",
")",
"{",
"result",
"=",
"append",
"(",
"result",
",",
... | // Distribution returns an ordered list of bars of the
// distribution of recorded values, counts can be normalized to a probability | [
"Distribution",
"returns",
"an",
"ordered",
"list",
"of",
"bars",
"of",
"the",
"distribution",
"of",
"recorded",
"values",
"counts",
"can",
"be",
"normalized",
"to",
"a",
"probability"
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L308-L319 |
133,390 | codahale/hdrhistogram | hdr.go | Export | func (h *Histogram) Export() *Snapshot {
return &Snapshot{
LowestTrackableValue: h.lowestTrackableValue,
HighestTrackableValue: h.highestTrackableValue,
SignificantFigures: h.significantFigures,
Counts: append([]int64(nil), h.counts...), // copy
}
} | go | func (h *Histogram) Export() *Snapshot {
return &Snapshot{
LowestTrackableValue: h.lowestTrackableValue,
HighestTrackableValue: h.highestTrackableValue,
SignificantFigures: h.significantFigures,
Counts: append([]int64(nil), h.counts...), // copy
}
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Export",
"(",
")",
"*",
"Snapshot",
"{",
"return",
"&",
"Snapshot",
"{",
"LowestTrackableValue",
":",
"h",
".",
"lowestTrackableValue",
",",
"HighestTrackableValue",
":",
"h",
".",
"highestTrackableValue",
",",
"Signif... | // Export returns a snapshot view of the Histogram. This can be later passed to
// Import to construct a new Histogram with the same state. | [
"Export",
"returns",
"a",
"snapshot",
"view",
"of",
"the",
"Histogram",
".",
"This",
"can",
"be",
"later",
"passed",
"to",
"Import",
"to",
"construct",
"a",
"new",
"Histogram",
"with",
"the",
"same",
"state",
"."
] | 3a0bb77429bd3a61596f5e8a3172445844342120 | https://github.com/codahale/hdrhistogram/blob/3a0bb77429bd3a61596f5e8a3172445844342120/hdr.go#L349-L356 |
133,391 | gin-contrib/secure | policy.go | newPolicy | func newPolicy(config Config) *policy {
policy := &policy{}
policy.loadConfig(config)
return policy
} | go | func newPolicy(config Config) *policy {
policy := &policy{}
policy.loadConfig(config)
return policy
} | [
"func",
"newPolicy",
"(",
"config",
"Config",
")",
"*",
"policy",
"{",
"policy",
":=",
"&",
"policy",
"{",
"}",
"\n",
"policy",
".",
"loadConfig",
"(",
"config",
")",
"\n",
"return",
"policy",
"\n",
"}"
] | // Constructs a new Policy instance with supplied options. | [
"Constructs",
"a",
"new",
"Policy",
"instance",
"with",
"supplied",
"options",
"."
] | f9a5befa61069cfea68e8b54d92ac2a0433de46f | https://github.com/gin-contrib/secure/blob/f9a5befa61069cfea68e8b54d92ac2a0433de46f/policy.go#L27-L31 |
133,392 | messagebird/go-rest-api | hlr/hlr.go | Read | func Read(c *messagebird.Client, id string) (*HLR, error) {
hlr := &HLR{}
if err := c.Request(hlr, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return hlr, nil
} | go | func Read(c *messagebird.Client, id string) (*HLR, error) {
hlr := &HLR{}
if err := c.Request(hlr, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return hlr, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"HLR",
",",
"error",
")",
"{",
"hlr",
":=",
"&",
"HLR",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"hlr",
",",
"http",
".",
"Me... | // Read looks up an existing HLR object for the specified id that was previously
// created by the NewHLR function. | [
"Read",
"looks",
"up",
"an",
"existing",
"HLR",
"object",
"for",
"the",
"specified",
"id",
"that",
"was",
"previously",
"created",
"by",
"the",
"NewHLR",
"function",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/hlr/hlr.go#L46-L53 |
133,393 | messagebird/go-rest-api | hlr/hlr.go | List | func List(c *messagebird.Client) (*HLRList, error) {
hlrList := &HLRList{}
if err := c.Request(hlrList, http.MethodGet, path, nil); err != nil {
return nil, err
}
return hlrList, nil
} | go | func List(c *messagebird.Client) (*HLRList, error) {
hlrList := &HLRList{}
if err := c.Request(hlrList, http.MethodGet, path, nil); err != nil {
return nil, err
}
return hlrList, nil
} | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
")",
"(",
"*",
"HLRList",
",",
"error",
")",
"{",
"hlrList",
":=",
"&",
"HLRList",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"hlrList",
",",
"http",
".",
"MethodGet",
... | // List all HLR objects that were previously created by the Create function. | [
"List",
"all",
"HLR",
"objects",
"that",
"were",
"previously",
"created",
"by",
"the",
"Create",
"function",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/hlr/hlr.go#L56-L63 |
133,394 | messagebird/go-rest-api | hlr/hlr.go | Create | func Create(c *messagebird.Client, msisdn string, reference string) (*HLR, error) {
requestData, err := requestDataForHLR(msisdn, reference)
if err != nil {
return nil, err
}
hlr := &HLR{}
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return hlr, nil
} | go | func Create(c *messagebird.Client, msisdn string, reference string) (*HLR, error) {
requestData, err := requestDataForHLR(msisdn, reference)
if err != nil {
return nil, err
}
hlr := &HLR{}
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return hlr, nil
} | [
"func",
"Create",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"msisdn",
"string",
",",
"reference",
"string",
")",
"(",
"*",
"HLR",
",",
"error",
")",
"{",
"requestData",
",",
"err",
":=",
"requestDataForHLR",
"(",
"msisdn",
",",
"reference",
")",
... | // Create creates a new HLR object. | [
"Create",
"creates",
"a",
"new",
"HLR",
"object",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/hlr/hlr.go#L66-L79 |
133,395 | messagebird/go-rest-api | balance/balance.go | Read | func Read(c *messagebird.Client) (*Balance, error) {
balance := &Balance{}
if err := c.Request(balance, http.MethodGet, path, nil); err != nil {
return nil, err
}
return balance, nil
} | go | func Read(c *messagebird.Client) (*Balance, error) {
balance := &Balance{}
if err := c.Request(balance, http.MethodGet, path, nil); err != nil {
return nil, err
}
return balance, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
")",
"(",
"*",
"Balance",
",",
"error",
")",
"{",
"balance",
":=",
"&",
"Balance",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"balance",
",",
"http",
".",
"MethodGet",
... | // Read returns the balance information for the account that is associated with
// the access key. | [
"Read",
"returns",
"the",
"balance",
"information",
"for",
"the",
"account",
"that",
"is",
"associated",
"with",
"the",
"access",
"key",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/balance/balance.go#L20-L27 |
133,396 | messagebird/go-rest-api | verify/verify.go | Create | func Create(c *messagebird.Client, recipient string, params *Params) (*Verify, error) {
requestData, err := requestDataForVerify(recipient, params)
if err != nil {
return nil, err
}
verify := &Verify{}
if err := c.Request(verify, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return ve... | go | func Create(c *messagebird.Client, recipient string, params *Params) (*Verify, error) {
requestData, err := requestDataForVerify(recipient, params)
if err != nil {
return nil, err
}
verify := &Verify{}
if err := c.Request(verify, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return ve... | [
"func",
"Create",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"recipient",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"Verify",
",",
"error",
")",
"{",
"requestData",
",",
"err",
":=",
"requestDataForVerify",
"(",
"recipient",
",",
"par... | // Create generates a new One-Time-Password for one recipient. | [
"Create",
"generates",
"a",
"new",
"One",
"-",
"Time",
"-",
"Password",
"for",
"one",
"recipient",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/verify/verify.go#L56-L68 |
133,397 | messagebird/go-rest-api | verify/verify.go | Delete | func Delete(c *messagebird.Client, id string) error {
return c.Request(nil, http.MethodDelete, path+"/"+id, nil)
} | go | func Delete(c *messagebird.Client, id string) error {
return c.Request(nil, http.MethodDelete, path+"/"+id, nil)
} | [
"func",
"Delete",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Request",
"(",
"nil",
",",
"http",
".",
"MethodDelete",
",",
"path",
"+",
"\"",
"\"",
"+",
"id",
",",
"nil",
")",
"\n",
"}... | // Delete deletes an existing Verify object by its ID. | [
"Delete",
"deletes",
"an",
"existing",
"Verify",
"object",
"by",
"its",
"ID",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/verify/verify.go#L71-L73 |
133,398 | messagebird/go-rest-api | verify/verify.go | Read | func Read(c *messagebird.Client, id string) (*Verify, error) {
verify := &Verify{}
if err := c.Request(verify, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return verify, nil
} | go | func Read(c *messagebird.Client, id string) (*Verify, error) {
verify := &Verify{}
if err := c.Request(verify, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return verify, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Verify",
",",
"error",
")",
"{",
"verify",
":=",
"&",
"Verify",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"verify",
",",
"http"... | // Read retrieves an existing Verify object by its ID. | [
"Read",
"retrieves",
"an",
"existing",
"Verify",
"object",
"by",
"its",
"ID",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/verify/verify.go#L76-L84 |
133,399 | messagebird/go-rest-api | verify/verify.go | VerifyToken | func VerifyToken(c *messagebird.Client, id, token string) (*Verify, error) {
params := &url.Values{}
params.Set("token", token)
pathWithParams := path + "/" + id + "?" + params.Encode()
verify := &Verify{}
if err := c.Request(verify, http.MethodGet, pathWithParams, nil); err != nil {
return nil, err
}
retur... | go | func VerifyToken(c *messagebird.Client, id, token string) (*Verify, error) {
params := &url.Values{}
params.Set("token", token)
pathWithParams := path + "/" + id + "?" + params.Encode()
verify := &Verify{}
if err := c.Request(verify, http.MethodGet, pathWithParams, nil); err != nil {
return nil, err
}
retur... | [
"func",
"VerifyToken",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
",",
"token",
"string",
")",
"(",
"*",
"Verify",
",",
"error",
")",
"{",
"params",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n",
"params",
".",
"Set",
"(",
"\"",
"\... | // VerifyToken performs token value check against MessageBird API. | [
"VerifyToken",
"performs",
"token",
"value",
"check",
"against",
"MessageBird",
"API",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/verify/verify.go#L87-L99 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.