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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
126,800 | ligato/cn-infra | examples/tutorials/06_plugin_lookup/plugin2.go | RegisterWorld | func (p *HelloUniverse) RegisterWorld(name string, size int) {
p.worlds[name] = size
log.Printf("World %s (size %d) was registered", name, size)
} | go | func (p *HelloUniverse) RegisterWorld(name string, size int) {
p.worlds[name] = size
log.Printf("World %s (size %d) was registered", name, size)
} | [
"func",
"(",
"p",
"*",
"HelloUniverse",
")",
"RegisterWorld",
"(",
"name",
"string",
",",
"size",
"int",
")",
"{",
"p",
".",
"worlds",
"[",
"name",
"]",
"=",
"size",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"name",
",",
"size",
")",
"\n"... | // RegisterWorld is exported for other plugins to use | [
"RegisterWorld",
"is",
"exported",
"for",
"other",
"plugins",
"to",
"use"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/tutorials/06_plugin_lookup/plugin2.go#L39-L42 |
126,801 | ligato/cn-infra | utils/safeclose/safeclose.go | safeClose | func safeClose(obj interface{}) error {
defer func() {
if r := recover(); r != nil {
logrus.DefaultLogger().Error("Recovered in safeclose: ", r)
}
}()
// closerWithoutErr is similar interface to io.Closer, but Close() does not return error
type closerWithoutErr interface {
Close()
}
if val := reflect.V... | go | func safeClose(obj interface{}) error {
defer func() {
if r := recover(); r != nil {
logrus.DefaultLogger().Error("Recovered in safeclose: ", r)
}
}()
// closerWithoutErr is similar interface to io.Closer, but Close() does not return error
type closerWithoutErr interface {
Close()
}
if val := reflect.V... | [
"func",
"safeClose",
"(",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"logrus",
".",
"DefaultLogger",
"(",
")",
".",
"Error",
"(",
"\"",
"\"",
... | // safeClose closes closable object. | [
"safeClose",
"closes",
"closable",
"object",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/utils/safeclose/safeclose.go#L26-L62 |
126,802 | ligato/cn-infra | utils/safeclose/safeclose.go | Close | func Close(objs ...interface{}) error {
errs := make([]error, len(objs))
for i, obj := range objs {
errs[i] = safeClose(obj)
}
for _, err := range errs {
if err != nil {
return CloseErrors(errs)
}
}
return nil
} | go | func Close(objs ...interface{}) error {
errs := make([]error, len(objs))
for i, obj := range objs {
errs[i] = safeClose(obj)
}
for _, err := range errs {
if err != nil {
return CloseErrors(errs)
}
}
return nil
} | [
"func",
"Close",
"(",
"objs",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"errs",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"len",
"(",
"objs",
")",
")",
"\n\n",
"for",
"i",
",",
"obj",
":=",
"range",
"objs",
"{",
"errs",
"[",
"i",
"]",
... | // Close tries to close all objects and return all errors using CloseErrors if there are any. | [
"Close",
"tries",
"to",
"close",
"all",
"objects",
"and",
"return",
"all",
"errors",
"using",
"CloseErrors",
"if",
"there",
"are",
"any",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/utils/safeclose/safeclose.go#L65-L79 |
126,803 | ligato/cn-infra | examples/redis-lib/airport/airport.go | main | func main() {
var debug bool
var redisConfigPath string
// init example flags
flag.BoolVar(&debug, "debug", false, "Enable debugging")
flag.StringVar(&redisConfigPath, "redis-config", "", "Redis configuration file path")
flag.Parse()
log := logrus.DefaultLogger()
if debug {
log.SetLevel(logging.DebugLevel)
... | go | func main() {
var debug bool
var redisConfigPath string
// init example flags
flag.BoolVar(&debug, "debug", false, "Enable debugging")
flag.StringVar(&redisConfigPath, "redis-config", "", "Redis configuration file path")
flag.Parse()
log := logrus.DefaultLogger()
if debug {
log.SetLevel(logging.DebugLevel)
... | [
"func",
"main",
"(",
")",
"{",
"var",
"debug",
"bool",
"\n",
"var",
"redisConfigPath",
"string",
"\n\n",
"// init example flags",
"flag",
".",
"BoolVar",
"(",
"&",
"debug",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"flag",
".",
"String... | // Initialize airport and start serving | [
"Initialize",
"airport",
"and",
"start",
"serving"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/airport/airport.go#L161-L198 |
126,804 | ligato/cn-infra | examples/redis-lib/airport/airport.go | init | func (a *Airport) init(config interface{}, doneChan chan struct{}) (err error) {
a.log.Info("Airport redis example. If you need more info about what is happening, run example with -debug=true")
rand.Seed(time.Now().UnixNano())
printHeaders()
setupFlightStatusFormat()
// prepare client to connect to the redis DB... | go | func (a *Airport) init(config interface{}, doneChan chan struct{}) (err error) {
a.log.Info("Airport redis example. If you need more info about what is happening, run example with -debug=true")
rand.Seed(time.Now().UnixNano())
printHeaders()
setupFlightStatusFormat()
// prepare client to connect to the redis DB... | [
"func",
"(",
"a",
"*",
"Airport",
")",
"init",
"(",
"config",
"interface",
"{",
"}",
",",
"doneChan",
"chan",
"struct",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"a",
".",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"rand",
".",
"Seed... | // Set all required brokers, watchers, prepare redis connection | [
"Set",
"all",
"required",
"brokers",
"watchers",
"prepare",
"redis",
"connection"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/airport/airport.go#L201-L247 |
126,805 | ligato/cn-infra | examples/redis-lib/airport/airport.go | processArrivals | func (a *Airport) processArrivals() {
for {
arrival, ok := <-a.arrivalChan
if !ok {
a.log.Errorf("arrival channel closed")
return
}
switch arrival.GetChangeType() {
case datasync.Put:
fl := flight.Info{}
if err := arrival.GetValue(&fl); err != nil {
a.log.Errorf("failed to get value for arriv... | go | func (a *Airport) processArrivals() {
for {
arrival, ok := <-a.arrivalChan
if !ok {
a.log.Errorf("arrival channel closed")
return
}
switch arrival.GetChangeType() {
case datasync.Put:
fl := flight.Info{}
if err := arrival.GetValue(&fl); err != nil {
a.log.Errorf("failed to get value for arriv... | [
"func",
"(",
"a",
"*",
"Airport",
")",
"processArrivals",
"(",
")",
"{",
"for",
"{",
"arrival",
",",
"ok",
":=",
"<-",
"a",
".",
"arrivalChan",
"\n",
"if",
"!",
"ok",
"{",
"a",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\... | // Wait for arrivals. Incoming flights are set to 'arrival' status and sent to runway. | [
"Wait",
"for",
"arrivals",
".",
"Incoming",
"flights",
"are",
"set",
"to",
"arrival",
"status",
"and",
"sent",
"to",
"runway",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/airport/airport.go#L295-L315 |
126,806 | ligato/cn-infra | examples/redis-lib/airport/airport.go | processDepartures | func (a *Airport) processDepartures() {
for {
departure, ok := <-a.departureChan
if !ok {
a.log.Errorf("departure channel closed")
return
}
switch departure.GetChangeType() {
case datasync.Put:
fl := flight.Info{}
if err := departure.GetValue(&fl); err != nil {
a.log.Errorf("failed to get val... | go | func (a *Airport) processDepartures() {
for {
departure, ok := <-a.departureChan
if !ok {
a.log.Errorf("departure channel closed")
return
}
switch departure.GetChangeType() {
case datasync.Put:
fl := flight.Info{}
if err := departure.GetValue(&fl); err != nil {
a.log.Errorf("failed to get val... | [
"func",
"(",
"a",
"*",
"Airport",
")",
"processDepartures",
"(",
")",
"{",
"for",
"{",
"departure",
",",
"ok",
":=",
"<-",
"a",
".",
"departureChan",
"\n",
"if",
"!",
"ok",
"{",
"a",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return"... | // Wait for departures. Outgoing flights are set to 'departure' and sent to runway | [
"Wait",
"for",
"departures",
".",
"Outgoing",
"flights",
"are",
"set",
"to",
"departure",
"and",
"sent",
"to",
"runway"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/airport/airport.go#L318-L338 |
126,807 | ligato/cn-infra | examples/redis-lib/airport/airport.go | processHangar | func (a *Airport) processHangar() {
for {
hangar, ok := <-a.hangarChan
if !ok {
a.log.Errorf("hangar channel closed")
return
}
switch hangar.GetChangeType() {
case datasync.Put:
a.log.Debugf("hangar %s updated", hangar.GetKey())
case datasync.Delete:
fl := flight.Info{}
if _, err := fmt.Ssca... | go | func (a *Airport) processHangar() {
for {
hangar, ok := <-a.hangarChan
if !ok {
a.log.Errorf("hangar channel closed")
return
}
switch hangar.GetChangeType() {
case datasync.Put:
a.log.Debugf("hangar %s updated", hangar.GetKey())
case datasync.Delete:
fl := flight.Info{}
if _, err := fmt.Ssca... | [
"func",
"(",
"a",
"*",
"Airport",
")",
"processHangar",
"(",
")",
"{",
"for",
"{",
"hangar",
",",
"ok",
":=",
"<-",
"a",
".",
"hangarChan",
"\n",
"if",
"!",
"ok",
"{",
"a",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
... | // Wait for hangar. Incoming flights are stored, outgoing are sent to departure. | [
"Wait",
"for",
"hangar",
".",
"Incoming",
"flights",
"are",
"stored",
"outgoing",
"are",
"sent",
"to",
"departure",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/airport/airport.go#L341-L363 |
126,808 | ligato/cn-infra | datasync/syncbase/msg/change_event.go | Done | func (ev *ChangeEvent) Done(err error) {
//TODO publish response to the topic
if err != nil {
logrus.DefaultLogger().Error(err)
}
} | go | func (ev *ChangeEvent) Done(err error) {
//TODO publish response to the topic
if err != nil {
logrus.DefaultLogger().Error(err)
}
} | [
"func",
"(",
"ev",
"*",
"ChangeEvent",
")",
"Done",
"(",
"err",
"error",
")",
"{",
"//TODO publish response to the topic",
"if",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"DefaultLogger",
"(",
")",
".",
"Error",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // Done does nothing yet. | [
"Done",
"does",
"nothing",
"yet",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/syncbase/msg/change_event.go#L57-L62 |
126,809 | ligato/cn-infra | datasync/syncbase/msg/change_event.go | GetChangeType | func (ev *ChangeWatchResp) GetChangeType() datasync.Op {
if ev.message.OperationType == PutDel_DEL {
return datasync.Delete
}
return datasync.Put
} | go | func (ev *ChangeWatchResp) GetChangeType() datasync.Op {
if ev.message.OperationType == PutDel_DEL {
return datasync.Delete
}
return datasync.Put
} | [
"func",
"(",
"ev",
"*",
"ChangeWatchResp",
")",
"GetChangeType",
"(",
")",
"datasync",
".",
"Op",
"{",
"if",
"ev",
".",
"message",
".",
"OperationType",
"==",
"PutDel_DEL",
"{",
"return",
"datasync",
".",
"Delete",
"\n",
"}",
"\n\n",
"return",
"datasync",
... | // GetChangeType - see the comment in implemented interface datasync.ChangeEvent. | [
"GetChangeType",
"-",
"see",
"the",
"comment",
"in",
"implemented",
"interface",
"datasync",
".",
"ChangeEvent",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/syncbase/msg/change_event.go#L70-L76 |
126,810 | ligato/cn-infra | datasync/syncbase/msg/change_event.go | GetValue | func (ev *ChangeWatchResp) GetValue(val proto.Message) error {
return json.Unmarshal(ev.message.Content, val) //TODO use contentType...
} | go | func (ev *ChangeWatchResp) GetValue(val proto.Message) error {
return json.Unmarshal(ev.message.Content, val) //TODO use contentType...
} | [
"func",
"(",
"ev",
"*",
"ChangeWatchResp",
")",
"GetValue",
"(",
"val",
"proto",
".",
"Message",
")",
"error",
"{",
"return",
"json",
".",
"Unmarshal",
"(",
"ev",
".",
"message",
".",
"Content",
",",
"val",
")",
"//TODO use contentType...",
"\n",
"}"
] | // GetValue - see the comments in the interface datasync.ChangeEvent. | [
"GetValue",
"-",
"see",
"the",
"comments",
"in",
"the",
"interface",
"datasync",
".",
"ChangeEvent",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/syncbase/msg/change_event.go#L89-L91 |
126,811 | ligato/cn-infra | datasync/grpcsync/grpc_watcher.go | NewAdapter | func NewAdapter(grpcServer *grpc.Server) *Adapter {
//TODO grpcServer.RegisterCodec(json.NewCodec(), "application/json")
adapter := &Adapter{
base: syncbase.NewRegistry(),
server: grpcServer,
}
msg.RegisterDataMsgServiceServer(grpcServer, &DataMsgServiceServer{adapter})
return adapter
} | go | func NewAdapter(grpcServer *grpc.Server) *Adapter {
//TODO grpcServer.RegisterCodec(json.NewCodec(), "application/json")
adapter := &Adapter{
base: syncbase.NewRegistry(),
server: grpcServer,
}
msg.RegisterDataMsgServiceServer(grpcServer, &DataMsgServiceServer{adapter})
return adapter
} | [
"func",
"NewAdapter",
"(",
"grpcServer",
"*",
"grpc",
".",
"Server",
")",
"*",
"Adapter",
"{",
"//TODO grpcServer.RegisterCodec(json.NewCodec(), \"application/json\")",
"adapter",
":=",
"&",
"Adapter",
"{",
"base",
":",
"syncbase",
".",
"NewRegistry",
"(",
")",
",",... | // NewAdapter creates a new instance of Adapter. | [
"NewAdapter",
"creates",
"a",
"new",
"instance",
"of",
"Adapter",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/grpcsync/grpc_watcher.go#L35-L44 |
126,812 | ligato/cn-infra | examples/redis-lib/simple/simple.go | Close | func (sr *SimpleRedis) Close() error {
return safeclose.Close(sr.client, sr.respChan, sr.closeChan)
} | go | func (sr *SimpleRedis) Close() error {
return safeclose.Close(sr.client, sr.respChan, sr.closeChan)
} | [
"func",
"(",
"sr",
"*",
"SimpleRedis",
")",
"Close",
"(",
")",
"error",
"{",
"return",
"safeclose",
".",
"Close",
"(",
"sr",
".",
"client",
",",
"sr",
".",
"respChan",
",",
"sr",
".",
"closeChan",
")",
"\n",
"}"
] | // Close close the redis client and watcher channels | [
"Close",
"close",
"the",
"redis",
"client",
"and",
"watcher",
"channels"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/redis-lib/simple/simple.go#L221-L223 |
126,813 | ligato/cn-infra | datasync/kvdbsync/options.go | UseKV | func UseKV(kv keyval.KvProtoPlugin) Option {
return func(p *Plugin) {
p.KvPlugin = kv
}
} | go | func UseKV(kv keyval.KvProtoPlugin) Option {
return func(p *Plugin) {
p.KvPlugin = kv
}
} | [
"func",
"UseKV",
"(",
"kv",
"keyval",
".",
"KvProtoPlugin",
")",
"Option",
"{",
"return",
"func",
"(",
"p",
"*",
"Plugin",
")",
"{",
"p",
".",
"KvPlugin",
"=",
"kv",
"\n",
"}",
"\n",
"}"
] | // UseKV returns Option that sets KvPlugin dependency. | [
"UseKV",
"returns",
"Option",
"that",
"sets",
"KvPlugin",
"dependency",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/options.go#L62-L66 |
126,814 | ligato/cn-infra | db/keyval/kvproto/proto_watcher_impl.go | GetValue | func (wr *protoWatchResp) GetValue(msg proto.Message) error {
return wr.serializer.Unmarshal(wr.BytesWatchResp.GetValue(), msg)
} | go | func (wr *protoWatchResp) GetValue(msg proto.Message) error {
return wr.serializer.Unmarshal(wr.BytesWatchResp.GetValue(), msg)
} | [
"func",
"(",
"wr",
"*",
"protoWatchResp",
")",
"GetValue",
"(",
"msg",
"proto",
".",
"Message",
")",
"error",
"{",
"return",
"wr",
".",
"serializer",
".",
"Unmarshal",
"(",
"wr",
".",
"BytesWatchResp",
".",
"GetValue",
"(",
")",
",",
"msg",
")",
"\n",
... | // GetValue returns the value after the change. | [
"GetValue",
"returns",
"the",
"value",
"after",
"the",
"change",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/kvproto/proto_watcher_impl.go#L53-L55 |
126,815 | ligato/cn-infra | db/keyval/kvproto/proto_watcher_impl.go | GetPrevValue | func (wr *protoWatchResp) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
prevVal := wr.BytesWatchResp.GetPrevValue()
if prevVal == nil {
return false, nil
}
err = wr.serializer.Unmarshal(prevVal, msg)
if err != nil {
return true, err
}
return true, nil
} | go | func (wr *protoWatchResp) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
prevVal := wr.BytesWatchResp.GetPrevValue()
if prevVal == nil {
return false, nil
}
err = wr.serializer.Unmarshal(prevVal, msg)
if err != nil {
return true, err
}
return true, nil
} | [
"func",
"(",
"wr",
"*",
"protoWatchResp",
")",
"GetPrevValue",
"(",
"msg",
"proto",
".",
"Message",
")",
"(",
"prevValueExist",
"bool",
",",
"err",
"error",
")",
"{",
"prevVal",
":=",
"wr",
".",
"BytesWatchResp",
".",
"GetPrevValue",
"(",
")",
"\n",
"if"... | // GetPrevValue returns the previous value after the change. | [
"GetPrevValue",
"returns",
"the",
"previous",
"value",
"after",
"the",
"change",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/kvproto/proto_watcher_impl.go#L58-L68 |
126,816 | ligato/cn-infra | processmanager/status/status.go | ReadStatusFromFile | func (r *Reader) ReadStatusFromFile(file *os.File) *File {
return r.parse(file)
} | go | func (r *Reader) ReadStatusFromFile(file *os.File) *File {
return r.parse(file)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"ReadStatusFromFile",
"(",
"file",
"*",
"os",
".",
"File",
")",
"*",
"File",
"{",
"return",
"r",
".",
"parse",
"(",
"file",
")",
"\n",
"}"
] | // ReadStatusFromFile allows to eventually read status from custom location and parse it directly | [
"ReadStatusFromFile",
"allows",
"to",
"eventually",
"read",
"status",
"from",
"custom",
"location",
"and",
"parse",
"it",
"directly"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/status/status.go#L136-L138 |
126,817 | ligato/cn-infra | processmanager/status/status.go | toInt | func (r *Reader) toInt(input string) int {
result, err := strconv.Atoi(prune(input))
if err != nil {
return -1
}
return result
} | go | func (r *Reader) toInt(input string) int {
result, err := strconv.Atoi(prune(input))
if err != nil {
return -1
}
return result
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"toInt",
"(",
"input",
"string",
")",
"int",
"{",
"result",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"prune",
"(",
"input",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
"\n",
"}"... | // This method should save a few lines, converting provided string to int while error is logged but not returned | [
"This",
"method",
"should",
"save",
"a",
"few",
"lines",
"converting",
"provided",
"string",
"to",
"int",
"while",
"error",
"is",
"logged",
"but",
"not",
"returned"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/status/status.go#L282-L288 |
126,818 | ligato/cn-infra | datasync/kvdbsync/local/local_proto_txn.go | NewProtoTxn | func NewProtoTxn(commit func(context.Context, map[string]datasync.ChangeValue) error) *ProtoTxn {
return &ProtoTxn{
items: make(map[string]*protoTxnItem),
commit: commit,
}
} | go | func NewProtoTxn(commit func(context.Context, map[string]datasync.ChangeValue) error) *ProtoTxn {
return &ProtoTxn{
items: make(map[string]*protoTxnItem),
commit: commit,
}
} | [
"func",
"NewProtoTxn",
"(",
"commit",
"func",
"(",
"context",
".",
"Context",
",",
"map",
"[",
"string",
"]",
"datasync",
".",
"ChangeValue",
")",
"error",
")",
"*",
"ProtoTxn",
"{",
"return",
"&",
"ProtoTxn",
"{",
"items",
":",
"make",
"(",
"map",
"["... | // NewProtoTxn is a constructor. | [
"NewProtoTxn",
"is",
"a",
"constructor",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/local/local_proto_txn.go#L50-L55 |
126,819 | ligato/cn-infra | datasync/kvdbsync/local/local_proto_txn.go | Delete | func (txn *ProtoTxn) Delete(key string) keyval.ProtoTxn {
txn.access.Lock()
defer txn.access.Unlock()
txn.items[key] = &protoTxnItem{delete: true}
return txn
} | go | func (txn *ProtoTxn) Delete(key string) keyval.ProtoTxn {
txn.access.Lock()
defer txn.access.Unlock()
txn.items[key] = &protoTxnItem{delete: true}
return txn
} | [
"func",
"(",
"txn",
"*",
"ProtoTxn",
")",
"Delete",
"(",
"key",
"string",
")",
"keyval",
".",
"ProtoTxn",
"{",
"txn",
".",
"access",
".",
"Lock",
"(",
")",
"\n",
"defer",
"txn",
".",
"access",
".",
"Unlock",
"(",
")",
"\n\n",
"txn",
".",
"items",
... | // Delete adds delete operation into transaction. | [
"Delete",
"adds",
"delete",
"operation",
"into",
"transaction",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/local/local_proto_txn.go#L68-L75 |
126,820 | ligato/cn-infra | examples/kafka-lib/syncproducer/syncproducer.go | sendMessage | func sendMessage(producer *client.SyncProducer, msg utils.Message) error {
var (
msgKey []byte
msgValue []byte
)
// init message
if msg.Key != "" {
msgKey = []byte(msg.Key)
}
msgValue = []byte(msg.Text)
// Demonstrate the use of SyncProducer.SendMsgByte() API.
// The function doesn't return until the ... | go | func sendMessage(producer *client.SyncProducer, msg utils.Message) error {
var (
msgKey []byte
msgValue []byte
)
// init message
if msg.Key != "" {
msgKey = []byte(msg.Key)
}
msgValue = []byte(msg.Text)
// Demonstrate the use of SyncProducer.SendMsgByte() API.
// The function doesn't return until the ... | [
"func",
"sendMessage",
"(",
"producer",
"*",
"client",
".",
"SyncProducer",
",",
"msg",
"utils",
".",
"Message",
")",
"error",
"{",
"var",
"(",
"msgKey",
"[",
"]",
"byte",
"\n",
"msgValue",
"[",
"]",
"byte",
"\n",
")",
"\n\n",
"// init message",
"if",
... | // sendMessage demonstrates SyncProducer.SendMsgByte API to publish a single
// message to a Kafka topic. | [
"sendMessage",
"demonstrates",
"SyncProducer",
".",
"SendMsgByte",
"API",
"to",
"publish",
"a",
"single",
"message",
"to",
"a",
"Kafka",
"topic",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/kafka-lib/syncproducer/syncproducer.go#L111-L132 |
126,821 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | NewSyncPublisher | func (conn *BytesConnectionStr) NewSyncPublisher(topic string) (BytesPublisher, error) {
return &bytesSyncPublisherKafka{conn, topic}, nil
} | go | func (conn *BytesConnectionStr) NewSyncPublisher(topic string) (BytesPublisher, error) {
return &bytesSyncPublisherKafka{conn, topic}, nil
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"NewSyncPublisher",
"(",
"topic",
"string",
")",
"(",
"BytesPublisher",
",",
"error",
")",
"{",
"return",
"&",
"bytesSyncPublisherKafka",
"{",
"conn",
",",
"topic",
"}",
",",
"nil",
"\n",
"}"
] | // NewSyncPublisher creates a new instance of bytesSyncPublisherKafka that allows to publish sync kafka messages using common messaging API | [
"NewSyncPublisher",
"creates",
"a",
"new",
"instance",
"of",
"bytesSyncPublisherKafka",
"that",
"allows",
"to",
"publish",
"sync",
"kafka",
"messages",
"using",
"common",
"messaging",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L77-L79 |
126,822 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | NewAsyncPublisher | func (conn *BytesConnectionStr) NewAsyncPublisher(topic string, successClb func(*client.ProducerMessage), errorClb func(err *client.ProducerError)) (BytesPublisher, error) {
return &bytesAsyncPublisherKafka{conn, topic, successClb, errorClb}, nil
} | go | func (conn *BytesConnectionStr) NewAsyncPublisher(topic string, successClb func(*client.ProducerMessage), errorClb func(err *client.ProducerError)) (BytesPublisher, error) {
return &bytesAsyncPublisherKafka{conn, topic, successClb, errorClb}, nil
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"NewAsyncPublisher",
"(",
"topic",
"string",
",",
"successClb",
"func",
"(",
"*",
"client",
".",
"ProducerMessage",
")",
",",
"errorClb",
"func",
"(",
"err",
"*",
"client",
".",
"ProducerError",
")",
")",
... | // NewAsyncPublisher creates a new instance of bytesAsyncPublisherKafka that allows to publish async kafka messages using common messaging API | [
"NewAsyncPublisher",
"creates",
"a",
"new",
"instance",
"of",
"bytesAsyncPublisherKafka",
"that",
"allows",
"to",
"publish",
"async",
"kafka",
"messages",
"using",
"common",
"messaging",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L82-L84 |
126,823 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | NewSyncPublisherToPartition | func (conn *BytesManualConnectionStr) NewSyncPublisherToPartition(topic string, partition int32) (BytesPublisher, error) {
return &bytesManualSyncPublisherKafka{conn, topic, partition}, nil
} | go | func (conn *BytesManualConnectionStr) NewSyncPublisherToPartition(topic string, partition int32) (BytesPublisher, error) {
return &bytesManualSyncPublisherKafka{conn, topic, partition}, nil
} | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"NewSyncPublisherToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
")",
"(",
"BytesPublisher",
",",
"error",
")",
"{",
"return",
"&",
"bytesManualSyncPublisherKafka",
"{",
"conn",
",",
"topi... | // NewSyncPublisherToPartition creates a new instance of bytesSyncPublisherKafka that allows to publish sync kafka messages using common messaging API | [
"NewSyncPublisherToPartition",
"creates",
"a",
"new",
"instance",
"of",
"bytesSyncPublisherKafka",
"that",
"allows",
"to",
"publish",
"sync",
"kafka",
"messages",
"using",
"common",
"messaging",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L87-L89 |
126,824 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | NewAsyncPublisherToPartition | func (conn *BytesManualConnectionStr) NewAsyncPublisherToPartition(topic string, partition int32, successClb func(*client.ProducerMessage), errorClb func(err *client.ProducerError)) (BytesPublisher, error) {
return &bytesManualAsyncPublisherKafka{conn, topic, partition, successClb, errorClb}, nil
} | go | func (conn *BytesManualConnectionStr) NewAsyncPublisherToPartition(topic string, partition int32, successClb func(*client.ProducerMessage), errorClb func(err *client.ProducerError)) (BytesPublisher, error) {
return &bytesManualAsyncPublisherKafka{conn, topic, partition, successClb, errorClb}, nil
} | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"NewAsyncPublisherToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"successClb",
"func",
"(",
"*",
"client",
".",
"ProducerMessage",
")",
",",
"errorClb",
"func",
"(",
"err",
"*",
... | // NewAsyncPublisherToPartition creates a new instance of bytesAsyncPublisherKafka that allows to publish async kafka messages using common messaging API | [
"NewAsyncPublisherToPartition",
"creates",
"a",
"new",
"instance",
"of",
"bytesAsyncPublisherKafka",
"that",
"allows",
"to",
"publish",
"async",
"kafka",
"messages",
"using",
"common",
"messaging",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L92-L94 |
126,825 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | ConsumeTopic | func (conn *BytesConnectionStr) ConsumeTopic(msgClb func(message *client.ConsumerMessage), topics ...string) error {
conn.multiplexer.rwlock.Lock()
defer conn.multiplexer.rwlock.Unlock()
if conn.multiplexer.started {
return fmt.Errorf("ConsumeTopic can be called only if the multiplexer has not been started yet")
... | go | func (conn *BytesConnectionStr) ConsumeTopic(msgClb func(message *client.ConsumerMessage), topics ...string) error {
conn.multiplexer.rwlock.Lock()
defer conn.multiplexer.rwlock.Unlock()
if conn.multiplexer.started {
return fmt.Errorf("ConsumeTopic can be called only if the multiplexer has not been started yet")
... | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"ConsumeTopic",
"(",
"msgClb",
"func",
"(",
"message",
"*",
"client",
".",
"ConsumerMessage",
")",
",",
"topics",
"...",
"string",
")",
"error",
"{",
"conn",
".",
"multiplexer",
".",
"rwlock",
".",
"Lock... | // ConsumeTopic is called to start consuming of a topic.
// Function can be called until the multiplexer is started, it returns an error otherwise.
// The provided channel should be buffered, otherwise messages might be lost. | [
"ConsumeTopic",
"is",
"called",
"to",
"start",
"consuming",
"of",
"a",
"topic",
".",
"Function",
"can",
"be",
"called",
"until",
"the",
"multiplexer",
"is",
"started",
"it",
"returns",
"an",
"error",
"otherwise",
".",
"The",
"provided",
"channel",
"should",
... | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L99-L140 |
126,826 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | StartPostInitConsumer | func (conn *BytesManualConnectionStr) StartPostInitConsumer(topic string, partition int32, offset int64) (*sarama.PartitionConsumer, error) {
multiplexer := conn.multiplexer
multiplexer.WithFields(logging.Fields{"topic": topic}).Debugf("Post-init consuming started")
if multiplexer.Consumer == nil || multiplexer.Con... | go | func (conn *BytesManualConnectionStr) StartPostInitConsumer(topic string, partition int32, offset int64) (*sarama.PartitionConsumer, error) {
multiplexer := conn.multiplexer
multiplexer.WithFields(logging.Fields{"topic": topic}).Debugf("Post-init consuming started")
if multiplexer.Consumer == nil || multiplexer.Con... | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"StartPostInitConsumer",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"offset",
"int64",
")",
"(",
"*",
"sarama",
".",
"PartitionConsumer",
",",
"error",
")",
"{",
"multiplexer",
":=",
"conn... | // StartPostInitConsumer allows to start a new partition consumer after mux is initialized | [
"StartPostInitConsumer",
"allows",
"to",
"start",
"a",
"new",
"partition",
"consumer",
"after",
"mux",
"is",
"initialized"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L197-L214 |
126,827 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | StopConsuming | func (conn *BytesConnectionStr) StopConsuming(topic string) error {
return conn.multiplexer.stopConsuming(topic, conn.name)
} | go | func (conn *BytesConnectionStr) StopConsuming(topic string) error {
return conn.multiplexer.stopConsuming(topic, conn.name)
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"StopConsuming",
"(",
"topic",
"string",
")",
"error",
"{",
"return",
"conn",
".",
"multiplexer",
".",
"stopConsuming",
"(",
"topic",
",",
"conn",
".",
"name",
")",
"\n",
"}"
] | // StopConsuming cancels the previously created subscription for consuming the topic. | [
"StopConsuming",
"cancels",
"the",
"previously",
"created",
"subscription",
"for",
"consuming",
"the",
"topic",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L217-L219 |
126,828 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendSyncMessage | func (conn *BytesConnectionStr) SendSyncMessage(topic string, key client.Encoder, value client.Encoder) (offset int64, err error) {
msg, err := conn.multiplexer.hashSyncProducer.SendMsgToPartition(topic, DefPartition, key, value)
if err != nil {
return 0, err
}
return msg.Offset, err
} | go | func (conn *BytesConnectionStr) SendSyncMessage(topic string, key client.Encoder, value client.Encoder) (offset int64, err error) {
msg, err := conn.multiplexer.hashSyncProducer.SendMsgToPartition(topic, DefPartition, key, value)
if err != nil {
return 0, err
}
return msg.Offset, err
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendSyncMessage",
"(",
"topic",
"string",
",",
"key",
"client",
".",
"Encoder",
",",
"value",
"client",
".",
"Encoder",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"msg",
",",
"err",
... | //SendSyncMessage sends a message using the sync API and default partitioner | [
"SendSyncMessage",
"sends",
"a",
"message",
"using",
"the",
"sync",
"API",
"and",
"default",
"partitioner"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L227-L233 |
126,829 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendAsyncMessage | func (conn *BytesConnectionStr) SendAsyncMessage(topic string, key client.Encoder, value client.Encoder, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
auxMeta := &asyncMeta{successClb: successClb, errorClb: errClb, usersMeta: meta}
conn.multiplexer.hashAsyncProducer... | go | func (conn *BytesConnectionStr) SendAsyncMessage(topic string, key client.Encoder, value client.Encoder, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
auxMeta := &asyncMeta{successClb: successClb, errorClb: errClb, usersMeta: meta}
conn.multiplexer.hashAsyncProducer... | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendAsyncMessage",
"(",
"topic",
"string",
",",
"key",
"client",
".",
"Encoder",
",",
"value",
"client",
".",
"Encoder",
",",
"meta",
"interface",
"{",
"}",
",",
"successClb",
"func",
"(",
"*",
"client"... | // SendAsyncMessage sends a message using the async API and default partitioner | [
"SendAsyncMessage",
"sends",
"a",
"message",
"using",
"the",
"async",
"API",
"and",
"default",
"partitioner"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L236-L239 |
126,830 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendSyncMessageToPartition | func (conn *BytesManualConnectionStr) SendSyncMessageToPartition(topic string, partition int32, key client.Encoder, value client.Encoder) (offset int64, err error) {
msg, err := conn.multiplexer.manSyncProducer.SendMsgToPartition(topic, partition, key, value)
if err != nil {
return 0, err
}
return msg.Offset, err... | go | func (conn *BytesManualConnectionStr) SendSyncMessageToPartition(topic string, partition int32, key client.Encoder, value client.Encoder) (offset int64, err error) {
msg, err := conn.multiplexer.manSyncProducer.SendMsgToPartition(topic, partition, key, value)
if err != nil {
return 0, err
}
return msg.Offset, err... | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"SendSyncMessageToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"key",
"client",
".",
"Encoder",
",",
"value",
"client",
".",
"Encoder",
")",
"(",
"offset",
"int64",
",",
"err",
... | //SendSyncMessageToPartition sends a message using the sync API and default partitioner | [
"SendSyncMessageToPartition",
"sends",
"a",
"message",
"using",
"the",
"sync",
"API",
"and",
"default",
"partitioner"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L242-L248 |
126,831 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendAsyncMessageToPartition | func (conn *BytesManualConnectionStr) SendAsyncMessageToPartition(topic string, partition int32, key client.Encoder, value client.Encoder, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
auxMeta := &asyncMeta{successClb: successClb, errorClb: errClb, usersMeta: meta}
... | go | func (conn *BytesManualConnectionStr) SendAsyncMessageToPartition(topic string, partition int32, key client.Encoder, value client.Encoder, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
auxMeta := &asyncMeta{successClb: successClb, errorClb: errClb, usersMeta: meta}
... | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"SendAsyncMessageToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"key",
"client",
".",
"Encoder",
",",
"value",
"client",
".",
"Encoder",
",",
"meta",
"interface",
"{",
"}",
",",
... | // SendAsyncMessageToPartition sends a message using the async API and default partitioner | [
"SendAsyncMessageToPartition",
"sends",
"a",
"message",
"using",
"the",
"async",
"API",
"and",
"default",
"partitioner"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L251-L254 |
126,832 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendSyncByte | func (conn *BytesConnectionStr) SendSyncByte(topic string, key []byte, value []byte) (offset int64, err error) {
return conn.SendSyncMessage(topic, sarama.ByteEncoder(key), sarama.ByteEncoder(value))
} | go | func (conn *BytesConnectionStr) SendSyncByte(topic string, key []byte, value []byte) (offset int64, err error) {
return conn.SendSyncMessage(topic, sarama.ByteEncoder(key), sarama.ByteEncoder(value))
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendSyncByte",
"(",
"topic",
"string",
",",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"conn",
".",
"SendSyncMessa... | // SendSyncByte sends a message that uses byte encoder using the sync API | [
"SendSyncByte",
"sends",
"a",
"message",
"that",
"uses",
"byte",
"encoder",
"using",
"the",
"sync",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L257-L259 |
126,833 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendSyncString | func (conn *BytesConnectionStr) SendSyncString(topic string, key string, value string) (offset int64, err error) {
return conn.SendSyncMessage(topic, sarama.StringEncoder(key), sarama.StringEncoder(value))
} | go | func (conn *BytesConnectionStr) SendSyncString(topic string, key string, value string) (offset int64, err error) {
return conn.SendSyncMessage(topic, sarama.StringEncoder(key), sarama.StringEncoder(value))
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendSyncString",
"(",
"topic",
"string",
",",
"key",
"string",
",",
"value",
"string",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"conn",
".",
"SendSyncMessage",
"(",
"topic",... | // SendSyncString sends a message that uses string encoder using the sync API | [
"SendSyncString",
"sends",
"a",
"message",
"that",
"uses",
"string",
"encoder",
"using",
"the",
"sync",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L262-L264 |
126,834 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendSyncStringToPartition | func (conn *BytesManualConnectionStr) SendSyncStringToPartition(topic string, partition int32, key string, value string) (offset int64, err error) {
return conn.SendSyncMessageToPartition(topic, partition, sarama.StringEncoder(key), sarama.StringEncoder(value))
} | go | func (conn *BytesManualConnectionStr) SendSyncStringToPartition(topic string, partition int32, key string, value string) (offset int64, err error) {
return conn.SendSyncMessageToPartition(topic, partition, sarama.StringEncoder(key), sarama.StringEncoder(value))
} | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"SendSyncStringToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"key",
"string",
",",
"value",
"string",
")",
"(",
"offset",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"co... | // SendSyncStringToPartition sends a message that uses string encoder using the sync API to custom partition | [
"SendSyncStringToPartition",
"sends",
"a",
"message",
"that",
"uses",
"string",
"encoder",
"using",
"the",
"sync",
"API",
"to",
"custom",
"partition"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L267-L269 |
126,835 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendAsyncByte | func (conn *BytesConnectionStr) SendAsyncByte(topic string, key []byte, value []byte, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessage(topic, sarama.ByteEncoder(key), sarama.ByteEncoder(value), meta, successClb, errClb)
} | go | func (conn *BytesConnectionStr) SendAsyncByte(topic string, key []byte, value []byte, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessage(topic, sarama.ByteEncoder(key), sarama.ByteEncoder(value), meta, successClb, errClb)
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendAsyncByte",
"(",
"topic",
"string",
",",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
",",
"meta",
"interface",
"{",
"}",
",",
"successClb",
"func",
"(",
"*",
"client",
".",
"Produce... | // SendAsyncByte sends a message that uses byte encoder using the async API | [
"SendAsyncByte",
"sends",
"a",
"message",
"that",
"uses",
"byte",
"encoder",
"using",
"the",
"async",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L272-L274 |
126,836 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendAsyncString | func (conn *BytesConnectionStr) SendAsyncString(topic string, key string, value string, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessage(topic, sarama.StringEncoder(key), sarama.StringEncoder(value), meta, successClb, errClb)
} | go | func (conn *BytesConnectionStr) SendAsyncString(topic string, key string, value string, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessage(topic, sarama.StringEncoder(key), sarama.StringEncoder(value), meta, successClb, errClb)
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionStr",
")",
"SendAsyncString",
"(",
"topic",
"string",
",",
"key",
"string",
",",
"value",
"string",
",",
"meta",
"interface",
"{",
"}",
",",
"successClb",
"func",
"(",
"*",
"client",
".",
"ProducerMessage",
")",
",... | // SendAsyncString sends a message that uses string encoder using the async API | [
"SendAsyncString",
"sends",
"a",
"message",
"that",
"uses",
"string",
"encoder",
"using",
"the",
"async",
"API"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L277-L279 |
126,837 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | SendAsyncStringToPartition | func (conn *BytesManualConnectionStr) SendAsyncStringToPartition(topic string, partition int32, key string, value string, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessageToPartition(topic, partition, sarama.StringEncoder(key), sarama.StringEncoder(... | go | func (conn *BytesManualConnectionStr) SendAsyncStringToPartition(topic string, partition int32, key string, value string, meta interface{}, successClb func(*client.ProducerMessage), errClb func(*client.ProducerError)) {
conn.SendAsyncMessageToPartition(topic, partition, sarama.StringEncoder(key), sarama.StringEncoder(... | [
"func",
"(",
"conn",
"*",
"BytesManualConnectionStr",
")",
"SendAsyncStringToPartition",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"key",
"string",
",",
"value",
"string",
",",
"meta",
"interface",
"{",
"}",
",",
"successClb",
"func",
"(",
"*",
... | // SendAsyncStringToPartition sends a message that uses string encoder using the async API to custom partition | [
"SendAsyncStringToPartition",
"sends",
"a",
"message",
"that",
"uses",
"string",
"encoder",
"using",
"the",
"async",
"API",
"to",
"custom",
"partition"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L282-L284 |
126,838 | ligato/cn-infra | messaging/kafka/mux/bytes_connection.go | CommitOffsets | func (conn *BytesConnectionFields) CommitOffsets() error {
if conn.multiplexer != nil && conn.multiplexer.Consumer != nil {
return conn.multiplexer.Consumer.CommitOffsets()
}
return fmt.Errorf("cannot commit offsets, consumer not available")
} | go | func (conn *BytesConnectionFields) CommitOffsets() error {
if conn.multiplexer != nil && conn.multiplexer.Consumer != nil {
return conn.multiplexer.Consumer.CommitOffsets()
}
return fmt.Errorf("cannot commit offsets, consumer not available")
} | [
"func",
"(",
"conn",
"*",
"BytesConnectionFields",
")",
"CommitOffsets",
"(",
")",
"error",
"{",
"if",
"conn",
".",
"multiplexer",
"!=",
"nil",
"&&",
"conn",
".",
"multiplexer",
".",
"Consumer",
"!=",
"nil",
"{",
"return",
"conn",
".",
"multiplexer",
".",
... | // CommitOffsets manually commits message offsets | [
"CommitOffsets",
"manually",
"commits",
"message",
"offsets"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/mux/bytes_connection.go#L318-L323 |
126,839 | ligato/cn-infra | db/keyval/kvproto/proto_broker_impl.go | NewProtoWrapper | func NewProtoWrapper(db keyval.CoreBrokerWatcher, serializer ...keyval.Serializer) *ProtoWrapper {
if len(serializer) > 0 {
return &ProtoWrapper{db, serializer[0]}
}
return &ProtoWrapper{db, &keyval.SerializerProto{}}
} | go | func NewProtoWrapper(db keyval.CoreBrokerWatcher, serializer ...keyval.Serializer) *ProtoWrapper {
if len(serializer) > 0 {
return &ProtoWrapper{db, serializer[0]}
}
return &ProtoWrapper{db, &keyval.SerializerProto{}}
} | [
"func",
"NewProtoWrapper",
"(",
"db",
"keyval",
".",
"CoreBrokerWatcher",
",",
"serializer",
"...",
"keyval",
".",
"Serializer",
")",
"*",
"ProtoWrapper",
"{",
"if",
"len",
"(",
"serializer",
")",
">",
"0",
"{",
"return",
"&",
"ProtoWrapper",
"{",
"db",
",... | // NewProtoWrapper initializes proto decorator.
// The default serializer is used - SerializerProto. | [
"NewProtoWrapper",
"initializes",
"proto",
"decorator",
".",
"The",
"default",
"serializer",
"is",
"used",
"-",
"SerializerProto",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/kvproto/proto_broker_impl.go#L55-L60 |
126,840 | ligato/cn-infra | db/keyval/kvproto/proto_broker_impl.go | NewProtoWrapperWithSerializer | func NewProtoWrapperWithSerializer(db keyval.CoreBrokerWatcher, serializer keyval.Serializer) *ProtoWrapper {
// OBSOLETE, use NewProtoWrapper
return NewProtoWrapper(db, serializer)
} | go | func NewProtoWrapperWithSerializer(db keyval.CoreBrokerWatcher, serializer keyval.Serializer) *ProtoWrapper {
// OBSOLETE, use NewProtoWrapper
return NewProtoWrapper(db, serializer)
} | [
"func",
"NewProtoWrapperWithSerializer",
"(",
"db",
"keyval",
".",
"CoreBrokerWatcher",
",",
"serializer",
"keyval",
".",
"Serializer",
")",
"*",
"ProtoWrapper",
"{",
"// OBSOLETE, use NewProtoWrapper",
"return",
"NewProtoWrapper",
"(",
"db",
",",
"serializer",
")",
"... | // NewProtoWrapperWithSerializer initializes proto decorator with the specified
// serializer. | [
"NewProtoWrapperWithSerializer",
"initializes",
"proto",
"decorator",
"with",
"the",
"specified",
"serializer",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/kvproto/proto_broker_impl.go#L64-L67 |
126,841 | ligato/cn-infra | db/keyval/kvproto/proto_broker_impl.go | NewWatcher | func (db *ProtoWrapper) NewWatcher(prefix string) keyval.ProtoWatcher {
return &protoWatcher{db.broker.NewWatcher(prefix), db.serializer}
} | go | func (db *ProtoWrapper) NewWatcher(prefix string) keyval.ProtoWatcher {
return &protoWatcher{db.broker.NewWatcher(prefix), db.serializer}
} | [
"func",
"(",
"db",
"*",
"ProtoWrapper",
")",
"NewWatcher",
"(",
"prefix",
"string",
")",
"keyval",
".",
"ProtoWatcher",
"{",
"return",
"&",
"protoWatcher",
"{",
"db",
".",
"broker",
".",
"NewWatcher",
"(",
"prefix",
")",
",",
"db",
".",
"serializer",
"}"... | // NewWatcher creates a new instance of the proxy that shares the underlying
// connection and allows subscribing for watching of the changes. | [
"NewWatcher",
"creates",
"a",
"new",
"instance",
"of",
"the",
"proxy",
"that",
"shares",
"the",
"underlying",
"connection",
"and",
"allows",
"subscribing",
"for",
"watching",
"of",
"the",
"changes",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/kvproto/proto_broker_impl.go#L84-L86 |
126,842 | ligato/cn-infra | health/probe/prometheus_probe.go | getServiceHealth | func (p *Plugin) getServiceHealth() float64 {
agentStatus := p.StatusCheck.GetAgentStatus()
// Adapt Ligato status code for now.
// TODO: Consolidate with that from the "Common Container Telemetry" proposal.
health := float64(agentStatus.State)
p.Log.Infof("ServiceHealth: %v", health)
return health
} | go | func (p *Plugin) getServiceHealth() float64 {
agentStatus := p.StatusCheck.GetAgentStatus()
// Adapt Ligato status code for now.
// TODO: Consolidate with that from the "Common Container Telemetry" proposal.
health := float64(agentStatus.State)
p.Log.Infof("ServiceHealth: %v", health)
return health
} | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"getServiceHealth",
"(",
")",
"float64",
"{",
"agentStatus",
":=",
"p",
".",
"StatusCheck",
".",
"GetAgentStatus",
"(",
")",
"\n",
"// Adapt Ligato status code for now.",
"// TODO: Consolidate with that from the \"Common Container Tel... | // getServiceHealth returns agent health status | [
"getServiceHealth",
"returns",
"agent",
"health",
"status"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/probe/prometheus_probe.go#L105-L112 |
126,843 | ligato/cn-infra | health/probe/prometheus_probe.go | getDependencyHealth | func (p *Plugin) getDependencyHealth(pluginName string, pluginStatus *status.PluginStatus) func() float64 {
p.Log.Infof("DependencyHealth for plugin %v: %v", pluginName, float64(pluginStatus.State))
return func() float64 {
health := float64(pluginStatus.State)
p.Log.Infof("Dependency Health %v: %v", pluginName, ... | go | func (p *Plugin) getDependencyHealth(pluginName string, pluginStatus *status.PluginStatus) func() float64 {
p.Log.Infof("DependencyHealth for plugin %v: %v", pluginName, float64(pluginStatus.State))
return func() float64 {
health := float64(pluginStatus.State)
p.Log.Infof("Dependency Health %v: %v", pluginName, ... | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"getDependencyHealth",
"(",
"pluginName",
"string",
",",
"pluginStatus",
"*",
"status",
".",
"PluginStatus",
")",
"func",
"(",
")",
"float64",
"{",
"p",
".",
"Log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"pluginName",
... | // getDependencyHealth returns plugin health status | [
"getDependencyHealth",
"returns",
"plugin",
"health",
"status"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/probe/prometheus_probe.go#L115-L123 |
126,844 | ligato/cn-infra | examples/cryptodata-proto-plugin/main.go | watchChanges | func (plugin *ExamplePlugin) watchChanges(x datasync.ProtoWatchResp) {
message := &ipsec.TunnelInterfaces{}
err := x.GetValue(message)
if err == nil {
plugin.Log.Infof("Got watch message %v", message)
}
} | go | func (plugin *ExamplePlugin) watchChanges(x datasync.ProtoWatchResp) {
message := &ipsec.TunnelInterfaces{}
err := x.GetValue(message)
if err == nil {
plugin.Log.Infof("Got watch message %v", message)
}
} | [
"func",
"(",
"plugin",
"*",
"ExamplePlugin",
")",
"watchChanges",
"(",
"x",
"datasync",
".",
"ProtoWatchResp",
")",
"{",
"message",
":=",
"&",
"ipsec",
".",
"TunnelInterfaces",
"{",
"}",
"\n",
"err",
":=",
"x",
".",
"GetValue",
"(",
"message",
")",
"\n",... | // watchChanges is watching for changes in DB | [
"watchChanges",
"is",
"watching",
"for",
"changes",
"in",
"DB"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/cryptodata-proto-plugin/main.go#L175-L181 |
126,845 | ligato/cn-infra | db/cryptodata/plugin.go | Init | func (p *Plugin) Init() (err error) {
var config Config
found, err := p.Cfg.LoadValue(&config)
if err != nil {
return err
}
if !found {
p.Log.Info("cryptodata config not found, skip loading this plugin")
p.disabled = true
return nil
}
// Read client config and create it
clientConfig := ClientConfig{}
... | go | func (p *Plugin) Init() (err error) {
var config Config
found, err := p.Cfg.LoadValue(&config)
if err != nil {
return err
}
if !found {
p.Log.Info("cryptodata config not found, skip loading this plugin")
p.disabled = true
return nil
}
// Read client config and create it
clientConfig := ClientConfig{}
... | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"Init",
"(",
")",
"(",
"err",
"error",
")",
"{",
"var",
"config",
"Config",
"\n",
"found",
",",
"err",
":=",
"p",
".",
"Cfg",
".",
"LoadValue",
"(",
"&",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Init initializes cryptodata plugin. | [
"Init",
"initializes",
"cryptodata",
"plugin",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/plugin.go#L45-L98 |
126,846 | ligato/cn-infra | messaging/kafka/client/messages.go | NewProtoConsumerMessage | func NewProtoConsumerMessage(msg *ConsumerMessage, serializer keyval.Serializer) *ProtoConsumerMessage {
return &ProtoConsumerMessage{msg, serializer}
} | go | func NewProtoConsumerMessage(msg *ConsumerMessage, serializer keyval.Serializer) *ProtoConsumerMessage {
return &ProtoConsumerMessage{msg, serializer}
} | [
"func",
"NewProtoConsumerMessage",
"(",
"msg",
"*",
"ConsumerMessage",
",",
"serializer",
"keyval",
".",
"Serializer",
")",
"*",
"ProtoConsumerMessage",
"{",
"return",
"&",
"ProtoConsumerMessage",
"{",
"msg",
",",
"serializer",
"}",
"\n",
"}"
] | // NewProtoConsumerMessage creates new instance of ProtoConsumerMessage | [
"NewProtoConsumerMessage",
"creates",
"new",
"instance",
"of",
"ProtoConsumerMessage"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/messages.go#L79-L81 |
126,847 | ligato/cn-infra | messaging/kafka/client/messages.go | GetValue | func (cm *ProtoConsumerMessage) GetValue(msg proto.Message) error {
err := cm.serializer.Unmarshal(cm.ConsumerMessage.GetValue(), msg)
if err != nil {
return err
}
return nil
} | go | func (cm *ProtoConsumerMessage) GetValue(msg proto.Message) error {
err := cm.serializer.Unmarshal(cm.ConsumerMessage.GetValue(), msg)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"cm",
"*",
"ProtoConsumerMessage",
")",
"GetValue",
"(",
"msg",
"proto",
".",
"Message",
")",
"error",
"{",
"err",
":=",
"cm",
".",
"serializer",
".",
"Unmarshal",
"(",
"cm",
".",
"ConsumerMessage",
".",
"GetValue",
"(",
")",
",",
"msg",
"... | // GetValue returns the value associated with the message. | [
"GetValue",
"returns",
"the",
"value",
"associated",
"with",
"the",
"message",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/messages.go#L104-L110 |
126,848 | ligato/cn-infra | messaging/kafka/client/messages.go | GetPrevValue | func (cm *ProtoConsumerMessage) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
prevVal := cm.ConsumerMessage.GetPrevValue()
if prevVal == nil {
return false, nil
}
err = cm.serializer.Unmarshal(prevVal, msg)
if err != nil {
return true, err
}
return true, nil
} | go | func (cm *ProtoConsumerMessage) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
prevVal := cm.ConsumerMessage.GetPrevValue()
if prevVal == nil {
return false, nil
}
err = cm.serializer.Unmarshal(prevVal, msg)
if err != nil {
return true, err
}
return true, nil
} | [
"func",
"(",
"cm",
"*",
"ProtoConsumerMessage",
")",
"GetPrevValue",
"(",
"msg",
"proto",
".",
"Message",
")",
"(",
"prevValueExist",
"bool",
",",
"err",
"error",
")",
"{",
"prevVal",
":=",
"cm",
".",
"ConsumerMessage",
".",
"GetPrevValue",
"(",
")",
"\n",... | // GetPrevValue returns the previous value associated with the latest message. | [
"GetPrevValue",
"returns",
"the",
"previous",
"value",
"associated",
"with",
"the",
"latest",
"message",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/messages.go#L113-L123 |
126,849 | ligato/cn-infra | messaging/kafka/client/messages.go | GetValue | func (pm *ProducerMessage) GetValue() []byte {
val, _ := pm.Value.Encode()
return val
} | go | func (pm *ProducerMessage) GetValue() []byte {
val, _ := pm.Value.Encode()
return val
} | [
"func",
"(",
"pm",
"*",
"ProducerMessage",
")",
"GetValue",
"(",
")",
"[",
"]",
"byte",
"{",
"val",
",",
"_",
":=",
"pm",
".",
"Value",
".",
"Encode",
"(",
")",
"\n",
"return",
"val",
"\n",
"}"
] | // GetValue returns the content of the message. | [
"GetValue",
"returns",
"the",
"content",
"of",
"the",
"message",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/messages.go#L175-L178 |
126,850 | ligato/cn-infra | messaging/kafka/client/messages.go | GetValue | func (ppm *ProtoProducerMessage) GetValue(msg proto.Message) error {
err := ppm.Serializer.Unmarshal(ppm.ProducerMessage.GetValue(), msg)
if err != nil {
return err
}
return nil
} | go | func (ppm *ProtoProducerMessage) GetValue(msg proto.Message) error {
err := ppm.Serializer.Unmarshal(ppm.ProducerMessage.GetValue(), msg)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"ppm",
"*",
"ProtoProducerMessage",
")",
"GetValue",
"(",
"msg",
"proto",
".",
"Message",
")",
"error",
"{",
"err",
":=",
"ppm",
".",
"Serializer",
".",
"Unmarshal",
"(",
"ppm",
".",
"ProducerMessage",
".",
"GetValue",
"(",
")",
",",
"msg",
... | // GetValue unmarshalls the content of the msg into provided structure. | [
"GetValue",
"unmarshalls",
"the",
"content",
"of",
"the",
"msg",
"into",
"provided",
"structure",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/messages.go#L255-L261 |
126,851 | ligato/cn-infra | db/cryptodata/client.go | NewClient | func NewClient(clientConfig ClientConfig) *Client {
client := &Client{
ClientConfig: clientConfig,
}
// If reader is nil use default rand.Reader
if clientConfig.Reader == nil {
client.Reader = rand.Reader
}
// If hash is nil use default sha256
if clientConfig.Hash == nil {
client.Hash = sha256.New()
}
... | go | func NewClient(clientConfig ClientConfig) *Client {
client := &Client{
ClientConfig: clientConfig,
}
// If reader is nil use default rand.Reader
if clientConfig.Reader == nil {
client.Reader = rand.Reader
}
// If hash is nil use default sha256
if clientConfig.Hash == nil {
client.Hash = sha256.New()
}
... | [
"func",
"NewClient",
"(",
"clientConfig",
"ClientConfig",
")",
"*",
"Client",
"{",
"client",
":=",
"&",
"Client",
"{",
"ClientConfig",
":",
"clientConfig",
",",
"}",
"\n\n",
"// If reader is nil use default rand.Reader",
"if",
"clientConfig",
".",
"Reader",
"==",
... | // NewClient creates new client from provided config and reader | [
"NewClient",
"creates",
"new",
"client",
"from",
"provided",
"config",
"and",
"reader"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/client.go#L55-L71 |
126,852 | ligato/cn-infra | db/cryptodata/client.go | EncryptData | func (client *Client) EncryptData(inData []byte, pub *rsa.PublicKey) (data []byte, err error) {
return rsa.EncryptOAEP(client.Hash, client.Reader, pub, inData, nil)
} | go | func (client *Client) EncryptData(inData []byte, pub *rsa.PublicKey) (data []byte, err error) {
return rsa.EncryptOAEP(client.Hash, client.Reader, pub, inData, nil)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"EncryptData",
"(",
"inData",
"[",
"]",
"byte",
",",
"pub",
"*",
"rsa",
".",
"PublicKey",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"rsa",
".",
"EncryptOAEP",
"(",
"clien... | // EncryptData implements ClientAPI.EncryptData | [
"EncryptData",
"implements",
"ClientAPI",
".",
"EncryptData"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/client.go#L74-L76 |
126,853 | ligato/cn-infra | db/cryptodata/client.go | DecryptData | func (client *Client) DecryptData(inData []byte) (data []byte, err error) {
for _, key := range client.PrivateKeys {
data, err := rsa.DecryptOAEP(client.Hash, client.Reader, key, inData, nil)
if err == nil {
return data, nil
}
}
return nil, errors.New("failed to decrypt data due to no private key matching... | go | func (client *Client) DecryptData(inData []byte) (data []byte, err error) {
for _, key := range client.PrivateKeys {
data, err := rsa.DecryptOAEP(client.Hash, client.Reader, key, inData, nil)
if err == nil {
return data, nil
}
}
return nil, errors.New("failed to decrypt data due to no private key matching... | [
"func",
"(",
"client",
"*",
"Client",
")",
"DecryptData",
"(",
"inData",
"[",
"]",
"byte",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"key",
":=",
"range",
"client",
".",
"PrivateKeys",
"{",
"data",
",",
"... | // DecryptData implements ClientAPI.DecryptData | [
"DecryptData",
"implements",
"ClientAPI",
".",
"DecryptData"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/client.go#L79-L89 |
126,854 | ligato/cn-infra | db/cryptodata/client.go | WrapBytes | func (client *Client) WrapBytes(cbw keyval.KvBytesPlugin, decrypter ArbitraryDecrypter) keyval.KvBytesPlugin {
return NewKvBytesPluginWrapper(cbw, decrypter, client.DecryptData)
} | go | func (client *Client) WrapBytes(cbw keyval.KvBytesPlugin, decrypter ArbitraryDecrypter) keyval.KvBytesPlugin {
return NewKvBytesPluginWrapper(cbw, decrypter, client.DecryptData)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"WrapBytes",
"(",
"cbw",
"keyval",
".",
"KvBytesPlugin",
",",
"decrypter",
"ArbitraryDecrypter",
")",
"keyval",
".",
"KvBytesPlugin",
"{",
"return",
"NewKvBytesPluginWrapper",
"(",
"cbw",
",",
"decrypter",
",",
"client"... | // WrapBytes implements ClientAPI.WrapBytes | [
"WrapBytes",
"implements",
"ClientAPI",
".",
"WrapBytes"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/client.go#L92-L94 |
126,855 | ligato/cn-infra | db/cryptodata/client.go | WrapProto | func (client *Client) WrapProto(kvp keyval.KvProtoPlugin, decrypter ArbitraryDecrypter) keyval.KvProtoPlugin {
return NewKvProtoPluginWrapper(kvp, decrypter, client.DecryptData)
} | go | func (client *Client) WrapProto(kvp keyval.KvProtoPlugin, decrypter ArbitraryDecrypter) keyval.KvProtoPlugin {
return NewKvProtoPluginWrapper(kvp, decrypter, client.DecryptData)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"WrapProto",
"(",
"kvp",
"keyval",
".",
"KvProtoPlugin",
",",
"decrypter",
"ArbitraryDecrypter",
")",
"keyval",
".",
"KvProtoPlugin",
"{",
"return",
"NewKvProtoPluginWrapper",
"(",
"kvp",
",",
"decrypter",
",",
"client"... | // WrapProto implements ClientAPI.WrapProto | [
"WrapProto",
"implements",
"ClientAPI",
".",
"WrapProto"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/client.go#L97-L99 |
126,856 | ligato/cn-infra | datasync/kvdbsync/local/local_bytes_txn.go | NewBytesTxn | func NewBytesTxn(commit func(context.Context, map[string]datasync.ChangeValue) error) *BytesTxn {
return &BytesTxn{
items: make(map[string]*bytesTxnItem),
commit: commit,
}
} | go | func NewBytesTxn(commit func(context.Context, map[string]datasync.ChangeValue) error) *BytesTxn {
return &BytesTxn{
items: make(map[string]*bytesTxnItem),
commit: commit,
}
} | [
"func",
"NewBytesTxn",
"(",
"commit",
"func",
"(",
"context",
".",
"Context",
",",
"map",
"[",
"string",
"]",
"datasync",
".",
"ChangeValue",
")",
"error",
")",
"*",
"BytesTxn",
"{",
"return",
"&",
"BytesTxn",
"{",
"items",
":",
"make",
"(",
"map",
"["... | // NewBytesTxn is a constructor. | [
"NewBytesTxn",
"is",
"a",
"constructor",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/local/local_bytes_txn.go#L41-L46 |
126,857 | ligato/cn-infra | datasync/kvdbsync/local/local_bytes_txn.go | Delete | func (txn *BytesTxn) Delete(key string) keyval.BytesTxn {
txn.access.Lock()
defer txn.access.Unlock()
txn.items[key] = &bytesTxnItem{delete: true}
return txn
} | go | func (txn *BytesTxn) Delete(key string) keyval.BytesTxn {
txn.access.Lock()
defer txn.access.Unlock()
txn.items[key] = &bytesTxnItem{delete: true}
return txn
} | [
"func",
"(",
"txn",
"*",
"BytesTxn",
")",
"Delete",
"(",
"key",
"string",
")",
"keyval",
".",
"BytesTxn",
"{",
"txn",
".",
"access",
".",
"Lock",
"(",
")",
"\n",
"defer",
"txn",
".",
"access",
".",
"Unlock",
"(",
")",
"\n\n",
"txn",
".",
"items",
... | // Delete add delete operation into transaction. | [
"Delete",
"add",
"delete",
"operation",
"into",
"transaction",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/local/local_bytes_txn.go#L59-L66 |
126,858 | ligato/cn-infra | examples/bolt-plugin/main.go | Init | func (p *BoltExample) Init() (err error) {
db := p.DB.NewBroker(keyval.Root)
// Store some data
txn := db.NewTxn()
txn.Put("/agent/config/interface/iface0", nil)
txn.Put("/agent/config/interface/iface1", nil)
txn.Commit(context.Background())
// List keys
const listPrefix = "/agent/config/interface/"
p.Log.I... | go | func (p *BoltExample) Init() (err error) {
db := p.DB.NewBroker(keyval.Root)
// Store some data
txn := db.NewTxn()
txn.Put("/agent/config/interface/iface0", nil)
txn.Put("/agent/config/interface/iface1", nil)
txn.Commit(context.Background())
// List keys
const listPrefix = "/agent/config/interface/"
p.Log.I... | [
"func",
"(",
"p",
"*",
"BoltExample",
")",
"Init",
"(",
")",
"(",
"err",
"error",
")",
"{",
"db",
":=",
"p",
".",
"DB",
".",
"NewBroker",
"(",
"keyval",
".",
"Root",
")",
"\n\n",
"// Store some data",
"txn",
":=",
"db",
".",
"NewTxn",
"(",
")",
"... | // Init demonstrates using Bolt plugin. | [
"Init",
"demonstrates",
"using",
"Bolt",
"plugin",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/bolt-plugin/main.go#L40-L69 |
126,859 | ligato/cn-infra | db/keyval/etcd/mocks/embeded_etcd.go | Start | func (embd *Embedded) Start(t *testing.T) {
dir, err := ioutil.TempDir("", "ETCD")
if err != nil {
t.Error(err)
t.FailNow()
}
cfg := embed.NewConfig()
cfg.Dir = dir
lpurl, _ := url.Parse("http://localhost:0")
lcurl, _ := url.Parse("http://localhost:0")
cfg.LPUrls = []url.URL{*lpurl}
cfg.LCUrls = []url.URL... | go | func (embd *Embedded) Start(t *testing.T) {
dir, err := ioutil.TempDir("", "ETCD")
if err != nil {
t.Error(err)
t.FailNow()
}
cfg := embed.NewConfig()
cfg.Dir = dir
lpurl, _ := url.Parse("http://localhost:0")
lcurl, _ := url.Parse("http://localhost:0")
cfg.LPUrls = []url.URL{*lpurl}
cfg.LCUrls = []url.URL... | [
"func",
"(",
"embd",
"*",
"Embedded",
")",
"Start",
"(",
"t",
"*",
"testing",
".",
"T",
")",
"{",
"dir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Error"... | // Start starts embedded ETCD. | [
"Start",
"starts",
"embedded",
"ETCD",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/etcd/mocks/embeded_etcd.go#L28-L57 |
126,860 | ligato/cn-infra | db/keyval/etcd/mocks/embeded_etcd.go | Stop | func (embd *Embedded) Stop() {
embd.ETCD.Close()
os.RemoveAll(embd.tmpDir)
} | go | func (embd *Embedded) Stop() {
embd.ETCD.Close()
os.RemoveAll(embd.tmpDir)
} | [
"func",
"(",
"embd",
"*",
"Embedded",
")",
"Stop",
"(",
")",
"{",
"embd",
".",
"ETCD",
".",
"Close",
"(",
")",
"\n",
"os",
".",
"RemoveAll",
"(",
"embd",
".",
"tmpDir",
")",
"\n",
"}"
] | // Stop stops the embedded ETCD & cleanups the tmp dir. | [
"Stop",
"stops",
"the",
"embedded",
"ETCD",
"&",
"cleanups",
"the",
"tmp",
"dir",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/etcd/mocks/embeded_etcd.go#L60-L63 |
126,861 | ligato/cn-infra | db/keyval/etcd/mocks/embeded_etcd.go | CleanDs | func (embd *Embedded) CleanDs() {
if embd.client != nil {
resp, err := embd.client.Delete(context.Background(), "", clientv3.WithPrefix())
if err != nil {
panic(err)
}
fmt.Printf("resp: %+v\n", resp)
}
} | go | func (embd *Embedded) CleanDs() {
if embd.client != nil {
resp, err := embd.client.Delete(context.Background(), "", clientv3.WithPrefix())
if err != nil {
panic(err)
}
fmt.Printf("resp: %+v\n", resp)
}
} | [
"func",
"(",
"embd",
"*",
"Embedded",
")",
"CleanDs",
"(",
")",
"{",
"if",
"embd",
".",
"client",
"!=",
"nil",
"{",
"resp",
",",
"err",
":=",
"embd",
".",
"client",
".",
"Delete",
"(",
"context",
".",
"Background",
"(",
")",
",",
"\"",
"\"",
",",... | // CleanDs deletes all stored key-value pairs. | [
"CleanDs",
"deletes",
"all",
"stored",
"key",
"-",
"value",
"pairs",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/etcd/mocks/embeded_etcd.go#L66-L74 |
126,862 | ligato/cn-infra | datasync/restsync/rest_watcher.go | NewAdapter | func NewAdapter(registerHTTPHandler registerHTTPHandler, localtransp *syncbase.Registry) *Adapter {
return &Adapter{registerHTTPHandler: registerHTTPHandler, base: localtransp}
} | go | func NewAdapter(registerHTTPHandler registerHTTPHandler, localtransp *syncbase.Registry) *Adapter {
return &Adapter{registerHTTPHandler: registerHTTPHandler, base: localtransp}
} | [
"func",
"NewAdapter",
"(",
"registerHTTPHandler",
"registerHTTPHandler",
",",
"localtransp",
"*",
"syncbase",
".",
"Registry",
")",
"*",
"Adapter",
"{",
"return",
"&",
"Adapter",
"{",
"registerHTTPHandler",
":",
"registerHTTPHandler",
",",
"base",
":",
"localtransp"... | // NewAdapter is a constructor. | [
"NewAdapter",
"is",
"a",
"constructor",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/restsync/rest_watcher.go#L33-L35 |
126,863 | ligato/cn-infra | datasync/restsync/rest_watcher.go | Watch | func (adapter *Adapter) Watch(resyncName string, changeChan chan datasync.ChangeEvent,
resyncChan chan datasync.ResyncEvent, keyPrefixes ...string) (datasync.WatchRegistration, error) {
logrus.DefaultLogger().Debug("REST KeyValProtoWatcher WatchData ", resyncName, " ", keyPrefixes)
for _, keyPrefix := range keyPre... | go | func (adapter *Adapter) Watch(resyncName string, changeChan chan datasync.ChangeEvent,
resyncChan chan datasync.ResyncEvent, keyPrefixes ...string) (datasync.WatchRegistration, error) {
logrus.DefaultLogger().Debug("REST KeyValProtoWatcher WatchData ", resyncName, " ", keyPrefixes)
for _, keyPrefix := range keyPre... | [
"func",
"(",
"adapter",
"*",
"Adapter",
")",
"Watch",
"(",
"resyncName",
"string",
",",
"changeChan",
"chan",
"datasync",
".",
"ChangeEvent",
",",
"resyncChan",
"chan",
"datasync",
".",
"ResyncEvent",
",",
"keyPrefixes",
"...",
"string",
")",
"(",
"datasync",
... | // Watch registers HTTP handlers - basically bridges them with local dbadapter. | [
"Watch",
"registers",
"HTTP",
"handlers",
"-",
"basically",
"bridges",
"them",
"with",
"local",
"dbadapter",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/restsync/rest_watcher.go#L50-L63 |
126,864 | ligato/cn-infra | examples/kafka-lib/consumer/consumer.go | watchChannels | func watchChannels(consumer *client.Consumer, cfg *client.Config) {
for {
select {
case notification, more := <-cfg.RecvNotificationChan:
if more {
handleNotifcation(consumer, notification)
}
case err, more := <-cfg.RecvErrorChan:
if more {
fmt.Printf("Message Recv Errored: %v\n", err)
}
c... | go | func watchChannels(consumer *client.Consumer, cfg *client.Config) {
for {
select {
case notification, more := <-cfg.RecvNotificationChan:
if more {
handleNotifcation(consumer, notification)
}
case err, more := <-cfg.RecvErrorChan:
if more {
fmt.Printf("Message Recv Errored: %v\n", err)
}
c... | [
"func",
"watchChannels",
"(",
"consumer",
"*",
"client",
".",
"Consumer",
",",
"cfg",
"*",
"client",
".",
"Config",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"notification",
",",
"more",
":=",
"<-",
"cfg",
".",
"RecvNotificationChan",
":",
"if",
"more... | // watchChannels watches channels configured for delivery of Kafka messages,
// notifications and errors. | [
"watchChannels",
"watches",
"channels",
"configured",
"for",
"delivery",
"of",
"Kafka",
"messages",
"notifications",
"and",
"errors",
"."
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/kafka-lib/consumer/consumer.go#L134-L154 |
126,865 | ligato/cn-infra | examples/prometheus-plugin/main.go | Init | func (plugin *ExamplePlugin) Init() error {
// add new metric to default registry (accessible at the path /metrics)
//
// the current value is returned by provided callback
// created gauge is identified by tuple(namespace, subsystem, name) only the name field is mandatory
// additional properties can be defined ... | go | func (plugin *ExamplePlugin) Init() error {
// add new metric to default registry (accessible at the path /metrics)
//
// the current value is returned by provided callback
// created gauge is identified by tuple(namespace, subsystem, name) only the name field is mandatory
// additional properties can be defined ... | [
"func",
"(",
"plugin",
"*",
"ExamplePlugin",
")",
"Init",
"(",
")",
"error",
"{",
"// add new metric to default registry (accessible at the path /metrics)",
"//",
"// the current value is returned by provided callback",
"// created gauge is identified by tuple(namespace, subsystem, name)... | // Init creates metric registries and adds gauges | [
"Init",
"creates",
"metric",
"registries",
"and",
"adds",
"gauges"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/prometheus-plugin/main.go#L72-L117 |
126,866 | ligato/cn-infra | processmanager/process_options.go | Writer | func Writer(outW, errW io.Writer) POption {
return func(p *POptions) {
p.outWriter, p.errWriter = outW, errW
}
} | go | func Writer(outW, errW io.Writer) POption {
return func(p *POptions) {
p.outWriter, p.errWriter = outW, errW
}
} | [
"func",
"Writer",
"(",
"outW",
",",
"errW",
"io",
".",
"Writer",
")",
"POption",
"{",
"return",
"func",
"(",
"p",
"*",
"POptions",
")",
"{",
"p",
".",
"outWriter",
",",
"p",
".",
"errWriter",
"=",
"outW",
",",
"errW",
"\n",
"}",
"\n",
"}"
] | // Writer allows to use custom writer instance. Can be defined with nil parameters, in such a case
// standard output will be used | [
"Writer",
"allows",
"to",
"use",
"custom",
"writer",
"instance",
".",
"Can",
"be",
"defined",
"with",
"nil",
"parameters",
"in",
"such",
"a",
"case",
"standard",
"output",
"will",
"be",
"used"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process_options.go#L71-L75 |
126,867 | ligato/cn-infra | processmanager/process_options.go | Template | func Template(runOnStartup bool) POption {
return func(p *POptions) {
p.template = true
p.runOnStartup = runOnStartup
}
} | go | func Template(runOnStartup bool) POption {
return func(p *POptions) {
p.template = true
p.runOnStartup = runOnStartup
}
} | [
"func",
"Template",
"(",
"runOnStartup",
"bool",
")",
"POption",
"{",
"return",
"func",
"(",
"p",
"*",
"POptions",
")",
"{",
"p",
".",
"template",
"=",
"true",
"\n",
"p",
".",
"runOnStartup",
"=",
"runOnStartup",
"\n",
"}",
"\n",
"}"
] | // Template will be created for given process. Process template also requires a flag whether the process
// should be started automatically with plugin | [
"Template",
"will",
"be",
"created",
"for",
"given",
"process",
".",
"Process",
"template",
"also",
"requires",
"a",
"flag",
"whether",
"the",
"process",
"should",
"be",
"started",
"automatically",
"with",
"plugin"
] | 6552f4407e293b0986ec353eb0f01968cbecb928 | https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process_options.go#L93-L98 |
126,868 | paked/configure | hcl.go | Setup | func (h *HCL) Setup() error {
r, err := h.gen()
if err != nil {
return err
}
buf := new(bytes.Buffer)
buf.ReadFrom(r)
s := buf.String()
//first parse the hcl file
obj, err := hcl.Parse(s)
if err != nil {
return err
}
h.values = make(map[string]interface{})
// then decode the object
if err = hcl.Dec... | go | func (h *HCL) Setup() error {
r, err := h.gen()
if err != nil {
return err
}
buf := new(bytes.Buffer)
buf.ReadFrom(r)
s := buf.String()
//first parse the hcl file
obj, err := hcl.Parse(s)
if err != nil {
return err
}
h.values = make(map[string]interface{})
// then decode the object
if err = hcl.Dec... | [
"func",
"(",
"h",
"*",
"HCL",
")",
"Setup",
"(",
")",
"error",
"{",
"r",
",",
"err",
":=",
"h",
".",
"gen",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
... | // Setup initializes the HCL Checker | [
"Setup",
"initializes",
"the",
"HCL",
"Checker"
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/hcl.go#L38-L62 |
126,869 | paked/configure | hcl.go | Int | func (h *HCL) Int(name string) (int, error) {
v, err := h.value(name)
if err != nil {
return 0, err
}
f, ok := v.(float64)
if !ok {
i, ok := v.(int)
if !ok {
return v.(int), errors.New(fmt.Sprintf("%T unable", v))
}
return i, nil
}
return int(f), nil
} | go | func (h *HCL) Int(name string) (int, error) {
v, err := h.value(name)
if err != nil {
return 0, err
}
f, ok := v.(float64)
if !ok {
i, ok := v.(int)
if !ok {
return v.(int), errors.New(fmt.Sprintf("%T unable", v))
}
return i, nil
}
return int(f), nil
} | [
"func",
"(",
"h",
"*",
"HCL",
")",
"Int",
"(",
"name",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"h",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",... | // Int returns an int if it exists within the HCL io.Reader | [
"Int",
"returns",
"an",
"int",
"if",
"it",
"exists",
"within",
"the",
"HCL",
"io",
".",
"Reader"
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/hcl.go#L74-L91 |
126,870 | paked/configure | hcl.go | Bool | func (h *HCL) Bool(name string) (bool, error) {
v, err := h.value(name)
if err != nil {
return false, err
}
return v.(bool), nil
} | go | func (h *HCL) Bool(name string) (bool, error) {
v, err := h.value(name)
if err != nil {
return false, err
}
return v.(bool), nil
} | [
"func",
"(",
"h",
"*",
"HCL",
")",
"Bool",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"h",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
... | // Bool returns a bool if it exists within the HCL io.Reader. | [
"Bool",
"returns",
"a",
"bool",
"if",
"it",
"exists",
"within",
"the",
"HCL",
"io",
".",
"Reader",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/hcl.go#L94-L101 |
126,871 | paked/configure | hcl.go | String | func (h *HCL) String(name string) (string, error) {
v, err := h.value(name)
if err != nil {
return "", err
}
return v.(string), nil
} | go | func (h *HCL) String(name string) (string, error) {
v, err := h.value(name)
if err != nil {
return "", err
}
return v.(string), nil
} | [
"func",
"(",
"h",
"*",
"HCL",
")",
"String",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"h",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",... | // String returns a string if it exists within the HCL io.Reader. | [
"String",
"returns",
"a",
"string",
"if",
"it",
"exists",
"within",
"the",
"HCL",
"io",
".",
"Reader",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/hcl.go#L104-L111 |
126,872 | paked/configure | configure.go | Int | func (c *Configure) Int(name string, def int, description string) *int {
i := new(int)
c.IntVar(i, name, def, description)
return i
} | go | func (c *Configure) Int(name string, def int, description string) *int {
i := new(int)
c.IntVar(i, name, def, description)
return i
} | [
"func",
"(",
"c",
"*",
"Configure",
")",
"Int",
"(",
"name",
"string",
",",
"def",
"int",
",",
"description",
"string",
")",
"*",
"int",
"{",
"i",
":=",
"new",
"(",
"int",
")",
"\n",
"c",
".",
"IntVar",
"(",
"i",
",",
"name",
",",
"def",
",",
... | // Int defines an int flag with a name, default and description. The return value
// is a pointer which will be populated with the value of the flag. | [
"Int",
"defines",
"an",
"int",
"flag",
"with",
"a",
"name",
"default",
"and",
"description",
".",
"The",
"return",
"value",
"is",
"a",
"pointer",
"which",
"will",
"be",
"populated",
"with",
"the",
"value",
"of",
"the",
"flag",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L38-L43 |
126,873 | paked/configure | configure.go | String | func (c *Configure) String(name string, def string, description string) *string {
s := new(string)
c.StringVar(s, name, def, description)
return s
} | go | func (c *Configure) String(name string, def string, description string) *string {
s := new(string)
c.StringVar(s, name, def, description)
return s
} | [
"func",
"(",
"c",
"*",
"Configure",
")",
"String",
"(",
"name",
"string",
",",
"def",
"string",
",",
"description",
"string",
")",
"*",
"string",
"{",
"s",
":=",
"new",
"(",
"string",
")",
"\n",
"c",
".",
"StringVar",
"(",
"s",
",",
"name",
",",
... | // String defines a string flag with a name, default and description. The return value
// is a pointer which will be populated with the value of the flag. | [
"String",
"defines",
"a",
"string",
"flag",
"with",
"a",
"name",
"default",
"and",
"description",
".",
"The",
"return",
"value",
"is",
"a",
"pointer",
"which",
"will",
"be",
"populated",
"with",
"the",
"value",
"of",
"the",
"flag",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L52-L57 |
126,874 | paked/configure | configure.go | Bool | func (c *Configure) Bool(name string, def bool, description string) *bool {
b := new(bool)
c.BoolVar(b, name, def, description)
return b
} | go | func (c *Configure) Bool(name string, def bool, description string) *bool {
b := new(bool)
c.BoolVar(b, name, def, description)
return b
} | [
"func",
"(",
"c",
"*",
"Configure",
")",
"Bool",
"(",
"name",
"string",
",",
"def",
"bool",
",",
"description",
"string",
")",
"*",
"bool",
"{",
"b",
":=",
"new",
"(",
"bool",
")",
"\n",
"c",
".",
"BoolVar",
"(",
"b",
",",
"name",
",",
"def",
"... | // Bool defines a bool flag with a name, default and description. The return value
// is a pointer which will be populated with the value of the flag. | [
"Bool",
"defines",
"a",
"bool",
"flag",
"with",
"a",
"name",
"default",
"and",
"description",
".",
"The",
"return",
"value",
"is",
"a",
"pointer",
"which",
"will",
"be",
"populated",
"with",
"the",
"value",
"of",
"the",
"flag",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L66-L71 |
126,875 | paked/configure | configure.go | option | func (c *Configure) option(value interface{}, name string, def interface{}, description string, typ valueType) {
opt := &option{
name: name,
def: def,
description: description,
typ: typ,
value: value,
}
c.options[name] = opt
} | go | func (c *Configure) option(value interface{}, name string, def interface{}, description string, typ valueType) {
opt := &option{
name: name,
def: def,
description: description,
typ: typ,
value: value,
}
c.options[name] = opt
} | [
"func",
"(",
"c",
"*",
"Configure",
")",
"option",
"(",
"value",
"interface",
"{",
"}",
",",
"name",
"string",
",",
"def",
"interface",
"{",
"}",
",",
"description",
"string",
",",
"typ",
"valueType",
")",
"{",
"opt",
":=",
"&",
"option",
"{",
"name"... | // option will bind a pointer to a value provided in the value parameter to
// set flag value. | [
"option",
"will",
"bind",
"a",
"pointer",
"to",
"a",
"value",
"provided",
"in",
"the",
"value",
"parameter",
"to",
"set",
"flag",
"value",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L75-L85 |
126,876 | paked/configure | configure.go | Use | func (c *Configure) Use(checkers ...Checker) {
c.stack = append(c.stack, checkers...)
} | go | func (c *Configure) Use(checkers ...Checker) {
c.stack = append(c.stack, checkers...)
} | [
"func",
"(",
"c",
"*",
"Configure",
")",
"Use",
"(",
"checkers",
"...",
"Checker",
")",
"{",
"c",
".",
"stack",
"=",
"append",
"(",
"c",
".",
"stack",
",",
"checkers",
"...",
")",
"\n",
"}"
] | // Use adds a variable amount of Checkers onto the stack. | [
"Use",
"adds",
"a",
"variable",
"amount",
"of",
"Checkers",
"onto",
"the",
"stack",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L88-L90 |
126,877 | paked/configure | configure.go | Parse | func (c *Configure) Parse() {
c.setup()
for _, opt := range c.options {
changed := false
for _, checker := range c.stack {
switch opt.typ {
case stringType:
s, err := checker.String(opt.name)
if err != nil {
continue
}
opt.set(s)
case intType:
i, err := checker.Int(opt.name)
... | go | func (c *Configure) Parse() {
c.setup()
for _, opt := range c.options {
changed := false
for _, checker := range c.stack {
switch opt.typ {
case stringType:
s, err := checker.String(opt.name)
if err != nil {
continue
}
opt.set(s)
case intType:
i, err := checker.Int(opt.name)
... | [
"func",
"(",
"c",
"*",
"Configure",
")",
"Parse",
"(",
")",
"{",
"c",
".",
"setup",
"(",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"c",
".",
"options",
"{",
"changed",
":=",
"false",
"\n",
"for",
"_",
",",
"checker",
":=",
"range",
"c",... | // Parse populates all of the defined arguments with their values provided by
// the stacks Checkers. | [
"Parse",
"populates",
"all",
"of",
"the",
"defined",
"arguments",
"with",
"their",
"values",
"provided",
"by",
"the",
"stacks",
"Checkers",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L104-L141 |
126,878 | paked/configure | configure.go | New | func New(stack ...Checker) *Configure {
c := &Configure{
options: make(map[string]*option),
stack: stack,
}
return c
} | go | func New(stack ...Checker) *Configure {
c := &Configure{
options: make(map[string]*option),
stack: stack,
}
return c
} | [
"func",
"New",
"(",
"stack",
"...",
"Checker",
")",
"*",
"Configure",
"{",
"c",
":=",
"&",
"Configure",
"{",
"options",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"option",
")",
",",
"stack",
":",
"stack",
",",
"}",
"\n\n",
"return",
"c",
... | // New returns a pointer to a new Configure instance with a stack
// provided through the variadic stack variable. | [
"New",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Configure",
"instance",
"with",
"a",
"stack",
"provided",
"through",
"the",
"variadic",
"stack",
"variable",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/configure.go#L145-L152 |
126,879 | paked/configure | environment.go | Int | func (e Environment) Int(name string) (int, error) {
v, err := e.value(name)
if err != nil {
return 0, err
}
i, err := strconv.Atoi(v)
if err != nil {
return 0, err
}
return i, nil
} | go | func (e Environment) Int(name string) (int, error) {
v, err := e.value(name)
if err != nil {
return 0, err
}
i, err := strconv.Atoi(v)
if err != nil {
return 0, err
}
return i, nil
} | [
"func",
"(",
"e",
"Environment",
")",
"Int",
"(",
"name",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"e",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}"... | // Int returns an int if it exists in the set environment variables. | [
"Int",
"returns",
"an",
"int",
"if",
"it",
"exists",
"in",
"the",
"set",
"environment",
"variables",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/environment.go#L49-L61 |
126,880 | paked/configure | environment.go | Bool | func (e *Environment) Bool(name string) (bool, error) {
v, err := e.value(name)
if err != nil {
return false, err
}
return strconv.ParseBool(v)
} | go | func (e *Environment) Bool(name string) (bool, error) {
v, err := e.value(name)
if err != nil {
return false, err
}
return strconv.ParseBool(v)
} | [
"func",
"(",
"e",
"*",
"Environment",
")",
"Bool",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"e",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
... | // Bool returns a bool if it exists in the set environment variables. | [
"Bool",
"returns",
"a",
"bool",
"if",
"it",
"exists",
"in",
"the",
"set",
"environment",
"variables",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/environment.go#L64-L71 |
126,881 | paked/configure | environment.go | String | func (e Environment) String(name string) (string, error) {
return e.value(name)
} | go | func (e Environment) String(name string) (string, error) {
return e.value(name)
} | [
"func",
"(",
"e",
"Environment",
")",
"String",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"e",
".",
"value",
"(",
"name",
")",
"\n",
"}"
] | // String returns a string if it exists in the set environment variables. | [
"String",
"returns",
"a",
"string",
"if",
"it",
"exists",
"in",
"the",
"set",
"environment",
"variables",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/environment.go#L74-L76 |
126,882 | paked/configure | json.go | NewJSONFromFile | func NewJSONFromFile(path string) *JSON {
return NewJSON(func() (io.Reader, error) {
return os.Open(path)
})
} | go | func NewJSONFromFile(path string) *JSON {
return NewJSON(func() (io.Reader, error) {
return os.Open(path)
})
} | [
"func",
"NewJSONFromFile",
"(",
"path",
"string",
")",
"*",
"JSON",
"{",
"return",
"NewJSON",
"(",
"func",
"(",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"return",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"}",
")",
"\n",
"}"
] | // NewJSONFromFile returns an instance of the JSON checker. It reads its
// data from a file which its location has been specified through the path
// parameter | [
"NewJSONFromFile",
"returns",
"an",
"instance",
"of",
"the",
"JSON",
"checker",
".",
"It",
"reads",
"its",
"data",
"from",
"a",
"file",
"which",
"its",
"location",
"has",
"been",
"specified",
"through",
"the",
"path",
"parameter"
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/json.go#L23-L27 |
126,883 | paked/configure | json.go | Setup | func (j *JSON) Setup() error {
r, err := j.gen()
if err != nil {
return err
}
dec := json.NewDecoder(r)
j.values = make(map[string]interface{})
return dec.Decode(&j.values)
} | go | func (j *JSON) Setup() error {
r, err := j.gen()
if err != nil {
return err
}
dec := json.NewDecoder(r)
j.values = make(map[string]interface{})
return dec.Decode(&j.values)
} | [
"func",
"(",
"j",
"*",
"JSON",
")",
"Setup",
"(",
")",
"error",
"{",
"r",
",",
"err",
":=",
"j",
".",
"gen",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"dec",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
... | //Setup initializes the JSON Checker | [
"Setup",
"initializes",
"the",
"JSON",
"Checker"
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/json.go#L36-L46 |
126,884 | paked/configure | json.go | Int | func (j *JSON) Int(name string) (int, error) {
v, err := j.value(name)
if err != nil {
return 0, err
}
f, ok := v.(float64)
if !ok {
return 0, errors.New(fmt.Sprintf("%T unable", v))
}
return int(f), nil
} | go | func (j *JSON) Int(name string) (int, error) {
v, err := j.value(name)
if err != nil {
return 0, err
}
f, ok := v.(float64)
if !ok {
return 0, errors.New(fmt.Sprintf("%T unable", v))
}
return int(f), nil
} | [
"func",
"(",
"j",
"*",
"JSON",
")",
"Int",
"(",
"name",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"j",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}"... | // Int returns an int if it exists within the marshalled JSON io.Reader. | [
"Int",
"returns",
"an",
"int",
"if",
"it",
"exists",
"within",
"the",
"marshalled",
"JSON",
"io",
".",
"Reader",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/json.go#L58-L70 |
126,885 | paked/configure | json.go | Bool | func (j *JSON) Bool(name string) (bool, error) {
v, err := j.value(name)
if err != nil {
return false, err
}
b, ok := v.(bool)
if !ok {
return false, errors.New("unable to cast")
}
return b, nil
} | go | func (j *JSON) Bool(name string) (bool, error) {
v, err := j.value(name)
if err != nil {
return false, err
}
b, ok := v.(bool)
if !ok {
return false, errors.New("unable to cast")
}
return b, nil
} | [
"func",
"(",
"j",
"*",
"JSON",
")",
"Bool",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"j",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",... | // Bool returns a bool if it exists within the marshalled JSON io.Reader. | [
"Bool",
"returns",
"a",
"bool",
"if",
"it",
"exists",
"within",
"the",
"marshalled",
"JSON",
"io",
".",
"Reader",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/json.go#L73-L85 |
126,886 | paked/configure | json.go | String | func (j *JSON) String(name string) (string, error) {
v, err := j.value(name)
if err != nil {
return "", err
}
s, ok := v.(string)
if !ok {
return "", errors.New(fmt.Sprintf("unable to cast %T", v))
}
return s, nil
} | go | func (j *JSON) String(name string) (string, error) {
v, err := j.value(name)
if err != nil {
return "", err
}
s, ok := v.(string)
if !ok {
return "", errors.New(fmt.Sprintf("unable to cast %T", v))
}
return s, nil
} | [
"func",
"(",
"j",
"*",
"JSON",
")",
"String",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"j",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err"... | // String returns a string if it exists within the marshalled JSON io.Reader. | [
"String",
"returns",
"a",
"string",
"if",
"it",
"exists",
"within",
"the",
"marshalled",
"JSON",
"io",
".",
"Reader",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/json.go#L88-L100 |
126,887 | paked/configure | flag.go | NewFlag | func NewFlag() *Flag {
f := &Flag{
args: os.Args,
defaults: defaultsPrinter,
}
return f
} | go | func NewFlag() *Flag {
f := &Flag{
args: os.Args,
defaults: defaultsPrinter,
}
return f
} | [
"func",
"NewFlag",
"(",
")",
"*",
"Flag",
"{",
"f",
":=",
"&",
"Flag",
"{",
"args",
":",
"os",
".",
"Args",
",",
"defaults",
":",
"defaultsPrinter",
",",
"}",
"\n\n",
"return",
"f",
"\n",
"}"
] | // NewFlag returns a new instance of the Flag Checker, using os.Args as its
// flag source. | [
"NewFlag",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Flag",
"Checker",
"using",
"os",
".",
"Args",
"as",
"its",
"flag",
"source",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/flag.go#L13-L20 |
126,888 | paked/configure | flag.go | NewFlagWithUsage | func NewFlagWithUsage(defaulter func() string) *Flag {
f := &Flag{
args: os.Args,
defaults: defaulter,
}
return f
} | go | func NewFlagWithUsage(defaulter func() string) *Flag {
f := &Flag{
args: os.Args,
defaults: defaulter,
}
return f
} | [
"func",
"NewFlagWithUsage",
"(",
"defaulter",
"func",
"(",
")",
"string",
")",
"*",
"Flag",
"{",
"f",
":=",
"&",
"Flag",
"{",
"args",
":",
"os",
".",
"Args",
",",
"defaults",
":",
"defaulter",
",",
"}",
"\n\n",
"return",
"f",
"\n",
"}"
] | // NewFlagWithUsage returns a new instance of the Flag Checker with a custom
// usage printer. It uses os.Args as its flag source. | [
"NewFlagWithUsage",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Flag",
"Checker",
"with",
"a",
"custom",
"usage",
"printer",
".",
"It",
"uses",
"os",
".",
"Args",
"as",
"its",
"flag",
"source",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/flag.go#L24-L31 |
126,889 | paked/configure | flag.go | Int | func (f Flag) Int(name string) (int, error) {
v, err := f.value(name)
if err != nil {
return 0, err
}
i, err := strconv.Atoi(v)
if err != nil {
return 0, err
}
return i, nil
} | go | func (f Flag) Int(name string) (int, error) {
v, err := f.value(name)
if err != nil {
return 0, err
}
i, err := strconv.Atoi(v)
if err != nil {
return 0, err
}
return i, nil
} | [
"func",
"(",
"f",
"Flag",
")",
"Int",
"(",
"name",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"f",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n... | // Int returns an int if it exists in the set flags. | [
"Int",
"returns",
"an",
"int",
"if",
"it",
"exists",
"in",
"the",
"set",
"flags",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/flag.go#L74-L86 |
126,890 | paked/configure | flag.go | Bool | func (f *Flag) Bool(name string) (bool, error) {
v, err := f.value(name)
if err != nil {
return false, err
}
return strconv.ParseBool(v)
} | go | func (f *Flag) Bool(name string) (bool, error) {
v, err := f.value(name)
if err != nil {
return false, err
}
return strconv.ParseBool(v)
} | [
"func",
"(",
"f",
"*",
"Flag",
")",
"Bool",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"f",
".",
"value",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",... | // Bool returns a bool if it exists in the set flags. | [
"Bool",
"returns",
"a",
"bool",
"if",
"it",
"exists",
"in",
"the",
"set",
"flags",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/flag.go#L89-L96 |
126,891 | paked/configure | flag.go | String | func (f Flag) String(name string) (string, error) {
return f.value(name)
} | go | func (f Flag) String(name string) (string, error) {
return f.value(name)
} | [
"func",
"(",
"f",
"Flag",
")",
"String",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"f",
".",
"value",
"(",
"name",
")",
"\n",
"}"
] | // String returns a string if it exists in the set flags. | [
"String",
"returns",
"a",
"string",
"if",
"it",
"exists",
"in",
"the",
"set",
"flags",
"."
] | 28f9c3f21a4454ca2e6ae1358856c6908293a46f | https://github.com/paked/configure/blob/28f9c3f21a4454ca2e6ae1358856c6908293a46f/flag.go#L99-L101 |
126,892 | go-playground/log | log.go | SetContext | func SetContext(ctx context.Context, e Entry) context.Context {
return context.WithValue(ctx, ctxIdent, e)
} | go | func SetContext(ctx context.Context, e Entry) context.Context {
return context.WithValue(ctx, ctxIdent, e)
} | [
"func",
"SetContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"e",
"Entry",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxIdent",
",",
"e",
")",
"\n",
"}"
] | // SetContext sets a log entry into the provided context | [
"SetContext",
"sets",
"a",
"log",
"entry",
"into",
"the",
"provided",
"context"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L49-L51 |
126,893 | go-playground/log | log.go | GetContext | func GetContext(ctx context.Context) Entry {
v := ctx.Value(ctxIdent)
if v == nil {
return newEntryWithFields(nil)
}
return v.(Entry)
} | go | func GetContext(ctx context.Context) Entry {
v := ctx.Value(ctxIdent)
if v == nil {
return newEntryWithFields(nil)
}
return v.(Entry)
} | [
"func",
"GetContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"Entry",
"{",
"v",
":=",
"ctx",
".",
"Value",
"(",
"ctxIdent",
")",
"\n",
"if",
"v",
"==",
"nil",
"{",
"return",
"newEntryWithFields",
"(",
"nil",
")",
"\n",
"}",
"\n",
"return",
"v",
... | // GetContext returns the log Entry found in the context,
// or a new Default log Entry if none is found | [
"GetContext",
"returns",
"the",
"log",
"Entry",
"found",
"in",
"the",
"context",
"or",
"a",
"new",
"Default",
"log",
"Entry",
"if",
"none",
"is",
"found"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L55-L61 |
126,894 | go-playground/log | log.go | HandleEntry | func HandleEntry(e Entry) {
if !e.start.IsZero() {
e = e.WithField("duration", time.Since(e.start))
}
e.Timestamp = time.Now()
rw.RLock()
for _, h := range logHandlers[e.Level] {
h.Log(e)
}
rw.RUnlock()
} | go | func HandleEntry(e Entry) {
if !e.start.IsZero() {
e = e.WithField("duration", time.Since(e.start))
}
e.Timestamp = time.Now()
rw.RLock()
for _, h := range logHandlers[e.Level] {
h.Log(e)
}
rw.RUnlock()
} | [
"func",
"HandleEntry",
"(",
"e",
"Entry",
")",
"{",
"if",
"!",
"e",
".",
"start",
".",
"IsZero",
"(",
")",
"{",
"e",
"=",
"e",
".",
"WithField",
"(",
"\"",
"\"",
",",
"time",
".",
"Since",
"(",
"e",
".",
"start",
")",
")",
"\n",
"}",
"\n",
... | // HandleEntry handles the log entry and fans out to all handlers with the proper log level
// This is exposed to allow for centralized logging whereby the log entry is marshalled, passed
// to a central logging server, unmarshalled and finally fanned out from there. | [
"HandleEntry",
"handles",
"the",
"log",
"entry",
"and",
"fans",
"out",
"to",
"all",
"handlers",
"with",
"the",
"proper",
"log",
"level",
"This",
"is",
"exposed",
"to",
"allow",
"for",
"centralized",
"logging",
"whereby",
"the",
"log",
"entry",
"is",
"marshal... | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L66-L77 |
126,895 | go-playground/log | log.go | F | func F(key string, value interface{}) Field {
return Field{Key: key, Value: value}
} | go | func F(key string, value interface{}) Field {
return Field{Key: key, Value: value}
} | [
"func",
"F",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"Field",
"{",
"return",
"Field",
"{",
"Key",
":",
"key",
",",
"Value",
":",
"value",
"}",
"\n",
"}"
] | // F creates a new Field using the supplied key + value.
// it is shorthand for defining field manually | [
"F",
"creates",
"a",
"new",
"Field",
"using",
"the",
"supplied",
"key",
"+",
"value",
".",
"it",
"is",
"shorthand",
"for",
"defining",
"field",
"manually"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L81-L83 |
126,896 | go-playground/log | log.go | AddHandler | func AddHandler(h Handler, levels ...Level) {
rw.Lock()
for _, level := range levels {
handler := append(logHandlers[level], h)
logHandlers[level] = handler
}
rw.Unlock()
} | go | func AddHandler(h Handler, levels ...Level) {
rw.Lock()
for _, level := range levels {
handler := append(logHandlers[level], h)
logHandlers[level] = handler
}
rw.Unlock()
} | [
"func",
"AddHandler",
"(",
"h",
"Handler",
",",
"levels",
"...",
"Level",
")",
"{",
"rw",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"level",
":=",
"range",
"levels",
"{",
"handler",
":=",
"append",
"(",
"logHandlers",
"[",
"level",
"]",
",",
"h... | // AddHandler adds a new log handler and accepts which log levels that
// handler will be triggered for | [
"AddHandler",
"adds",
"a",
"new",
"log",
"handler",
"and",
"accepts",
"which",
"log",
"levels",
"that",
"handler",
"will",
"be",
"triggered",
"for"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L87-L94 |
126,897 | go-playground/log | log.go | RemoveHandler | func RemoveHandler(h Handler) {
rw.Lock()
OUTER:
for lvl, handlers := range logHandlers {
for i, handler := range handlers {
if h == handler {
n := append(handlers[:i], handlers[i+1:]...)
if len(n) == 0 {
delete(logHandlers, lvl)
continue OUTER
}
logHandlers[lvl] = n
continue OUTER
... | go | func RemoveHandler(h Handler) {
rw.Lock()
OUTER:
for lvl, handlers := range logHandlers {
for i, handler := range handlers {
if h == handler {
n := append(handlers[:i], handlers[i+1:]...)
if len(n) == 0 {
delete(logHandlers, lvl)
continue OUTER
}
logHandlers[lvl] = n
continue OUTER
... | [
"func",
"RemoveHandler",
"(",
"h",
"Handler",
")",
"{",
"rw",
".",
"Lock",
"(",
")",
"\n",
"OUTER",
":",
"for",
"lvl",
",",
"handlers",
":=",
"range",
"logHandlers",
"{",
"for",
"i",
",",
"handler",
":=",
"range",
"handlers",
"{",
"if",
"h",
"==",
... | // RemoveHandler removes an existing handler | [
"RemoveHandler",
"removes",
"an",
"existing",
"handler"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L97-L114 |
126,898 | go-playground/log | log.go | RemoveHandlerLevels | func RemoveHandlerLevels(h Handler, levels ...Level) {
rw.Lock()
OUTER:
for _, lvl := range levels {
handlers := logHandlers[lvl]
for i, handler := range handlers {
if h == handler {
n := append(handlers[:i], handlers[i+1:]...)
if len(n) == 0 {
delete(logHandlers, lvl)
continue OUTER
}
... | go | func RemoveHandlerLevels(h Handler, levels ...Level) {
rw.Lock()
OUTER:
for _, lvl := range levels {
handlers := logHandlers[lvl]
for i, handler := range handlers {
if h == handler {
n := append(handlers[:i], handlers[i+1:]...)
if len(n) == 0 {
delete(logHandlers, lvl)
continue OUTER
}
... | [
"func",
"RemoveHandlerLevels",
"(",
"h",
"Handler",
",",
"levels",
"...",
"Level",
")",
"{",
"rw",
".",
"Lock",
"(",
")",
"\n",
"OUTER",
":",
"for",
"_",
",",
"lvl",
":=",
"range",
"levels",
"{",
"handlers",
":=",
"logHandlers",
"[",
"lvl",
"]",
"\n"... | // RemoveHandlerLevels removes the supplied levels, if no more levels exists for the handler
// it will no longer be registered and need to to added via AddHandler again. | [
"RemoveHandlerLevels",
"removes",
"the",
"supplied",
"levels",
"if",
"no",
"more",
"levels",
"exists",
"for",
"the",
"handler",
"it",
"will",
"no",
"longer",
"be",
"registered",
"and",
"need",
"to",
"to",
"added",
"via",
"AddHandler",
"again",
"."
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L118-L136 |
126,899 | go-playground/log | log.go | WithTrace | func WithTrace() Entry {
ne := newEntryWithFields(logFields)
ne.start = time.Now()
return ne
} | go | func WithTrace() Entry {
ne := newEntryWithFields(logFields)
ne.start = time.Now()
return ne
} | [
"func",
"WithTrace",
"(",
")",
"Entry",
"{",
"ne",
":=",
"newEntryWithFields",
"(",
"logFields",
")",
"\n",
"ne",
".",
"start",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"return",
"ne",
"\n",
"}"
] | // WithTrace withh add duration of how long the between this function call and
// the susequent log | [
"WithTrace",
"withh",
"add",
"duration",
"of",
"how",
"long",
"the",
"between",
"this",
"function",
"call",
"and",
"the",
"susequent",
"log"
] | fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19 | https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L159-L163 |
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.