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,600
ligato/cn-infra
db/keyval/filedb/decoder/mock_decoder.go
Encode
func (mock *Mock) Encode(data []*FileDataEntry) ([]byte, error) { items := mock.getReturnValues("Decode") if len(items) == 1 { switch typed := items[0].(type) { case []byte: return typed, nil case error: return []byte{}, typed } } else if len(items) == 2 { return items[0].([]byte), items[1].(error) ...
go
func (mock *Mock) Encode(data []*FileDataEntry) ([]byte, error) { items := mock.getReturnValues("Decode") if len(items) == 1 { switch typed := items[0].(type) { case []byte: return typed, nil case error: return []byte{}, typed } } else if len(items) == 2 { return items[0].([]byte), items[1].(error) ...
[ "func", "(", "mock", "*", "Mock", ")", "Encode", "(", "data", "[", "]", "*", "FileDataEntry", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "if", "len", "(", "items"...
// Encode mocks original method
[ "Encode", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/decoder/mock_decoder.go#L87-L100
126,601
ligato/cn-infra
db/keyval/filedb/decoder/mock_decoder.go
Decode
func (mock *Mock) Decode(data []byte) ([]*FileDataEntry, error) { items := mock.getReturnValues("Decode") if len(items) == 1 { switch typed := items[0].(type) { case []*FileDataEntry: return typed, nil case error: return []*FileDataEntry{}, typed } } else if len(items) == 2 { return items[0].([]*File...
go
func (mock *Mock) Decode(data []byte) ([]*FileDataEntry, error) { items := mock.getReturnValues("Decode") if len(items) == 1 { switch typed := items[0].(type) { case []*FileDataEntry: return typed, nil case error: return []*FileDataEntry{}, typed } } else if len(items) == 2 { return items[0].([]*File...
[ "func", "(", "mock", "*", "Mock", ")", "Decode", "(", "data", "[", "]", "byte", ")", "(", "[", "]", "*", "FileDataEntry", ",", "error", ")", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "if", "len", "(", "items"...
// Decode mocks original method
[ "Decode", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/decoder/mock_decoder.go#L103-L116
126,602
ligato/cn-infra
rpc/grpc/plugin_impl_grpc.go
Init
func (p *Plugin) Init() (err error) { // Get GRPC configuration file if p.Config == nil { p.Config, err = p.getGrpcConfig() if err != nil || p.disabled { return err } } // Prepare GRPC server if p.grpcServer == nil { opts := p.Config.getGrpcOptions() if p.tlsConfig != nil { opts = append(opts, grp...
go
func (p *Plugin) Init() (err error) { // Get GRPC configuration file if p.Config == nil { p.Config, err = p.getGrpcConfig() if err != nil || p.disabled { return err } } // Prepare GRPC server if p.grpcServer == nil { opts := p.Config.getGrpcOptions() if p.tlsConfig != nil { opts = append(opts, grp...
[ "func", "(", "p", "*", "Plugin", ")", "Init", "(", ")", "(", "err", "error", ")", "{", "// Get GRPC configuration file", "if", "p", ".", "Config", "==", "nil", "{", "p", ".", "Config", ",", "err", "=", "p", ".", "getGrpcConfig", "(", ")", "\n", "if...
// Init prepares GRPC netListener for registration of individual service
[ "Init", "prepares", "GRPC", "netListener", "for", "registration", "of", "individual", "service" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/grpc/plugin_impl_grpc.go#L55-L81
126,603
ligato/cn-infra
rpc/grpc/plugin_impl_grpc.go
AfterInit
func (p *Plugin) AfterInit() (err error) { if p.disabled { return nil } if p.Deps.HTTP != nil { p.Log.Infof("exposing GRPC services via HTTP (port %v) on: /service", strconv.Itoa(p.Deps.HTTP.GetPort())) p.Deps.HTTP.RegisterHTTPHandler("/service", func(formatter *render.Render) http.HandlerFunc { return ...
go
func (p *Plugin) AfterInit() (err error) { if p.disabled { return nil } if p.Deps.HTTP != nil { p.Log.Infof("exposing GRPC services via HTTP (port %v) on: /service", strconv.Itoa(p.Deps.HTTP.GetPort())) p.Deps.HTTP.RegisterHTTPHandler("/service", func(formatter *render.Render) http.HandlerFunc { return ...
[ "func", "(", "p", "*", "Plugin", ")", "AfterInit", "(", ")", "(", "err", "error", ")", "{", "if", "p", ".", "disabled", "{", "return", "nil", "\n", "}", "\n\n", "if", "p", ".", "Deps", ".", "HTTP", "!=", "nil", "{", "p", ".", "Log", ".", "Inf...
// AfterInit starts the HTTP netListener.
[ "AfterInit", "starts", "the", "HTTP", "netListener", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/grpc/plugin_impl_grpc.go#L84-L107
126,604
ligato/cn-infra
rpc/grpc/plugin_impl_grpc.go
Close
func (p *Plugin) Close() error { if p.grpcServer != nil { p.grpcServer.Stop() } return nil }
go
func (p *Plugin) Close() error { if p.grpcServer != nil { p.grpcServer.Stop() } return nil }
[ "func", "(", "p", "*", "Plugin", ")", "Close", "(", ")", "error", "{", "if", "p", ".", "grpcServer", "!=", "nil", "{", "p", ".", "grpcServer", ".", "Stop", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Close stops the HTTP netListener.
[ "Close", "stops", "the", "HTTP", "netListener", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/grpc/plugin_impl_grpc.go#L110-L115
126,605
ligato/cn-infra
db/keyval/redis/config.go
ConfigToClient
func ConfigToClient(config interface{}) (Client, error) { switch cfg := config.(type) { case NodeConfig: return CreateNodeClient(cfg) case ClusterConfig: return CreateClusterClient(cfg) case SentinelConfig: return CreateSentinelClient(cfg) case nil: return nil, fmt.Errorf("Configuration cannot be nil") } ...
go
func ConfigToClient(config interface{}) (Client, error) { switch cfg := config.(type) { case NodeConfig: return CreateNodeClient(cfg) case ClusterConfig: return CreateClusterClient(cfg) case SentinelConfig: return CreateSentinelClient(cfg) case nil: return nil, fmt.Errorf("Configuration cannot be nil") } ...
[ "func", "ConfigToClient", "(", "config", "interface", "{", "}", ")", "(", "Client", ",", "error", ")", "{", "switch", "cfg", ":=", "config", ".", "(", "type", ")", "{", "case", "NodeConfig", ":", "return", "CreateNodeClient", "(", "cfg", ")", "\n", "ca...
// ConfigToClient creates an appropriate client according to the configuration // parameter.
[ "ConfigToClient", "creates", "an", "appropriate", "client", "according", "to", "the", "configuration", "parameter", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/redis/config.go#L191-L203
126,606
ligato/cn-infra
db/keyval/redis/config.go
CreateClusterClient
func CreateClusterClient(config ClusterConfig) (Client, error) { return goredis.NewClusterClient(&goredis.ClusterOptions{ Addrs: config.Endpoints, // Enables read only queries on slave nodes. ReadOnly: config.EnableReadQueryOnSlave, MaxRedirects: config.MaxRedirects, RouteByLatency: config.RouteByLatency...
go
func CreateClusterClient(config ClusterConfig) (Client, error) { return goredis.NewClusterClient(&goredis.ClusterOptions{ Addrs: config.Endpoints, // Enables read only queries on slave nodes. ReadOnly: config.EnableReadQueryOnSlave, MaxRedirects: config.MaxRedirects, RouteByLatency: config.RouteByLatency...
[ "func", "CreateClusterClient", "(", "config", "ClusterConfig", ")", "(", "Client", ",", "error", ")", "{", "return", "goredis", ".", "NewClusterClient", "(", "&", "goredis", ".", "ClusterOptions", "{", "Addrs", ":", "config", ".", "Endpoints", ",", "// Enables...
// CreateClusterClient Creates a client that will connect to a redis cluster.
[ "CreateClusterClient", "Creates", "a", "client", "that", "will", "connect", "to", "a", "redis", "cluster", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/redis/config.go#L263-L302
126,607
ligato/cn-infra
db/keyval/redis/config.go
CreateSentinelClient
func CreateSentinelClient(config SentinelConfig) (Client, error) { return goredis.NewFailoverClient(&goredis.FailoverOptions{ SentinelAddrs: config.Endpoints, DB: config.DB, MasterName: config.MasterName, // Optional password. Must match the password specified in the requirepass server configuration option....
go
func CreateSentinelClient(config SentinelConfig) (Client, error) { return goredis.NewFailoverClient(&goredis.FailoverOptions{ SentinelAddrs: config.Endpoints, DB: config.DB, MasterName: config.MasterName, // Optional password. Must match the password specified in the requirepass server configuration option....
[ "func", "CreateSentinelClient", "(", "config", "SentinelConfig", ")", "(", "Client", ",", "error", ")", "{", "return", "goredis", ".", "NewFailoverClient", "(", "&", "goredis", ".", "FailoverOptions", "{", "SentinelAddrs", ":", "config", ".", "Endpoints", ",", ...
// CreateSentinelClient Creates a failover client that will connect to redis sentinels.
[ "CreateSentinelClient", "Creates", "a", "failover", "client", "that", "will", "connect", "to", "redis", "sentinels", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/redis/config.go#L305-L338
126,608
ligato/cn-infra
db/keyval/redis/config.go
LoadConfig
func LoadConfig(configFile string) (cfg interface{}, err error) { b, err := ioutil.ReadFile(configFile) if err != nil { return nil, err } var s SentinelConfig err = yaml.Unmarshal(b, &s) if err != nil { return nil, err } if s.MasterName != "" { return s, nil } n := NodeConfig{} err = yaml.Unmarshal(b...
go
func LoadConfig(configFile string) (cfg interface{}, err error) { b, err := ioutil.ReadFile(configFile) if err != nil { return nil, err } var s SentinelConfig err = yaml.Unmarshal(b, &s) if err != nil { return nil, err } if s.MasterName != "" { return s, nil } n := NodeConfig{} err = yaml.Unmarshal(b...
[ "func", "LoadConfig", "(", "configFile", "string", ")", "(", "cfg", "interface", "{", "}", ",", "err", "error", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "configFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// LoadConfig Loads the given configFile and returns appropriate config instance.
[ "LoadConfig", "Loads", "the", "given", "configFile", "and", "returns", "appropriate", "config", "instance", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/redis/config.go#L341-L371
126,609
ligato/cn-infra
datasync/grpcsync/plugin_impl_grpsync.go
Init
func (p *Plugin) Init() error { p.Adapter = &syncbase.Adapter{ Watcher: NewAdapter(p.GRPC.GetServer()), } return nil }
go
func (p *Plugin) Init() error { p.Adapter = &syncbase.Adapter{ Watcher: NewAdapter(p.GRPC.GetServer()), } return nil }
[ "func", "(", "p", "*", "Plugin", ")", "Init", "(", ")", "error", "{", "p", ".", "Adapter", "=", "&", "syncbase", ".", "Adapter", "{", "Watcher", ":", "NewAdapter", "(", "p", ".", "GRPC", ".", "GetServer", "(", ")", ")", ",", "}", "\n", "return", ...
// Init registers new gRPC service and instantiates plugin.Adapter.
[ "Init", "registers", "new", "gRPC", "service", "and", "instantiates", "plugin", ".", "Adapter", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/grpcsync/plugin_impl_grpsync.go#L38-L43
126,610
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
NewPluginStatusMap
func NewPluginStatusMap(owner infra.PluginName) PluginStatusIdxMapRW { return &pluginStatusMap{ mapping: mem.NewNamedMapping(logrus.DefaultLogger(), "plugin_status", IndexPluginStatus), } }
go
func NewPluginStatusMap(owner infra.PluginName) PluginStatusIdxMapRW { return &pluginStatusMap{ mapping: mem.NewNamedMapping(logrus.DefaultLogger(), "plugin_status", IndexPluginStatus), } }
[ "func", "NewPluginStatusMap", "(", "owner", "infra", ".", "PluginName", ")", "PluginStatusIdxMapRW", "{", "return", "&", "pluginStatusMap", "{", "mapping", ":", "mem", ".", "NewNamedMapping", "(", "logrus", ".", "DefaultLogger", "(", ")", ",", "\"", "\"", ",",...
// NewPluginStatusMap is a constructor for PluginStatusIdxMapRW.
[ "NewPluginStatusMap", "is", "a", "constructor", "for", "PluginStatusIdxMapRW", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L52-L56
126,611
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
Put
func (swi *pluginStatusMap) Put(pluginName string, pluginStatus *status.PluginStatus) { swi.mapping.Put(pluginName, pluginStatus) }
go
func (swi *pluginStatusMap) Put(pluginName string, pluginStatus *status.PluginStatus) { swi.mapping.Put(pluginName, pluginStatus) }
[ "func", "(", "swi", "*", "pluginStatusMap", ")", "Put", "(", "pluginName", "string", ",", "pluginStatus", "*", "status", ".", "PluginStatus", ")", "{", "swi", ".", "mapping", ".", "Put", "(", "pluginName", ",", "pluginStatus", ")", "\n", "}" ]
// RegisterName adds new item into the name-to-index mapping.
[ "RegisterName", "adds", "new", "item", "into", "the", "name", "-", "to", "-", "index", "mapping", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L82-L84
126,612
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
IndexPluginStatus
func IndexPluginStatus(data interface{}) map[string][]string { logrus.DefaultLogger().Debug("IndexPluginStatus ", data) indexes := map[string][]string{} pluginStatus, ok := data.(*status.PluginStatus) if !ok || pluginStatus == nil { return indexes } state := pluginStatus.State if state != 0 { indexes[state...
go
func IndexPluginStatus(data interface{}) map[string][]string { logrus.DefaultLogger().Debug("IndexPluginStatus ", data) indexes := map[string][]string{} pluginStatus, ok := data.(*status.PluginStatus) if !ok || pluginStatus == nil { return indexes } state := pluginStatus.State if state != 0 { indexes[state...
[ "func", "IndexPluginStatus", "(", "data", "interface", "{", "}", ")", "map", "[", "string", "]", "[", "]", "string", "{", "logrus", ".", "DefaultLogger", "(", ")", ".", "Debug", "(", "\"", "\"", ",", "data", ")", "\n\n", "indexes", ":=", "map", "[", ...
// IndexPluginStatus creates indexes for plugin states and records the state // passed as untyped data.
[ "IndexPluginStatus", "creates", "indexes", "for", "plugin", "states", "and", "records", "the", "state", "passed", "as", "untyped", "data", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L88-L102
126,613
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
Delete
func (swi *pluginStatusMap) Delete(pluginName string) (data *status.PluginStatus, exists bool) { meta, exists := swi.mapping.Delete(pluginName) return swi.castdata(meta), exists }
go
func (swi *pluginStatusMap) Delete(pluginName string) (data *status.PluginStatus, exists bool) { meta, exists := swi.mapping.Delete(pluginName) return swi.castdata(meta), exists }
[ "func", "(", "swi", "*", "pluginStatusMap", ")", "Delete", "(", "pluginName", "string", ")", "(", "data", "*", "status", ".", "PluginStatus", ",", "exists", "bool", ")", "{", "meta", ",", "exists", ":=", "swi", ".", "mapping", ".", "Delete", "(", "plug...
// UnregisterName removes an item identified by name from mapping
[ "UnregisterName", "removes", "an", "item", "identified", "by", "name", "from", "mapping" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L105-L108
126,614
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
LookupByState
func (swi *pluginStatusMap) LookupByState(state status.OperationalState) []string { return swi.mapping.ListNames(stateIndexKey, state.String()) }
go
func (swi *pluginStatusMap) LookupByState(state status.OperationalState) []string { return swi.mapping.ListNames(stateIndexKey, state.String()) }
[ "func", "(", "swi", "*", "pluginStatusMap", ")", "LookupByState", "(", "state", "status", ".", "OperationalState", ")", "[", "]", "string", "{", "return", "swi", ".", "mapping", ".", "ListNames", "(", "stateIndexKey", ",", "state", ".", "String", "(", ")",...
// LookupNameByIP returns names of items that contains given IP address in Value
[ "LookupNameByIP", "returns", "names", "of", "items", "that", "contains", "given", "IP", "address", "in", "Value" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L120-L122
126,615
ligato/cn-infra
health/statuscheck/pluginstatusmap/plugin_status_map.go
WatchNameToIdx
func (swi *pluginStatusMap) WatchNameToIdx(subscriber infra.PluginName, pluginChannel chan PluginStatusEvent) { swi.mapping.Watch(string(subscriber), func(event idxmap.NamedMappingGenericEvent) { pluginChannel <- PluginStatusEvent{ NamedMappingEvent: event.NamedMappingEvent, Value: swi.castdata(eve...
go
func (swi *pluginStatusMap) WatchNameToIdx(subscriber infra.PluginName, pluginChannel chan PluginStatusEvent) { swi.mapping.Watch(string(subscriber), func(event idxmap.NamedMappingGenericEvent) { pluginChannel <- PluginStatusEvent{ NamedMappingEvent: event.NamedMappingEvent, Value: swi.castdata(eve...
[ "func", "(", "swi", "*", "pluginStatusMap", ")", "WatchNameToIdx", "(", "subscriber", "infra", ".", "PluginName", ",", "pluginChannel", "chan", "PluginStatusEvent", ")", "{", "swi", ".", "mapping", ".", "Watch", "(", "string", "(", "subscriber", ")", ",", "f...
// WatchNameToIdx allows to subscribe for watching changes in pluginStatusMap mapping
[ "WatchNameToIdx", "allows", "to", "subscribe", "for", "watching", "changes", "in", "pluginStatusMap", "mapping" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/health/statuscheck/pluginstatusmap/plugin_status_map.go#L133-L140
126,616
ligato/cn-infra
processmanager/process.go
Start
func (p *Process) Start() (err error) { if p.command, err = p.startProcess(); err != nil { return err } p.log.Debugf("New process %s was started (PID: %d)", p.GetName(), p.GetPid()) return nil }
go
func (p *Process) Start() (err error) { if p.command, err = p.startProcess(); err != nil { return err } p.log.Debugf("New process %s was started (PID: %d)", p.GetName(), p.GetPid()) return nil }
[ "func", "(", "p", "*", "Process", ")", "Start", "(", ")", "(", "err", "error", ")", "{", "if", "p", ".", "command", ",", "err", "=", "p", ".", "startProcess", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "p", ".",...
// Start a process with defined arguments. Every process is watched for liveness and status changes
[ "Start", "a", "process", "with", "defined", "arguments", ".", "Every", "process", "is", "watched", "for", "liveness", "and", "status", "changes" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L106-L113
126,617
ligato/cn-infra
processmanager/process.go
Restart
func (p *Process) Restart() (err error) { if p.isAlive() { if _, err = p.StopAndWait(); err != nil { p.log.Warnf("Cannot stop process %s due to error, trying force stop... (err: %v)", p.GetName(), err) if err = p.forceStopProcess(); err != nil { return err } } } p.command, err = p.startProcess() p....
go
func (p *Process) Restart() (err error) { if p.isAlive() { if _, err = p.StopAndWait(); err != nil { p.log.Warnf("Cannot stop process %s due to error, trying force stop... (err: %v)", p.GetName(), err) if err = p.forceStopProcess(); err != nil { return err } } } p.command, err = p.startProcess() p....
[ "func", "(", "p", "*", "Process", ")", "Restart", "(", ")", "(", "err", "error", ")", "{", "if", "p", ".", "isAlive", "(", ")", "{", "if", "_", ",", "err", "=", "p", ".", "StopAndWait", "(", ")", ";", "err", "!=", "nil", "{", "p", ".", "log...
// Restart the process, or start it if it is not running
[ "Restart", "the", "process", "or", "start", "it", "if", "it", "is", "not", "running" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L121-L133
126,618
ligato/cn-infra
processmanager/process.go
Stop
func (p *Process) Stop() error { if err := p.stopProcess(); err != nil { return err } p.log.Debugf("Process %s was stopped (last PID: %d)", p.GetName(), p.GetPid()) return nil }
go
func (p *Process) Stop() error { if err := p.stopProcess(); err != nil { return err } p.log.Debugf("Process %s was stopped (last PID: %d)", p.GetName(), p.GetPid()) return nil }
[ "func", "(", "p", "*", "Process", ")", "Stop", "(", ")", "error", "{", "if", "err", ":=", "p", ".", "stopProcess", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "p", ".", "log", ".", "Debugf", "(", "\"", "\"", ",",...
// Stop sends the SIGTERM signal to stop given process
[ "Stop", "sends", "the", "SIGTERM", "signal", "to", "stop", "given", "process" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L136-L142
126,619
ligato/cn-infra
processmanager/process.go
StopAndWait
func (p *Process) StopAndWait() (*os.ProcessState, error) { if err := p.stopProcess(); err != nil { return nil, err } state, err := p.waitOnProcess() if err != nil { return nil, errors.Errorf("process exit with error: %v", err) } p.log.Debugf("Process %s was stopped (last PID: %d)", p.GetName(), p.GetPid()) ...
go
func (p *Process) StopAndWait() (*os.ProcessState, error) { if err := p.stopProcess(); err != nil { return nil, err } state, err := p.waitOnProcess() if err != nil { return nil, errors.Errorf("process exit with error: %v", err) } p.log.Debugf("Process %s was stopped (last PID: %d)", p.GetName(), p.GetPid()) ...
[ "func", "(", "p", "*", "Process", ")", "StopAndWait", "(", ")", "(", "*", "os", ".", "ProcessState", ",", "error", ")", "{", "if", "err", ":=", "p", ".", "stopProcess", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// StopAndWait sends the SIGTERM signal to stop given process and waits until it is completed
[ "StopAndWait", "sends", "the", "SIGTERM", "signal", "to", "stop", "given", "process", "and", "waits", "until", "it", "is", "completed" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L145-L155
126,620
ligato/cn-infra
processmanager/process.go
Kill
func (p *Process) Kill() error { if err := p.forceStopProcess(); err != nil { return err } p.log.Debugf("Process %s was forced to stop (last PID: %d)", p.GetName(), p.GetPid()) return nil }
go
func (p *Process) Kill() error { if err := p.forceStopProcess(); err != nil { return err } p.log.Debugf("Process %s was forced to stop (last PID: %d)", p.GetName(), p.GetPid()) return nil }
[ "func", "(", "p", "*", "Process", ")", "Kill", "(", ")", "error", "{", "if", "err", ":=", "p", ".", "forceStopProcess", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "p", ".", "log", ".", "Debugf", "(", "\"", "\"", ...
// Kill sends the SIGKILL signal to force stop given process
[ "Kill", "sends", "the", "SIGKILL", "signal", "to", "force", "stop", "given", "process" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L158-L164
126,621
ligato/cn-infra
processmanager/process.go
Signal
func (p *Process) Signal(signal os.Signal) error { return p.signalToProcess(signal) }
go
func (p *Process) Signal(signal os.Signal) error { return p.signalToProcess(signal) }
[ "func", "(", "p", "*", "Process", ")", "Signal", "(", "signal", "os", ".", "Signal", ")", "error", "{", "return", "p", ".", "signalToProcess", "(", "signal", ")", "\n", "}" ]
// Signal sends custom signal to the process
[ "Signal", "sends", "custom", "signal", "to", "the", "process" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L172-L174
126,622
ligato/cn-infra
processmanager/process.go
GetPid
func (p *Process) GetPid() int { if p.command != nil && p.command.Process != nil { return p.command.Process.Pid } return p.status.Pid }
go
func (p *Process) GetPid() int { if p.command != nil && p.command.Process != nil { return p.command.Process.Pid } return p.status.Pid }
[ "func", "(", "p", "*", "Process", ")", "GetPid", "(", ")", "int", "{", "if", "p", ".", "command", "!=", "nil", "&&", "p", ".", "command", ".", "Process", "!=", "nil", "{", "return", "p", ".", "command", ".", "Process", ".", "Pid", "\n", "}", "\...
// GetPid returns process ID
[ "GetPid", "returns", "process", "ID" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L187-L192
126,623
ligato/cn-infra
processmanager/process.go
GetArguments
func (p *Process) GetArguments() []string { if p.options.args == nil { return []string{} } return p.options.args }
go
func (p *Process) GetArguments() []string { if p.options.args == nil { return []string{} } return p.options.args }
[ "func", "(", "p", "*", "Process", ")", "GetArguments", "(", ")", "[", "]", "string", "{", "if", "p", ".", "options", ".", "args", "==", "nil", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n", "return", "p", ".", "options", ".", "ar...
// GetArguments returns arguments process was started with, if any. May be empty also for attached processes
[ "GetArguments", "returns", "arguments", "process", "was", "started", "with", "if", "any", ".", "May", "be", "empty", "also", "for", "attached", "processes" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L200-L205
126,624
ligato/cn-infra
processmanager/process.go
GetStatus
func (p *Process) GetStatus(pid int) (statusFile *status.File, err error) { p.status, err = p.sh.ReadStatusFromPID(pid) if err != nil { return &status.File{}, errors.Errorf("failed to read status file for process ID %d: %v", pid, err) } return p.status, nil }
go
func (p *Process) GetStatus(pid int) (statusFile *status.File, err error) { p.status, err = p.sh.ReadStatusFromPID(pid) if err != nil { return &status.File{}, errors.Errorf("failed to read status file for process ID %d: %v", pid, err) } return p.status, nil }
[ "func", "(", "p", "*", "Process", ")", "GetStatus", "(", "pid", "int", ")", "(", "statusFile", "*", "status", ".", "File", ",", "err", "error", ")", "{", "p", ".", "status", ",", "err", "=", "p", ".", "sh", ".", "ReadStatusFromPID", "(", "pid", "...
// GetStatus updates actual process status and returns status file
[ "GetStatus", "updates", "actual", "process", "status", "and", "returns", "status", "file" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L208-L214
126,625
ligato/cn-infra
processmanager/process.go
GetNotificationChan
func (p *Process) GetNotificationChan() <-chan status.ProcessStatus { if p.options != nil && p.options.notifyChan != nil { return p.options.notifyChan } return nil }
go
func (p *Process) GetNotificationChan() <-chan status.ProcessStatus { if p.options != nil && p.options.notifyChan != nil { return p.options.notifyChan } return nil }
[ "func", "(", "p", "*", "Process", ")", "GetNotificationChan", "(", ")", "<-", "chan", "status", ".", "ProcessStatus", "{", "if", "p", ".", "options", "!=", "nil", "&&", "p", ".", "options", ".", "notifyChan", "!=", "nil", "{", "return", "p", ".", "op...
// GetNotificationChan returns channel listening on notifications about process status changes
[ "GetNotificationChan", "returns", "channel", "listening", "on", "notifications", "about", "process", "status", "changes" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L217-L222
126,626
ligato/cn-infra
processmanager/process.go
GetUptime
func (p *Process) GetUptime() time.Duration { if p.startTime.Nanosecond() == 0 { return 0 } return time.Since(p.startTime) }
go
func (p *Process) GetUptime() time.Duration { if p.startTime.Nanosecond() == 0 { return 0 } return time.Since(p.startTime) }
[ "func", "(", "p", "*", "Process", ")", "GetUptime", "(", ")", "time", ".", "Duration", "{", "if", "p", ".", "startTime", ".", "Nanosecond", "(", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "time", ".", "Since", "(", "p", ".", ...
// GetUptime returns process uptime since the last start
[ "GetUptime", "returns", "process", "uptime", "since", "the", "last", "start" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/processmanager/process.go#L230-L235
126,627
ligato/cn-infra
db/keyval/filedb/client.go
NewClient
func NewClient(cfgPaths []string, statusPath string, dcs []decoder.API, fsh filesystem.API, log logging.Logger) (*Client, error) { // Init client object c := &Client{ cfgPaths: cfgPaths, statusPath: statusPath, fsHandler: fsh, watchers: make(map[string]chan keyedData), db: database.NewDbClient(...
go
func NewClient(cfgPaths []string, statusPath string, dcs []decoder.API, fsh filesystem.API, log logging.Logger) (*Client, error) { // Init client object c := &Client{ cfgPaths: cfgPaths, statusPath: statusPath, fsHandler: fsh, watchers: make(map[string]chan keyedData), db: database.NewDbClient(...
[ "func", "NewClient", "(", "cfgPaths", "[", "]", "string", ",", "statusPath", "string", ",", "dcs", "[", "]", "decoder", ".", "API", ",", "fsh", "filesystem", ".", "API", ",", "log", "logging", ".", "Logger", ")", "(", "*", "Client", ",", "error", ")"...
// NewClient initializes file watcher, database and registers paths provided via plugin configuration file
[ "NewClient", "initializes", "file", "watcher", "database", "and", "registers", "paths", "provided", "via", "plugin", "configuration", "file" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L69-L125
126,628
ligato/cn-infra
db/keyval/filedb/client.go
GetDataForFile
func (c *Client) GetDataForFile(path string) []*decoder.FileDataEntry { return c.db.GetDataForFile(path) }
go
func (c *Client) GetDataForFile(path string) []*decoder.FileDataEntry { return c.db.GetDataForFile(path) }
[ "func", "(", "c", "*", "Client", ")", "GetDataForFile", "(", "path", "string", ")", "[", "]", "*", "decoder", ".", "FileDataEntry", "{", "return", "c", ".", "db", ".", "GetDataForFile", "(", "path", ")", "\n", "}" ]
// GetDataForFile returns data gor given file
[ "GetDataForFile", "returns", "data", "gor", "given", "file" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L133-L135
126,629
ligato/cn-infra
db/keyval/filedb/client.go
GetDataForKey
func (c *Client) GetDataForKey(key string) (*decoder.FileDataEntry, bool) { return c.db.GetDataForKey(key) }
go
func (c *Client) GetDataForKey(key string) (*decoder.FileDataEntry, bool) { return c.db.GetDataForKey(key) }
[ "func", "(", "c", "*", "Client", ")", "GetDataForKey", "(", "key", "string", ")", "(", "*", "decoder", ".", "FileDataEntry", ",", "bool", ")", "{", "return", "c", ".", "db", ".", "GetDataForKey", "(", "key", ")", "\n", "}" ]
// GetDataForKey returns data gor given file
[ "GetDataForKey", "returns", "data", "gor", "given", "file" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L138-L140
126,630
ligato/cn-infra
db/keyval/filedb/client.go
Put
func (c *Client) Put(key string, data []byte, opts ...datasync.PutOption) error { newEntry := &decoder.FileDataEntry{Key: key, Value: data} statusDataEntries := c.db.GetDataForFile(c.statusPath) // Add/update data var updated bool for _, statusDataEntry := range statusDataEntries { if statusDataEntry.Key == key ...
go
func (c *Client) Put(key string, data []byte, opts ...datasync.PutOption) error { newEntry := &decoder.FileDataEntry{Key: key, Value: data} statusDataEntries := c.db.GetDataForFile(c.statusPath) // Add/update data var updated bool for _, statusDataEntry := range statusDataEntries { if statusDataEntry.Key == key ...
[ "func", "(", "c", "*", "Client", ")", "Put", "(", "key", "string", ",", "data", "[", "]", "byte", ",", "opts", "...", "datasync", ".", "PutOption", ")", "error", "{", "newEntry", ":=", "&", "decoder", ".", "FileDataEntry", "{", "Key", ":", "key", "...
// Put reads status file, add data to it and performs write
[ "Put", "reads", "status", "file", "add", "data", "to", "it", "and", "performs", "write" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L165-L191
126,631
ligato/cn-infra
db/keyval/filedb/client.go
GetValue
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) { var entry *decoder.FileDataEntry entry, found = c.db.GetDataForKey(key) data = entry.Value return }
go
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) { var entry *decoder.FileDataEntry entry, found = c.db.GetDataForKey(key) data = entry.Value return }
[ "func", "(", "c", "*", "Client", ")", "GetValue", "(", "key", "string", ")", "(", "data", "[", "]", "byte", ",", "found", "bool", ",", "revision", "int64", ",", "err", "error", ")", "{", "var", "entry", "*", "decoder", ".", "FileDataEntry", "\n", "...
// GetValue returns a value for given key
[ "GetValue", "returns", "a", "value", "for", "given", "key" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L200-L205
126,632
ligato/cn-infra
db/keyval/filedb/client.go
ListValues
func (c *Client) ListValues(prefix string) (keyval.BytesKeyValIterator, error) { keyValues := c.db.GetDataForPrefix(prefix) data := make([]*decoder.FileDataEntry, 0, len(keyValues)) for _, entry := range keyValues { data = append(data, &decoder.FileDataEntry{ Key: entry.Key, Value: entry.Value, }) } re...
go
func (c *Client) ListValues(prefix string) (keyval.BytesKeyValIterator, error) { keyValues := c.db.GetDataForPrefix(prefix) data := make([]*decoder.FileDataEntry, 0, len(keyValues)) for _, entry := range keyValues { data = append(data, &decoder.FileDataEntry{ Key: entry.Key, Value: entry.Value, }) } re...
[ "func", "(", "c", "*", "Client", ")", "ListValues", "(", "prefix", "string", ")", "(", "keyval", ".", "BytesKeyValIterator", ",", "error", ")", "{", "keyValues", ":=", "c", ".", "db", ".", "GetDataForPrefix", "(", "prefix", ")", "\n", "data", ":=", "ma...
// ListValues returns a list of values for given prefix
[ "ListValues", "returns", "a", "list", "of", "values", "for", "given", "prefix" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L208-L218
126,633
ligato/cn-infra
db/keyval/filedb/client.go
ListKeys
func (c *Client) ListKeys(prefix string) (keyval.BytesKeyIterator, error) { entries := c.db.GetDataForPrefix(prefix) var keysWithoutPrefix []string for _, entry := range entries { keysWithoutPrefix = append(keysWithoutPrefix, entry.Key) } return &bytesKeyIterator{len: len(keysWithoutPrefix), keys: keysWithoutPre...
go
func (c *Client) ListKeys(prefix string) (keyval.BytesKeyIterator, error) { entries := c.db.GetDataForPrefix(prefix) var keysWithoutPrefix []string for _, entry := range entries { keysWithoutPrefix = append(keysWithoutPrefix, entry.Key) } return &bytesKeyIterator{len: len(keysWithoutPrefix), keys: keysWithoutPre...
[ "func", "(", "c", "*", "Client", ")", "ListKeys", "(", "prefix", "string", ")", "(", "keyval", ".", "BytesKeyIterator", ",", "error", ")", "{", "entries", ":=", "c", ".", "db", ".", "GetDataForPrefix", "(", "prefix", ")", "\n", "var", "keysWithoutPrefix"...
// ListKeys returns a set of keys for given prefix
[ "ListKeys", "returns", "a", "set", "of", "keys", "for", "given", "prefix" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L221-L228
126,634
ligato/cn-infra
db/keyval/filedb/client.go
Delete
func (c *Client) Delete(key string, opts ...datasync.DelOption) (existed bool, err error) { c.log.Warnf("deleting configuration from fileDB is currently not allowed") return false, nil }
go
func (c *Client) Delete(key string, opts ...datasync.DelOption) (existed bool, err error) { c.log.Warnf("deleting configuration from fileDB is currently not allowed") return false, nil }
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "key", "string", ",", "opts", "...", "datasync", ".", "DelOption", ")", "(", "existed", "bool", ",", "err", "error", ")", "{", "c", ".", "log", ".", "Warnf", "(", "\"", "\"", ")", "\n", "return...
// Delete is not allowed for fileDB, configuration file is read-only
[ "Delete", "is", "not", "allowed", "for", "fileDB", "configuration", "file", "is", "read", "-", "only" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L231-L234
126,635
ligato/cn-infra
db/keyval/filedb/client.go
Watch
func (c *Client) Watch(resp func(response keyval.BytesWatchResp), closeChan chan string, keys ...string) error { c.Lock() defer c.Unlock() for _, key := range keys { dc := make(chan keyedData) go c.watch(resp, dc, closeChan, key) c.watchers[key] = dc } return nil }
go
func (c *Client) Watch(resp func(response keyval.BytesWatchResp), closeChan chan string, keys ...string) error { c.Lock() defer c.Unlock() for _, key := range keys { dc := make(chan keyedData) go c.watch(resp, dc, closeChan, key) c.watchers[key] = dc } return nil }
[ "func", "(", "c", "*", "Client", ")", "Watch", "(", "resp", "func", "(", "response", "keyval", ".", "BytesWatchResp", ")", ",", "closeChan", "chan", "string", ",", "keys", "...", "string", ")", "error", "{", "c", ".", "Lock", "(", ")", "\n", "defer",...
// Watch starts single watcher for every key prefix. Every watcher listens on its own data channel.
[ "Watch", "starts", "single", "watcher", "for", "every", "key", "prefix", ".", "Every", "watcher", "listens", "on", "its", "own", "data", "channel", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L237-L248
126,636
ligato/cn-infra
db/keyval/filedb/client.go
Close
func (c *Client) Close() error { if c.fsHandler != nil { return c.fsHandler.Close() } return nil }
go
func (c *Client) Close() error { if c.fsHandler != nil { return c.fsHandler.Close() } return nil }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "error", "{", "if", "c", ".", "fsHandler", "!=", "nil", "{", "return", "c", ".", "fsHandler", ".", "Close", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Close closes all readers
[ "Close", "closes", "all", "readers" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L251-L256
126,637
ligato/cn-infra
db/keyval/filedb/client.go
watch
func (c *Client) watch(resp func(response keyval.BytesWatchResp), dataChan chan keyedData, closeChan chan string, key string) { for { select { case keyedData, ok := <-dataChan: if !ok { return } if keyedData.Op == datasync.Delete || !bytes.Equal(keyedData.PrevValue, keyedData.Value) { resp(&keyedD...
go
func (c *Client) watch(resp func(response keyval.BytesWatchResp), dataChan chan keyedData, closeChan chan string, key string) { for { select { case keyedData, ok := <-dataChan: if !ok { return } if keyedData.Op == datasync.Delete || !bytes.Equal(keyedData.PrevValue, keyedData.Value) { resp(&keyedD...
[ "func", "(", "c", "*", "Client", ")", "watch", "(", "resp", "func", "(", "response", "keyval", ".", "BytesWatchResp", ")", ",", "dataChan", "chan", "keyedData", ",", "closeChan", "chan", "string", ",", "key", "string", ")", "{", "for", "{", "select", "...
// Awaits changes from data channel, prepares responses and sends them to the response function
[ "Awaits", "changes", "from", "data", "channel", "prepares", "responses", "and", "sends", "them", "to", "the", "response", "function" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L259-L273
126,638
ligato/cn-infra
db/keyval/filedb/client.go
eventWatcher
func (c *Client) eventWatcher() { c.fsHandler.Watch(c.cfgPaths, c.onEvent, c.onClose) }
go
func (c *Client) eventWatcher() { c.fsHandler.Watch(c.cfgPaths, c.onEvent, c.onClose) }
[ "func", "(", "c", "*", "Client", ")", "eventWatcher", "(", ")", "{", "c", ".", "fsHandler", ".", "Watch", "(", "c", ".", "cfgPaths", ",", "c", ".", "onEvent", ",", "c", ".", "onClose", ")", "\n", "}" ]
// Event watcher starts file system watcher for every reader available.
[ "Event", "watcher", "starts", "file", "system", "watcher", "for", "every", "reader", "available", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L276-L278
126,639
ligato/cn-infra
db/keyval/filedb/client.go
onEvent
func (c *Client) onEvent(event fsnotify.Event) { // If file was removed, delete all configuration associated with it. Do the same action for // rename, following action will be create with the new name which re-applies the configuration // (if new name is in scope of the defined path) if (event.Op == fsnotify.Renam...
go
func (c *Client) onEvent(event fsnotify.Event) { // If file was removed, delete all configuration associated with it. Do the same action for // rename, following action will be create with the new name which re-applies the configuration // (if new name is in scope of the defined path) if (event.Op == fsnotify.Renam...
[ "func", "(", "c", "*", "Client", ")", "onEvent", "(", "event", "fsnotify", ".", "Event", ")", "{", "// If file was removed, delete all configuration associated with it. Do the same action for", "// rename, following action will be create with the new name which re-applies the configura...
// OnEvent is common method called when new event from file system arrives. Different files may require different // reader, but the data processing is the same.
[ "OnEvent", "is", "common", "method", "called", "when", "new", "event", "from", "file", "system", "arrives", ".", "Different", "files", "may", "require", "different", "reader", "but", "the", "data", "processing", "is", "the", "same", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L282-L343
126,640
ligato/cn-infra
db/keyval/filedb/client.go
sendToChannel
func (c *Client) sendToChannel(keyed keyedData) { c.Lock() defer c.Unlock() for key, channel := range c.watchers { if strings.Contains(keyed.Key, key) { channel <- keyed return } } }
go
func (c *Client) sendToChannel(keyed keyedData) { c.Lock() defer c.Unlock() for key, channel := range c.watchers { if strings.Contains(keyed.Key, key) { channel <- keyed return } } }
[ "func", "(", "c", "*", "Client", ")", "sendToChannel", "(", "keyed", "keyedData", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "for", "key", ",", "channel", ":=", "range", "c", ".", "watchers", "{", "...
// Send data to correct channel
[ "Send", "data", "to", "correct", "channel" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L353-L363
126,641
ligato/cn-infra
db/keyval/filedb/client.go
getFileDecoder
func (c *Client) getFileDecoder(file string) decoder.API { for _, dc := range c.decoders { if dc.IsProcessable(file) { return dc } } return nil }
go
func (c *Client) getFileDecoder(file string) decoder.API { for _, dc := range c.decoders { if dc.IsProcessable(file) { return dc } } return nil }
[ "func", "(", "c", "*", "Client", ")", "getFileDecoder", "(", "file", "string", ")", "decoder", ".", "API", "{", "for", "_", ",", "dc", ":=", "range", "c", ".", "decoders", "{", "if", "dc", ".", "IsProcessable", "(", "file", ")", "{", "return", "dc"...
// Use known decoders to decide whether the file can or cannot be processed. If so, return proper decoder.
[ "Use", "known", "decoders", "to", "decide", "whether", "the", "file", "can", "or", "cannot", "be", "processed", ".", "If", "so", "return", "proper", "decoder", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/client.go#L366-L373
126,642
ligato/cn-infra
db/sql/sql_expression.go
SELECT
func SELECT(entity interface{}, afterKeyword Expression, binding ...interface{}) Expression { return &PrefixedExp{"SELECT", []Expression{FROM(entity, afterKeyword)}, "", binding} }
go
func SELECT(entity interface{}, afterKeyword Expression, binding ...interface{}) Expression { return &PrefixedExp{"SELECT", []Expression{FROM(entity, afterKeyword)}, "", binding} }
[ "func", "SELECT", "(", "entity", "interface", "{", "}", ",", "afterKeyword", "Expression", ",", "binding", "...", "interface", "{", "}", ")", "Expression", "{", "return", "&", "PrefixedExp", "{", "\"", "\"", ",", "[", "]", "Expression", "{", "FROM", "(",...
// SELECT keyword of an SQL expression.
[ "SELECT", "keyword", "of", "an", "SQL", "expression", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/sql/sql_expression.go#L119-L121
126,643
ligato/cn-infra
datasync/restsync/http_handlers.go
putMessage
func (adapter *Adapter) putMessage(formatter *render.Render) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { body, err := req.GetBody() if err != nil { var data []byte data, err = ioutil.ReadAll(body) defer req.Body.Close() if err != nil { localtxn := local.NewBytesTxn(a...
go
func (adapter *Adapter) putMessage(formatter *render.Render) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { body, err := req.GetBody() if err != nil { var data []byte data, err = ioutil.ReadAll(body) defer req.Body.Close() if err != nil { localtxn := local.NewBytesTxn(a...
[ "func", "(", "adapter", "*", "Adapter", ")", "putMessage", "(", "formatter", "*", "render", ".", "Render", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{...
// putMessage is only a stub prepared for later implementation.
[ "putMessage", "is", "only", "a", "stub", "prepared", "for", "later", "implementation", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/restsync/http_handlers.go#L28-L49
126,644
ligato/cn-infra
datasync/restsync/http_handlers.go
delMessage
func (adapter *Adapter) delMessage(formatter *render.Render) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { localtxn := local.NewBytesTxn(adapter.base.PropagateChanges) localtxn.Delete(req.RequestURI) err := localtxn.Commit(context.Background()) if err != nil { formatter.JSON(w,...
go
func (adapter *Adapter) delMessage(formatter *render.Render) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { localtxn := local.NewBytesTxn(adapter.base.PropagateChanges) localtxn.Delete(req.RequestURI) err := localtxn.Commit(context.Background()) if err != nil { formatter.JSON(w,...
[ "func", "(", "adapter", "*", "Adapter", ")", "delMessage", "(", "formatter", "*", "render", ".", "Render", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{...
// delMessage only calls local dbadapter delete.
[ "delMessage", "only", "calls", "local", "dbadapter", "delete", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/restsync/http_handlers.go#L52-L64
126,645
ligato/cn-infra
db/sql/cassandra/plugin_impl_cassa.go
Init
func (p *Plugin) Init() (err error) { if p.session != nil { return nil // skip initialization } // Retrieve config var cfg Config found, err := p.Cfg.LoadValue(&cfg) // need to be strict about config presence for ETCD if !found { p.Log.Info("cassandra client config not found ", p.Cfg.GetConfigName(), " -...
go
func (p *Plugin) Init() (err error) { if p.session != nil { return nil // skip initialization } // Retrieve config var cfg Config found, err := p.Cfg.LoadValue(&cfg) // need to be strict about config presence for ETCD if !found { p.Log.Info("cassandra client config not found ", p.Cfg.GetConfigName(), " -...
[ "func", "(", "p", "*", "Plugin", ")", "Init", "(", ")", "(", "err", "error", ")", "{", "if", "p", ".", "session", "!=", "nil", "{", "return", "nil", "// skip initialization", "\n", "}", "\n\n", "// Retrieve config", "var", "cfg", "Config", "\n", "found...
// Init is called at plugin startup. The session to Cassandra is established.
[ "Init", "is", "called", "at", "plugin", "startup", ".", "The", "session", "to", "Cassandra", "is", "established", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/sql/cassandra/plugin_impl_cassa.go#L62-L96
126,646
ligato/cn-infra
db/sql/cassandra/plugin_impl_cassa.go
AfterInit
func (p *Plugin) AfterInit() error { if p.StatusCheck != nil && p.session != nil { p.StatusCheck.Register(p.PluginName, func() (statuscheck.PluginState, error) { broker := p.NewBroker() err := broker.Exec(`select keyspace_name from system_schema.keyspaces`) if err == nil { return statuscheck.OK, nil ...
go
func (p *Plugin) AfterInit() error { if p.StatusCheck != nil && p.session != nil { p.StatusCheck.Register(p.PluginName, func() (statuscheck.PluginState, error) { broker := p.NewBroker() err := broker.Exec(`select keyspace_name from system_schema.keyspaces`) if err == nil { return statuscheck.OK, nil ...
[ "func", "(", "p", "*", "Plugin", ")", "AfterInit", "(", ")", "error", "{", "if", "p", ".", "StatusCheck", "!=", "nil", "&&", "p", ".", "session", "!=", "nil", "{", "p", ".", "StatusCheck", ".", "Register", "(", "p", ".", "PluginName", ",", "func", ...
// AfterInit registers Cassandra to status check.
[ "AfterInit", "registers", "Cassandra", "to", "status", "check", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/sql/cassandra/plugin_impl_cassa.go#L99-L113
126,647
ligato/cn-infra
datasync/kvdbsync/change_event.go
NewChangeWatchResp
func NewChangeWatchResp(ctx context.Context, delegate datasync.ProtoWatchResp, prevVal datasync.LazyValue) *ChangeWatchResp { return &ChangeWatchResp{ ctx: ctx, changes: []datasync.ProtoWatchResp{ &changePrev{ ProtoWatchResp: delegate, prev: prevVal, }, }, DoneChannel: &syncbase.DoneCha...
go
func NewChangeWatchResp(ctx context.Context, delegate datasync.ProtoWatchResp, prevVal datasync.LazyValue) *ChangeWatchResp { return &ChangeWatchResp{ ctx: ctx, changes: []datasync.ProtoWatchResp{ &changePrev{ ProtoWatchResp: delegate, prev: prevVal, }, }, DoneChannel: &syncbase.DoneCha...
[ "func", "NewChangeWatchResp", "(", "ctx", "context", ".", "Context", ",", "delegate", "datasync", ".", "ProtoWatchResp", ",", "prevVal", "datasync", ".", "LazyValue", ")", "*", "ChangeWatchResp", "{", "return", "&", "ChangeWatchResp", "{", "ctx", ":", "ctx", "...
// NewChangeWatchResp creates a new instance of ChangeWatchResp.
[ "NewChangeWatchResp", "creates", "a", "new", "instance", "of", "ChangeWatchResp", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/change_event.go#L34-L45
126,648
ligato/cn-infra
datasync/kvdbsync/change_event.go
GetValue
func (ev *changePrev) GetValue(val proto.Message) (err error) { if ev.ProtoWatchResp.GetChangeType() != datasync.Delete { return ev.ProtoWatchResp.GetValue(val) } return nil }
go
func (ev *changePrev) GetValue(val proto.Message) (err error) { if ev.ProtoWatchResp.GetChangeType() != datasync.Delete { return ev.ProtoWatchResp.GetValue(val) } return nil }
[ "func", "(", "ev", "*", "changePrev", ")", "GetValue", "(", "val", "proto", ".", "Message", ")", "(", "err", "error", ")", "{", "if", "ev", ".", "ProtoWatchResp", ".", "GetChangeType", "(", ")", "!=", "datasync", ".", "Delete", "{", "return", "ev", "...
// GetValue returns previous value associated with a change. For description of parameter and output // values, see the comment in implemented interface datasync.ChangeEvent.
[ "GetValue", "returns", "previous", "value", "associated", "with", "a", "change", ".", "For", "description", "of", "parameter", "and", "output", "values", "see", "the", "comment", "in", "implemented", "interface", "datasync", ".", "ChangeEvent", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/change_event.go#L64-L69
126,649
ligato/cn-infra
datasync/kvdbsync/change_event.go
GetPrevValue
func (ev *changePrev) GetPrevValue(prevVal proto.Message) (exists bool, err error) { if ev.prev != nil { return true, ev.prev.GetValue(prevVal) } return false, nil }
go
func (ev *changePrev) GetPrevValue(prevVal proto.Message) (exists bool, err error) { if ev.prev != nil { return true, ev.prev.GetValue(prevVal) } return false, nil }
[ "func", "(", "ev", "*", "changePrev", ")", "GetPrevValue", "(", "prevVal", "proto", ".", "Message", ")", "(", "exists", "bool", ",", "err", "error", ")", "{", "if", "ev", ".", "prev", "!=", "nil", "{", "return", "true", ",", "ev", ".", "prev", ".",...
// GetPrevValue returns previous value associated with a change. For description of parameter and output // values, see the comment in implemented interface datasync.ChangeEvent.
[ "GetPrevValue", "returns", "previous", "value", "associated", "with", "a", "change", ".", "For", "description", "of", "parameter", "and", "output", "values", "see", "the", "comment", "in", "implemented", "interface", "datasync", ".", "ChangeEvent", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/kvdbsync/change_event.go#L73-L78
126,650
ligato/cn-infra
rpc/prometheus/plugin_impl_prometheus.go
Init
func (p *Plugin) Init() error { p.regs = map[string]*registry{} // add default registry p.regs[DefaultRegistry] = &registry{ Gatherer: prometheus.DefaultGatherer, Registerer: prometheus.DefaultRegisterer, } return nil }
go
func (p *Plugin) Init() error { p.regs = map[string]*registry{} // add default registry p.regs[DefaultRegistry] = &registry{ Gatherer: prometheus.DefaultGatherer, Registerer: prometheus.DefaultRegisterer, } return nil }
[ "func", "(", "p", "*", "Plugin", ")", "Init", "(", ")", "error", "{", "p", ".", "regs", "=", "map", "[", "string", "]", "*", "registry", "{", "}", "\n\n", "// add default registry", "p", ".", "regs", "[", "DefaultRegistry", "]", "=", "&", "registry",...
// Init initializes the internal structures
[ "Init", "initializes", "the", "internal", "structures" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/prometheus/plugin_impl_prometheus.go#L68-L78
126,651
ligato/cn-infra
rpc/prometheus/plugin_impl_prometheus.go
AfterInit
func (p *Plugin) AfterInit() error { if p.HTTP != nil { p.Lock() defer p.Unlock() for path, reg := range p.regs { p.HTTP.RegisterHTTPHandler(path, p.createHandlerHandler(reg.Gatherer, reg.httpOpts), "GET") p.Log.Infof("Serving %s on port %d", path, p.HTTP.GetPort()) } } else { p.Log.Info("Unable to r...
go
func (p *Plugin) AfterInit() error { if p.HTTP != nil { p.Lock() defer p.Unlock() for path, reg := range p.regs { p.HTTP.RegisterHTTPHandler(path, p.createHandlerHandler(reg.Gatherer, reg.httpOpts), "GET") p.Log.Infof("Serving %s on port %d", path, p.HTTP.GetPort()) } } else { p.Log.Info("Unable to r...
[ "func", "(", "p", "*", "Plugin", ")", "AfterInit", "(", ")", "error", "{", "if", "p", ".", "HTTP", "!=", "nil", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "for", "path", ",", "reg", ":=", "range", "p",...
// AfterInit registers HTTP handlers.
[ "AfterInit", "registers", "HTTP", "handlers", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/prometheus/plugin_impl_prometheus.go#L81-L95
126,652
ligato/cn-infra
rpc/prometheus/plugin_impl_prometheus.go
Register
func (p *Plugin) Register(registryPath string, collector prometheus.Collector) error { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { p.Log.WithField("path", registryPath).Error(ErrRegistryNotFound) return ErrRegistryNotFound } return reg.Register(collector) }
go
func (p *Plugin) Register(registryPath string, collector prometheus.Collector) error { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { p.Log.WithField("path", registryPath).Error(ErrRegistryNotFound) return ErrRegistryNotFound } return reg.Register(collector) }
[ "func", "(", "p", "*", "Plugin", ")", "Register", "(", "registryPath", "string", ",", "collector", "prometheus", ".", "Collector", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n\n", "reg", ",", "found"...
// Register registers prometheus metric to a specified registry. In order to add metrics // to default registry use prometheus.DefaultRegistry const.
[ "Register", "registers", "prometheus", "metric", "to", "a", "specified", "registry", ".", "In", "order", "to", "add", "metrics", "to", "default", "registry", "use", "prometheus", ".", "DefaultRegistry", "const", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/prometheus/plugin_impl_prometheus.go#L129-L139
126,653
ligato/cn-infra
rpc/prometheus/plugin_impl_prometheus.go
Unregister
func (p *Plugin) Unregister(registryPath string, collector prometheus.Collector) bool { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { return false } return reg.Unregister(collector) }
go
func (p *Plugin) Unregister(registryPath string, collector prometheus.Collector) bool { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { return false } return reg.Unregister(collector) }
[ "func", "(", "p", "*", "Plugin", ")", "Unregister", "(", "registryPath", "string", ",", "collector", "prometheus", ".", "Collector", ")", "bool", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n\n", "reg", ",", "found...
// Unregister unregisters the given metric. The function // returns whether a Collector was unregistered.
[ "Unregister", "unregisters", "the", "given", "metric", ".", "The", "function", "returns", "whether", "a", "Collector", "was", "unregistered", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/prometheus/plugin_impl_prometheus.go#L143-L152
126,654
ligato/cn-infra
rpc/prometheus/plugin_impl_prometheus.go
RegisterGaugeFunc
func (p *Plugin) RegisterGaugeFunc(registryPath string, namespace string, subsystem string, name string, help string, labels prometheus.Labels, valueFunc func() float64) error { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { p.Log.WithField("path", registryPath).Error(ErrRegistryNotFo...
go
func (p *Plugin) RegisterGaugeFunc(registryPath string, namespace string, subsystem string, name string, help string, labels prometheus.Labels, valueFunc func() float64) error { p.Lock() defer p.Unlock() reg, found := p.regs[registryPath] if !found { p.Log.WithField("path", registryPath).Error(ErrRegistryNotFo...
[ "func", "(", "p", "*", "Plugin", ")", "RegisterGaugeFunc", "(", "registryPath", "string", ",", "namespace", "string", ",", "subsystem", "string", ",", "name", "string", ",", "help", "string", ",", "labels", "prometheus", ".", "Labels", ",", "valueFunc", "fun...
// RegisterGaugeFunc registers custom gauge with specific valueFunc to report status when invoked. // This method simplifies using of Register for common use case. If you want create metric different from // GagugeFunc or you're adding a metric that will be unregister later on, use generic Register method instead. // R...
[ "RegisterGaugeFunc", "registers", "custom", "gauge", "with", "specific", "valueFunc", "to", "report", "status", "when", "invoked", ".", "This", "method", "simplifies", "using", "of", "Register", "for", "common", "use", "case", ".", "If", "you", "want", "create",...
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/prometheus/plugin_impl_prometheus.go#L158-L194
126,655
ligato/cn-infra
messaging/kafka/client/config.go
NewConfig
func NewConfig(log logging.Logger) *Config { cfg := &Config{ Logger: log, Config: cluster.NewConfig(), Partition: -1, Partitioner: sarama.NewHashPartitioner, RequiredAcks: AcksUnset, } return cfg }
go
func NewConfig(log logging.Logger) *Config { cfg := &Config{ Logger: log, Config: cluster.NewConfig(), Partition: -1, Partitioner: sarama.NewHashPartitioner, RequiredAcks: AcksUnset, } return cfg }
[ "func", "NewConfig", "(", "log", "logging", ".", "Logger", ")", "*", "Config", "{", "cfg", ":=", "&", "Config", "{", "Logger", ":", "log", ",", "Config", ":", "cluster", ".", "NewConfig", "(", ")", ",", "Partition", ":", "-", "1", ",", "Partitioner",...
// NewConfig return a new Config object.
[ "NewConfig", "return", "a", "new", "Config", "object", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L124-L135
126,656
ligato/cn-infra
messaging/kafka/client/config.go
SetTopics
func (ref *Config) SetTopics(topics string) { ref.Topics = strings.Split(topics, ",") }
go
func (ref *Config) SetTopics(topics string) { ref.Topics = strings.Split(topics, ",") }
[ "func", "(", "ref", "*", "Config", ")", "SetTopics", "(", "topics", "string", ")", "{", "ref", ".", "Topics", "=", "strings", ".", "Split", "(", "topics", ",", "\"", "\"", ")", "\n", "}" ]
// SetTopics sets the Config.Topics field
[ "SetTopics", "sets", "the", "Config", ".", "Topics", "field" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L143-L145
126,657
ligato/cn-infra
messaging/kafka/client/config.go
SetDebug
func (ref *Config) SetDebug(val bool) { if val { ref.Debug = val sarama.Logger = ref.Logger ref.SetLevel(logging.DebugLevel) } else { ref.Debug = val } }
go
func (ref *Config) SetDebug(val bool) { if val { ref.Debug = val sarama.Logger = ref.Logger ref.SetLevel(logging.DebugLevel) } else { ref.Debug = val } }
[ "func", "(", "ref", "*", "Config", ")", "SetDebug", "(", "val", "bool", ")", "{", "if", "val", "{", "ref", ".", "Debug", "=", "val", "\n", "sarama", ".", "Logger", "=", "ref", ".", "Logger", "\n", "ref", ".", "SetLevel", "(", "logging", ".", "Deb...
// SetDebug sets the Config.Debug field
[ "SetDebug", "sets", "the", "Config", ".", "Debug", "field" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L148-L156
126,658
ligato/cn-infra
messaging/kafka/client/config.go
SetPartitioner
func (ref *Config) SetPartitioner(val string) { switch val { default: ref.Errorf("Invalid partitioner %s - defaulting to ''", val) fallthrough case "": if ref.Partition >= 0 { ref.Partitioner = sarama.NewManualPartitioner } else { ref.Partitioner = sarama.NewHashPartitioner } case Hash: ref.Partit...
go
func (ref *Config) SetPartitioner(val string) { switch val { default: ref.Errorf("Invalid partitioner %s - defaulting to ''", val) fallthrough case "": if ref.Partition >= 0 { ref.Partitioner = sarama.NewManualPartitioner } else { ref.Partitioner = sarama.NewHashPartitioner } case Hash: ref.Partit...
[ "func", "(", "ref", "*", "Config", ")", "SetPartitioner", "(", "val", "string", ")", "{", "switch", "val", "{", "default", ":", "ref", ".", "Errorf", "(", "\"", "\"", ",", "val", ")", "\n", "fallthrough", "\n", "case", "\"", "\"", ":", "if", "ref",...
// SetPartitioner sets the Config.SetPartitioner field
[ "SetPartitioner", "sets", "the", "Config", ".", "SetPartitioner", "field" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L234-L258
126,659
ligato/cn-infra
messaging/kafka/client/config.go
SetTLS
func (ref *Config) SetTLS(tlsConfig *tls.Config) (err error) { ref.Net.TLS.Enable = true ref.Net.TLS.Config = tlsConfig return nil }
go
func (ref *Config) SetTLS(tlsConfig *tls.Config) (err error) { ref.Net.TLS.Enable = true ref.Net.TLS.Config = tlsConfig return nil }
[ "func", "(", "ref", "*", "Config", ")", "SetTLS", "(", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "err", "error", ")", "{", "ref", ".", "Net", ".", "TLS", ".", "Enable", "=", "true", "\n", "ref", ".", "Net", ".", "TLS", ".", "Config", "=...
// SetTLS sets the TLS configuration
[ "SetTLS", "sets", "the", "TLS", "configuration" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L261-L266
126,660
ligato/cn-infra
messaging/kafka/client/config.go
ValidateAsyncProducerConfig
func (ref *Config) ValidateAsyncProducerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } if ref.SendSuccess && ref.SuccessChan == nil { return errors.New("success channel not specified") } if ref.SendError && ref.ErrorChan == nil { return...
go
func (ref *Config) ValidateAsyncProducerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } if ref.SendSuccess && ref.SuccessChan == nil { return errors.New("success channel not specified") } if ref.SendError && ref.ErrorChan == nil { return...
[ "func", "(", "ref", "*", "Config", ")", "ValidateAsyncProducerConfig", "(", ")", "error", "{", "if", "ref", ".", "Brokers", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "ref", ".", "SendSuccess", "&&"...
// ValidateAsyncProducerConfig validates config for an Async Producer
[ "ValidateAsyncProducerConfig", "validates", "config", "for", "an", "Async", "Producer" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L269-L280
126,661
ligato/cn-infra
messaging/kafka/client/config.go
ValidateSyncProducerConfig
func (ref *Config) ValidateSyncProducerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } return ref.ProducerConfig().Validate() }
go
func (ref *Config) ValidateSyncProducerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } return ref.ProducerConfig().Validate() }
[ "func", "(", "ref", "*", "Config", ")", "ValidateSyncProducerConfig", "(", ")", "error", "{", "if", "ref", ".", "Brokers", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "ref", ".", "ProducerConfig", ...
// ValidateSyncProducerConfig validates config for a Sync Producer
[ "ValidateSyncProducerConfig", "validates", "config", "for", "a", "Sync", "Producer" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L283-L288
126,662
ligato/cn-infra
messaging/kafka/client/config.go
ValidateConsumerConfig
func (ref *Config) ValidateConsumerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } if ref.GroupID == "" { return errors.New("invalid GroupID - no GroupID specified") } if ref.RecvNotification && ref.RecvNotificationChan == nil { return e...
go
func (ref *Config) ValidateConsumerConfig() error { if ref.Brokers == nil { return errors.New("invalid Brokers - one or more brokers must be specified") } if ref.GroupID == "" { return errors.New("invalid GroupID - no GroupID specified") } if ref.RecvNotification && ref.RecvNotificationChan == nil { return e...
[ "func", "(", "ref", "*", "Config", ")", "ValidateConsumerConfig", "(", ")", "error", "{", "if", "ref", ".", "Brokers", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "ref", ".", "GroupID", "==", "\"",...
// ValidateConsumerConfig validates config for Consumer
[ "ValidateConsumerConfig", "validates", "config", "for", "Consumer" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/messaging/kafka/client/config.go#L291-L308
126,663
ligato/cn-infra
db/keyval/consul/consul.go
NewClient
func NewClient(cfg *api.Config) (store *Client, err error) { var c *api.Client if c, err = api.NewClient(cfg); err != nil { return nil, fmt.Errorf("failed to create Consul client %s", err) } peers, err := c.Status().Peers() if err != nil { return nil, err } consulLogger.Infof("consul peers: %v", peers) re...
go
func NewClient(cfg *api.Config) (store *Client, err error) { var c *api.Client if c, err = api.NewClient(cfg); err != nil { return nil, fmt.Errorf("failed to create Consul client %s", err) } peers, err := c.Status().Peers() if err != nil { return nil, err } consulLogger.Infof("consul peers: %v", peers) re...
[ "func", "NewClient", "(", "cfg", "*", "api", ".", "Config", ")", "(", "store", "*", "Client", ",", "err", "error", ")", "{", "var", "c", "*", "api", ".", "Client", "\n", "if", "c", ",", "err", "=", "api", ".", "NewClient", "(", "cfg", ")", ";",...
// NewClient creates new client for Consul using given address.
[ "NewClient", "creates", "new", "client", "for", "Consul", "using", "given", "address", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L50-L66
126,664
ligato/cn-infra
db/keyval/consul/consul.go
Put
func (c *Client) Put(key string, data []byte, opts ...datasync.PutOption) error { consulLogger.Debugf("Put: %q", key) p := &api.KVPair{Key: transformKey(key), Value: data} _, err := c.client.KV().Put(p, nil) if err != nil { return err } return nil }
go
func (c *Client) Put(key string, data []byte, opts ...datasync.PutOption) error { consulLogger.Debugf("Put: %q", key) p := &api.KVPair{Key: transformKey(key), Value: data} _, err := c.client.KV().Put(p, nil) if err != nil { return err } return nil }
[ "func", "(", "c", "*", "Client", ")", "Put", "(", "key", "string", ",", "data", "[", "]", "byte", ",", "opts", "...", "datasync", ".", "PutOption", ")", "error", "{", "consulLogger", ".", "Debugf", "(", "\"", "\"", ",", "key", ")", "\n", "p", ":=...
// Put stores given data for the key.
[ "Put", "stores", "given", "data", "for", "the", "key", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L69-L78
126,665
ligato/cn-infra
db/keyval/consul/consul.go
GetValue
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) { consulLogger.Debugf("GetValue: %q", key) pair, _, err := c.client.KV().Get(transformKey(key), nil) if err != nil { return nil, false, 0, err } else if pair == nil { return nil, false, 0, nil } return pair.Value, true...
go
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) { consulLogger.Debugf("GetValue: %q", key) pair, _, err := c.client.KV().Get(transformKey(key), nil) if err != nil { return nil, false, 0, err } else if pair == nil { return nil, false, 0, nil } return pair.Value, true...
[ "func", "(", "c", "*", "Client", ")", "GetValue", "(", "key", "string", ")", "(", "data", "[", "]", "byte", ",", "found", "bool", ",", "revision", "int64", ",", "err", "error", ")", "{", "consulLogger", ".", "Debugf", "(", "\"", "\"", ",", "key", ...
// GetValue returns data for the given key.
[ "GetValue", "returns", "data", "for", "the", "given", "key", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L88-L98
126,666
ligato/cn-infra
db/keyval/consul/consul.go
ListValues
func (c *Client) ListValues(key string) (keyval.BytesKeyValIterator, error) { pairs, _, err := c.client.KV().List(transformKey(key), nil) if err != nil { return nil, err } return &bytesKeyValIterator{len: len(pairs), pairs: pairs}, nil }
go
func (c *Client) ListValues(key string) (keyval.BytesKeyValIterator, error) { pairs, _, err := c.client.KV().List(transformKey(key), nil) if err != nil { return nil, err } return &bytesKeyValIterator{len: len(pairs), pairs: pairs}, nil }
[ "func", "(", "c", "*", "Client", ")", "ListValues", "(", "key", "string", ")", "(", "keyval", ".", "BytesKeyValIterator", ",", "error", ")", "{", "pairs", ",", "_", ",", "err", ":=", "c", ".", "client", ".", "KV", "(", ")", ".", "List", "(", "tra...
// ListValues returns interator with key-value pairs for given key prefix.
[ "ListValues", "returns", "interator", "with", "key", "-", "value", "pairs", "for", "given", "key", "prefix", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L101-L108
126,667
ligato/cn-infra
db/keyval/consul/consul.go
ListKeys
func (c *Client) ListKeys(prefix string) (keyval.BytesKeyIterator, error) { keys, _, err := c.client.KV().Keys(transformKey(prefix), "", nil) if err != nil { return nil, err } return &bytesKeyIterator{len: len(keys), keys: keys}, nil }
go
func (c *Client) ListKeys(prefix string) (keyval.BytesKeyIterator, error) { keys, _, err := c.client.KV().Keys(transformKey(prefix), "", nil) if err != nil { return nil, err } return &bytesKeyIterator{len: len(keys), keys: keys}, nil }
[ "func", "(", "c", "*", "Client", ")", "ListKeys", "(", "prefix", "string", ")", "(", "keyval", ".", "BytesKeyIterator", ",", "error", ")", "{", "keys", ",", "_", ",", "err", ":=", "c", ".", "client", ".", "KV", "(", ")", ".", "Keys", "(", "transf...
// ListKeys returns interator with keys for given key prefix.
[ "ListKeys", "returns", "interator", "with", "keys", "for", "given", "key", "prefix", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L111-L118
126,668
ligato/cn-infra
db/keyval/consul/consul.go
Delete
func (c *Client) Delete(key string, opts ...datasync.DelOption) (existed bool, err error) { consulLogger.Debugf("Delete: %q", key) if _, err := c.client.KV().Delete(transformKey(key), nil); err != nil { return false, err } return true, nil }
go
func (c *Client) Delete(key string, opts ...datasync.DelOption) (existed bool, err error) { consulLogger.Debugf("Delete: %q", key) if _, err := c.client.KV().Delete(transformKey(key), nil); err != nil { return false, err } return true, nil }
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "key", "string", ",", "opts", "...", "datasync", ".", "DelOption", ")", "(", "existed", "bool", ",", "err", "error", ")", "{", "consulLogger", ".", "Debugf", "(", "\"", "\"", ",", "key", ")", "\n...
// Delete deletes given key.
[ "Delete", "deletes", "given", "key", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/consul/consul.go#L121-L128
126,669
ligato/cn-infra
rpc/rest/mock/httpmock.go
NewRequest
func (mock *HTTPMock) NewRequest(method, url string, body io.Reader) (*http.Response, error) { req, err := http.NewRequest(method, url, body) if err != nil { return nil, err } recorder := httptest.NewRecorder() mock.handler.ServeHTTP(recorder, req) return recorder.Result(), nil }
go
func (mock *HTTPMock) NewRequest(method, url string, body io.Reader) (*http.Response, error) { req, err := http.NewRequest(method, url, body) if err != nil { return nil, err } recorder := httptest.NewRecorder() mock.handler.ServeHTTP(recorder, req) return recorder.Result(), nil }
[ "func", "(", "mock", "*", "HTTPMock", ")", "NewRequest", "(", "method", ",", "url", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(",...
// NewRequest propagates the request to the httpmux
[ "NewRequest", "propagates", "the", "request", "to", "the", "httpmux" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/mock/httpmock.go#L45-L54
126,670
ligato/cn-infra
db/cryptodata/decrypter.go
IsEncrypted
func (d DecrypterJSON) IsEncrypted(object interface{}) bool { inData, ok := object.([]byte) if !ok { return false } var jsonData EncryptionCheck err := json.Unmarshal(inData, &jsonData) return err == nil && jsonData.IsEncrypted }
go
func (d DecrypterJSON) IsEncrypted(object interface{}) bool { inData, ok := object.([]byte) if !ok { return false } var jsonData EncryptionCheck err := json.Unmarshal(inData, &jsonData) return err == nil && jsonData.IsEncrypted }
[ "func", "(", "d", "DecrypterJSON", ")", "IsEncrypted", "(", "object", "interface", "{", "}", ")", "bool", "{", "inData", ",", "ok", ":=", "object", ".", "(", "[", "]", "byte", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n\n", ...
// IsEncrypted checks if provided data are marked as encrypted. First it tries to unmarshal JSON to EncryptionCheck // and then check the IsEncrypted for being true
[ "IsEncrypted", "checks", "if", "provided", "data", "are", "marked", "as", "encrypted", ".", "First", "it", "tries", "to", "unmarshal", "JSON", "to", "EncryptionCheck", "and", "then", "check", "the", "IsEncrypted", "for", "being", "true" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L63-L72
126,671
ligato/cn-infra
db/cryptodata/decrypter.go
decryptJSON
func (d DecrypterJSON) decryptJSON(data map[string]interface{}, decryptFunc DecryptFunc) error { for k, v := range data { switch t := v.(type) { case string: if s := strings.TrimPrefix(t, d.prefix); s != t { s, err := base64.URLEncoding.DecodeString(s) if err != nil { return err } decrypte...
go
func (d DecrypterJSON) decryptJSON(data map[string]interface{}, decryptFunc DecryptFunc) error { for k, v := range data { switch t := v.(type) { case string: if s := strings.TrimPrefix(t, d.prefix); s != t { s, err := base64.URLEncoding.DecodeString(s) if err != nil { return err } decrypte...
[ "func", "(", "d", "DecrypterJSON", ")", "decryptJSON", "(", "data", "map", "[", "string", "]", "interface", "{", "}", ",", "decryptFunc", "DecryptFunc", ")", "error", "{", "for", "k", ",", "v", ":=", "range", "data", "{", "switch", "t", ":=", "v", "....
// decryptJSON recursively navigates JSON structure and tries to decrypt all string values with Prefix
[ "decryptJSON", "recursively", "navigates", "JSON", "structure", "and", "tries", "to", "decrypt", "all", "string", "values", "with", "Prefix" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L100-L126
126,672
ligato/cn-infra
db/cryptodata/decrypter.go
RegisterMapping
func (d DecrypterProto) RegisterMapping(object proto.Message, paths ...[]string) { d.mapping[reflect.TypeOf(object)] = paths }
go
func (d DecrypterProto) RegisterMapping(object proto.Message, paths ...[]string) { d.mapping[reflect.TypeOf(object)] = paths }
[ "func", "(", "d", "DecrypterProto", ")", "RegisterMapping", "(", "object", "proto", ".", "Message", ",", "paths", "...", "[", "]", "string", ")", "{", "d", ".", "mapping", "[", "reflect", ".", "TypeOf", "(", "object", ")", "]", "=", "paths", "\n", "}...
// RegisterMapping registers mapping to decrypter that maps proto.Message type to path used to access encrypted values
[ "RegisterMapping", "registers", "mapping", "to", "decrypter", "that", "maps", "proto", ".", "Message", "type", "to", "path", "used", "to", "access", "encrypted", "values" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L140-L142
126,673
ligato/cn-infra
db/cryptodata/decrypter.go
IsEncrypted
func (d DecrypterProto) IsEncrypted(object interface{}) bool { _, ok := object.(proto.Message) if !ok { return false } _, ok = d.mapping[reflect.TypeOf(object)] return ok }
go
func (d DecrypterProto) IsEncrypted(object interface{}) bool { _, ok := object.(proto.Message) if !ok { return false } _, ok = d.mapping[reflect.TypeOf(object)] return ok }
[ "func", "(", "d", "DecrypterProto", ")", "IsEncrypted", "(", "object", "interface", "{", "}", ")", "bool", "{", "_", ",", "ok", ":=", "object", ".", "(", "proto", ".", "Message", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", ...
// IsEncrypted checks if provided data type is contained in the Mapping
[ "IsEncrypted", "checks", "if", "provided", "data", "type", "is", "contained", "in", "the", "Mapping" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L145-L152
126,674
ligato/cn-infra
db/cryptodata/decrypter.go
Decrypt
func (d DecrypterProto) Decrypt(object interface{}, decryptFunc DecryptFunc) (interface{}, error) { if !d.IsEncrypted(object) { return object, nil } for _, path := range d.mapping[reflect.TypeOf(object)] { if err := d.decryptStruct(object, path, decryptFunc); err != nil { return nil, err } } return obje...
go
func (d DecrypterProto) Decrypt(object interface{}, decryptFunc DecryptFunc) (interface{}, error) { if !d.IsEncrypted(object) { return object, nil } for _, path := range d.mapping[reflect.TypeOf(object)] { if err := d.decryptStruct(object, path, decryptFunc); err != nil { return nil, err } } return obje...
[ "func", "(", "d", "DecrypterProto", ")", "Decrypt", "(", "object", "interface", "{", "}", ",", "decryptFunc", "DecryptFunc", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "!", "d", ".", "IsEncrypted", "(", "object", ")", "{", "return",...
// Decrypt tries to find encrypted values in protobuf data and decrypt them. It uses IsEncrypted function on the // data to check if it contains any encrypted data. // Then it goes through provided mapping and tries to reflect all fields in the mapping and decrypt string values the // mappings must point to. // This fu...
[ "Decrypt", "tries", "to", "find", "encrypted", "values", "in", "protobuf", "data", "and", "decrypt", "them", ".", "It", "uses", "IsEncrypted", "function", "on", "the", "data", "to", "check", "if", "it", "contains", "any", "encrypted", "data", ".", "Then", ...
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L159-L171
126,675
ligato/cn-infra
db/cryptodata/decrypter.go
decryptStruct
func (d DecrypterProto) decryptStruct(object interface{}, path []string, decryptFunc DecryptFunc) error { v, ok := object.(reflect.Value) if !ok { v = reflect.ValueOf(object) } for pathIndex, key := range path { if v.Kind() == reflect.Ptr { v = v.Elem() } if v.Kind() == reflect.Struct { v = v.FieldB...
go
func (d DecrypterProto) decryptStruct(object interface{}, path []string, decryptFunc DecryptFunc) error { v, ok := object.(reflect.Value) if !ok { v = reflect.ValueOf(object) } for pathIndex, key := range path { if v.Kind() == reflect.Ptr { v = v.Elem() } if v.Kind() == reflect.Struct { v = v.FieldB...
[ "func", "(", "d", "DecrypterProto", ")", "decryptStruct", "(", "object", "interface", "{", "}", ",", "path", "[", "]", "string", ",", "decryptFunc", "DecryptFunc", ")", "error", "{", "v", ",", "ok", ":=", "object", ".", "(", "reflect", ".", "Value", ")...
// decryptStruct recursively tries to decrypt fields in object on provided path using provided decryptFunc
[ "decryptStruct", "recursively", "tries", "to", "decrypt", "fields", "in", "object", "on", "provided", "path", "using", "provided", "decryptFunc" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/cryptodata/decrypter.go#L174-L231
126,676
ligato/cn-infra
rpc/rest/config.go
FixConfig
func FixConfig(cfg *Config) { if cfg == nil { return } if cfg.Endpoint == "" { cfg.Endpoint = DefaultEndpoint } }
go
func FixConfig(cfg *Config) { if cfg == nil { return } if cfg.Endpoint == "" { cfg.Endpoint = DefaultEndpoint } }
[ "func", "FixConfig", "(", "cfg", "*", "Config", ")", "{", "if", "cfg", "==", "nil", "{", "return", "\n", "}", "\n", "if", "cfg", ".", "Endpoint", "==", "\"", "\"", "{", "cfg", ".", "Endpoint", "=", "DefaultEndpoint", "\n", "}", "\n", "}" ]
// FixConfig fill default values for empty fields
[ "FixConfig", "fill", "default", "values", "for", "empty", "fields" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/config.go#L140-L147
126,677
ligato/cn-infra
examples/process-manager-plugin/templates/main.go
runExample
func (p *PMExample) runExample() { // Process templates (create a template, start process using template) if err := p.templateExample(); err != nil { p.Log.Errorf("simple process manager example failed with error: %v", err) } close(p.finished) return }
go
func (p *PMExample) runExample() { // Process templates (create a template, start process using template) if err := p.templateExample(); err != nil { p.Log.Errorf("simple process manager example failed with error: %v", err) } close(p.finished) return }
[ "func", "(", "p", "*", "PMExample", ")", "runExample", "(", ")", "{", "// Process templates (create a template, start process using template)", "if", "err", ":=", "p", ".", "templateExample", "(", ")", ";", "err", "!=", "nil", "{", "p", ".", "Log", ".", "Error...
// Runs example with step by step description
[ "Runs", "example", "with", "step", "by", "step", "description" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/process-manager-plugin/templates/main.go#L78-L85
126,678
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
NewFileSystemMock
func NewFileSystemMock() *Mock { return &Mock{ responses: make([]*WhenResp, 0), eventChan: make(chan fsnotify.Event), } }
go
func NewFileSystemMock() *Mock { return &Mock{ responses: make([]*WhenResp, 0), eventChan: make(chan fsnotify.Event), } }
[ "func", "NewFileSystemMock", "(", ")", "*", "Mock", "{", "return", "&", "Mock", "{", "responses", ":", "make", "(", "[", "]", "*", "WhenResp", ",", "0", ")", ",", "eventChan", ":", "make", "(", "chan", "fsnotify", ".", "Event", ")", ",", "}", "\n",...
// NewFileSystemMock creates new instance of the mock and initializes response list
[ "NewFileSystemMock", "creates", "new", "instance", "of", "the", "mock", "and", "initializes", "response", "list" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L28-L33
126,679
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
CreateFile
func (mock *Mock) CreateFile(file string) error { items := mock.getReturnValues("CreateFile") return items[0].(error) }
go
func (mock *Mock) CreateFile(file string) error { items := mock.getReturnValues("CreateFile") return items[0].(error) }
[ "func", "(", "mock", "*", "Mock", ")", "CreateFile", "(", "file", "string", ")", "error", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "return", "items", "[", "0", "]", ".", "(", "error", ")", "\n", "}" ]
// CreateFile mocks original method
[ "CreateFile", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L81-L84
126,680
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
ReadFile
func (mock *Mock) ReadFile(file string) ([]byte, error) { items := mock.getReturnValues("ReadFile") if len(items) == 1 { switch typed := items[0].(type) { case []byte: return typed, nil case error: return []byte{}, typed } } else if len(items) == 2 { return items[0].([]byte), items[1].(error) } ret...
go
func (mock *Mock) ReadFile(file string) ([]byte, error) { items := mock.getReturnValues("ReadFile") if len(items) == 1 { switch typed := items[0].(type) { case []byte: return typed, nil case error: return []byte{}, typed } } else if len(items) == 2 { return items[0].([]byte), items[1].(error) } ret...
[ "func", "(", "mock", "*", "Mock", ")", "ReadFile", "(", "file", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "if", "len", "(", "items", ")", "==", "1", ...
// ReadFile mocks original method
[ "ReadFile", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L87-L100
126,681
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
WriteFile
func (mock *Mock) WriteFile(file string, data []byte) error { items := mock.getReturnValues("WriteFile") return items[0].(error) }
go
func (mock *Mock) WriteFile(file string, data []byte) error { items := mock.getReturnValues("WriteFile") return items[0].(error) }
[ "func", "(", "mock", "*", "Mock", ")", "WriteFile", "(", "file", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "return", "items", "[", "0", "]", ".", "(", "e...
// WriteFile mocks original method
[ "WriteFile", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L103-L106
126,682
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
FileExists
func (mock *Mock) FileExists(file string) bool { items := mock.getReturnValues("FileExists") return items[0].(bool) }
go
func (mock *Mock) FileExists(file string) bool { items := mock.getReturnValues("FileExists") return items[0].(bool) }
[ "func", "(", "mock", "*", "Mock", ")", "FileExists", "(", "file", "string", ")", "bool", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "return", "items", "[", "0", "]", ".", "(", "bool", ")", "\n", "}" ]
// FileExists mocks original method
[ "FileExists", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L109-L112
126,683
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
GetFileNames
func (mock *Mock) GetFileNames(paths []string) ([]string, error) { items := mock.getReturnValues("GetFileNames") if len(items) == 1 { switch typed := items[0].(type) { case []string: return typed, nil case error: return []string{}, typed } } else if len(items) == 2 { return items[0].([]string), items...
go
func (mock *Mock) GetFileNames(paths []string) ([]string, error) { items := mock.getReturnValues("GetFileNames") if len(items) == 1 { switch typed := items[0].(type) { case []string: return typed, nil case error: return []string{}, typed } } else if len(items) == 2 { return items[0].([]string), items...
[ "func", "(", "mock", "*", "Mock", ")", "GetFileNames", "(", "paths", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "items", ":=", "mock", ".", "getReturnValues", "(", "\"", "\"", ")", "\n", "if", "len", "(", "items", "...
// GetFileNames mocks original method
[ "GetFileNames", "mocks", "original", "method" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L115-L128
126,684
ligato/cn-infra
db/keyval/filedb/filesystem/mock_filesystem.go
Watch
func (mock *Mock) Watch(paths []string, onEvent func(event fsnotify.Event), onClose func()) error { go func() { for { select { case event, ok := <-mock.eventChan: if !ok { onClose() return } onEvent(event) } } }() return nil }
go
func (mock *Mock) Watch(paths []string, onEvent func(event fsnotify.Event), onClose func()) error { go func() { for { select { case event, ok := <-mock.eventChan: if !ok { onClose() return } onEvent(event) } } }() return nil }
[ "func", "(", "mock", "*", "Mock", ")", "Watch", "(", "paths", "[", "]", "string", ",", "onEvent", "func", "(", "event", "fsnotify", ".", "Event", ")", ",", "onClose", "func", "(", ")", ")", "error", "{", "go", "func", "(", ")", "{", "for", "{", ...
// Watch calls onEvent when event arrives and onClose when channel is closed
[ "Watch", "calls", "onEvent", "when", "event", "arrives", "and", "onClose", "when", "channel", "is", "closed" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/db/keyval/filedb/filesystem/mock_filesystem.go#L131-L145
126,685
ligato/cn-infra
rpc/rest/security/rest_security.go
NewAuthenticator
func NewAuthenticator(router *mux.Router, ctx *Settings, log logging.Logger) AuthenticatorAPI { a := &authenticator{ router: router, log: log, formatter: render.New(render.Options{ IndentJSON: true, }), groupDb: make(map[string][]*access.PermissionGroup_Permissions), expTime: ctx.ExpTime, } // Aut...
go
func NewAuthenticator(router *mux.Router, ctx *Settings, log logging.Logger) AuthenticatorAPI { a := &authenticator{ router: router, log: log, formatter: render.New(render.Options{ IndentJSON: true, }), groupDb: make(map[string][]*access.PermissionGroup_Permissions), expTime: ctx.ExpTime, } // Aut...
[ "func", "NewAuthenticator", "(", "router", "*", "mux", ".", "Router", ",", "ctx", "*", "Settings", ",", "log", "logging", ".", "Logger", ")", "AuthenticatorAPI", "{", "a", ":=", "&", "authenticator", "{", "router", ":", "router", ",", "log", ":", "log", ...
// NewAuthenticator prepares new instance of authenticator.
[ "NewAuthenticator", "prepares", "new", "instance", "of", "authenticator", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L110-L159
126,686
ligato/cn-infra
rpc/rest/security/rest_security.go
AddPermissionGroup
func (a *authenticator) AddPermissionGroup(group ...*access.PermissionGroup) { for _, newPermissionGroup := range group { if _, ok := a.groupDb[newPermissionGroup.Name]; ok { a.log.Warnf("permission group %s already exists, skipped") continue } a.log.Debugf("added HTTP permission group %s", newPermissionGr...
go
func (a *authenticator) AddPermissionGroup(group ...*access.PermissionGroup) { for _, newPermissionGroup := range group { if _, ok := a.groupDb[newPermissionGroup.Name]; ok { a.log.Warnf("permission group %s already exists, skipped") continue } a.log.Debugf("added HTTP permission group %s", newPermissionGr...
[ "func", "(", "a", "*", "authenticator", ")", "AddPermissionGroup", "(", "group", "...", "*", "access", ".", "PermissionGroup", ")", "{", "for", "_", ",", "newPermissionGroup", ":=", "range", "group", "{", "if", "_", ",", "ok", ":=", "a", ".", "groupDb", ...
// AddPermissionGroup adds new permission group.
[ "AddPermissionGroup", "adds", "new", "permission", "group", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L162-L171
126,687
ligato/cn-infra
rpc/rest/security/rest_security.go
Validate
func (a *authenticator) Validate(provider http.HandlerFunc) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { // Token may be accessed via cookie, or from authentication header tokenString, errCode, err := a.getTokenStringFromRequest(req) if err != nil { a.formatter.T...
go
func (a *authenticator) Validate(provider http.HandlerFunc) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { // Token may be accessed via cookie, or from authentication header tokenString, errCode, err := a.getTokenStringFromRequest(req) if err != nil { a.formatter.T...
[ "func", "(", "a", "*", "authenticator", ")", "Validate", "(", "provider", "http", ".", "HandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http...
// Validate the request
[ "Validate", "the", "request" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L174-L211
126,688
ligato/cn-infra
rpc/rest/security/rest_security.go
registerSecurityHandlers
func (a *authenticator) registerSecurityHandlers() { a.router.HandleFunc(login, a.loginHandler).Methods(http.MethodGet, http.MethodPost) a.router.HandleFunc(authenticate, a.authenticationHandler).Methods(http.MethodPost) a.router.HandleFunc(logout, a.logoutHandler).Methods(http.MethodPost) }
go
func (a *authenticator) registerSecurityHandlers() { a.router.HandleFunc(login, a.loginHandler).Methods(http.MethodGet, http.MethodPost) a.router.HandleFunc(authenticate, a.authenticationHandler).Methods(http.MethodPost) a.router.HandleFunc(logout, a.logoutHandler).Methods(http.MethodPost) }
[ "func", "(", "a", "*", "authenticator", ")", "registerSecurityHandlers", "(", ")", "{", "a", ".", "router", ".", "HandleFunc", "(", "login", ",", "a", ".", "loginHandler", ")", ".", "Methods", "(", "http", ".", "MethodGet", ",", "http", ".", "MethodPost"...
// Register authenticator-wide security handlers
[ "Register", "authenticator", "-", "wide", "security", "handlers" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L214-L218
126,689
ligato/cn-infra
rpc/rest/security/rest_security.go
loginHandler
func (a *authenticator) loginHandler(w http.ResponseWriter, req *http.Request) { // GET returns login page. Submit redirects to authenticate. if req.Method == http.MethodGet { r := render.New(render.Options{ Directory: "templates", Asset: Asset, AssetNames: AssetNames, }) r.HTML(w, http.StatusOK,...
go
func (a *authenticator) loginHandler(w http.ResponseWriter, req *http.Request) { // GET returns login page. Submit redirects to authenticate. if req.Method == http.MethodGet { r := render.New(render.Options{ Directory: "templates", Asset: Asset, AssetNames: AssetNames, }) r.HTML(w, http.StatusOK,...
[ "func", "(", "a", "*", "authenticator", ")", "loginHandler", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// GET returns login page. Submit redirects to authenticate.", "if", "req", ".", "Method", "==", "http", "."...
// Login handler shows simple page to log in
[ "Login", "handler", "shows", "simple", "page", "to", "log", "in" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L221-L249
126,690
ligato/cn-infra
rpc/rest/security/rest_security.go
logoutHandler
func (a *authenticator) logoutHandler(w http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) var credentials credentials err := decoder.Decode(&credentials) if err != nil { errStr := fmt.Sprintf("500 internal server error: failed to decode json: %v", err) a.formatter.Text(w, http.Statu...
go
func (a *authenticator) logoutHandler(w http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) var credentials credentials err := decoder.Decode(&credentials) if err != nil { errStr := fmt.Sprintf("500 internal server error: failed to decode json: %v", err) a.formatter.Text(w, http.Statu...
[ "func", "(", "a", "*", "authenticator", ")", "logoutHandler", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "decoder", ":=", "json", ".", "NewDecoder", "(", "req", ".", "Body", ")", "\n", "var", "credential...
// Removes token endpoint from the DB. During processing, token will not be found and will be considered as invalid.
[ "Removes", "token", "endpoint", "from", "the", "DB", ".", "During", "processing", "token", "will", "not", "be", "found", "and", "will", "be", "considered", "as", "invalid", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L277-L289
126,691
ligato/cn-infra
rpc/rest/security/rest_security.go
getTokenStringFromRequest
func (a *authenticator) getTokenStringFromRequest(req *http.Request) (result string, errCode int, err error) { // Try to read header, validate it if exists. authHeader := req.Header.Get(AuthHeaderKey) if authHeader != "" { bearerToken := strings.Split(authHeader, " ") if len(bearerToken) != 2 { return "", htt...
go
func (a *authenticator) getTokenStringFromRequest(req *http.Request) (result string, errCode int, err error) { // Try to read header, validate it if exists. authHeader := req.Header.Get(AuthHeaderKey) if authHeader != "" { bearerToken := strings.Split(authHeader, " ") if len(bearerToken) != 2 { return "", htt...
[ "func", "(", "a", "*", "authenticator", ")", "getTokenStringFromRequest", "(", "req", "*", "http", ".", "Request", ")", "(", "result", "string", ",", "errCode", "int", ",", "err", "error", ")", "{", "// Try to read header, validate it if exists.", "authHeader", ...
// Read raw token from request.
[ "Read", "raw", "token", "from", "request", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L292-L316
126,692
ligato/cn-infra
rpc/rest/security/rest_security.go
getTokenFor
func (a *authenticator) getTokenFor(credentials *credentials) (string, int, error) { name, errCode, err := a.validateCredentials(credentials) if err != nil { return "", errCode, err } claims := jwt.StandardClaims{ Audience: name, ExpiresAt: a.expTime.Nanoseconds(), } token := jwt.NewWithClaims(jwt.SigningM...
go
func (a *authenticator) getTokenFor(credentials *credentials) (string, int, error) { name, errCode, err := a.validateCredentials(credentials) if err != nil { return "", errCode, err } claims := jwt.StandardClaims{ Audience: name, ExpiresAt: a.expTime.Nanoseconds(), } token := jwt.NewWithClaims(jwt.SigningM...
[ "func", "(", "a", "*", "authenticator", ")", "getTokenFor", "(", "credentials", "*", "credentials", ")", "(", "string", ",", "int", ",", "error", ")", "{", "name", ",", "errCode", ",", "err", ":=", "a", ".", "validateCredentials", "(", "credentials", ")"...
// Get token for credentials
[ "Get", "token", "for", "credentials" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L319-L337
126,693
ligato/cn-infra
rpc/rest/security/rest_security.go
validateToken
func (a *authenticator) validateToken(token *jwt.Token, url, method string) error { var userName string // Read audience from the token switch v := token.Claims.(type) { case jwt.MapClaims: var ok bool if userName, ok = v["aud"].(string); !ok { return fmt.Errorf("failed to validate token claims audience") ...
go
func (a *authenticator) validateToken(token *jwt.Token, url, method string) error { var userName string // Read audience from the token switch v := token.Claims.(type) { case jwt.MapClaims: var ok bool if userName, ok = v["aud"].(string); !ok { return fmt.Errorf("failed to validate token claims audience") ...
[ "func", "(", "a", "*", "authenticator", ")", "validateToken", "(", "token", "*", "jwt", ".", "Token", ",", "url", ",", "method", "string", ")", "error", "{", "var", "userName", "string", "\n", "// Read audience from the token", "switch", "v", ":=", "token", ...
// Validates token itself and permissions
[ "Validates", "token", "itself", "and", "permissions" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L352-L393
126,694
ligato/cn-infra
rpc/rest/security/rest_security.go
userIsAdmin
func userIsAdmin(user *User) bool { for _, permission := range user.Permissions { if permission == admin { return true } } return false }
go
func userIsAdmin(user *User) bool { for _, permission := range user.Permissions { if permission == admin { return true } } return false }
[ "func", "userIsAdmin", "(", "user", "*", "User", ")", "bool", "{", "for", "_", ",", "permission", ":=", "range", "user", ".", "Permissions", "{", "if", "permission", "==", "admin", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", ...
// Checks user admin permission
[ "Checks", "user", "admin", "permission" ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/rpc/rest/security/rest_security.go#L415-L422
126,695
ligato/cn-infra
examples/logs-plugin/main.go
AfterInit
func (plugin *ExamplePlugin) AfterInit() (err error) { late := plugin.Log.NewLogger("late") late.Debugf("late debug message") // End the example plugin.Log.Info("logs in plugin example finished, sending shutdown ...") close(plugin.exampleFinished) return nil }
go
func (plugin *ExamplePlugin) AfterInit() (err error) { late := plugin.Log.NewLogger("late") late.Debugf("late debug message") // End the example plugin.Log.Info("logs in plugin example finished, sending shutdown ...") close(plugin.exampleFinished) return nil }
[ "func", "(", "plugin", "*", "ExamplePlugin", ")", "AfterInit", "(", ")", "(", "err", "error", ")", "{", "late", ":=", "plugin", ".", "Log", ".", "NewLogger", "(", "\"", "\"", ")", "\n", "late", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "// End t...
// AfterInit demonstrates the usage of PluginLogger API.
[ "AfterInit", "demonstrates", "the", "usage", "of", "PluginLogger", "API", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/logs-plugin/main.go#L96-L105
126,696
ligato/cn-infra
examples/logs-plugin/main.go
showPanicLog
func (plugin *ExamplePlugin) showPanicLog() { defer func() { if err := recover(); err != nil { plugin.Log.Info("Recovered from panic") } }() plugin.Log.Panic("Panic log: calls panic() after log, will be recovered") //calls panic() after logging }
go
func (plugin *ExamplePlugin) showPanicLog() { defer func() { if err := recover(); err != nil { plugin.Log.Info("Recovered from panic") } }() plugin.Log.Panic("Panic log: calls panic() after log, will be recovered") //calls panic() after logging }
[ "func", "(", "plugin", "*", "ExamplePlugin", ")", "showPanicLog", "(", ")", "{", "defer", "func", "(", ")", "{", "if", "err", ":=", "recover", "(", ")", ";", "err", "!=", "nil", "{", "plugin", ".", "Log", ".", "Info", "(", "\"", "\"", ")", "\n", ...
// showPanicLog demonstrates panic log + recovering.
[ "showPanicLog", "demonstrates", "panic", "log", "+", "recovering", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/examples/logs-plugin/main.go#L113-L120
126,697
ligato/cn-infra
infra/infra.go
SetupLog
func (d *PluginDeps) SetupLog() { if d.Log == nil { d.Log = logging.ForPlugin(d.String()) } }
go
func (d *PluginDeps) SetupLog() { if d.Log == nil { d.Log = logging.ForPlugin(d.String()) } }
[ "func", "(", "d", "*", "PluginDeps", ")", "SetupLog", "(", ")", "{", "if", "d", ".", "Log", "==", "nil", "{", "d", ".", "Log", "=", "logging", ".", "ForPlugin", "(", "d", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
// SetupLog sets up default instance for plugin log dep.
[ "SetupLog", "sets", "up", "default", "instance", "for", "plugin", "log", "dep", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/infra/infra.go#L68-L72
126,698
ligato/cn-infra
infra/infra.go
Setup
func (d *PluginDeps) Setup() { d.SetupLog() if d.Cfg == nil { d.Cfg = config.ForPlugin(d.String()) } }
go
func (d *PluginDeps) Setup() { d.SetupLog() if d.Cfg == nil { d.Cfg = config.ForPlugin(d.String()) } }
[ "func", "(", "d", "*", "PluginDeps", ")", "Setup", "(", ")", "{", "d", ".", "SetupLog", "(", ")", "\n", "if", "d", ".", "Cfg", "==", "nil", "{", "d", ".", "Cfg", "=", "config", ".", "ForPlugin", "(", "d", ".", "String", "(", ")", ")", "\n", ...
// Setup sets up default instances for plugin deps.
[ "Setup", "sets", "up", "default", "instances", "for", "plugin", "deps", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/infra/infra.go#L75-L80
126,699
ligato/cn-infra
datasync/syncbase/prev_revisions.go
Get
func (r *PrevRevisions) Get(key string) (found bool, value datasync.KeyVal) { r.mu.RLock() prev, found := r.revisions[key] r.mu.RUnlock() return found, prev }
go
func (r *PrevRevisions) Get(key string) (found bool, value datasync.KeyVal) { r.mu.RLock() prev, found := r.revisions[key] r.mu.RUnlock() return found, prev }
[ "func", "(", "r", "*", "PrevRevisions", ")", "Get", "(", "key", "string", ")", "(", "found", "bool", ",", "value", "datasync", ".", "KeyVal", ")", "{", "r", ".", "mu", ".", "RLock", "(", ")", "\n", "prev", ",", "found", ":=", "r", ".", "revisions...
// Get gets the last proto.Message with it's revision.
[ "Get", "gets", "the", "last", "proto", ".", "Message", "with", "it", "s", "revision", "." ]
6552f4407e293b0986ec353eb0f01968cbecb928
https://github.com/ligato/cn-infra/blob/6552f4407e293b0986ec353eb0f01968cbecb928/datasync/syncbase/prev_revisions.go#L37-L43