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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,400 | intelsdi-x/snap | mgmt/rest/server.go | authMiddleware | func (s *Server) authMiddleware(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
reqOrigin := r.Header.Get("Origin")
s.setAllowedOrigins(rw, reqOrigin)
defer r.Body.Close()
if s.auth {
_, password, ok := r.BasicAuth()
// If we have valid password or going to tribe/agreements endpoint
// go t... | go | func (s *Server) authMiddleware(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
reqOrigin := r.Header.Get("Origin")
s.setAllowedOrigins(rw, reqOrigin)
defer r.Body.Close()
if s.auth {
_, password, ok := r.BasicAuth()
// If we have valid password or going to tribe/agreements endpoint
// go t... | [
"func",
"(",
"s",
"*",
"Server",
")",
"authMiddleware",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"next",
"http",
".",
"HandlerFunc",
")",
"{",
"reqOrigin",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
... | // Auth Middleware for REST API | [
"Auth",
"Middleware",
"for",
"REST",
"API"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/server.go#L164-L182 |
15,401 | intelsdi-x/snap | mgmt/rest/server.go | setAllowedOrigins | func (s *Server) setAllowedOrigins(rw http.ResponseWriter, ro string) {
if len(s.allowedOrigins) > 0 {
if _, ok := s.allowedOrigins[ro]; ok {
// localhost CORS is not supported by all browsers. It has to use "*".
if strings.Contains(ro, "127.0.0.1") || strings.Contains(ro, "localhost") {
ro = "*"
}
r... | go | func (s *Server) setAllowedOrigins(rw http.ResponseWriter, ro string) {
if len(s.allowedOrigins) > 0 {
if _, ok := s.allowedOrigins[ro]; ok {
// localhost CORS is not supported by all browsers. It has to use "*".
if strings.Contains(ro, "127.0.0.1") || strings.Contains(ro, "localhost") {
ro = "*"
}
r... | [
"func",
"(",
"s",
"*",
"Server",
")",
"setAllowedOrigins",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"ro",
"string",
")",
"{",
"if",
"len",
"(",
"s",
".",
"allowedOrigins",
")",
">",
"0",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"allowedOrig... | // CORS origins have to be turned on explicitly in the global config.
// Otherwise, it defaults to the same origin. | [
"CORS",
"origins",
"have",
"to",
"be",
"turned",
"on",
"explicitly",
"in",
"the",
"global",
"config",
".",
"Otherwise",
"it",
"defaults",
"to",
"the",
"same",
"origin",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/server.go#L186-L199 |
15,402 | intelsdi-x/snap | pkg/schedule/cron_schedule.go | NewCronSchedule | func NewCronSchedule(entry string) *CronSchedule {
schedule := cron.New()
return &CronSchedule{
entry: entry,
schedule: schedule,
enabled: false,
}
} | go | func NewCronSchedule(entry string) *CronSchedule {
schedule := cron.New()
return &CronSchedule{
entry: entry,
schedule: schedule,
enabled: false,
}
} | [
"func",
"NewCronSchedule",
"(",
"entry",
"string",
")",
"*",
"CronSchedule",
"{",
"schedule",
":=",
"cron",
".",
"New",
"(",
")",
"\n",
"return",
"&",
"CronSchedule",
"{",
"entry",
":",
"entry",
",",
"schedule",
":",
"schedule",
",",
"enabled",
":",
"fal... | // NewCronSchedule creates and starts new cron schedule and returns an instance of CronSchedule | [
"NewCronSchedule",
"creates",
"and",
"starts",
"new",
"cron",
"schedule",
"and",
"returns",
"an",
"instance",
"of",
"CronSchedule"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/schedule/cron_schedule.go#L40-L47 |
15,403 | intelsdi-x/snap | pkg/schedule/cron_schedule.go | Validate | func (c *CronSchedule) Validate() error {
if c.entry == "" {
return ErrMissingCronEntry
}
_, err := cron.Parse(c.entry)
if err != nil {
return err
}
return nil
} | go | func (c *CronSchedule) Validate() error {
if c.entry == "" {
return ErrMissingCronEntry
}
_, err := cron.Parse(c.entry)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"CronSchedule",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"entry",
"==",
"\"",
"\"",
"{",
"return",
"ErrMissingCronEntry",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"cron",
".",
"Parse",
"(",
"c",
".",
"entry",
... | // Validate returns error if cron entry doesn't match crontab format | [
"Validate",
"returns",
"error",
"if",
"cron",
"entry",
"doesn",
"t",
"match",
"crontab",
"format"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/schedule/cron_schedule.go#L60-L69 |
15,404 | intelsdi-x/snap | pkg/schedule/cron_schedule.go | Wait | func (c *CronSchedule) Wait(last time.Time) Response {
var err error
now := time.Now()
// first run
if (last == time.Time{}) {
last = now
}
// schedule not enabled, either due to first run or invalid cron entry
if !c.enabled {
err = c.schedule.AddFunc(c.entry, func() {})
if err != nil {
c.state = Error... | go | func (c *CronSchedule) Wait(last time.Time) Response {
var err error
now := time.Now()
// first run
if (last == time.Time{}) {
last = now
}
// schedule not enabled, either due to first run or invalid cron entry
if !c.enabled {
err = c.schedule.AddFunc(c.entry, func() {})
if err != nil {
c.state = Error... | [
"func",
"(",
"c",
"*",
"CronSchedule",
")",
"Wait",
"(",
"last",
"time",
".",
"Time",
")",
"Response",
"{",
"var",
"err",
"error",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"// first run",
"if",
"(",
"last",
"==",
"time",
".",
"Time"... | // Wait waits as long as specified in cron entry | [
"Wait",
"waits",
"as",
"long",
"as",
"specified",
"in",
"cron",
"entry"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/schedule/cron_schedule.go#L72-L114 |
15,405 | intelsdi-x/snap | core/cdata/tree.go | Add | func (c *ConfigDataTree) Add(ns []string, cdn *ConfigDataNode) {
c.cTree.Add(ns, cdn)
} | go | func (c *ConfigDataTree) Add(ns []string, cdn *ConfigDataNode) {
c.cTree.Add(ns, cdn)
} | [
"func",
"(",
"c",
"*",
"ConfigDataTree",
")",
"Add",
"(",
"ns",
"[",
"]",
"string",
",",
"cdn",
"*",
"ConfigDataNode",
")",
"{",
"c",
".",
"cTree",
".",
"Add",
"(",
"ns",
",",
"cdn",
")",
"\n",
"}"
] | // Adds a ConfigDataNode at the provided namespace. | [
"Adds",
"a",
"ConfigDataNode",
"at",
"the",
"provided",
"namespace",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/tree.go#L58-L60 |
15,406 | intelsdi-x/snap | core/cdata/tree.go | Get | func (c *ConfigDataTree) Get(ns []string) *ConfigDataNode {
n := c.cTree.Get(ns)
if n == nil {
return nil
}
switch t := n.(type) {
case ConfigDataNode:
return &t
default:
return t.(*ConfigDataNode)
}
} | go | func (c *ConfigDataTree) Get(ns []string) *ConfigDataNode {
n := c.cTree.Get(ns)
if n == nil {
return nil
}
switch t := n.(type) {
case ConfigDataNode:
return &t
default:
return t.(*ConfigDataNode)
}
} | [
"func",
"(",
"c",
"*",
"ConfigDataTree",
")",
"Get",
"(",
"ns",
"[",
"]",
"string",
")",
"*",
"ConfigDataNode",
"{",
"n",
":=",
"c",
".",
"cTree",
".",
"Get",
"(",
"ns",
")",
"\n",
"if",
"n",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
... | // Returns a ConfigDataNode that is a merged version of the namespace provided. | [
"Returns",
"a",
"ConfigDataNode",
"that",
"is",
"a",
"merged",
"version",
"of",
"the",
"namespace",
"provided",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/tree.go#L63-L75 |
15,407 | intelsdi-x/snap | control/plugin/plugin_deprecated.go | CacheTTL | func CacheTTL(t time.Duration) metaOp {
return func(m *PluginMeta) {
m.CacheTTL = t
}
} | go | func CacheTTL(t time.Duration) metaOp {
return func(m *PluginMeta) {
m.CacheTTL = t
}
} | [
"func",
"CacheTTL",
"(",
"t",
"time",
".",
"Duration",
")",
"metaOp",
"{",
"return",
"func",
"(",
"m",
"*",
"PluginMeta",
")",
"{",
"m",
".",
"CacheTTL",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // CacheTTL is an option that can be be provided to the func NewPluginMeta. | [
"CacheTTL",
"is",
"an",
"option",
"that",
"can",
"be",
"be",
"provided",
"to",
"the",
"func",
"NewPluginMeta",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/plugin_deprecated.go#L74-L78 |
15,408 | intelsdi-x/snap | control/plugin/plugin_deprecated.go | NewPluginMeta | func NewPluginMeta(name string, version int, pluginType PluginType, acceptContentTypes, returnContentTypes []string, opts ...metaOp) *PluginMeta {
// An empty accepted content type default to "snap.*"
if len(acceptContentTypes) == 0 {
acceptContentTypes = append(acceptContentTypes, "snap.*")
}
// Validate content... | go | func NewPluginMeta(name string, version int, pluginType PluginType, acceptContentTypes, returnContentTypes []string, opts ...metaOp) *PluginMeta {
// An empty accepted content type default to "snap.*"
if len(acceptContentTypes) == 0 {
acceptContentTypes = append(acceptContentTypes, "snap.*")
}
// Validate content... | [
"func",
"NewPluginMeta",
"(",
"name",
"string",
",",
"version",
"int",
",",
"pluginType",
"PluginType",
",",
"acceptContentTypes",
",",
"returnContentTypes",
"[",
"]",
"string",
",",
"opts",
"...",
"metaOp",
")",
"*",
"PluginMeta",
"{",
"// An empty accepted conte... | // NewPluginMeta constructs and returns a PluginMeta struct | [
"NewPluginMeta",
"constructs",
"and",
"returns",
"a",
"PluginMeta",
"struct"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/plugin_deprecated.go#L81-L122 |
15,409 | intelsdi-x/snap | control/strategy/config_based.go | Select | func (cb *configBased) Select(aps []AvailablePlugin, id string) (AvailablePlugin, error) {
if ap, ok := cb.plugins[id]; ok && ap != nil {
return ap, nil
}
// add first one in case it's new id
for _, ap := range aps {
available := true
for _, busyPlugin := range cb.plugins {
if ap == busyPlugin {
avail... | go | func (cb *configBased) Select(aps []AvailablePlugin, id string) (AvailablePlugin, error) {
if ap, ok := cb.plugins[id]; ok && ap != nil {
return ap, nil
}
// add first one in case it's new id
for _, ap := range aps {
available := true
for _, busyPlugin := range cb.plugins {
if ap == busyPlugin {
avail... | [
"func",
"(",
"cb",
"*",
"configBased",
")",
"Select",
"(",
"aps",
"[",
"]",
"AvailablePlugin",
",",
"id",
"string",
")",
"(",
"AvailablePlugin",
",",
"error",
")",
"{",
"if",
"ap",
",",
"ok",
":=",
"cb",
".",
"plugins",
"[",
"id",
"]",
";",
"ok",
... | // Select selects an available plugin using the config based plugin strategy. | [
"Select",
"selects",
"an",
"available",
"plugin",
"using",
"the",
"config",
"based",
"plugin",
"strategy",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/config_based.go#L52-L76 |
15,410 | intelsdi-x/snap | core/cdata/node.go | GobEncode | func (c *ConfigDataNode) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(&c.table); err != nil {
return nil, err
}
return w.Bytes(), nil
} | go | func (c *ConfigDataNode) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(&c.table); err != nil {
return nil, err
}
return w.Bytes(), nil
} | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"GobEncode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"encoder",
":=",
"gob",
".",
"NewEncoder",
"(",
"w",
")",
"\n",
"if",
... | // GobEcode encodes a ConfigDataNode in go binary format | [
"GobEcode",
"encodes",
"a",
"ConfigDataNode",
"in",
"go",
"binary",
"format"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L40-L47 |
15,411 | intelsdi-x/snap | core/cdata/node.go | GobDecode | func (c *ConfigDataNode) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
c.mutex = new(sync.Mutex)
decoder := gob.NewDecoder(r)
return decoder.Decode(&c.table)
} | go | func (c *ConfigDataNode) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
c.mutex = new(sync.Mutex)
decoder := gob.NewDecoder(r)
return decoder.Decode(&c.table)
} | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"GobDecode",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"buf",
")",
"\n",
"c",
".",
"mutex",
"=",
"new",
"(",
"sync",
".",
"Mutex",
")",
"\n",
"decoder... | // GobDecode decodes a GOB into a ConfigDataNode | [
"GobDecode",
"decodes",
"a",
"GOB",
"into",
"a",
"ConfigDataNode"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L50-L55 |
15,412 | intelsdi-x/snap | core/cdata/node.go | UnmarshalJSON | func (c *ConfigDataNode) UnmarshalJSON(data []byte) error {
t := map[string]interface{}{}
c.table = map[string]ctypes.ConfigValue{}
dec := json.NewDecoder(bytes.NewReader(data))
dec.UseNumber()
if err := dec.Decode(&t); err != nil {
return err
}
for k, i := range t {
switch t := i.(type) {
case string:
... | go | func (c *ConfigDataNode) UnmarshalJSON(data []byte) error {
t := map[string]interface{}{}
c.table = map[string]ctypes.ConfigValue{}
dec := json.NewDecoder(bytes.NewReader(data))
dec.UseNumber()
if err := dec.Decode(&t); err != nil {
return err
}
for k, i := range t {
switch t := i.(type) {
case string:
... | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"t",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"c",
".",
"table",
"=",
"map",
"[",
"string",
"]",
"ctyp... | // UnmarshalJSON unmarshals JSON into a ConfigDataNode | [
"UnmarshalJSON",
"unmarshals",
"JSON",
"into",
"a",
"ConfigDataNode"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L63-L93 |
15,413 | intelsdi-x/snap | core/cdata/node.go | NewNode | func NewNode() *ConfigDataNode {
return &ConfigDataNode{
mutex: new(sync.Mutex),
table: make(map[string]ctypes.ConfigValue),
}
} | go | func NewNode() *ConfigDataNode {
return &ConfigDataNode{
mutex: new(sync.Mutex),
table: make(map[string]ctypes.ConfigValue),
}
} | [
"func",
"NewNode",
"(",
")",
"*",
"ConfigDataNode",
"{",
"return",
"&",
"ConfigDataNode",
"{",
"mutex",
":",
"new",
"(",
"sync",
".",
"Mutex",
")",
",",
"table",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"ctypes",
".",
"ConfigValue",
")",
",",
"}"... | // Returns a new and empty node. | [
"Returns",
"a",
"new",
"and",
"empty",
"node",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L96-L101 |
15,414 | intelsdi-x/snap | core/cdata/node.go | AddItem | func (c *ConfigDataNode) AddItem(k string, v ctypes.ConfigValue) {
// And empty is a noop
if k == "" {
return
}
c.mutex.Lock()
defer c.mutex.Unlock()
c.table[k] = v
} | go | func (c *ConfigDataNode) AddItem(k string, v ctypes.ConfigValue) {
// And empty is a noop
if k == "" {
return
}
c.mutex.Lock()
defer c.mutex.Unlock()
c.table[k] = v
} | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"AddItem",
"(",
"k",
"string",
",",
"v",
"ctypes",
".",
"ConfigValue",
")",
"{",
"// And empty is a noop",
"if",
"k",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"c",
".",
"mutex",
".",
"Lock",
"(",... | // Adds an item to the ConfigDataNode. | [
"Adds",
"an",
"item",
"to",
"the",
"ConfigDataNode",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L118-L126 |
15,415 | intelsdi-x/snap | core/cdata/node.go | ReverseMergeInPlace | func (c *ConfigDataNode) ReverseMergeInPlace(n ctree.Node) ctree.Node {
cd := n.(*ConfigDataNode)
new_table := make(map[string]ctypes.ConfigValue)
// Lock here since we are modifying c.table
c.mutex.Lock()
defer c.mutex.Unlock()
t := cd.Table()
t2 := c.table
for k, v := range t {
new_table[k] = v
}
for k, v... | go | func (c *ConfigDataNode) ReverseMergeInPlace(n ctree.Node) ctree.Node {
cd := n.(*ConfigDataNode)
new_table := make(map[string]ctypes.ConfigValue)
// Lock here since we are modifying c.table
c.mutex.Lock()
defer c.mutex.Unlock()
t := cd.Table()
t2 := c.table
for k, v := range t {
new_table[k] = v
}
for k, v... | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"ReverseMergeInPlace",
"(",
"n",
"ctree",
".",
"Node",
")",
"ctree",
".",
"Node",
"{",
"cd",
":=",
"n",
".",
"(",
"*",
"ConfigDataNode",
")",
"\n",
"new_table",
":=",
"make",
"(",
"map",
"[",
"string",
"]... | // Merges a ConfigDataNode with this one but does not overwrite any
// conflicting values. Any conflicts are decided by the callers value. | [
"Merges",
"a",
"ConfigDataNode",
"with",
"this",
"one",
"but",
"does",
"not",
"overwrite",
"any",
"conflicting",
"values",
".",
"Any",
"conflicts",
"are",
"decided",
"by",
"the",
"callers",
"value",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L145-L161 |
15,416 | intelsdi-x/snap | core/cdata/node.go | ReverseMerge | func (c *ConfigDataNode) ReverseMerge(n ctree.Node) *ConfigDataNode {
cd := n.(*ConfigDataNode)
copy := NewNode()
t2 := c.table
for k, v := range cd.Table() {
copy.table[k] = v
}
for k, v := range t2 {
copy.table[k] = v
}
return copy
} | go | func (c *ConfigDataNode) ReverseMerge(n ctree.Node) *ConfigDataNode {
cd := n.(*ConfigDataNode)
copy := NewNode()
t2 := c.table
for k, v := range cd.Table() {
copy.table[k] = v
}
for k, v := range t2 {
copy.table[k] = v
}
return copy
} | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"ReverseMerge",
"(",
"n",
"ctree",
".",
"Node",
")",
"*",
"ConfigDataNode",
"{",
"cd",
":=",
"n",
".",
"(",
"*",
"ConfigDataNode",
")",
"\n",
"copy",
":=",
"NewNode",
"(",
")",
"\n",
"t2",
":=",
"c",
".... | // Merges a ConfigDataNode with a copy of the current ConfigDataNode and returns
// the copy. The merge does not overwrite any conflicting values.
// Any conflicts are decided by the callers value. | [
"Merges",
"a",
"ConfigDataNode",
"with",
"a",
"copy",
"of",
"the",
"current",
"ConfigDataNode",
"and",
"returns",
"the",
"copy",
".",
"The",
"merge",
"does",
"not",
"overwrite",
"any",
"conflicting",
"values",
".",
"Any",
"conflicts",
"are",
"decided",
"by",
... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L166-L177 |
15,417 | intelsdi-x/snap | core/cdata/node.go | ApplyDefaults | func (c *ConfigDataNode) ApplyDefaults(defaults map[string]ctypes.ConfigValue) {
// Lock here since we are modifying c.table
c.mutex.Lock()
defer c.mutex.Unlock()
for name, def := range defaults {
if _, ok := c.table[name]; !ok {
c.table[name] = def
}
}
} | go | func (c *ConfigDataNode) ApplyDefaults(defaults map[string]ctypes.ConfigValue) {
// Lock here since we are modifying c.table
c.mutex.Lock()
defer c.mutex.Unlock()
for name, def := range defaults {
if _, ok := c.table[name]; !ok {
c.table[name] = def
}
}
} | [
"func",
"(",
"c",
"*",
"ConfigDataNode",
")",
"ApplyDefaults",
"(",
"defaults",
"map",
"[",
"string",
"]",
"ctypes",
".",
"ConfigValue",
")",
"{",
"// Lock here since we are modifying c.table",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".... | // ApplyDefaults will set default values if the given ConfigDataNode doesn't
// already have a value for the given configuration. | [
"ApplyDefaults",
"will",
"set",
"default",
"values",
"if",
"the",
"given",
"ConfigDataNode",
"doesn",
"t",
"already",
"have",
"a",
"value",
"for",
"the",
"given",
"configuration",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L181-L190 |
15,418 | intelsdi-x/snap | core/cdata/node.go | DeleteItem | func (c ConfigDataNode) DeleteItem(k string) {
c.mutex.Lock()
defer c.mutex.Unlock()
delete(c.table, k)
} | go | func (c ConfigDataNode) DeleteItem(k string) {
c.mutex.Lock()
defer c.mutex.Unlock()
delete(c.table, k)
} | [
"func",
"(",
"c",
"ConfigDataNode",
")",
"DeleteItem",
"(",
"k",
"string",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"c",
".",
"table",
",",
"k",
")",
"\n... | // Deletes a field in ConfigDataNode. If the field does not exist Delete is
// considered a no-op | [
"Deletes",
"a",
"field",
"in",
"ConfigDataNode",
".",
"If",
"the",
"field",
"does",
"not",
"exist",
"Delete",
"is",
"considered",
"a",
"no",
"-",
"op"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/cdata/node.go#L194-L198 |
15,419 | intelsdi-x/snap | mgmt/tribe/tribe.go | broadcast | func (t *tribe) broadcast(mt msgType, msg interface{}, notify chan<- struct{}) error {
raw, err := encodeMessage(mt, msg)
if err != nil {
return err
}
t.broadcasts.QueueBroadcast(&broadcast{
msg: raw,
notify: notify,
})
return nil
} | go | func (t *tribe) broadcast(mt msgType, msg interface{}, notify chan<- struct{}) error {
raw, err := encodeMessage(mt, msg)
if err != nil {
return err
}
t.broadcasts.QueueBroadcast(&broadcast{
msg: raw,
notify: notify,
})
return nil
} | [
"func",
"(",
"t",
"*",
"tribe",
")",
"broadcast",
"(",
"mt",
"msgType",
",",
"msg",
"interface",
"{",
"}",
",",
"notify",
"chan",
"<-",
"struct",
"{",
"}",
")",
"error",
"{",
"raw",
",",
"err",
":=",
"encodeMessage",
"(",
"mt",
",",
"msg",
")",
"... | // broadcast takes a tribe message type, encodes it for the wire, and queues
// the broadcast. If a notify channel is given, this channel will be closed
// when the broadcast is sent. | [
"broadcast",
"takes",
"a",
"tribe",
"message",
"type",
"encodes",
"it",
"for",
"the",
"wire",
"and",
"queues",
"the",
"broadcast",
".",
"If",
"a",
"notify",
"channel",
"is",
"given",
"this",
"channel",
"will",
"be",
"closed",
"when",
"the",
"broadcast",
"i... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/tribe/tribe.go#L435-L446 |
15,420 | intelsdi-x/snap | mgmt/rest/config.go | GetDefaultConfig | func GetDefaultConfig() *Config {
return &Config{
Enable: defaultEnable,
Port: defaultPort,
Address: defaultAddress,
HTTPS: defaultHTTPS,
RestCertificate: defaultRestCertificate,
RestKey: defaultRestKey,
RestAuth: defaultAuth,
RestAuthPassword... | go | func GetDefaultConfig() *Config {
return &Config{
Enable: defaultEnable,
Port: defaultPort,
Address: defaultAddress,
HTTPS: defaultHTTPS,
RestCertificate: defaultRestCertificate,
RestKey: defaultRestKey,
RestAuth: defaultAuth,
RestAuthPassword... | [
"func",
"GetDefaultConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Enable",
":",
"defaultEnable",
",",
"Port",
":",
"defaultPort",
",",
"Address",
":",
"defaultAddress",
",",
"HTTPS",
":",
"defaultHTTPS",
",",
"RestCertificate",
":",
"d... | // GetDefaultConfig gets the default snapteld configuration | [
"GetDefaultConfig",
"gets",
"the",
"default",
"snapteld",
"configuration"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/config.go#L80-L94 |
15,421 | intelsdi-x/snap | core/task.go | TaskDeadlineDuration | func TaskDeadlineDuration(v time.Duration) TaskOption {
return func(t Task) TaskOption {
previous := t.DeadlineDuration()
t.SetDeadlineDuration(v)
log.WithFields(log.Fields{
"_module": "core",
"_block": "TaskDeadlineDuration",
"task-id": t.ID(),
"task-nam... | go | func TaskDeadlineDuration(v time.Duration) TaskOption {
return func(t Task) TaskOption {
previous := t.DeadlineDuration()
t.SetDeadlineDuration(v)
log.WithFields(log.Fields{
"_module": "core",
"_block": "TaskDeadlineDuration",
"task-id": t.ID(),
"task-nam... | [
"func",
"TaskDeadlineDuration",
"(",
"v",
"time",
".",
"Duration",
")",
"TaskOption",
"{",
"return",
"func",
"(",
"t",
"Task",
")",
"TaskOption",
"{",
"previous",
":=",
"t",
".",
"DeadlineDuration",
"(",
")",
"\n",
"t",
".",
"SetDeadlineDuration",
"(",
"v"... | // TaskDeadlineDuration sets the tasks deadline.
// The deadline is the amount of time that can pass before a worker begins
// processing the tasks collect job. | [
"TaskDeadlineDuration",
"sets",
"the",
"tasks",
"deadline",
".",
"The",
"deadline",
"is",
"the",
"amount",
"of",
"time",
"that",
"can",
"pass",
"before",
"a",
"worker",
"begins",
"processing",
"the",
"tasks",
"collect",
"job",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/task.go#L108-L122 |
15,422 | intelsdi-x/snap | core/task.go | OptionStopOnFailure | func OptionStopOnFailure(v int) TaskOption {
return func(t Task) TaskOption {
previous := t.GetStopOnFailure()
t.SetStopOnFailure(v)
log.WithFields(log.Fields{
"_module": "core",
"_block": "OptionStopOnFailure",
"task-id": t.ID(),
"task-name": ... | go | func OptionStopOnFailure(v int) TaskOption {
return func(t Task) TaskOption {
previous := t.GetStopOnFailure()
t.SetStopOnFailure(v)
log.WithFields(log.Fields{
"_module": "core",
"_block": "OptionStopOnFailure",
"task-id": t.ID(),
"task-name": ... | [
"func",
"OptionStopOnFailure",
"(",
"v",
"int",
")",
"TaskOption",
"{",
"return",
"func",
"(",
"t",
"Task",
")",
"TaskOption",
"{",
"previous",
":=",
"t",
".",
"GetStopOnFailure",
"(",
")",
"\n",
"t",
".",
"SetStopOnFailure",
"(",
"v",
")",
"\n",
"log",
... | // TaskStopOnFailure sets the tasks stopOnFailure
// The stopOnFailure is the number of consecutive task failures that will
// trigger disabling the task | [
"TaskStopOnFailure",
"sets",
"the",
"tasks",
"stopOnFailure",
"The",
"stopOnFailure",
"is",
"the",
"number",
"of",
"consecutive",
"task",
"failures",
"that",
"will",
"trigger",
"disabling",
"the",
"task"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/task.go#L127-L140 |
15,423 | intelsdi-x/snap | control/control.go | CacheExpiration | func CacheExpiration(t time.Duration) PluginControlOpt {
return func(c *pluginControl) {
strategy.GlobalCacheExpiration = t
}
} | go | func CacheExpiration(t time.Duration) PluginControlOpt {
return func(c *pluginControl) {
strategy.GlobalCacheExpiration = t
}
} | [
"func",
"CacheExpiration",
"(",
"t",
"time",
".",
"Duration",
")",
"PluginControlOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"pluginControl",
")",
"{",
"strategy",
".",
"GlobalCacheExpiration",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // CacheExpiration is the PluginControlOpt which sets the global metric cache TTL | [
"CacheExpiration",
"is",
"the",
"PluginControlOpt",
"which",
"sets",
"the",
"global",
"metric",
"cache",
"TTL"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L167-L171 |
15,424 | intelsdi-x/snap | control/control.go | OptSetConfig | func OptSetConfig(cfg *Config) PluginControlOpt {
return func(c *pluginControl) {
c.Config = cfg
c.pluginManager.SetPluginConfig(cfg.Plugins)
c.pluginManager.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
c.pluginRunner.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
}
} | go | func OptSetConfig(cfg *Config) PluginControlOpt {
return func(c *pluginControl) {
c.Config = cfg
c.pluginManager.SetPluginConfig(cfg.Plugins)
c.pluginManager.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
c.pluginRunner.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
}
} | [
"func",
"OptSetConfig",
"(",
"cfg",
"*",
"Config",
")",
"PluginControlOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"pluginControl",
")",
"{",
"c",
".",
"Config",
"=",
"cfg",
"\n",
"c",
".",
"pluginManager",
".",
"SetPluginConfig",
"(",
"cfg",
".",
"Plugin... | // OptSetConfig sets the plugin control configuration. | [
"OptSetConfig",
"sets",
"the",
"plugin",
"control",
"configuration",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L174-L181 |
15,425 | intelsdi-x/snap | control/control.go | OptSetTags | func OptSetTags(tags map[string]map[string]string) PluginControlOpt {
return func(c *pluginControl) {
c.pluginManager.SetPluginTags(tags)
}
} | go | func OptSetTags(tags map[string]map[string]string) PluginControlOpt {
return func(c *pluginControl) {
c.pluginManager.SetPluginTags(tags)
}
} | [
"func",
"OptSetTags",
"(",
"tags",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"PluginControlOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"pluginControl",
")",
"{",
"c",
".",
"pluginManager",
".",
"SetPluginTags",
"(",
"tags",
")"... | // OptSetTags sets the plugin control tags. | [
"OptSetTags",
"sets",
"the",
"plugin",
"control",
"tags",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L184-L188 |
15,426 | intelsdi-x/snap | control/control.go | New | func New(cfg *Config) *pluginControl {
// construct a slice of options from the input configuration
opts := []PluginControlOpt{
MaxRunningPlugins(cfg.MaxRunningPlugins),
CacheExpiration(cfg.CacheExpiration.Duration),
OptSetConfig(cfg),
OptSetTags(cfg.Tags),
MaxPluginRestarts(cfg),
}
c := &pluginControl{}
... | go | func New(cfg *Config) *pluginControl {
// construct a slice of options from the input configuration
opts := []PluginControlOpt{
MaxRunningPlugins(cfg.MaxRunningPlugins),
CacheExpiration(cfg.CacheExpiration.Duration),
OptSetConfig(cfg),
OptSetTags(cfg.Tags),
MaxPluginRestarts(cfg),
}
c := &pluginControl{}
... | [
"func",
"New",
"(",
"cfg",
"*",
"Config",
")",
"*",
"pluginControl",
"{",
"// construct a slice of options from the input configuration",
"opts",
":=",
"[",
"]",
"PluginControlOpt",
"{",
"MaxRunningPlugins",
"(",
"cfg",
".",
"MaxRunningPlugins",
")",
",",
"CacheExpira... | // New returns a new pluginControl instance | [
"New",
"returns",
"a",
"new",
"pluginControl",
"instance"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L198-L283 |
15,427 | intelsdi-x/snap | control/control.go | Load | func (p *pluginControl) Load(rp *core.RequestedPlugin) (core.CatalogedPlugin, serror.SnapError) {
f := map[string]interface{}{
"_block": "load",
}
details, serr := p.returnPluginDetails(rp)
if serr != nil {
return nil, serr
}
if details.IsPackage {
defer os.RemoveAll(filepath.Dir(details.ExecPath))
}
co... | go | func (p *pluginControl) Load(rp *core.RequestedPlugin) (core.CatalogedPlugin, serror.SnapError) {
f := map[string]interface{}{
"_block": "load",
}
details, serr := p.returnPluginDetails(rp)
if serr != nil {
return nil, serr
}
if details.IsPackage {
defer os.RemoveAll(filepath.Dir(details.ExecPath))
}
co... | [
"func",
"(",
"p",
"*",
"pluginControl",
")",
"Load",
"(",
"rp",
"*",
"core",
".",
"RequestedPlugin",
")",
"(",
"core",
".",
"CatalogedPlugin",
",",
"serror",
".",
"SnapError",
")",
"{",
"f",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{"... | // Load is the public method to load a plugin into
// the LoadedPlugins array and issue an event when
// successful. | [
"Load",
"is",
"the",
"public",
"method",
"to",
"load",
"a",
"plugin",
"into",
"the",
"LoadedPlugins",
"array",
"and",
"issue",
"an",
"event",
"when",
"successful",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L523-L564 |
15,428 | intelsdi-x/snap | control/control.go | SubscribeDeps | func (p *pluginControl) SubscribeDeps(id string, requested []core.RequestedMetric, plugins []core.SubscribedPlugin, configTree *cdata.ConfigDataTree) (serrs []serror.SnapError) {
return p.subscriptionGroups.Add(id, requested, configTree, plugins)
} | go | func (p *pluginControl) SubscribeDeps(id string, requested []core.RequestedMetric, plugins []core.SubscribedPlugin, configTree *cdata.ConfigDataTree) (serrs []serror.SnapError) {
return p.subscriptionGroups.Add(id, requested, configTree, plugins)
} | [
"func",
"(",
"p",
"*",
"pluginControl",
")",
"SubscribeDeps",
"(",
"id",
"string",
",",
"requested",
"[",
"]",
"core",
".",
"RequestedMetric",
",",
"plugins",
"[",
"]",
"core",
".",
"SubscribedPlugin",
",",
"configTree",
"*",
"cdata",
".",
"ConfigDataTree",
... | // SubscribeDeps will subscribe to collectors, processors and publishers. The collectors are subscribed by mapping the provided
// array of core.RequestedMetrics to the corresponding plugins while processors and publishers provided in the array of core.Plugin
// will be subscribed directly. The ID provides a logical ... | [
"SubscribeDeps",
"will",
"subscribe",
"to",
"collectors",
"processors",
"and",
"publishers",
".",
"The",
"collectors",
"are",
"subscribed",
"by",
"mapping",
"the",
"provided",
"array",
"of",
"core",
".",
"RequestedMetrics",
"to",
"the",
"corresponding",
"plugins",
... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L748-L750 |
15,429 | intelsdi-x/snap | control/control.go | UnsubscribeDeps | func (p *pluginControl) UnsubscribeDeps(id string) []serror.SnapError {
// update view and unsubscribe to plugins
return p.subscriptionGroups.Remove(id)
} | go | func (p *pluginControl) UnsubscribeDeps(id string) []serror.SnapError {
// update view and unsubscribe to plugins
return p.subscriptionGroups.Remove(id)
} | [
"func",
"(",
"p",
"*",
"pluginControl",
")",
"UnsubscribeDeps",
"(",
"id",
"string",
")",
"[",
"]",
"serror",
".",
"SnapError",
"{",
"// update view and unsubscribe to plugins",
"return",
"p",
".",
"subscriptionGroups",
".",
"Remove",
"(",
"id",
")",
"\n",
"}"... | // UnsubscribeDeps unsubscribes a group of dependencies provided the subscription group ID | [
"UnsubscribeDeps",
"unsubscribes",
"a",
"group",
"of",
"dependencies",
"provided",
"the",
"subscription",
"group",
"ID"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L753-L756 |
15,430 | intelsdi-x/snap | control/control.go | SetMonitorOptions | func (p *pluginControl) SetMonitorOptions(options ...monitorOption) {
p.pluginRunner.Monitor().Option(options...)
} | go | func (p *pluginControl) SetMonitorOptions(options ...monitorOption) {
p.pluginRunner.Monitor().Option(options...)
} | [
"func",
"(",
"p",
"*",
"pluginControl",
")",
"SetMonitorOptions",
"(",
"options",
"...",
"monitorOption",
")",
"{",
"p",
".",
"pluginRunner",
".",
"Monitor",
"(",
")",
".",
"Option",
"(",
"options",
"...",
")",
"\n",
"}"
] | // SetMonitorOptions exposes monitors options | [
"SetMonitorOptions",
"exposes",
"monitors",
"options"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L878-L880 |
15,431 | intelsdi-x/snap | control/control.go | CollectMetrics | func (p *pluginControl) CollectMetrics(id string, allTags map[string]map[string]string) (metrics []core.Metric, errs []error) {
// If control is not started we don't want tasks to be able to
// go through a workflow.
if !p.Started {
return nil, []error{ErrControllerNotStarted}
}
// Subscription groups are proce... | go | func (p *pluginControl) CollectMetrics(id string, allTags map[string]map[string]string) (metrics []core.Metric, errs []error) {
// If control is not started we don't want tasks to be able to
// go through a workflow.
if !p.Started {
return nil, []error{ErrControllerNotStarted}
}
// Subscription groups are proce... | [
"func",
"(",
"p",
"*",
"pluginControl",
")",
"CollectMetrics",
"(",
"id",
"string",
",",
"allTags",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"metrics",
"[",
"]",
"core",
".",
"Metric",
",",
"errs",
"[",
"]",
"error",
... | // CollectMetrics is a blocking call to collector plugins returning a collection
// of metrics and errors. If an error is encountered no metrics will be
// returned. | [
"CollectMetrics",
"is",
"a",
"blocking",
"call",
"to",
"collector",
"plugins",
"returning",
"a",
"collection",
"of",
"metrics",
"and",
"errors",
".",
"If",
"an",
"error",
"is",
"encountered",
"no",
"metrics",
"will",
"be",
"returned",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/control.go#L988-L1079 |
15,432 | intelsdi-x/snap | scheduler/scheduler.go | New | func New(cfg *Config) *scheduler {
schedulerLogger.WithFields(log.Fields{
"_block": "New",
"value": cfg.WorkManagerQueueSize,
}).Info("Setting work manager queue size")
schedulerLogger.WithFields(log.Fields{
"_block": "New",
"value": cfg.WorkManagerPoolSize,
}).Info("Setting work manager pool size")
opts... | go | func New(cfg *Config) *scheduler {
schedulerLogger.WithFields(log.Fields{
"_block": "New",
"value": cfg.WorkManagerQueueSize,
}).Info("Setting work manager queue size")
schedulerLogger.WithFields(log.Fields{
"_block": "New",
"value": cfg.WorkManagerPoolSize,
}).Info("Setting work manager pool size")
opts... | [
"func",
"New",
"(",
"cfg",
"*",
"Config",
")",
"*",
"scheduler",
"{",
"schedulerLogger",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"cfg",
".",
"WorkManagerQueueSize",
",",
"}",
")",
".",
"... | // New returns an instance of the scheduler
// The MetricManager must be set before the scheduler can be started.
// The MetricManager must be started before it can be used. | [
"New",
"returns",
"an",
"instance",
"of",
"the",
"scheduler",
"The",
"MetricManager",
"must",
"be",
"set",
"before",
"the",
"scheduler",
"can",
"be",
"started",
".",
"The",
"MetricManager",
"must",
"be",
"started",
"before",
"it",
"can",
"be",
"used",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L243-L273 |
15,433 | intelsdi-x/snap | scheduler/scheduler.go | CreateTask | func (s *scheduler) CreateTask(sch schedule.Schedule, wfMap *wmap.WorkflowMap, startOnCreate bool, opts ...core.TaskOption) (core.Task, core.TaskErrors) {
return s.createTask(sch, wfMap, startOnCreate, "user", opts...)
} | go | func (s *scheduler) CreateTask(sch schedule.Schedule, wfMap *wmap.WorkflowMap, startOnCreate bool, opts ...core.TaskOption) (core.Task, core.TaskErrors) {
return s.createTask(sch, wfMap, startOnCreate, "user", opts...)
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"CreateTask",
"(",
"sch",
"schedule",
".",
"Schedule",
",",
"wfMap",
"*",
"wmap",
".",
"WorkflowMap",
",",
"startOnCreate",
"bool",
",",
"opts",
"...",
"core",
".",
"TaskOption",
")",
"(",
"core",
".",
"Task",
"... | // CreateTask creates and returns task | [
"CreateTask",
"creates",
"and",
"returns",
"task"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L292-L294 |
15,434 | intelsdi-x/snap | scheduler/scheduler.go | GetTasks | func (s *scheduler) GetTasks() map[string]core.Task {
tasks := make(map[string]core.Task)
for id, t := range s.tasks.Table() {
tasks[id] = t
}
return tasks
} | go | func (s *scheduler) GetTasks() map[string]core.Task {
tasks := make(map[string]core.Task)
for id, t := range s.tasks.Table() {
tasks[id] = t
}
return tasks
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"GetTasks",
"(",
")",
"map",
"[",
"string",
"]",
"core",
".",
"Task",
"{",
"tasks",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"core",
".",
"Task",
")",
"\n",
"for",
"id",
",",
"t",
":=",
"range",
"s"... | // GetTasks returns a copy of the tasks in a map where the task id is the key | [
"GetTasks",
"returns",
"a",
"copy",
"of",
"the",
"tasks",
"in",
"a",
"map",
"where",
"the",
"task",
"id",
"is",
"the",
"key"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L486-L492 |
15,435 | intelsdi-x/snap | scheduler/scheduler.go | GetTask | func (s *scheduler) GetTask(id string) (core.Task, error) {
t, err := s.getTask(id)
if err != nil {
schedulerLogger.WithFields(log.Fields{
"_block": "get-task",
"_error": ErrTaskNotFound,
"task-id": id,
}).Error("error getting task")
return nil, err // We do this to send back an explicit nil on the i... | go | func (s *scheduler) GetTask(id string) (core.Task, error) {
t, err := s.getTask(id)
if err != nil {
schedulerLogger.WithFields(log.Fields{
"_block": "get-task",
"_error": ErrTaskNotFound,
"task-id": id,
}).Error("error getting task")
return nil, err // We do this to send back an explicit nil on the i... | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"GetTask",
"(",
"id",
"string",
")",
"(",
"core",
".",
"Task",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"s",
".",
"getTask",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"schedulerLogger",
... | // GetTask provided the task id a task is returned | [
"GetTask",
"provided",
"the",
"task",
"id",
"a",
"task",
"is",
"returned"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L495-L506 |
15,436 | intelsdi-x/snap | scheduler/scheduler.go | StartTask | func (s *scheduler) StartTask(id string) []serror.SnapError {
return s.startTask(id, "user")
} | go | func (s *scheduler) StartTask(id string) []serror.SnapError {
return s.startTask(id, "user")
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"StartTask",
"(",
"id",
"string",
")",
"[",
"]",
"serror",
".",
"SnapError",
"{",
"return",
"s",
".",
"startTask",
"(",
"id",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // StartTask provided a task id a task is started | [
"StartTask",
"provided",
"a",
"task",
"id",
"a",
"task",
"is",
"started"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L509-L511 |
15,437 | intelsdi-x/snap | scheduler/scheduler.go | StopTask | func (s *scheduler) StopTask(id string) []serror.SnapError {
return s.stopTask(id, "user")
} | go | func (s *scheduler) StopTask(id string) []serror.SnapError {
return s.stopTask(id, "user")
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"StopTask",
"(",
"id",
"string",
")",
"[",
"]",
"serror",
".",
"SnapError",
"{",
"return",
"s",
".",
"stopTask",
"(",
"id",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // StopTask provided a task id a task is stopped | [
"StopTask",
"provided",
"a",
"task",
"id",
"a",
"task",
"is",
"stopped"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L583-L585 |
15,438 | intelsdi-x/snap | scheduler/scheduler.go | EnableTask | func (s *scheduler) EnableTask(id string) (core.Task, error) {
t, e := s.getTask(id)
if e != nil {
schedulerLogger.WithFields(log.Fields{
"_block": "enable-task",
"_error": ErrTaskNotFound,
"task-id": id,
}).Error("error enabling task")
return nil, e
}
err := t.Enable()
if err != nil {
schedule... | go | func (s *scheduler) EnableTask(id string) (core.Task, error) {
t, e := s.getTask(id)
if e != nil {
schedulerLogger.WithFields(log.Fields{
"_block": "enable-task",
"_error": ErrTaskNotFound,
"task-id": id,
}).Error("error enabling task")
return nil, e
}
err := t.Enable()
if err != nil {
schedule... | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"EnableTask",
"(",
"id",
"string",
")",
"(",
"core",
".",
"Task",
",",
"error",
")",
"{",
"t",
",",
"e",
":=",
"s",
".",
"getTask",
"(",
"id",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"schedulerLogger",
"... | //EnableTask changes state from disabled to stopped | [
"EnableTask",
"changes",
"state",
"from",
"disabled",
"to",
"stopped"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L644-L670 |
15,439 | intelsdi-x/snap | scheduler/scheduler.go | SetMetricManager | func (s *scheduler) SetMetricManager(mm managesMetrics) {
s.metricManager = mm
schedulerLogger.WithFields(log.Fields{
"_block": "set-metric-manager",
}).Debug("metric manager linked")
} | go | func (s *scheduler) SetMetricManager(mm managesMetrics) {
s.metricManager = mm
schedulerLogger.WithFields(log.Fields{
"_block": "set-metric-manager",
}).Debug("metric manager linked")
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"SetMetricManager",
"(",
"mm",
"managesMetrics",
")",
"{",
"s",
".",
"metricManager",
"=",
"mm",
"\n",
"schedulerLogger",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"}",... | // Set metricManager for scheduler | [
"Set",
"metricManager",
"for",
"scheduler"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L750-L755 |
15,440 | intelsdi-x/snap | scheduler/scheduler.go | HandleGomitEvent | func (s *scheduler) HandleGomitEvent(e gomit.Event) {
switch v := e.Body.(type) {
case *scheduler_event.MetricCollectedEvent:
log.WithFields(log.Fields{
"_module": "scheduler-events",
"_block": "handle-events",
"event-namespace": e.Namespace(),
"task-id": v.TaskID,
"metric-c... | go | func (s *scheduler) HandleGomitEvent(e gomit.Event) {
switch v := e.Body.(type) {
case *scheduler_event.MetricCollectedEvent:
log.WithFields(log.Fields{
"_module": "scheduler-events",
"_block": "handle-events",
"event-namespace": e.Namespace(),
"task-id": v.TaskID,
"metric-c... | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"HandleGomitEvent",
"(",
"e",
"gomit",
".",
"Event",
")",
"{",
"switch",
"v",
":=",
"e",
".",
"Body",
".",
"(",
"type",
")",
"{",
"case",
"*",
"scheduler_event",
".",
"MetricCollectedEvent",
":",
"log",
".",
"... | // Central handling for all async events in scheduler | [
"Central",
"handling",
"for",
"all",
"async",
"events",
"in",
"scheduler"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/scheduler.go#L772-L848 |
15,441 | intelsdi-x/snap | mgmt/rest/v1/task.go | enableTask | func (s *apiV1) enableTask(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
id := p.ByName("id")
tsk, err := s.taskManager.EnableTask(id)
if err != nil {
if strings.Contains(err.Error(), ErrTaskNotFound.Error()) {
rbody.Write(404, rbody.FromError(err), w)
return
}
rbody.Write(500, rbody.Fro... | go | func (s *apiV1) enableTask(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
id := p.ByName("id")
tsk, err := s.taskManager.EnableTask(id)
if err != nil {
if strings.Contains(err.Error(), ErrTaskNotFound.Error()) {
rbody.Write(404, rbody.FromError(err), w)
return
}
rbody.Write(500, rbody.Fro... | [
"func",
"(",
"s",
"*",
"apiV1",
")",
"enableTask",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"p",
"httprouter",
".",
"Params",
")",
"{",
"id",
":=",
"p",
".",
"ByName",
"(",
"\"",
"\"",
")",
"\n",
"tsk",... | //enableTask changes the task state from Disabled to Stopped | [
"enableTask",
"changes",
"the",
"task",
"state",
"from",
"Disabled",
"to",
"Stopped"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/v1/task.go#L241-L255 |
15,442 | intelsdi-x/snap | pkg/aci/aci.go | Manifest | func Manifest(f io.ReadSeeker) (*schema.ImageManifest, error) {
m, err := specaci.ManifestFromImage(f)
if err != nil {
return nil, err
}
return m, nil
} | go | func Manifest(f io.ReadSeeker) (*schema.ImageManifest, error) {
m, err := specaci.ManifestFromImage(f)
if err != nil {
return nil, err
}
return m, nil
} | [
"func",
"Manifest",
"(",
"f",
"io",
".",
"ReadSeeker",
")",
"(",
"*",
"schema",
".",
"ImageManifest",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"specaci",
".",
"ManifestFromImage",
"(",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Manifest returns the ImageManifest inside the ACI file | [
"Manifest",
"returns",
"the",
"ImageManifest",
"inside",
"the",
"ACI",
"file"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/aci/aci.go#L56-L62 |
15,443 | intelsdi-x/snap | pkg/aci/aci.go | Extract | func Extract(f io.ReadSeeker) (string, error) {
fileMode := os.FileMode(0755)
tr, err := specaci.NewCompressedTarReader(f)
if err != nil {
return "", err
}
defer tr.Close()
// Extract archive to temporary directory
dir, err := ioutil.TempDir("", "")
if err != nil {
return "", err
}
aciLogger.WithField("... | go | func Extract(f io.ReadSeeker) (string, error) {
fileMode := os.FileMode(0755)
tr, err := specaci.NewCompressedTarReader(f)
if err != nil {
return "", err
}
defer tr.Close()
// Extract archive to temporary directory
dir, err := ioutil.TempDir("", "")
if err != nil {
return "", err
}
aciLogger.WithField("... | [
"func",
"Extract",
"(",
"f",
"io",
".",
"ReadSeeker",
")",
"(",
"string",
",",
"error",
")",
"{",
"fileMode",
":=",
"os",
".",
"FileMode",
"(",
"0755",
")",
"\n\n",
"tr",
",",
"err",
":=",
"specaci",
".",
"NewCompressedTarReader",
"(",
"f",
")",
"\n"... | // Extract expands the ACI file to a temporary directory, returning
// the directory path where the ACI was expanded or an error | [
"Extract",
"expands",
"the",
"ACI",
"file",
"to",
"a",
"temporary",
"directory",
"returning",
"the",
"directory",
"path",
"where",
"the",
"ACI",
"was",
"expanded",
"or",
"an",
"error"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/aci/aci.go#L66-L126 |
15,444 | intelsdi-x/snap | pkg/aci/aci.go | Validate | func Validate(f io.ReadSeeker) error {
tr, err := specaci.NewCompressedTarReader(f)
defer tr.Close()
if err != nil {
return err
}
if err := specaci.ValidateArchive(tr.Reader); err != nil {
return err
}
return nil
} | go | func Validate(f io.ReadSeeker) error {
tr, err := specaci.NewCompressedTarReader(f)
defer tr.Close()
if err != nil {
return err
}
if err := specaci.ValidateArchive(tr.Reader); err != nil {
return err
}
return nil
} | [
"func",
"Validate",
"(",
"f",
"io",
".",
"ReadSeeker",
")",
"error",
"{",
"tr",
",",
"err",
":=",
"specaci",
".",
"NewCompressedTarReader",
"(",
"f",
")",
"\n",
"defer",
"tr",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // Validate makes sure the archive is valid. Otherwise,
// an error is returned | [
"Validate",
"makes",
"sure",
"the",
"archive",
"is",
"valid",
".",
"Otherwise",
"an",
"error",
"is",
"returned"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/aci/aci.go#L130-L141 |
15,445 | intelsdi-x/snap | control/subscription_group.go | Remove | func (s subscriptionGroups) Remove(id string) []serror.SnapError {
s.Lock()
defer s.Unlock()
return s.remove(id)
} | go | func (s subscriptionGroups) Remove(id string) []serror.SnapError {
s.Lock()
defer s.Unlock()
return s.remove(id)
} | [
"func",
"(",
"s",
"subscriptionGroups",
")",
"Remove",
"(",
"id",
"string",
")",
"[",
"]",
"serror",
".",
"SnapError",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"return",
"s",
".",
"remove",
"(",
"id",
")... | // Remove removes a subscription group given a subscription group ID. | [
"Remove",
"removes",
"a",
"subscription",
"group",
"given",
"a",
"subscription",
"group",
"ID",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/subscription_group.go#L144-L148 |
15,446 | intelsdi-x/snap | control/subscription_group.go | validatePluginUnloading | func (s *subscriptionGroups) validatePluginUnloading(pluginToUnload *loadedPlugin) (errs []serror.SnapError) {
s.Lock()
defer s.Unlock()
for id, group := range s.subscriptionMap {
if err := group.validatePluginUnloading(id, pluginToUnload); err != nil {
errs = append(errs, err)
}
}
return errs
} | go | func (s *subscriptionGroups) validatePluginUnloading(pluginToUnload *loadedPlugin) (errs []serror.SnapError) {
s.Lock()
defer s.Unlock()
for id, group := range s.subscriptionMap {
if err := group.validatePluginUnloading(id, pluginToUnload); err != nil {
errs = append(errs, err)
}
}
return errs
} | [
"func",
"(",
"s",
"*",
"subscriptionGroups",
")",
"validatePluginUnloading",
"(",
"pluginToUnload",
"*",
"loadedPlugin",
")",
"(",
"errs",
"[",
"]",
"serror",
".",
"SnapError",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",... | // validatePluginUnloading checks if process of unloading the plugin is safe for existing running tasks.
// If the plugin is used by running task and there is no replacements, return an error with appropriate message
// containing ids of tasks which use the plugin, what blocks unloading process until they are stopped | [
"validatePluginUnloading",
"checks",
"if",
"process",
"of",
"unloading",
"the",
"plugin",
"is",
"safe",
"for",
"existing",
"running",
"tasks",
".",
"If",
"the",
"plugin",
"is",
"used",
"by",
"running",
"task",
"and",
"there",
"is",
"no",
"replacements",
"retur... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/subscription_group.go#L260-L269 |
15,447 | intelsdi-x/snap | control/subscription_group.go | pluginIsSubscribed | func (s *subscriptionGroup) pluginIsSubscribed(plugin *loadedPlugin) bool {
// range over subscribed plugins to find if the plugin is there
for _, sp := range s.plugins {
if sp.TypeName() == plugin.TypeName() && sp.Name() == plugin.Name() && sp.Version() == plugin.Version() {
return true
}
}
return false
} | go | func (s *subscriptionGroup) pluginIsSubscribed(plugin *loadedPlugin) bool {
// range over subscribed plugins to find if the plugin is there
for _, sp := range s.plugins {
if sp.TypeName() == plugin.TypeName() && sp.Name() == plugin.Name() && sp.Version() == plugin.Version() {
return true
}
}
return false
} | [
"func",
"(",
"s",
"*",
"subscriptionGroup",
")",
"pluginIsSubscribed",
"(",
"plugin",
"*",
"loadedPlugin",
")",
"bool",
"{",
"// range over subscribed plugins to find if the plugin is there",
"for",
"_",
",",
"sp",
":=",
"range",
"s",
".",
"plugins",
"{",
"if",
"s... | // pluginIsSubscribed returns true if a provided plugin has been found among subscribed plugins
// in the following subscription group | [
"pluginIsSubscribed",
"returns",
"true",
"if",
"a",
"provided",
"plugin",
"has",
"been",
"found",
"among",
"subscribed",
"plugins",
"in",
"the",
"following",
"subscription",
"group"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/subscription_group.go#L365-L373 |
15,448 | intelsdi-x/snap | control/subscription_group.go | validatePluginUnloading | func (s *subscriptionGroup) validatePluginUnloading(id string, plgToUnload *loadedPlugin) (serr serror.SnapError) {
impacted := false
if !s.pluginIsSubscribed(plgToUnload) {
// the plugin is not subscribed, so the task is not impacted by its unloading
return nil
}
controlLogger.WithFields(log.Fields{
"_block"... | go | func (s *subscriptionGroup) validatePluginUnloading(id string, plgToUnload *loadedPlugin) (serr serror.SnapError) {
impacted := false
if !s.pluginIsSubscribed(plgToUnload) {
// the plugin is not subscribed, so the task is not impacted by its unloading
return nil
}
controlLogger.WithFields(log.Fields{
"_block"... | [
"func",
"(",
"s",
"*",
"subscriptionGroup",
")",
"validatePluginUnloading",
"(",
"id",
"string",
",",
"plgToUnload",
"*",
"loadedPlugin",
")",
"(",
"serr",
"serror",
".",
"SnapError",
")",
"{",
"impacted",
":=",
"false",
"\n",
"if",
"!",
"s",
".",
"pluginI... | // validatePluginUnloading verifies if a given plugin might be unloaded without causing running task failures | [
"validatePluginUnloading",
"verifies",
"if",
"a",
"given",
"plugin",
"might",
"be",
"unloaded",
"without",
"causing",
"running",
"task",
"failures"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/subscription_group.go#L376-L424 |
15,449 | intelsdi-x/snap | control/subscription_group.go | comparePlugins | func comparePlugins(newPlugins,
oldPlugins []core.SubscribedPlugin) (adds,
removes []core.SubscribedPlugin) {
newMap := make(map[string]int)
oldMap := make(map[string]int)
for _, n := range newPlugins {
newMap[key(n)]++
}
for _, o := range oldPlugins {
oldMap[key(o)]++
}
for _, n := range newPlugins {
... | go | func comparePlugins(newPlugins,
oldPlugins []core.SubscribedPlugin) (adds,
removes []core.SubscribedPlugin) {
newMap := make(map[string]int)
oldMap := make(map[string]int)
for _, n := range newPlugins {
newMap[key(n)]++
}
for _, o := range oldPlugins {
oldMap[key(o)]++
}
for _, n := range newPlugins {
... | [
"func",
"comparePlugins",
"(",
"newPlugins",
",",
"oldPlugins",
"[",
"]",
"core",
".",
"SubscribedPlugin",
")",
"(",
"adds",
",",
"removes",
"[",
"]",
"core",
".",
"SubscribedPlugin",
")",
"{",
"newMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int... | // comparePlugins compares the new state of plugins with the previous state.
// It returns an array of plugins that need to be subscribed and an array of
// plugins that need to be unsubscribed. | [
"comparePlugins",
"compares",
"the",
"new",
"state",
"of",
"plugins",
"with",
"the",
"previous",
"state",
".",
"It",
"returns",
"an",
"array",
"of",
"plugins",
"that",
"need",
"to",
"be",
"subscribed",
"and",
"an",
"array",
"of",
"plugins",
"that",
"need",
... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/subscription_group.go#L643-L673 |
15,450 | intelsdi-x/snap | mgmt/rest/client/plugin.go | LoadPlugin | func (c *Client) LoadPlugin(p []string) *LoadPluginResult {
r := new(LoadPluginResult)
resp, err := c.pluginUploadRequest(p)
if err != nil {
r.Err = serror.New(err)
return r
}
switch resp.Meta.Type {
case rbody.PluginsLoadedType:
pl := resp.Body.(*rbody.PluginsLoaded)
r.LoadedPlugins = convertLoadedPlugi... | go | func (c *Client) LoadPlugin(p []string) *LoadPluginResult {
r := new(LoadPluginResult)
resp, err := c.pluginUploadRequest(p)
if err != nil {
r.Err = serror.New(err)
return r
}
switch resp.Meta.Type {
case rbody.PluginsLoadedType:
pl := resp.Body.(*rbody.PluginsLoaded)
r.LoadedPlugins = convertLoadedPlugi... | [
"func",
"(",
"c",
"*",
"Client",
")",
"LoadPlugin",
"(",
"p",
"[",
"]",
"string",
")",
"*",
"LoadPluginResult",
"{",
"r",
":=",
"new",
"(",
"LoadPluginResult",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"pluginUploadRequest",
"(",
"p",
")",
"\n",... | // LoadPlugin loads plugins for the given plugin names.
// A slide of loaded plugins returns if succeeded. Otherwise, an error is returned. | [
"LoadPlugin",
"loads",
"plugins",
"for",
"the",
"given",
"plugin",
"names",
".",
"A",
"slide",
"of",
"loaded",
"plugins",
"returns",
"if",
"succeeded",
".",
"Otherwise",
"an",
"error",
"is",
"returned",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/plugin.go#L35-L58 |
15,451 | intelsdi-x/snap | mgmt/rest/client/plugin.go | UnloadPlugin | func (c *Client) UnloadPlugin(pluginType, name string, version int) *UnloadPluginResult {
r := &UnloadPluginResult{}
resp, err := c.do("DELETE", fmt.Sprintf("/plugins/%s/%s/%d", pluginType, url.QueryEscape(name), version), ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
case r... | go | func (c *Client) UnloadPlugin(pluginType, name string, version int) *UnloadPluginResult {
r := &UnloadPluginResult{}
resp, err := c.do("DELETE", fmt.Sprintf("/plugins/%s/%s/%d", pluginType, url.QueryEscape(name), version), ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
case r... | [
"func",
"(",
"c",
"*",
"Client",
")",
"UnloadPlugin",
"(",
"pluginType",
",",
"name",
"string",
",",
"version",
"int",
")",
"*",
"UnloadPluginResult",
"{",
"r",
":=",
"&",
"UnloadPluginResult",
"{",
"}",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"do",
... | // UnloadPlugin unloads a plugin given plugin type, name, and version through an HTTP DELETE request.
// The unloaded plugin returns if succeeded. Otherwise, an error is returned. | [
"UnloadPlugin",
"unloads",
"a",
"plugin",
"given",
"plugin",
"type",
"name",
"and",
"version",
"through",
"an",
"HTTP",
"DELETE",
"request",
".",
"The",
"unloaded",
"plugin",
"returns",
"if",
"succeeded",
".",
"Otherwise",
"an",
"error",
"is",
"returned",
"."
... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/plugin.go#L62-L81 |
15,452 | intelsdi-x/snap | mgmt/rest/client/plugin.go | GetPlugins | func (c *Client) GetPlugins(details bool) *GetPluginsResult {
r := &GetPluginsResult{}
var path string
if details {
path = "/plugins?details"
} else {
path = "/plugins"
}
resp, err := c.do("GET", path, ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
// TODO change th... | go | func (c *Client) GetPlugins(details bool) *GetPluginsResult {
r := &GetPluginsResult{}
var path string
if details {
path = "/plugins?details"
} else {
path = "/plugins"
}
resp, err := c.do("GET", path, ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
// TODO change th... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPlugins",
"(",
"details",
"bool",
")",
"*",
"GetPluginsResult",
"{",
"r",
":=",
"&",
"GetPluginsResult",
"{",
"}",
"\n\n",
"var",
"path",
"string",
"\n",
"if",
"details",
"{",
"path",
"=",
"\"",
"\"",
"\n",
"... | // GetPlugins returns the loaded and available plugins through an HTTP GET request.
// By specifying the details flag to tweak output info. An error returns if it failed. | [
"GetPlugins",
"returns",
"the",
"loaded",
"and",
"available",
"plugins",
"through",
"an",
"HTTP",
"GET",
"request",
".",
"By",
"specifying",
"the",
"details",
"flag",
"to",
"tweak",
"output",
"info",
".",
"An",
"error",
"returns",
"if",
"it",
"failed",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/plugin.go#L129-L159 |
15,453 | intelsdi-x/snap | mgmt/rest/client/plugin.go | GetPlugin | func (c *Client) GetPlugin(typ, name string, ver int) *GetPluginResult {
r := &GetPluginResult{}
path := "/plugins/" + typ + "/" + name + "/" + strconv.Itoa(ver)
resp, err := c.do("GET", path, ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
// TODO change this to concrete c... | go | func (c *Client) GetPlugin(typ, name string, ver int) *GetPluginResult {
r := &GetPluginResult{}
path := "/plugins/" + typ + "/" + name + "/" + strconv.Itoa(ver)
resp, err := c.do("GET", path, ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
// TODO change this to concrete c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPlugin",
"(",
"typ",
",",
"name",
"string",
",",
"ver",
"int",
")",
"*",
"GetPluginResult",
"{",
"r",
":=",
"&",
"GetPluginResult",
"{",
"}",
"\n\n",
"path",
":=",
"\"",
"\"",
"+",
"typ",
"+",
"\"",
"\"",
... | // GetPlugin returns the requested plugin through an HTTP GET request. An error returns if it failed. | [
"GetPlugin",
"returns",
"the",
"requested",
"plugin",
"through",
"an",
"HTTP",
"GET",
"request",
".",
"An",
"error",
"returns",
"if",
"it",
"failed",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/plugin.go#L162-L186 |
15,454 | intelsdi-x/snap | scheduler/watcher.go | Close | func (t *TaskWatcher) Close() error {
for _, x := range t.taskIDs {
t.parent.rm(x, t)
}
return nil
} | go | func (t *TaskWatcher) Close() error {
for _, x := range t.taskIDs {
t.parent.rm(x, t)
}
return nil
} | [
"func",
"(",
"t",
"*",
"TaskWatcher",
")",
"Close",
"(",
")",
"error",
"{",
"for",
"_",
",",
"x",
":=",
"range",
"t",
".",
"taskIDs",
"{",
"t",
".",
"parent",
".",
"rm",
"(",
"x",
",",
"t",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close stops watching a task. Cannot be restarted. | [
"Close",
"stops",
"watching",
"a",
"task",
".",
"Cannot",
"be",
"restarted",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/watcher.go#L44-L49 |
15,455 | intelsdi-x/snap | control/strategy/pool.go | Insert | func (p *pool) Insert(a AvailablePlugin) error {
if a.Type() != plugin.CollectorPluginType && a.Type() != plugin.ProcessorPluginType && a.Type() != plugin.PublisherPluginType && a.Type() != plugin.StreamCollectorPluginType {
return ErrBadType
}
// If an empty pool is created, it does not have
// any available plu... | go | func (p *pool) Insert(a AvailablePlugin) error {
if a.Type() != plugin.CollectorPluginType && a.Type() != plugin.ProcessorPluginType && a.Type() != plugin.PublisherPluginType && a.Type() != plugin.StreamCollectorPluginType {
return ErrBadType
}
// If an empty pool is created, it does not have
// any available plu... | [
"func",
"(",
"p",
"*",
"pool",
")",
"Insert",
"(",
"a",
"AvailablePlugin",
")",
"error",
"{",
"if",
"a",
".",
"Type",
"(",
")",
"!=",
"plugin",
".",
"CollectorPluginType",
"&&",
"a",
".",
"Type",
"(",
")",
"!=",
"plugin",
".",
"ProcessorPluginType",
... | // Insert inserts an AvailablePlugin into the pool | [
"Insert",
"inserts",
"an",
"AvailablePlugin",
"into",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L182-L199 |
15,456 | intelsdi-x/snap | control/strategy/pool.go | applyPluginMeta | func (p *pool) applyPluginMeta(a AvailablePlugin) error {
// Checking if plugin is exclusive
// (only one instance should be running).
if a.Exclusive() {
p.max = 1
}
// Set the cache TTL
cacheTTL := GlobalCacheExpiration
// if the plugin exposes a default TTL that is greater the the global default use it
if ... | go | func (p *pool) applyPluginMeta(a AvailablePlugin) error {
// Checking if plugin is exclusive
// (only one instance should be running).
if a.Exclusive() {
p.max = 1
}
// Set the cache TTL
cacheTTL := GlobalCacheExpiration
// if the plugin exposes a default TTL that is greater the the global default use it
if ... | [
"func",
"(",
"p",
"*",
"pool",
")",
"applyPluginMeta",
"(",
"a",
"AvailablePlugin",
")",
"error",
"{",
"// Checking if plugin is exclusive",
"// (only one instance should be running).",
"if",
"a",
".",
"Exclusive",
"(",
")",
"{",
"p",
".",
"max",
"=",
"1",
"\n",... | // applyPluginMeta is called when the first plugin is added to the pool | [
"applyPluginMeta",
"is",
"called",
"when",
"the",
"first",
"plugin",
"is",
"added",
"to",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L202-L233 |
15,457 | intelsdi-x/snap | control/strategy/pool.go | Subscribe | func (p *pool) Subscribe(taskID string) {
p.Lock()
defer p.Unlock()
if _, exists := p.subs[taskID]; !exists {
// Version is the last item in the key, so we split here
// to retrieve it for the subscription.
p.subs[taskID] = &subscription{
TaskID: taskID,
Version: p.version,
}
}
} | go | func (p *pool) Subscribe(taskID string) {
p.Lock()
defer p.Unlock()
if _, exists := p.subs[taskID]; !exists {
// Version is the last item in the key, so we split here
// to retrieve it for the subscription.
p.subs[taskID] = &subscription{
TaskID: taskID,
Version: p.version,
}
}
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"Subscribe",
"(",
"taskID",
"string",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"_",
",",
"exists",
":=",
"p",
".",
"subs",
"[",
"taskID",
"]",
";",
"!... | // subscribe adds a subscription to the pool.
// Using subscribe is idempotent. | [
"subscribe",
"adds",
"a",
"subscription",
"to",
"the",
"pool",
".",
"Using",
"subscribe",
"is",
"idempotent",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L237-L249 |
15,458 | intelsdi-x/snap | control/strategy/pool.go | Unsubscribe | func (p *pool) Unsubscribe(taskID string) {
p.Lock()
defer p.Unlock()
delete(p.subs, taskID)
} | go | func (p *pool) Unsubscribe(taskID string) {
p.Lock()
defer p.Unlock()
delete(p.subs, taskID)
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"Unsubscribe",
"(",
"taskID",
"string",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"p",
".",
"subs",
",",
"taskID",
")",
"\n",
"}"
] | // unsubscribe removes a subscription from the pool.
// Using unsubscribe is idempotent. | [
"unsubscribe",
"removes",
"a",
"subscription",
"from",
"the",
"pool",
".",
"Using",
"unsubscribe",
"is",
"idempotent",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L253-L257 |
15,459 | intelsdi-x/snap | control/strategy/pool.go | Eligible | func (p *pool) Eligible() bool {
p.RLock()
defer p.RUnlock()
// optimization: don't even bother with concurrency
// count if we have already reached pool max
if len(p.plugins) >= p.max {
return false
}
// Check if pool is eligible and number of plugins is less than maximum allowed
if len(p.subs) > p.concurr... | go | func (p *pool) Eligible() bool {
p.RLock()
defer p.RUnlock()
// optimization: don't even bother with concurrency
// count if we have already reached pool max
if len(p.plugins) >= p.max {
return false
}
// Check if pool is eligible and number of plugins is less than maximum allowed
if len(p.subs) > p.concurr... | [
"func",
"(",
"p",
"*",
"pool",
")",
"Eligible",
"(",
")",
"bool",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n\n",
"// optimization: don't even bother with concurrency",
"// count if we have already reached pool max",
"if",
... | // Eligible returns a bool indicating whether the pool is eligible to grow | [
"Eligible",
"returns",
"a",
"bool",
"indicating",
"whether",
"the",
"pool",
"is",
"eligible",
"to",
"grow"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L260-L276 |
15,460 | intelsdi-x/snap | control/strategy/pool.go | Kill | func (p *pool) Kill(id uint32, reason string) {
p.Lock()
defer p.Unlock()
ap, ok := p.plugins[id]
if ok {
ap.Kill(reason)
delete(p.plugins, id)
}
} | go | func (p *pool) Kill(id uint32, reason string) {
p.Lock()
defer p.Unlock()
ap, ok := p.plugins[id]
if ok {
ap.Kill(reason)
delete(p.plugins, id)
}
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"Kill",
"(",
"id",
"uint32",
",",
"reason",
"string",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"ap",
",",
"ok",
":=",
"p",
".",
"plugins",
"[",
"id",
"]",
... | // kill kills and removes the available plugin from its pool.
// Using kill is idempotent. | [
"kill",
"kills",
"and",
"removes",
"the",
"available",
"plugin",
"from",
"its",
"pool",
".",
"Using",
"kill",
"is",
"idempotent",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L280-L289 |
15,461 | intelsdi-x/snap | control/strategy/pool.go | KillAll | func (p *pool) KillAll(reason string) {
for id, rp := range p.plugins {
log.WithFields(log.Fields{
"_block": "KillAll",
"reason": reason,
}).Debug(fmt.Sprintf("handling 'KillAll' for pool '%v', killing plugin '%v:%v'", p.String(), rp.Name(), rp.Version()))
if err := rp.Stop(reason); err != nil {
log.Wit... | go | func (p *pool) KillAll(reason string) {
for id, rp := range p.plugins {
log.WithFields(log.Fields{
"_block": "KillAll",
"reason": reason,
}).Debug(fmt.Sprintf("handling 'KillAll' for pool '%v', killing plugin '%v:%v'", p.String(), rp.Name(), rp.Version()))
if err := rp.Stop(reason); err != nil {
log.Wit... | [
"func",
"(",
"p",
"*",
"pool",
")",
"KillAll",
"(",
"reason",
"string",
")",
"{",
"for",
"id",
",",
"rp",
":=",
"range",
"p",
".",
"plugins",
"{",
"log",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",... | // Kill all instances of a plugin | [
"Kill",
"all",
"instances",
"of",
"a",
"plugin"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L292-L306 |
15,462 | intelsdi-x/snap | control/strategy/pool.go | SelectAndKill | func (p *pool) SelectAndKill(id, reason string) {
rp, err := p.Remove(p.plugins.Values(), id)
if err != nil {
log.WithFields(log.Fields{
"_block": "SelectAndKill",
"taskID": id,
"reason": reason,
}).Error(err)
return
}
if err := rp.Stop(reason); err != nil {
log.WithFields(log.Fields{
"_block": ... | go | func (p *pool) SelectAndKill(id, reason string) {
rp, err := p.Remove(p.plugins.Values(), id)
if err != nil {
log.WithFields(log.Fields{
"_block": "SelectAndKill",
"taskID": id,
"reason": reason,
}).Error(err)
return
}
if err := rp.Stop(reason); err != nil {
log.WithFields(log.Fields{
"_block": ... | [
"func",
"(",
"p",
"*",
"pool",
")",
"SelectAndKill",
"(",
"id",
",",
"reason",
"string",
")",
"{",
"rp",
",",
"err",
":=",
"p",
".",
"Remove",
"(",
"p",
".",
"plugins",
".",
"Values",
"(",
")",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // SelectAndKill selects, kills and removes the available plugin from the pool | [
"SelectAndKill",
"selects",
"kills",
"and",
"removes",
"the",
"available",
"plugin",
"from",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L309-L334 |
15,463 | intelsdi-x/snap | control/strategy/pool.go | remove | func (p *pool) remove(id uint32) {
p.Lock()
defer p.Unlock()
delete(p.plugins, id)
} | go | func (p *pool) remove(id uint32) {
p.Lock()
defer p.Unlock()
delete(p.plugins, id)
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"remove",
"(",
"id",
"uint32",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"p",
".",
"plugins",
",",
"id",
")",
"\n",
"}"
] | // remove removes an available plugin from the the pool.
// using remove is idempotent. | [
"remove",
"removes",
"an",
"available",
"plugin",
"from",
"the",
"the",
"pool",
".",
"using",
"remove",
"is",
"idempotent",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L338-L342 |
15,464 | intelsdi-x/snap | control/strategy/pool.go | Count | func (p *pool) Count() int {
p.RLock()
defer p.RUnlock()
return len(p.plugins)
} | go | func (p *pool) Count() int {
p.RLock()
defer p.RUnlock()
return len(p.plugins)
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"Count",
"(",
")",
"int",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"p",
".",
"plugins",
")",
"\n",
"}"
] | // Count returns the number of plugins in the pool | [
"Count",
"returns",
"the",
"number",
"of",
"plugins",
"in",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L345-L349 |
15,465 | intelsdi-x/snap | control/strategy/pool.go | SubscriptionCount | func (p *pool) SubscriptionCount() int {
p.RLock()
defer p.RUnlock()
return len(p.subs)
} | go | func (p *pool) SubscriptionCount() int {
p.RLock()
defer p.RUnlock()
return len(p.subs)
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"SubscriptionCount",
"(",
")",
"int",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"p",
".",
"subs",
")",
"\n",
"}"
] | // SubscriptionCount returns the number of subscriptions in the pool | [
"SubscriptionCount",
"returns",
"the",
"number",
"of",
"subscriptions",
"in",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L359-L363 |
15,466 | intelsdi-x/snap | control/strategy/pool.go | SelectAP | func (p *pool) SelectAP(taskID string, config map[string]ctypes.ConfigValue) (AvailablePlugin, serror.SnapError) {
aps := p.plugins.Values()
var id string
switch p.Strategy().String() {
case "least-recently-used":
id = ""
case "sticky":
id = taskID
case "config-based":
id = idFromCfg(config)
default:
re... | go | func (p *pool) SelectAP(taskID string, config map[string]ctypes.ConfigValue) (AvailablePlugin, serror.SnapError) {
aps := p.plugins.Values()
var id string
switch p.Strategy().String() {
case "least-recently-used":
id = ""
case "sticky":
id = taskID
case "config-based":
id = idFromCfg(config)
default:
re... | [
"func",
"(",
"p",
"*",
"pool",
")",
"SelectAP",
"(",
"taskID",
"string",
",",
"config",
"map",
"[",
"string",
"]",
"ctypes",
".",
"ConfigValue",
")",
"(",
"AvailablePlugin",
",",
"serror",
".",
"SnapError",
")",
"{",
"aps",
":=",
"p",
".",
"plugins",
... | // SelectAP selects an available plugin from the pool
// the method is not thread safe, it should be protected outside of the body | [
"SelectAP",
"selects",
"an",
"available",
"plugin",
"from",
"the",
"pool",
"the",
"method",
"is",
"not",
"thread",
"safe",
"it",
"should",
"be",
"protected",
"outside",
"of",
"the",
"body"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L367-L387 |
15,467 | intelsdi-x/snap | control/strategy/pool.go | generatePID | func (p *pool) generatePID() uint32 {
atomic.AddUint32(&p.pidCounter, 1)
return p.pidCounter
} | go | func (p *pool) generatePID() uint32 {
atomic.AddUint32(&p.pidCounter, 1)
return p.pidCounter
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"generatePID",
"(",
")",
"uint32",
"{",
"atomic",
".",
"AddUint32",
"(",
"&",
"p",
".",
"pidCounter",
",",
"1",
")",
"\n",
"return",
"p",
".",
"pidCounter",
"\n",
"}"
] | // generatePID returns the next available pid for the pool | [
"generatePID",
"returns",
"the",
"next",
"available",
"pid",
"for",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L401-L404 |
15,468 | intelsdi-x/snap | control/strategy/pool.go | CacheTTL | func (p *pool) CacheTTL(taskID string) (time.Duration, error) {
if len(p.plugins) == 0 {
return 0, ErrPoolEmpty
}
return p.RoutingAndCaching.CacheTTL(taskID)
} | go | func (p *pool) CacheTTL(taskID string) (time.Duration, error) {
if len(p.plugins) == 0 {
return 0, ErrPoolEmpty
}
return p.RoutingAndCaching.CacheTTL(taskID)
} | [
"func",
"(",
"p",
"*",
"pool",
")",
"CacheTTL",
"(",
"taskID",
"string",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"if",
"len",
"(",
"p",
".",
"plugins",
")",
"==",
"0",
"{",
"return",
"0",
",",
"ErrPoolEmpty",
"\n",
"}",
"\n",
... | // CacheTTL returns the cacheTTL for the pool | [
"CacheTTL",
"returns",
"the",
"cacheTTL",
"for",
"the",
"pool"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/strategy/pool.go#L407-L412 |
15,469 | intelsdi-x/snap | pkg/psigning/psigning.go | ValidateSignature | func (s *SigningManager) ValidateSignature(keyringFiles []string, signedFile string, signature []byte) error {
var signedby string
var e error
var checked *openpgp.Entity
signed, err := os.Open(signedFile)
if err != nil {
return fmt.Errorf("%v: %v\n%v", ErrSignedFileNotFound, signedFile, err)
}
defer signed.C... | go | func (s *SigningManager) ValidateSignature(keyringFiles []string, signedFile string, signature []byte) error {
var signedby string
var e error
var checked *openpgp.Entity
signed, err := os.Open(signedFile)
if err != nil {
return fmt.Errorf("%v: %v\n%v", ErrSignedFileNotFound, signedFile, err)
}
defer signed.C... | [
"func",
"(",
"s",
"*",
"SigningManager",
")",
"ValidateSignature",
"(",
"keyringFiles",
"[",
"]",
"string",
",",
"signedFile",
"string",
",",
"signature",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"signedby",
"string",
"\n",
"var",
"e",
"error",
"\n",
... | //ValidateSignature is exported for plugin authoring | [
"ValidateSignature",
"is",
"exported",
"for",
"plugin",
"authoring"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/psigning/psigning.go#L49-L90 |
15,470 | intelsdi-x/snap | core/ctypes/ctypes.go | SupportedTypes | func SupportedTypes() []string {
// This is kind of a hack but keeps the definition of types here in
// ctypes.go. If you create a new ConfigValue type be sure and add here
// to return the Type() response. This will cause any depedant components
// to acknowledge and use that type.
t := []string{
// String
Co... | go | func SupportedTypes() []string {
// This is kind of a hack but keeps the definition of types here in
// ctypes.go. If you create a new ConfigValue type be sure and add here
// to return the Type() response. This will cause any depedant components
// to acknowledge and use that type.
t := []string{
// String
Co... | [
"func",
"SupportedTypes",
"(",
")",
"[",
"]",
"string",
"{",
"// This is kind of a hack but keeps the definition of types here in",
"// ctypes.go. If you create a new ConfigValue type be sure and add here",
"// to return the Type() response. This will cause any depedant components",
"// to ack... | // Returns a slice of string keywords for the types supported by ConfigValue. | [
"Returns",
"a",
"slice",
"of",
"string",
"keywords",
"for",
"the",
"types",
"supported",
"by",
"ConfigValue",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/ctypes/ctypes.go#L79-L95 |
15,471 | intelsdi-x/snap | control/plugin/execution.go | NewExecutablePlugin | func NewExecutablePlugin(a Arg, commands ...string) (*ExecutablePlugin, error) {
jsonArgs, err := json.Marshal(a)
if err != nil {
return nil, err
}
cmd := &exec.Cmd{
Path: commands[0],
Args: append(commands, string(jsonArgs)),
}
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
stderr, ... | go | func NewExecutablePlugin(a Arg, commands ...string) (*ExecutablePlugin, error) {
jsonArgs, err := json.Marshal(a)
if err != nil {
return nil, err
}
cmd := &exec.Cmd{
Path: commands[0],
Args: append(commands, string(jsonArgs)),
}
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
stderr, ... | [
"func",
"NewExecutablePlugin",
"(",
"a",
"Arg",
",",
"commands",
"...",
"string",
")",
"(",
"*",
"ExecutablePlugin",
",",
"error",
")",
"{",
"jsonArgs",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // NewExecutablePlugin returns a new ExecutablePlugin. | [
"NewExecutablePlugin",
"returns",
"a",
"new",
"ExecutablePlugin",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/execution.go#L80-L102 |
15,472 | intelsdi-x/snap | control/plugin/execution.go | Run | func (e *ExecutablePlugin) Run(timeout time.Duration) (Response, error) {
var (
respReceived bool
resp Response
err error
respBytes []byte
)
doneChan := make(chan struct{})
stdOutScanner := bufio.NewScanner(e.stdout)
// Start the command and begin reading its output.
if err = e.cmd.S... | go | func (e *ExecutablePlugin) Run(timeout time.Duration) (Response, error) {
var (
respReceived bool
resp Response
err error
respBytes []byte
)
doneChan := make(chan struct{})
stdOutScanner := bufio.NewScanner(e.stdout)
// Start the command and begin reading its output.
if err = e.cmd.S... | [
"func",
"(",
"e",
"*",
"ExecutablePlugin",
")",
"Run",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"Response",
",",
"error",
")",
"{",
"var",
"(",
"respReceived",
"bool",
"\n",
"resp",
"Response",
"\n",
"err",
"error",
"\n",
"respBytes",
"[",
"]... | // Run executes the plugin and waits for a response, or times out. | [
"Run",
"executes",
"the",
"plugin",
"and",
"waits",
"for",
"a",
"response",
"or",
"times",
"out",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/execution.go#L105-L190 |
15,473 | intelsdi-x/snap | core/metric.go | Strings | func (n Namespace) Strings() []string {
var ns []string
for _, namespaceElement := range n {
ns = append(ns, namespaceElement.Value)
}
return ns
} | go | func (n Namespace) Strings() []string {
var ns []string
for _, namespaceElement := range n {
ns = append(ns, namespaceElement.Value)
}
return ns
} | [
"func",
"(",
"n",
"Namespace",
")",
"Strings",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"ns",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"namespaceElement",
":=",
"range",
"n",
"{",
"ns",
"=",
"append",
"(",
"ns",
",",
"namespaceElement",
".",
"Va... | // Strings returns an array of strings that represent the elements of the
// namespace. | [
"Strings",
"returns",
"an",
"array",
"of",
"strings",
"that",
"represent",
"the",
"elements",
"of",
"the",
"namespace",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L62-L68 |
15,474 | intelsdi-x/snap | core/metric.go | getSeparator | func (n Namespace) getSeparator() string {
smap := initSeparatorMap()
for _, e := range n {
// look at each char
for _, r := range e.Value {
ch := fmt.Sprintf("%c", r)
if v, ok := smap[ch]; ok && !v {
smap[ch] = true
}
}
}
// Go through our separator list
for _, s := range nsPriorityList {
i... | go | func (n Namespace) getSeparator() string {
smap := initSeparatorMap()
for _, e := range n {
// look at each char
for _, r := range e.Value {
ch := fmt.Sprintf("%c", r)
if v, ok := smap[ch]; ok && !v {
smap[ch] = true
}
}
}
// Go through our separator list
for _, s := range nsPriorityList {
i... | [
"func",
"(",
"n",
"Namespace",
")",
"getSeparator",
"(",
")",
"string",
"{",
"smap",
":=",
"initSeparatorMap",
"(",
")",
"\n\n",
"for",
"_",
",",
"e",
":=",
"range",
"n",
"{",
"// look at each char",
"for",
"_",
",",
"r",
":=",
"range",
"e",
".",
"Va... | // getSeparator returns the highest suitable separator from the nsPriorityList.
// Otherwise the core separator is returned. | [
"getSeparator",
"returns",
"the",
"highest",
"suitable",
"separator",
"from",
"the",
"nsPriorityList",
".",
"Otherwise",
"the",
"core",
"separator",
"is",
"returned",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L72-L92 |
15,475 | intelsdi-x/snap | core/metric.go | initSeparatorMap | func initSeparatorMap() map[string]bool {
m := map[string]bool{}
for _, s := range nsPriorityList {
m[s] = false
}
return m
} | go | func initSeparatorMap() map[string]bool {
m := map[string]bool{}
for _, s := range nsPriorityList {
m[s] = false
}
return m
} | [
"func",
"initSeparatorMap",
"(",
")",
"map",
"[",
"string",
"]",
"bool",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"}",
"\n\n",
"for",
"_",
",",
"s",
":=",
"range",
"nsPriorityList",
"{",
"m",
"[",
"s",
"]",
"=",
"false",
"\n",
"}",... | // initSeparatorMap populates the local map of nsPriorityList. | [
"initSeparatorMap",
"populates",
"the",
"local",
"map",
"of",
"nsPriorityList",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L95-L102 |
15,476 | intelsdi-x/snap | core/metric.go | NewNamespace | func NewNamespace(ns ...string) Namespace {
n := make([]NamespaceElement, len(ns))
for i, ns := range ns {
n[i] = NamespaceElement{Value: ns}
}
return n
} | go | func NewNamespace(ns ...string) Namespace {
n := make([]NamespaceElement, len(ns))
for i, ns := range ns {
n[i] = NamespaceElement{Value: ns}
}
return n
} | [
"func",
"NewNamespace",
"(",
"ns",
"...",
"string",
")",
"Namespace",
"{",
"n",
":=",
"make",
"(",
"[",
"]",
"NamespaceElement",
",",
"len",
"(",
"ns",
")",
")",
"\n",
"for",
"i",
",",
"ns",
":=",
"range",
"ns",
"{",
"n",
"[",
"i",
"]",
"=",
"N... | // NewNamespace takes an array of strings and returns a Namespace. A Namespace
// is an array of NamespaceElements. The provided array of strings is used to
// set the corresponding Value fields in the array of NamespaceElements. | [
"NewNamespace",
"takes",
"an",
"array",
"of",
"strings",
"and",
"returns",
"a",
"Namespace",
".",
"A",
"Namespace",
"is",
"an",
"array",
"of",
"NamespaceElements",
".",
"The",
"provided",
"array",
"of",
"strings",
"is",
"used",
"to",
"set",
"the",
"correspon... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L124-L130 |
15,477 | intelsdi-x/snap | core/metric.go | AddDynamicElement | func (n Namespace) AddDynamicElement(name, description string) Namespace {
nse := NamespaceElement{Name: name, Description: description, Value: "*"}
return append(n, nse)
} | go | func (n Namespace) AddDynamicElement(name, description string) Namespace {
nse := NamespaceElement{Name: name, Description: description, Value: "*"}
return append(n, nse)
} | [
"func",
"(",
"n",
"Namespace",
")",
"AddDynamicElement",
"(",
"name",
",",
"description",
"string",
")",
"Namespace",
"{",
"nse",
":=",
"NamespaceElement",
"{",
"Name",
":",
"name",
",",
"Description",
":",
"description",
",",
"Value",
":",
"\"",
"\"",
"}"... | // AddDynamicElement adds a dynamic element to the given Namespace. A dynamic
// NamespaceElement is defined by having a nonempty Name field. | [
"AddDynamicElement",
"adds",
"a",
"dynamic",
"element",
"to",
"the",
"given",
"Namespace",
".",
"A",
"dynamic",
"NamespaceElement",
"is",
"defined",
"by",
"having",
"a",
"nonempty",
"Name",
"field",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L134-L137 |
15,478 | intelsdi-x/snap | core/metric.go | AddStaticElement | func (n Namespace) AddStaticElement(value string) Namespace {
nse := NamespaceElement{Value: value}
return append(n, nse)
} | go | func (n Namespace) AddStaticElement(value string) Namespace {
nse := NamespaceElement{Value: value}
return append(n, nse)
} | [
"func",
"(",
"n",
"Namespace",
")",
"AddStaticElement",
"(",
"value",
"string",
")",
"Namespace",
"{",
"nse",
":=",
"NamespaceElement",
"{",
"Value",
":",
"value",
"}",
"\n",
"return",
"append",
"(",
"n",
",",
"nse",
")",
"\n",
"}"
] | // AddStaticElement adds a static element to the given Namespace. A static
// NamespaceElement is defined by having an empty Name field. | [
"AddStaticElement",
"adds",
"a",
"static",
"element",
"to",
"the",
"given",
"Namespace",
".",
"A",
"static",
"NamespaceElement",
"is",
"defined",
"by",
"having",
"an",
"empty",
"Name",
"field",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L141-L144 |
15,479 | intelsdi-x/snap | core/metric.go | AddStaticElements | func (n Namespace) AddStaticElements(values ...string) Namespace {
for _, value := range values {
n = append(n, NamespaceElement{Value: value})
}
return n
} | go | func (n Namespace) AddStaticElements(values ...string) Namespace {
for _, value := range values {
n = append(n, NamespaceElement{Value: value})
}
return n
} | [
"func",
"(",
"n",
"Namespace",
")",
"AddStaticElements",
"(",
"values",
"...",
"string",
")",
"Namespace",
"{",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"n",
"=",
"append",
"(",
"n",
",",
"NamespaceElement",
"{",
"Value",
":",
"value",
"... | // AddStaticElements adds a static elements to the given Namespace. A static
// NamespaceElement is defined by having an empty Name field. | [
"AddStaticElements",
"adds",
"a",
"static",
"elements",
"to",
"the",
"given",
"Namespace",
".",
"A",
"static",
"NamespaceElement",
"is",
"defined",
"by",
"having",
"an",
"empty",
"Name",
"field",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/core/metric.go#L148-L153 |
15,480 | intelsdi-x/snap | scheduler/worker.go | start | func (w *worker) start() {
for {
select {
case q := <-w.rcv:
// assert that deadline is not exceeded
if chrono.Chrono.Now().Before(q.Job().Deadline()) {
q.Job().Run()
} else {
// the deadline was exceeded and this job will not run
q.Job().AddErrors(errors.New("Worker refused to run overdue job... | go | func (w *worker) start() {
for {
select {
case q := <-w.rcv:
// assert that deadline is not exceeded
if chrono.Chrono.Now().Before(q.Job().Deadline()) {
q.Job().Run()
} else {
// the deadline was exceeded and this job will not run
q.Job().AddErrors(errors.New("Worker refused to run overdue job... | [
"func",
"(",
"w",
"*",
"worker",
")",
"start",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"q",
":=",
"<-",
"w",
".",
"rcv",
":",
"// assert that deadline is not exceeded",
"if",
"chrono",
".",
"Chrono",
".",
"Now",
"(",
")",
".",
"Before",
"("... | // begin a worker | [
"begin",
"a",
"worker"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/scheduler/worker.go#L46-L70 |
15,481 | intelsdi-x/snap | mgmt/rest/client/metric.go | FetchMetrics | func (c *Client) FetchMetrics(ns string, ver int) *GetMetricsResult {
r := &GetMetricsResult{}
q := fmt.Sprintf("/metrics?ns=%s&ver=%d", ns, ver)
resp, err := c.do("GET", q, ContentTypeJSON)
if err != nil {
return &GetMetricsResult{Err: err}
}
switch resp.Meta.Type {
case rbody.MetricsReturnedType:
mc := re... | go | func (c *Client) FetchMetrics(ns string, ver int) *GetMetricsResult {
r := &GetMetricsResult{}
q := fmt.Sprintf("/metrics?ns=%s&ver=%d", ns, ver)
resp, err := c.do("GET", q, ContentTypeJSON)
if err != nil {
return &GetMetricsResult{Err: err}
}
switch resp.Meta.Type {
case rbody.MetricsReturnedType:
mc := re... | [
"func",
"(",
"c",
"*",
"Client",
")",
"FetchMetrics",
"(",
"ns",
"string",
",",
"ver",
"int",
")",
"*",
"GetMetricsResult",
"{",
"r",
":=",
"&",
"GetMetricsResult",
"{",
"}",
"\n",
"q",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ns",
",",
... | // FetchMetrics retrieves the metric catalog given metric namespace and version through an HTTP GET request.
// It returns the corresponding metric catalog if succeeded. Otherwise, an error is returned. | [
"FetchMetrics",
"retrieves",
"the",
"metric",
"catalog",
"given",
"metric",
"namespace",
"and",
"version",
"through",
"an",
"HTTP",
"GET",
"request",
".",
"It",
"returns",
"the",
"corresponding",
"metric",
"catalog",
"if",
"succeeded",
".",
"Otherwise",
"an",
"e... | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/metric.go#L57-L78 |
15,482 | intelsdi-x/snap | mgmt/rest/client/metric.go | GetMetricVersions | func (c *Client) GetMetricVersions(ns string) *GetMetricsResult {
r := &GetMetricsResult{}
q := fmt.Sprintf("/metrics?ns=%s", ns)
resp, err := c.do("GET", q, ContentTypeJSON)
if err != nil {
return &GetMetricsResult{Err: err}
}
switch resp.Meta.Type {
case rbody.MetricsReturnedType:
mc := resp.Body.(*rbody.... | go | func (c *Client) GetMetricVersions(ns string) *GetMetricsResult {
r := &GetMetricsResult{}
q := fmt.Sprintf("/metrics?ns=%s", ns)
resp, err := c.do("GET", q, ContentTypeJSON)
if err != nil {
return &GetMetricsResult{Err: err}
}
switch resp.Meta.Type {
case rbody.MetricsReturnedType:
mc := resp.Body.(*rbody.... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMetricVersions",
"(",
"ns",
"string",
")",
"*",
"GetMetricsResult",
"{",
"r",
":=",
"&",
"GetMetricsResult",
"{",
"}",
"\n",
"q",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ns",
")",
"\n",
"resp",
... | // GetMetricVersions retrieves all versions of a metric at a given namespace. | [
"GetMetricVersions",
"retrieves",
"all",
"versions",
"of",
"a",
"metric",
"at",
"a",
"given",
"namespace",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/metric.go#L81-L99 |
15,483 | intelsdi-x/snap | pkg/stringutils/string.go | GetFirstChar | func GetFirstChar(s string) string {
firstChar := ""
for _, r := range s {
firstChar = fmt.Sprintf("%c", r)
break
}
return firstChar
} | go | func GetFirstChar(s string) string {
firstChar := ""
for _, r := range s {
firstChar = fmt.Sprintf("%c", r)
break
}
return firstChar
} | [
"func",
"GetFirstChar",
"(",
"s",
"string",
")",
"string",
"{",
"firstChar",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"s",
"{",
"firstChar",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"break",
"\n",
"}",... | // GetFirstChar returns the first character from the input string. | [
"GetFirstChar",
"returns",
"the",
"first",
"character",
"from",
"the",
"input",
"string",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/stringutils/string.go#L25-L32 |
15,484 | intelsdi-x/snap | pkg/ctree/tree.go | GobEncode | func (c *ConfigTree) GobEncode() ([]byte, error) {
//todo throw an error if not frozen
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if c.root == nil {
c.root = &node{}
// c.root.setKeys([]string{})
}
if err := encoder.Encode(c.root); err != nil {
return nil, err
}
return w.Bytes(), nil
} | go | func (c *ConfigTree) GobEncode() ([]byte, error) {
//todo throw an error if not frozen
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if c.root == nil {
c.root = &node{}
// c.root.setKeys([]string{})
}
if err := encoder.Encode(c.root); err != nil {
return nil, err
}
return w.Bytes(), nil
} | [
"func",
"(",
"c",
"*",
"ConfigTree",
")",
"GobEncode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"//todo throw an error if not frozen",
"w",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"encoder",
":=",
"gob",
".",
"NewEncoder",
... | // GobEncode returns the encoded ConfigTree. Otherwise,
// an error is returned | [
"GobEncode",
"returns",
"the",
"encoded",
"ConfigTree",
".",
"Otherwise",
"an",
"error",
"is",
"returned"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L51-L63 |
15,485 | intelsdi-x/snap | pkg/ctree/tree.go | GobDecode | func (c *ConfigTree) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&c.root); err != nil {
return err
}
return nil
} | go | func (c *ConfigTree) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&c.root); err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"ConfigTree",
")",
"GobDecode",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"buf",
")",
"\n",
"decoder",
":=",
"gob",
".",
"NewDecoder",
"(",
"r",
")",
"\n",
"if",
"err",
":="... | // GobDecode decodes the ConfigTree. | [
"GobDecode",
"decodes",
"the",
"ConfigTree",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L66-L73 |
15,486 | intelsdi-x/snap | pkg/ctree/tree.go | MarshalJSON | func (c *ConfigTree) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Root *node `json:"root"`
}{
Root: c.root,
})
} | go | func (c *ConfigTree) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Root *node `json:"root"`
}{
Root: c.root,
})
} | [
"func",
"(",
"c",
"*",
"ConfigTree",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"&",
"struct",
"{",
"Root",
"*",
"node",
"`json:\"root\"`",
"\n",
"}",
"{",
"Root",
":",
"c",
... | // MarshalJSON marshals ConfigTree | [
"MarshalJSON",
"marshals",
"ConfigTree"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L76-L82 |
15,487 | intelsdi-x/snap | pkg/ctree/tree.go | Add | func (c *ConfigTree) Add(ns []string, inNode Node) {
c.log(fmt.Sprintf("Adding %v at %s\n", inNode, ns))
if len(ns) == 0 {
c.log(fmt.Sprintln("ns is empty - returning with no change to tree"))
return
}
f, remain := ns[0], ns[1:]
c.log(fmt.Sprintf("first ns (%s) remain (%s)", f, remain))
if c.root == nil {
/... | go | func (c *ConfigTree) Add(ns []string, inNode Node) {
c.log(fmt.Sprintf("Adding %v at %s\n", inNode, ns))
if len(ns) == 0 {
c.log(fmt.Sprintln("ns is empty - returning with no change to tree"))
return
}
f, remain := ns[0], ns[1:]
c.log(fmt.Sprintf("first ns (%s) remain (%s)", f, remain))
if c.root == nil {
/... | [
"func",
"(",
"c",
"*",
"ConfigTree",
")",
"Add",
"(",
"ns",
"[",
"]",
"string",
",",
"inNode",
"Node",
")",
"{",
"c",
".",
"log",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"inNode",
",",
"ns",
")",
")",
"\n",
"if",
"len",
"(",
... | // Add adds a new tree node | [
"Add",
"adds",
"a",
"new",
"tree",
"node"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L85-L115 |
15,488 | intelsdi-x/snap | pkg/ctree/tree.go | Get | func (c *ConfigTree) Get(ns []string) Node {
c.log(fmt.Sprintf("Get on ns (%s)\n", ns))
retNodes := new([]Node)
// Return if no root exists (no tree without a root)
if c.root == nil {
c.log(fmt.Sprintln("ctree: no root - returning nil"))
return nil
}
if len(c.root.keys) == 0 {
//This will be the case when ... | go | func (c *ConfigTree) Get(ns []string) Node {
c.log(fmt.Sprintf("Get on ns (%s)\n", ns))
retNodes := new([]Node)
// Return if no root exists (no tree without a root)
if c.root == nil {
c.log(fmt.Sprintln("ctree: no root - returning nil"))
return nil
}
if len(c.root.keys) == 0 {
//This will be the case when ... | [
"func",
"(",
"c",
"*",
"ConfigTree",
")",
"Get",
"(",
"ns",
"[",
"]",
"string",
")",
"Node",
"{",
"c",
".",
"log",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"ns",
")",
")",
"\n",
"retNodes",
":=",
"new",
"(",
"[",
"]",
"Node",
... | // Get returns a tree node given the namespace | [
"Get",
"returns",
"a",
"tree",
"node",
"given",
"the",
"namespace"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L153-L203 |
15,489 | intelsdi-x/snap | pkg/ctree/tree.go | MarshalJSON | func (n *node) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Nodes []*node `json:"nodes"`
Keys []string `json:"keys"`
KeysBytes []byte `json:"keysbytes"`
Node Node `json:"node"`
}{
Nodes: n.nodes,
Keys: n.keys,
KeysBytes: n.keysBytes,
Node: n.Node,
}... | go | func (n *node) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Nodes []*node `json:"nodes"`
Keys []string `json:"keys"`
KeysBytes []byte `json:"keysbytes"`
Node Node `json:"node"`
}{
Nodes: n.nodes,
Keys: n.keys,
KeysBytes: n.keysBytes,
Node: n.Node,
}... | [
"func",
"(",
"n",
"*",
"node",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"&",
"struct",
"{",
"Nodes",
"[",
"]",
"*",
"node",
"`json:\"nodes\"`",
"\n",
"Keys",
"[",
"]",
"st... | // MarshalJSON marshals the ConfigTree. | [
"MarshalJSON",
"marshals",
"the",
"ConfigTree",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L223-L235 |
15,490 | intelsdi-x/snap | pkg/ctree/tree.go | GobEncode | func (n *node) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(n.nodes); err != nil {
return nil, err
}
if err := encoder.Encode(n.keys); err != nil {
return nil, err
}
if err := encoder.Encode(n.keysBytes); err != nil {
return nil, err
}
if err ... | go | func (n *node) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(n.nodes); err != nil {
return nil, err
}
if err := encoder.Encode(n.keys); err != nil {
return nil, err
}
if err := encoder.Encode(n.keysBytes); err != nil {
return nil, err
}
if err ... | [
"func",
"(",
"n",
"*",
"node",
")",
"GobEncode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"encoder",
":=",
"gob",
".",
"NewEncoder",
"(",
"w",
")",
"\n",
"if",
"err",
"... | // GobEncode encodes every member of node struct instance | [
"GobEncode",
"encodes",
"every",
"member",
"of",
"node",
"struct",
"instance"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L238-L254 |
15,491 | intelsdi-x/snap | pkg/ctree/tree.go | GobDecode | func (n *node) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&n.nodes); err != nil {
return err
}
if err := decoder.Decode(&n.keys); err != nil {
return err
}
if err := decoder.Decode(&n.keysBytes); err != nil {
return err
}
return decoder.D... | go | func (n *node) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&n.nodes); err != nil {
return err
}
if err := decoder.Decode(&n.keys); err != nil {
return err
}
if err := decoder.Decode(&n.keysBytes); err != nil {
return err
}
return decoder.D... | [
"func",
"(",
"n",
"*",
"node",
")",
"GobDecode",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"buf",
")",
"\n",
"decoder",
":=",
"gob",
".",
"NewDecoder",
"(",
"r",
")",
"\n",
"if",
"err",
":=",
"d... | // GobDecode decodes every member of node struct instance | [
"GobDecode",
"decodes",
"every",
"member",
"of",
"node",
"struct",
"instance"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/pkg/ctree/tree.go#L257-L270 |
15,492 | intelsdi-x/snap | control/plugin/cpolicy/float.go | MarshalJSON | func (f *FloatRule) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Key string `json:"key"`
Required bool `json:"required"`
Default ctypes.ConfigValue `json:"default,omitempty"`
Minimum ctypes.ConfigValue `json:"minimum,omitempty"`
Maximum ctypes.ConfigValue `j... | go | func (f *FloatRule) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Key string `json:"key"`
Required bool `json:"required"`
Default ctypes.ConfigValue `json:"default,omitempty"`
Minimum ctypes.ConfigValue `json:"minimum,omitempty"`
Maximum ctypes.ConfigValue `j... | [
"func",
"(",
"f",
"*",
"FloatRule",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"&",
"struct",
"{",
"Key",
"string",
"`json:\"key\"`",
"\n",
"Required",
"bool",
"`json:\"required\"`"... | // MarshalJSON marshals a FloatRule into JSON | [
"MarshalJSON",
"marshals",
"a",
"FloatRule",
"into",
"JSON"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/cpolicy/float.go#L48-L64 |
15,493 | intelsdi-x/snap | control/plugin/cpolicy/float.go | GobEncode | func (f *FloatRule) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(f.key); err != nil {
return nil, err
}
if err := encoder.Encode(f.required); err != nil {
return nil, err
}
if f.default_ == nil {
encoder.Encode(false)
} else {
encoder.Encode(... | go | func (f *FloatRule) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(f.key); err != nil {
return nil, err
}
if err := encoder.Encode(f.required); err != nil {
return nil, err
}
if f.default_ == nil {
encoder.Encode(false)
} else {
encoder.Encode(... | [
"func",
"(",
"f",
"*",
"FloatRule",
")",
"GobEncode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"encoder",
":=",
"gob",
".",
"NewEncoder",
"(",
"w",
")",
"\n",
"if",
"err"... | // GobEncode encodes a FloatRule into a GOB | [
"GobEncode",
"encodes",
"a",
"FloatRule",
"into",
"a",
"GOB"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/cpolicy/float.go#L71-L105 |
15,494 | intelsdi-x/snap | control/plugin/cpolicy/float.go | Default | func (f *FloatRule) Default() ctypes.ConfigValue {
if f.default_ != nil {
return ctypes.ConfigValueFloat{Value: *f.default_}
}
return nil
} | go | func (f *FloatRule) Default() ctypes.ConfigValue {
if f.default_ != nil {
return ctypes.ConfigValueFloat{Value: *f.default_}
}
return nil
} | [
"func",
"(",
"f",
"*",
"FloatRule",
")",
"Default",
"(",
")",
"ctypes",
".",
"ConfigValue",
"{",
"if",
"f",
".",
"default_",
"!=",
"nil",
"{",
"return",
"ctypes",
".",
"ConfigValueFloat",
"{",
"Value",
":",
"*",
"f",
".",
"default_",
"}",
"\n",
"}",
... | // Default returns the rule's default value | [
"Default",
"returns",
"the",
"rule",
"s",
"default",
"value"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/control/plugin/cpolicy/float.go#L180-L185 |
15,495 | intelsdi-x/snap | mgmt/rest/client/client.go | parseURL | func parseURL(url string) error {
if !govalidator.IsURL(url) || !strings.HasPrefix(url, "http") {
return fmt.Errorf("URL %s is not in the format of http(s)://<ip>:<port>", url)
}
return nil
} | go | func parseURL(url string) error {
if !govalidator.IsURL(url) || !strings.HasPrefix(url, "http") {
return fmt.Errorf("URL %s is not in the format of http(s)://<ip>:<port>", url)
}
return nil
} | [
"func",
"parseURL",
"(",
"url",
"string",
")",
"error",
"{",
"if",
"!",
"govalidator",
".",
"IsURL",
"(",
"url",
")",
"||",
"!",
"strings",
".",
"HasPrefix",
"(",
"url",
",",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
... | // Checks validity of URL | [
"Checks",
"validity",
"of",
"URL"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/client.go#L85-L90 |
15,496 | intelsdi-x/snap | mgmt/rest/client/client.go | Password | func Password(p string) metaOp {
return func(c *Client) {
c.Password = strings.TrimSpace(p)
}
} | go | func Password(p string) metaOp {
return func(c *Client) {
c.Password = strings.TrimSpace(p)
}
} | [
"func",
"Password",
"(",
"p",
"string",
")",
"metaOp",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"Password",
"=",
"strings",
".",
"TrimSpace",
"(",
"p",
")",
"\n",
"}",
"\n",
"}"
] | //Password is an option than can be provided to the func client.New. | [
"Password",
"is",
"an",
"option",
"than",
"can",
"be",
"provided",
"to",
"the",
"func",
"client",
".",
"New",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/client.go#L95-L99 |
15,497 | intelsdi-x/snap | mgmt/rest/client/client.go | Timeout | func Timeout(t time.Duration) metaOp {
return func(c *Client) {
c.http.Timeout = t
}
} | go | func Timeout(t time.Duration) metaOp {
return func(c *Client) {
c.http.Timeout = t
}
} | [
"func",
"Timeout",
"(",
"t",
"time",
".",
"Duration",
")",
"metaOp",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"http",
".",
"Timeout",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | //Timeout is an option that can be provided to the func client.New in order to set HTTP connection timeout. | [
"Timeout",
"is",
"an",
"option",
"that",
"can",
"be",
"provided",
"to",
"the",
"func",
"client",
".",
"New",
"in",
"order",
"to",
"set",
"HTTP",
"connection",
"timeout",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/client.go#L109-L113 |
15,498 | intelsdi-x/snap | mgmt/rest/client/client.go | New | func New(url, ver string, insecure bool, opts ...metaOp) (*Client, error) {
if err := parseURL(url); err != nil {
return nil, err
}
if ver == "" {
ver = "v1"
}
var t *http.Transport
if insecure {
t = insecureTransport
} else {
t = secureTransport
}
c := &Client{
URL: url,
Version: ver,
http:... | go | func New(url, ver string, insecure bool, opts ...metaOp) (*Client, error) {
if err := parseURL(url); err != nil {
return nil, err
}
if ver == "" {
ver = "v1"
}
var t *http.Transport
if insecure {
t = insecureTransport
} else {
t = secureTransport
}
c := &Client{
URL: url,
Version: ver,
http:... | [
"func",
"New",
"(",
"url",
",",
"ver",
"string",
",",
"insecure",
"bool",
",",
"opts",
"...",
"metaOp",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"err",
":=",
"parseURL",
"(",
"url",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil"... | // New returns a pointer to a snap api client
// if ver is an empty string, v1 is used by default | [
"New",
"returns",
"a",
"pointer",
"to",
"a",
"snap",
"api",
"client",
"if",
"ver",
"is",
"an",
"empty",
"string",
"v1",
"is",
"used",
"by",
"default"
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/client.go#L128-L154 |
15,499 | intelsdi-x/snap | mgmt/rest/client/client.go | TribeRequest | func (c *Client) TribeRequest() (*http.Response, error) {
req, err := http.NewRequest("GET", c.URL, nil)
if err != nil {
return nil, err
}
addAuth(req, "snap", c.Password)
rsp, err := c.http.Do(req)
if err != nil {
return nil, err
}
return rsp, nil
} | go | func (c *Client) TribeRequest() (*http.Response, error) {
req, err := http.NewRequest("GET", c.URL, nil)
if err != nil {
return nil, err
}
addAuth(req, "snap", c.Password)
rsp, err := c.http.Do(req)
if err != nil {
return nil, err
}
return rsp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"TribeRequest",
"(",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"c",
".",
"URL",
",",
"nil",
")",
"\n",
"if",
... | // Passthrough for tribe request to allow use of client auth. | [
"Passthrough",
"for",
"tribe",
"request",
"to",
"allow",
"use",
"of",
"client",
"auth",
"."
] | e3a6c8e39994b3980df0c7b069d5ede810622952 | https://github.com/intelsdi-x/snap/blob/e3a6c8e39994b3980df0c7b069d5ede810622952/mgmt/rest/client/client.go#L421-L432 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.