id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,400 | tideland/golib | collections/tree.go | Deflate | func (t *tree) Deflate(v interface{}) {
t.container.root = &node{
content: justValue{v},
}
} | go | func (t *tree) Deflate(v interface{}) {
t.container.root = &node{
content: justValue{v},
}
} | [
"func",
"(",
"t",
"*",
"tree",
")",
"Deflate",
"(",
"v",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"container",
".",
"root",
"=",
"&",
"node",
"{",
"content",
":",
"justValue",
"{",
"v",
"}",
",",
"}",
"\n",
"}"
] | // Deflate implements the Tree interface. | [
"Deflate",
"implements",
"the",
"Tree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L445-L449 |
150,401 | tideland/golib | collections/tree.go | NewStringTree | func NewStringTree(v string, duplicates bool) StringTree {
return &stringTree{
container: newNodeContainer(justValue{v}, duplicates),
}
} | go | func NewStringTree(v string, duplicates bool) StringTree {
return &stringTree{
container: newNodeContainer(justValue{v}, duplicates),
}
} | [
"func",
"NewStringTree",
"(",
"v",
"string",
",",
"duplicates",
"bool",
")",
"StringTree",
"{",
"return",
"&",
"stringTree",
"{",
"container",
":",
"newNodeContainer",
"(",
"justValue",
"{",
"v",
"}",
",",
"duplicates",
")",
",",
"}",
"\n",
"}"
] | // NewStringTree creates a new string tree with or without
// duplicate values for children. | [
"NewStringTree",
"creates",
"a",
"new",
"string",
"tree",
"with",
"or",
"without",
"duplicate",
"values",
"for",
"children",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L467-L471 |
150,402 | tideland/golib | collections/tree.go | At | func (t *stringTree) At(values ...string) StringChanger {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.at(path...)
return &stringChanger{n, err}
} | go | func (t *stringTree) At(values ...string) StringChanger {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.at(path...)
return &stringChanger{n, err}
} | [
"func",
"(",
"t",
"*",
"stringTree",
")",
"At",
"(",
"values",
"...",
"string",
")",
"StringChanger",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"path",
"=",
"append",
"(",
"path",
",",
... | // At implements the StringTree interface. | [
"At",
"implements",
"the",
"StringTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L474-L481 |
150,403 | tideland/golib | collections/tree.go | DoAll | func (t *stringTree) DoAll(f func(v string) error) error {
return t.container.root.doAll(func(dn *node) error {
return f(dn.content.value().(string))
})
} | go | func (t *stringTree) DoAll(f func(v string) error) error {
return t.container.root.doAll(func(dn *node) error {
return f(dn.content.value().(string))
})
} | [
"func",
"(",
"t",
"*",
"stringTree",
")",
"DoAll",
"(",
"f",
"func",
"(",
"v",
"string",
")",
"error",
")",
"error",
"{",
"return",
"t",
".",
"container",
".",
"root",
".",
"doAll",
"(",
"func",
"(",
"dn",
"*",
"node",
")",
"error",
"{",
"return"... | // DoAll implements the StringTree interface. | [
"DoAll",
"implements",
"the",
"StringTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L522-L526 |
150,404 | tideland/golib | collections/tree.go | DoAllDeep | func (t *stringTree) DoAllDeep(f func(vs []string) error) error {
return t.container.root.doAll(func(dn *node) error {
values := []string{}
cn := dn
for cn != nil {
values = append([]string{cn.content.value().(string)}, values...)
cn = cn.parent
}
return f(values)
})
} | go | func (t *stringTree) DoAllDeep(f func(vs []string) error) error {
return t.container.root.doAll(func(dn *node) error {
values := []string{}
cn := dn
for cn != nil {
values = append([]string{cn.content.value().(string)}, values...)
cn = cn.parent
}
return f(values)
})
} | [
"func",
"(",
"t",
"*",
"stringTree",
")",
"DoAllDeep",
"(",
"f",
"func",
"(",
"vs",
"[",
"]",
"string",
")",
"error",
")",
"error",
"{",
"return",
"t",
".",
"container",
".",
"root",
".",
"doAll",
"(",
"func",
"(",
"dn",
"*",
"node",
")",
"error"... | // DoAllDeep implements the StringTree interface. | [
"DoAllDeep",
"implements",
"the",
"StringTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L529-L539 |
150,405 | tideland/golib | collections/tree.go | Deflate | func (t *stringTree) Deflate(v string) {
t.container.root = &node{
content: justValue{v},
}
} | go | func (t *stringTree) Deflate(v string) {
t.container.root = &node{
content: justValue{v},
}
} | [
"func",
"(",
"t",
"*",
"stringTree",
")",
"Deflate",
"(",
"v",
"string",
")",
"{",
"t",
".",
"container",
".",
"root",
"=",
"&",
"node",
"{",
"content",
":",
"justValue",
"{",
"v",
"}",
",",
"}",
"\n",
"}"
] | // Deflate implements the StringTree interface. | [
"Deflate",
"implements",
"the",
"StringTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L554-L558 |
150,406 | tideland/golib | collections/tree.go | At | func (t *keyValueTree) At(keys ...string) KeyValueChanger {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, nil})
}
n, err := t.container.root.at(path...)
return &keyValueChanger{n, err}
} | go | func (t *keyValueTree) At(keys ...string) KeyValueChanger {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, nil})
}
n, err := t.container.root.at(path...)
return &keyValueChanger{n, err}
} | [
"func",
"(",
"t",
"*",
"keyValueTree",
")",
"At",
"(",
"keys",
"...",
"string",
")",
"KeyValueChanger",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"path",
"=",
"append",
"(",
"path",
",",
... | // At implements the KeyValueTree interface. | [
"At",
"implements",
"the",
"KeyValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L583-L590 |
150,407 | tideland/golib | collections/tree.go | CopyAt | func (t *keyValueTree) CopyAt(keys ...string) (KeyValueTree, error) {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, ""})
}
n, err := t.container.root.at(path...)
if err != nil {
return nil, err
}
nc := &nodeContainer{
duplicates: t.container.duplicates,
}
nc.root = n... | go | func (t *keyValueTree) CopyAt(keys ...string) (KeyValueTree, error) {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, ""})
}
n, err := t.container.root.at(path...)
if err != nil {
return nil, err
}
nc := &nodeContainer{
duplicates: t.container.duplicates,
}
nc.root = n... | [
"func",
"(",
"t",
"*",
"keyValueTree",
")",
"CopyAt",
"(",
"keys",
"...",
"string",
")",
"(",
"KeyValueTree",
",",
"error",
")",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"path",
"=",
"ap... | // CopyAt implements the KeyValueTree interface. | [
"CopyAt",
"implements",
"the",
"KeyValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L663-L677 |
150,408 | tideland/golib | collections/tree.go | Create | func (t *keyStringValueTree) Create(keys ...string) KeyStringValueChanger {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, ""})
}
n, err := t.container.root.create(path...)
return &keyStringValueChanger{n, err}
} | go | func (t *keyStringValueTree) Create(keys ...string) KeyStringValueChanger {
var path []nodeContent
for _, key := range keys {
path = append(path, keyValue{key, ""})
}
n, err := t.container.root.create(path...)
return &keyStringValueChanger{n, err}
} | [
"func",
"(",
"t",
"*",
"keyStringValueTree",
")",
"Create",
"(",
"keys",
"...",
"string",
")",
"KeyStringValueChanger",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"path",
"=",
"append",
"(",
"... | // Create implements the KeyStringValueTree interface. | [
"Create",
"implements",
"the",
"KeyStringValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L724-L731 |
150,409 | tideland/golib | collections/tree.go | DoAll | func (t *keyStringValueTree) DoAll(f func(k, v string) error) error {
return t.container.root.doAll(func(dn *node) error {
return f(dn.content.key().(string), dn.content.value().(string))
})
} | go | func (t *keyStringValueTree) DoAll(f func(k, v string) error) error {
return t.container.root.doAll(func(dn *node) error {
return f(dn.content.key().(string), dn.content.value().(string))
})
} | [
"func",
"(",
"t",
"*",
"keyStringValueTree",
")",
"DoAll",
"(",
"f",
"func",
"(",
"k",
",",
"v",
"string",
")",
"error",
")",
"error",
"{",
"return",
"t",
".",
"container",
".",
"root",
".",
"doAll",
"(",
"func",
"(",
"dn",
"*",
"node",
")",
"err... | // DoAll implements the KeyStringValueTree interface. | [
"DoAll",
"implements",
"the",
"KeyStringValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L757-L761 |
150,410 | tideland/golib | collections/tree.go | DoAllDeep | func (t *keyStringValueTree) DoAllDeep(f func(ks []string, v string) error) error {
return t.container.root.doAll(func(dn *node) error {
keys := []string{}
cn := dn
for cn != nil {
keys = append([]string{cn.content.key().(string)}, keys...)
cn = cn.parent
}
return f(keys, dn.content.value().(string))
... | go | func (t *keyStringValueTree) DoAllDeep(f func(ks []string, v string) error) error {
return t.container.root.doAll(func(dn *node) error {
keys := []string{}
cn := dn
for cn != nil {
keys = append([]string{cn.content.key().(string)}, keys...)
cn = cn.parent
}
return f(keys, dn.content.value().(string))
... | [
"func",
"(",
"t",
"*",
"keyStringValueTree",
")",
"DoAllDeep",
"(",
"f",
"func",
"(",
"ks",
"[",
"]",
"string",
",",
"v",
"string",
")",
"error",
")",
"error",
"{",
"return",
"t",
".",
"container",
".",
"root",
".",
"doAll",
"(",
"func",
"(",
"dn",... | // DoAllDeep implements the KeyStringValueTree interface. | [
"DoAllDeep",
"implements",
"the",
"KeyStringValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L764-L774 |
150,411 | tideland/golib | collections/tree.go | Deflate | func (t *keyStringValueTree) Deflate(k, v string) {
t.container.root = &node{
content: keyValue{k, v},
}
} | go | func (t *keyStringValueTree) Deflate(k, v string) {
t.container.root = &node{
content: keyValue{k, v},
}
} | [
"func",
"(",
"t",
"*",
"keyStringValueTree",
")",
"Deflate",
"(",
"k",
",",
"v",
"string",
")",
"{",
"t",
".",
"container",
".",
"root",
"=",
"&",
"node",
"{",
"content",
":",
"keyValue",
"{",
"k",
",",
"v",
"}",
",",
"}",
"\n",
"}"
] | // Deflate implements the KeyStringValueTree interface. | [
"Deflate",
"implements",
"the",
"KeyStringValueTree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L806-L810 |
150,412 | tideland/golib | redis/pipeline.go | newPipeline | func newPipeline(db *Database) (*Pipeline, error) {
ppl := &Pipeline{
database: db,
}
err := ppl.ensureProtocol()
if err != nil {
return nil, err
}
// Perform authentication and database selection.
if err != nil {
return nil, err
}
err = ppl.resp.authenticate()
if err != nil {
ppl.database.pool.kill(p... | go | func newPipeline(db *Database) (*Pipeline, error) {
ppl := &Pipeline{
database: db,
}
err := ppl.ensureProtocol()
if err != nil {
return nil, err
}
// Perform authentication and database selection.
if err != nil {
return nil, err
}
err = ppl.resp.authenticate()
if err != nil {
ppl.database.pool.kill(p... | [
"func",
"newPipeline",
"(",
"db",
"*",
"Database",
")",
"(",
"*",
"Pipeline",
",",
"error",
")",
"{",
"ppl",
":=",
"&",
"Pipeline",
"{",
"database",
":",
"db",
",",
"}",
"\n",
"err",
":=",
"ppl",
".",
"ensureProtocol",
"(",
")",
"\n",
"if",
"err",
... | // newPipeline creates a new pipeline instance. | [
"newPipeline",
"creates",
"a",
"new",
"pipeline",
"instance",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pipeline.go#L35-L58 |
150,413 | tideland/golib | redis/pipeline.go | Collect | func (ppl *Pipeline) Collect() ([]*ResultSet, error) {
defer func() {
ppl.resp = nil
}()
err := ppl.ensureProtocol()
if err != nil {
return nil, err
}
results := []*ResultSet{}
for i := ppl.counter; i > 0; i-- {
result, err := ppl.resp.receiveResultSet()
if err != nil {
ppl.database.pool.kill(ppl.resp... | go | func (ppl *Pipeline) Collect() ([]*ResultSet, error) {
defer func() {
ppl.resp = nil
}()
err := ppl.ensureProtocol()
if err != nil {
return nil, err
}
results := []*ResultSet{}
for i := ppl.counter; i > 0; i-- {
result, err := ppl.resp.receiveResultSet()
if err != nil {
ppl.database.pool.kill(ppl.resp... | [
"func",
"(",
"ppl",
"*",
"Pipeline",
")",
"Collect",
"(",
")",
"(",
"[",
"]",
"*",
"ResultSet",
",",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"ppl",
".",
"resp",
"=",
"nil",
"\n",
"}",
"(",
")",
"\n",
"err",
":=",
"ppl",
".",
"ensur... | // Collect collects all the result sets of the commands and returns
// the connection back into the pool. | [
"Collect",
"collects",
"all",
"the",
"result",
"sets",
"of",
"the",
"commands",
"and",
"returns",
"the",
"connection",
"back",
"into",
"the",
"pool",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pipeline.go#L86-L105 |
150,414 | tideland/golib | gjp/processing.go | isValue | func isValue(raw interface{}) (interface{}, bool) {
if raw == nil {
return raw, true
}
_, ook := isObject(raw)
_, aok := isArray(raw)
if ook || aok {
return nil, false
}
return raw, true
} | go | func isValue(raw interface{}) (interface{}, bool) {
if raw == nil {
return raw, true
}
_, ook := isObject(raw)
_, aok := isArray(raw)
if ook || aok {
return nil, false
}
return raw, true
} | [
"func",
"isValue",
"(",
"raw",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"if",
"raw",
"==",
"nil",
"{",
"return",
"raw",
",",
"true",
"\n",
"}",
"\n",
"_",
",",
"ook",
":=",
"isObject",
"(",
"raw",
")",
"\n"... | // isValue checks if the raw is a value and returns it
// type-safe. Otherwise nil and false are returned. | [
"isValue",
"checks",
"if",
"the",
"raw",
"is",
"a",
"value",
"and",
"returns",
"it",
"type",
"-",
"safe",
".",
"Otherwise",
"nil",
"and",
"false",
"are",
"returned",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L35-L45 |
150,415 | tideland/golib | gjp/processing.go | isObject | func isObject(raw interface{}) (map[string]interface{}, bool) {
o, ok := raw.(map[string]interface{})
return o, ok
} | go | func isObject(raw interface{}) (map[string]interface{}, bool) {
o, ok := raw.(map[string]interface{})
return o, ok
} | [
"func",
"isObject",
"(",
"raw",
"interface",
"{",
"}",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"o",
",",
"ok",
":=",
"raw",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"retur... | // isObject checks if the raw is an object and returns it
// type-safe. Otherwise nil and false are returned. | [
"isObject",
"checks",
"if",
"the",
"raw",
"is",
"an",
"object",
"and",
"returns",
"it",
"type",
"-",
"safe",
".",
"Otherwise",
"nil",
"and",
"false",
"are",
"returned",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L49-L52 |
150,416 | tideland/golib | gjp/processing.go | valueAt | func valueAt(node interface{}, parts []string) (interface{}, error) {
length := len(parts)
if length == 0 {
// End of the parts.
return node, nil
}
// Further access depends on part content node and type.
head, tail := ht(parts)
if head == "" {
return node, nil
}
if o, ok := isObject(node); ok {
// JSON... | go | func valueAt(node interface{}, parts []string) (interface{}, error) {
length := len(parts)
if length == 0 {
// End of the parts.
return node, nil
}
// Further access depends on part content node and type.
head, tail := ht(parts)
if head == "" {
return node, nil
}
if o, ok := isObject(node); ok {
// JSON... | [
"func",
"valueAt",
"(",
"node",
"interface",
"{",
"}",
",",
"parts",
"[",
"]",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"length",
":=",
"len",
"(",
"parts",
")",
"\n",
"if",
"length",
"==",
"0",
"{",
"// End of the parts.",
... | // valueAt returns the value at the path parts. | [
"valueAt",
"returns",
"the",
"value",
"at",
"the",
"path",
"parts",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L62-L91 |
150,417 | tideland/golib | gjp/processing.go | setValueAt | func setValueAt(root, value interface{}, parts []string) (interface{}, error) {
h, t := ht(parts)
return setNodeValueAt(root, value, h, t)
} | go | func setValueAt(root, value interface{}, parts []string) (interface{}, error) {
h, t := ht(parts)
return setNodeValueAt(root, value, h, t)
} | [
"func",
"setValueAt",
"(",
"root",
",",
"value",
"interface",
"{",
"}",
",",
"parts",
"[",
"]",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"h",
",",
"t",
":=",
"ht",
"(",
"parts",
")",
"\n",
"return",
"setNodeValueAt",
"(",
... | // setValueAt sets the value at the path parts. | [
"setValueAt",
"sets",
"the",
"value",
"at",
"the",
"path",
"parts",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L94-L97 |
150,418 | tideland/golib | gjp/processing.go | ht | func ht(parts []string) (string, []string) {
switch len(parts) {
case 0:
return "", []string{}
case 1:
return parts[0], []string{}
default:
return parts[0], parts[1:]
}
} | go | func ht(parts []string) (string, []string) {
switch len(parts) {
case 0:
return "", []string{}
case 1:
return parts[0], []string{}
default:
return parts[0], parts[1:]
}
} | [
"func",
"ht",
"(",
"parts",
"[",
"]",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"switch",
"len",
"(",
"parts",
")",
"{",
"case",
"0",
":",
"return",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"}",
"\n",
"case",
"1",
":",... | // ht retrieves head and tail from parts. | [
"ht",
"retrieves",
"head",
"and",
"tail",
"from",
"parts",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L100-L109 |
150,419 | tideland/golib | gjp/processing.go | ensureArray | func ensureArray(a []interface{}, l int) []interface{} {
if len(a) >= l {
return a
}
b := make([]interface{}, l)
copy(b, a)
return b
} | go | func ensureArray(a []interface{}, l int) []interface{} {
if len(a) >= l {
return a
}
b := make([]interface{}, l)
copy(b, a)
return b
} | [
"func",
"ensureArray",
"(",
"a",
"[",
"]",
"interface",
"{",
"}",
",",
"l",
"int",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"if",
"len",
"(",
"a",
")",
">=",
"l",
"{",
"return",
"a",
"\n",
"}",
"\n",
"b",
":=",
"make",
"(",
"[",
"]",
"int... | // ensureArray ensures the right len of an array. | [
"ensureArray",
"ensures",
"the",
"right",
"len",
"of",
"an",
"array",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L204-L211 |
150,420 | tideland/golib | gjp/processing.go | process | func process(node interface{}, parts []string, separator string, processor ValueProcessor) error {
mkerr := func(err error, ps []string) error {
return errors.Annotate(err, ErrProcessing, errorMessages, pathify(ps, separator))
}
// First check objects and arrays.
if o, ok := isObject(node); ok {
if len(o) == 0 ... | go | func process(node interface{}, parts []string, separator string, processor ValueProcessor) error {
mkerr := func(err error, ps []string) error {
return errors.Annotate(err, ErrProcessing, errorMessages, pathify(ps, separator))
}
// First check objects and arrays.
if o, ok := isObject(node); ok {
if len(o) == 0 ... | [
"func",
"process",
"(",
"node",
"interface",
"{",
"}",
",",
"parts",
"[",
"]",
"string",
",",
"separator",
"string",
",",
"processor",
"ValueProcessor",
")",
"error",
"{",
"mkerr",
":=",
"func",
"(",
"err",
"error",
",",
"ps",
"[",
"]",
"string",
")",
... | // process processes node recursively. | [
"process",
"processes",
"node",
"recursively",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L214-L247 |
150,421 | tideland/golib | gjp/processing.go | pathify | func pathify(parts []string, separator string) string {
return separator + strings.Join(parts, separator)
} | go | func pathify(parts []string, separator string) string {
return separator + strings.Join(parts, separator)
} | [
"func",
"pathify",
"(",
"parts",
"[",
"]",
"string",
",",
"separator",
"string",
")",
"string",
"{",
"return",
"separator",
"+",
"strings",
".",
"Join",
"(",
"parts",
",",
"separator",
")",
"\n",
"}"
] | // pathify creates a path out of parts and separator. | [
"pathify",
"creates",
"a",
"path",
"out",
"of",
"parts",
"and",
"separator",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/processing.go#L250-L252 |
150,422 | tideland/golib | cache/tasks.go | failedTask | func failedTask(id string, err error) task {
return func(c *cache) error {
// Check for discarded Cacheable first.
if c.buckets[id] == nil {
return nil
}
// Notify all waiters.
for _, waiter := range c.buckets[id].waiters {
waiter <- func() (Cacheable, error) {
return nil, errors.Annotate(err, ErrL... | go | func failedTask(id string, err error) task {
return func(c *cache) error {
// Check for discarded Cacheable first.
if c.buckets[id] == nil {
return nil
}
// Notify all waiters.
for _, waiter := range c.buckets[id].waiters {
waiter <- func() (Cacheable, error) {
return nil, errors.Annotate(err, ErrL... | [
"func",
"failedTask",
"(",
"id",
"string",
",",
"err",
"error",
")",
"task",
"{",
"return",
"func",
"(",
"c",
"*",
"cache",
")",
"error",
"{",
"// Check for discarded Cacheable first.",
"if",
"c",
".",
"buckets",
"[",
"id",
"]",
"==",
"nil",
"{",
"return... | // failedTask notifies the cache that a loading failed. | [
"failedTask",
"notifies",
"the",
"cache",
"that",
"a",
"loading",
"failed",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L28-L43 |
150,423 | tideland/golib | cache/tasks.go | successTask | func successTask(id string, cacheable Cacheable) task {
return func(c *cache) error {
// Check for discarded Cacheable first.
if c.buckets[id] == nil {
return nil
}
// Set bucket values.
b := c.buckets[id]
b.cacheable = cacheable
b.status = statusLoaded
b.loaded = time.Now()
b.lastUsed = b.loaded
... | go | func successTask(id string, cacheable Cacheable) task {
return func(c *cache) error {
// Check for discarded Cacheable first.
if c.buckets[id] == nil {
return nil
}
// Set bucket values.
b := c.buckets[id]
b.cacheable = cacheable
b.status = statusLoaded
b.loaded = time.Now()
b.lastUsed = b.loaded
... | [
"func",
"successTask",
"(",
"id",
"string",
",",
"cacheable",
"Cacheable",
")",
"task",
"{",
"return",
"func",
"(",
"c",
"*",
"cache",
")",
"error",
"{",
"// Check for discarded Cacheable first.",
"if",
"c",
".",
"buckets",
"[",
"id",
"]",
"==",
"nil",
"{"... | // successTask notifies the cache that a loading succeeded. | [
"successTask",
"notifies",
"the",
"cache",
"that",
"a",
"loading",
"succeeded",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L46-L67 |
150,424 | tideland/golib | cache/tasks.go | loading | func loading(c *cache, id string) {
cacheable, err := c.load(id)
if err != nil {
c.taskc <- failedTask(id, err)
} else {
c.taskc <- successTask(id, cacheable)
}
} | go | func loading(c *cache, id string) {
cacheable, err := c.load(id)
if err != nil {
c.taskc <- failedTask(id, err)
} else {
c.taskc <- successTask(id, cacheable)
}
} | [
"func",
"loading",
"(",
"c",
"*",
"cache",
",",
"id",
"string",
")",
"{",
"cacheable",
",",
"err",
":=",
"c",
".",
"load",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"taskc",
"<-",
"failedTask",
"(",
"id",
",",
"err",
")",
... | // loading is the asynchronous loading function. | [
"loading",
"is",
"the",
"asynchronous",
"loading",
"function",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L70-L77 |
150,425 | tideland/golib | cache/tasks.go | lookupTask | func lookupTask(id string, responsec responder) task {
return func(c *cache) error {
b, ok := c.buckets[id]
switch {
case !ok:
// ID is unknown.
c.buckets[id] = &bucket{
status: statusLoading,
waiters: []responder{responsec},
}
go loading(c, id)
case ok && b.status == statusLoading:
// ... | go | func lookupTask(id string, responsec responder) task {
return func(c *cache) error {
b, ok := c.buckets[id]
switch {
case !ok:
// ID is unknown.
c.buckets[id] = &bucket{
status: statusLoading,
waiters: []responder{responsec},
}
go loading(c, id)
case ok && b.status == statusLoading:
// ... | [
"func",
"lookupTask",
"(",
"id",
"string",
",",
"responsec",
"responder",
")",
"task",
"{",
"return",
"func",
"(",
"c",
"*",
"cache",
")",
"error",
"{",
"b",
",",
"ok",
":=",
"c",
".",
"buckets",
"[",
"id",
"]",
"\n",
"switch",
"{",
"case",
"!",
... | // lookupTask returns the task for looking up the cache. | [
"lookupTask",
"returns",
"the",
"task",
"for",
"looking",
"up",
"the",
"cache",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L80-L119 |
150,426 | tideland/golib | cache/tasks.go | discardTask | func discardTask(id string, responsec responder) task {
return func(c *cache) error {
bucket, ok := c.buckets[id]
if !ok {
// Not found, so nothing to discard.
responsec <- func() (Cacheable, error) {
return nil, nil
}
return nil
}
// Discard Cacheable, notify possible waiters,
// delete buck... | go | func discardTask(id string, responsec responder) task {
return func(c *cache) error {
bucket, ok := c.buckets[id]
if !ok {
// Not found, so nothing to discard.
responsec <- func() (Cacheable, error) {
return nil, nil
}
return nil
}
// Discard Cacheable, notify possible waiters,
// delete buck... | [
"func",
"discardTask",
"(",
"id",
"string",
",",
"responsec",
"responder",
")",
"task",
"{",
"return",
"func",
"(",
"c",
"*",
"cache",
")",
"error",
"{",
"bucket",
",",
"ok",
":=",
"c",
".",
"buckets",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
... | // discardTask returns the task for discarding a Cacheable. | [
"discardTask",
"returns",
"the",
"task",
"for",
"discarding",
"a",
"Cacheable",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L122-L152 |
150,427 | tideland/golib | cache/tasks.go | clearTask | func clearTask(responsec responder) task {
return func(c *cache) error {
var errs []error
for id, bucket := range c.buckets {
switch bucket.status {
case statusLoading:
for _, waiter := range bucket.waiters {
waiter <- func() (Cacheable, error) {
return nil, errors.New(ErrDiscardedWhileLoading... | go | func clearTask(responsec responder) task {
return func(c *cache) error {
var errs []error
for id, bucket := range c.buckets {
switch bucket.status {
case statusLoading:
for _, waiter := range bucket.waiters {
waiter <- func() (Cacheable, error) {
return nil, errors.New(ErrDiscardedWhileLoading... | [
"func",
"clearTask",
"(",
"responsec",
"responder",
")",
"task",
"{",
"return",
"func",
"(",
"c",
"*",
"cache",
")",
"error",
"{",
"var",
"errs",
"[",
"]",
"error",
"\n",
"for",
"id",
",",
"bucket",
":=",
"range",
"c",
".",
"buckets",
"{",
"switch",
... | // clearTask returns the task to clear the cache. | [
"clearTask",
"returns",
"the",
"task",
"to",
"clear",
"the",
"cache",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/tasks.go#L155-L182 |
150,428 | tideland/golib | feed/utils/utils.go | newISO88591CharsetReader | func newISO88591CharsetReader(reader io.Reader) *iso88591CharsetReader {
buffer := bytes.NewBuffer(make([]byte, 0, utf8.UTFMax))
return &iso88591CharsetReader{reader.(io.ByteReader), buffer}
} | go | func newISO88591CharsetReader(reader io.Reader) *iso88591CharsetReader {
buffer := bytes.NewBuffer(make([]byte, 0, utf8.UTFMax))
return &iso88591CharsetReader{reader.(io.ByteReader), buffer}
} | [
"func",
"newISO88591CharsetReader",
"(",
"reader",
"io",
".",
"Reader",
")",
"*",
"iso88591CharsetReader",
"{",
"buffer",
":=",
"bytes",
".",
"NewBuffer",
"(",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"utf8",
".",
"UTFMax",
")",
")",
"\n",
"return",... | // newISO88591CharsetReader creates a new charset reader. | [
"newISO88591CharsetReader",
"creates",
"a",
"new",
"charset",
"reader",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/utils/utils.go#L36-L39 |
150,429 | tideland/golib | feed/utils/utils.go | ReadByte | func (cr *iso88591CharsetReader) ReadByte() (b byte, err error) {
if cr.buffer.Len() <= 0 {
r, err := cr.reader.ReadByte()
if err != nil {
return 0, err
}
if r < utf8.RuneSelf {
return r, nil
}
cr.buffer.WriteRune(rune(r))
}
return cr.buffer.ReadByte()
} | go | func (cr *iso88591CharsetReader) ReadByte() (b byte, err error) {
if cr.buffer.Len() <= 0 {
r, err := cr.reader.ReadByte()
if err != nil {
return 0, err
}
if r < utf8.RuneSelf {
return r, nil
}
cr.buffer.WriteRune(rune(r))
}
return cr.buffer.ReadByte()
} | [
"func",
"(",
"cr",
"*",
"iso88591CharsetReader",
")",
"ReadByte",
"(",
")",
"(",
"b",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"cr",
".",
"buffer",
".",
"Len",
"(",
")",
"<=",
"0",
"{",
"r",
",",
"err",
":=",
"cr",
".",
"reader",
".",
"Read... | // ReadByte reads one byte from the reader. | [
"ReadByte",
"reads",
"one",
"byte",
"from",
"the",
"reader",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/utils/utils.go#L42-L54 |
150,430 | tideland/golib | feed/utils/utils.go | CharsetReader | func CharsetReader(charset string, input io.Reader) (io.Reader, error) {
switch mapping[strings.ToLower(charset)] {
case "utf-8":
return input, nil
case "iso-8859-1":
return newISO88591CharsetReader(input), nil
}
return nil, fmt.Errorf("charset %q is not supported", charset)
} | go | func CharsetReader(charset string, input io.Reader) (io.Reader, error) {
switch mapping[strings.ToLower(charset)] {
case "utf-8":
return input, nil
case "iso-8859-1":
return newISO88591CharsetReader(input), nil
}
return nil, fmt.Errorf("charset %q is not supported", charset)
} | [
"func",
"CharsetReader",
"(",
"charset",
"string",
",",
"input",
"io",
".",
"Reader",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"switch",
"mapping",
"[",
"strings",
".",
"ToLower",
"(",
"charset",
")",
"]",
"{",
"case",
"\"",
"\"",
":",
... | // CharsetReader implements the charset reader function for the XML decoder.
// Currently UTF-8 and ISO-8859-1 are supported. | [
"CharsetReader",
"implements",
"the",
"charset",
"reader",
"function",
"for",
"the",
"XML",
"decoder",
".",
"Currently",
"UTF",
"-",
"8",
"and",
"ISO",
"-",
"8859",
"-",
"1",
"are",
"supported",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/utils/utils.go#L78-L86 |
150,431 | tideland/golib | feed/utils/utils.go | StripTags | func StripTags(raw string, strict, escaped bool) (string, error) {
// Remove escaping.
xmldoc := raw
if escaped {
xmldoc = html.UnescapeString(xmldoc)
}
// Decode the document.
buffer := []string{}
dec := xml.NewDecoder(bytes.NewBufferString(xmldoc))
dec.Strict = strict
dec.CharsetReader = CharsetReader
for... | go | func StripTags(raw string, strict, escaped bool) (string, error) {
// Remove escaping.
xmldoc := raw
if escaped {
xmldoc = html.UnescapeString(xmldoc)
}
// Decode the document.
buffer := []string{}
dec := xml.NewDecoder(bytes.NewBufferString(xmldoc))
dec.Strict = strict
dec.CharsetReader = CharsetReader
for... | [
"func",
"StripTags",
"(",
"raw",
"string",
",",
"strict",
",",
"escaped",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Remove escaping.",
"xmldoc",
":=",
"raw",
"\n",
"if",
"escaped",
"{",
"xmldoc",
"=",
"html",
".",
"UnescapeString",
"(",
"xm... | // StripTags removes the tags of the raw XML string. | [
"StripTags",
"removes",
"the",
"tags",
"of",
"the",
"raw",
"XML",
"string",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/utils/utils.go#L89-L117 |
150,432 | tideland/golib | redis/tools.go | join | func join(parts ...interface{}) []byte {
tmp := []byte{}
for _, part := range parts {
switch typedPart := part.(type) {
case []byte:
tmp = append(tmp, typedPart...)
case string:
tmp = append(tmp, []byte(typedPart)...)
case int:
tmp = append(tmp, []byte(strconv.Itoa(typedPart))...)
default:
tmp =... | go | func join(parts ...interface{}) []byte {
tmp := []byte{}
for _, part := range parts {
switch typedPart := part.(type) {
case []byte:
tmp = append(tmp, typedPart...)
case string:
tmp = append(tmp, []byte(typedPart)...)
case int:
tmp = append(tmp, []byte(strconv.Itoa(typedPart))...)
default:
tmp =... | [
"func",
"join",
"(",
"parts",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"tmp",
":=",
"[",
"]",
"byte",
"{",
"}",
"\n",
"for",
"_",
",",
"part",
":=",
"range",
"parts",
"{",
"switch",
"typedPart",
":=",
"part",
".",
"(",
"type",
... | // join builds a byte slice out of some parts. | [
"join",
"builds",
"a",
"byte",
"slice",
"out",
"of",
"some",
"parts",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L34-L49 |
150,433 | tideland/golib | redis/tools.go | valueToBytes | func valueToBytes(value interface{}) []byte {
switch typedValue := value.(type) {
case string:
return []byte(typedValue)
case []byte:
return typedValue
case []string:
return []byte(strings.Join(typedValue, "\r\n"))
case map[string]string:
tmp := make([]string, len(typedValue))
i := 0
for k, v := range ... | go | func valueToBytes(value interface{}) []byte {
switch typedValue := value.(type) {
case string:
return []byte(typedValue)
case []byte:
return typedValue
case []string:
return []byte(strings.Join(typedValue, "\r\n"))
case map[string]string:
tmp := make([]string, len(typedValue))
i := 0
for k, v := range ... | [
"func",
"valueToBytes",
"(",
"value",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"switch",
"typedValue",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"[",
"]",
"byte",
"(",
"typedValue",
")",
"\n",
"case",
"[",
... | // valueToBytes converts a value into a byte slice. | [
"valueToBytes",
"converts",
"a",
"value",
"into",
"a",
"byte",
"slice",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L52-L79 |
150,434 | tideland/golib | redis/tools.go | keyValueArgsToKeys | func keyValueArgsToKeys(kvs ...interface{}) []string {
keys := []string{}
ok := true
for _, k := range kvs {
if ok {
key := string(valueToBytes(k))
keys = append(keys, key)
}
ok = !ok
}
return keys
} | go | func keyValueArgsToKeys(kvs ...interface{}) []string {
keys := []string{}
ok := true
for _, k := range kvs {
if ok {
key := string(valueToBytes(k))
keys = append(keys, key)
}
ok = !ok
}
return keys
} | [
"func",
"keyValueArgsToKeys",
"(",
"kvs",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"ok",
":=",
"true",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"kvs",
"{",
"if",
"ok",
"{",
... | // keyValueArgsToKeys converts a mixed number of keys and values
// into a slice containing the keys. | [
"keyValueArgsToKeys",
"converts",
"a",
"mixed",
"number",
"of",
"keys",
"and",
"values",
"into",
"a",
"slice",
"containing",
"the",
"keys",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L83-L94 |
150,435 | tideland/golib | redis/tools.go | buildInterfaces | func buildInterfaces(values ...interface{}) []interface{} {
ifcs := []interface{}{}
for _, value := range values {
switch v := value.(type) {
case []string:
for _, s := range v {
ifcs = append(ifcs, s)
}
case []interface{}:
for _, i := range v {
ifcs = append(ifcs, i)
}
default:
ifcs = ... | go | func buildInterfaces(values ...interface{}) []interface{} {
ifcs := []interface{}{}
for _, value := range values {
switch v := value.(type) {
case []string:
for _, s := range v {
ifcs = append(ifcs, s)
}
case []interface{}:
for _, i := range v {
ifcs = append(ifcs, i)
}
default:
ifcs = ... | [
"func",
"buildInterfaces",
"(",
"values",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"ifcs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"switch",
"v",... | // buildInterfaces creates a slice of interfaces out
// of the passed arguments. Found string or interface
// slices are flattened. | [
"buildInterfaces",
"creates",
"a",
"slice",
"of",
"interfaces",
"out",
"of",
"the",
"passed",
"arguments",
".",
"Found",
"string",
"or",
"interface",
"slices",
"are",
"flattened",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L99-L116 |
150,436 | tideland/golib | redis/tools.go | containsPattern | func containsPattern(channel interface{}) bool {
ch := channel.(string)
if strings.IndexAny(ch, "*?[") != -1 {
return true
}
return false
} | go | func containsPattern(channel interface{}) bool {
ch := channel.(string)
if strings.IndexAny(ch, "*?[") != -1 {
return true
}
return false
} | [
"func",
"containsPattern",
"(",
"channel",
"interface",
"{",
"}",
")",
"bool",
"{",
"ch",
":=",
"channel",
".",
"(",
"string",
")",
"\n",
"if",
"strings",
".",
"IndexAny",
"(",
"ch",
",",
"\"",
"\"",
")",
"!=",
"-",
"1",
"{",
"return",
"true",
"\n"... | // containsPatterns checks, if the channel contains a pattern
// to subscribe to or unsubscribe from multiple channels. | [
"containsPatterns",
"checks",
"if",
"the",
"channel",
"contains",
"a",
"pattern",
"to",
"subscribe",
"to",
"or",
"unsubscribe",
"from",
"multiple",
"channels",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L120-L126 |
150,437 | tideland/golib | redis/tools.go | logCommand | func logCommand(cmd string, args []interface{}, err error, log bool) {
// Format the command for the log entry.
formatArgs := func() string {
if args == nil || len(args) == 0 {
return "(none)"
}
output := make([]string, len(args))
for i, arg := range args {
output[i] = string(valueToBytes(arg))
}
re... | go | func logCommand(cmd string, args []interface{}, err error, log bool) {
// Format the command for the log entry.
formatArgs := func() string {
if args == nil || len(args) == 0 {
return "(none)"
}
output := make([]string, len(args))
for i, arg := range args {
output[i] = string(valueToBytes(arg))
}
re... | [
"func",
"logCommand",
"(",
"cmd",
"string",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
",",
"log",
"bool",
")",
"{",
"// Format the command for the log entry.",
"formatArgs",
":=",
"func",
"(",
")",
"string",
"{",
"if",
"args",
"=="... | // logCommand logs a command and its execution status. | [
"logCommand",
"logs",
"a",
"command",
"and",
"its",
"execution",
"status",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/tools.go#L129-L157 |
150,438 | tideland/golib | monitoring/standardbackend.go | EndMeasuring | func (m *stdMeasuring) EndMeasuring() time.Duration {
if m.backend == nil {
return 0
}
m.duration = time.Since(m.startTime)
m.backend.measuringC <- m
return m.duration
} | go | func (m *stdMeasuring) EndMeasuring() time.Duration {
if m.backend == nil {
return 0
}
m.duration = time.Since(m.startTime)
m.backend.measuringC <- m
return m.duration
} | [
"func",
"(",
"m",
"*",
"stdMeasuring",
")",
"EndMeasuring",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"m",
".",
"backend",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"m",
".",
"duration",
"=",
"time",
".",
"Since",
"(",
"m",
".",
"star... | // EndMEasuring implements the Measuring interface. | [
"EndMEasuring",
"implements",
"the",
"Measuring",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L77-L84 |
150,439 | tideland/golib | monitoring/standardbackend.go | newStdMeasuringPoint | func newStdMeasuringPoint(m *stdMeasuring) *stdMeasuringPoint {
return &stdMeasuringPoint{
id: m.id,
count: 1,
minDuration: m.duration,
maxDuration: m.duration,
avgDuration: m.duration,
}
} | go | func newStdMeasuringPoint(m *stdMeasuring) *stdMeasuringPoint {
return &stdMeasuringPoint{
id: m.id,
count: 1,
minDuration: m.duration,
maxDuration: m.duration,
avgDuration: m.duration,
}
} | [
"func",
"newStdMeasuringPoint",
"(",
"m",
"*",
"stdMeasuring",
")",
"*",
"stdMeasuringPoint",
"{",
"return",
"&",
"stdMeasuringPoint",
"{",
"id",
":",
"m",
".",
"id",
",",
"count",
":",
"1",
",",
"minDuration",
":",
"m",
".",
"duration",
",",
"maxDuration"... | // newStdMeasuringPoint creates a new measuring point out of a measuring. | [
"newStdMeasuringPoint",
"creates",
"a",
"new",
"measuring",
"point",
"out",
"of",
"a",
"measuring",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L100-L108 |
150,440 | tideland/golib | monitoring/standardbackend.go | update | func (mp *stdMeasuringPoint) update(m *stdMeasuring) {
average := mp.avgDuration.Nanoseconds()
mp.count++
if mp.minDuration > m.duration {
mp.minDuration = m.duration
}
if mp.maxDuration < m.duration {
mp.maxDuration = m.duration
}
mp.avgDuration = time.Duration((average + m.duration.Nanoseconds()) / 2)
} | go | func (mp *stdMeasuringPoint) update(m *stdMeasuring) {
average := mp.avgDuration.Nanoseconds()
mp.count++
if mp.minDuration > m.duration {
mp.minDuration = m.duration
}
if mp.maxDuration < m.duration {
mp.maxDuration = m.duration
}
mp.avgDuration = time.Duration((average + m.duration.Nanoseconds()) / 2)
} | [
"func",
"(",
"mp",
"*",
"stdMeasuringPoint",
")",
"update",
"(",
"m",
"*",
"stdMeasuring",
")",
"{",
"average",
":=",
"mp",
".",
"avgDuration",
".",
"Nanoseconds",
"(",
")",
"\n",
"mp",
".",
"count",
"++",
"\n",
"if",
"mp",
".",
"minDuration",
">",
"... | // Uupdate a measuring point with a measuring. | [
"Uupdate",
"a",
"measuring",
"point",
"with",
"a",
"measuring",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L126-L136 |
150,441 | tideland/golib | monitoring/standardbackend.go | newStdStaySetVariable | func newStdStaySetVariable(v *stdSSVChange) *stdStaySetVariable {
return &stdStaySetVariable{
id: v.id,
count: 1,
actValue: v.variable,
minValue: v.variable,
maxValue: v.variable,
avgValue: v.variable,
}
} | go | func newStdStaySetVariable(v *stdSSVChange) *stdStaySetVariable {
return &stdStaySetVariable{
id: v.id,
count: 1,
actValue: v.variable,
minValue: v.variable,
maxValue: v.variable,
avgValue: v.variable,
}
} | [
"func",
"newStdStaySetVariable",
"(",
"v",
"*",
"stdSSVChange",
")",
"*",
"stdStaySetVariable",
"{",
"return",
"&",
"stdStaySetVariable",
"{",
"id",
":",
"v",
".",
"id",
",",
"count",
":",
"1",
",",
"actValue",
":",
"v",
".",
"variable",
",",
"minValue",
... | // newStdStaySetVariable creates a new stay-set variable out of a variable. | [
"newStdStaySetVariable",
"creates",
"a",
"new",
"stay",
"-",
"set",
"variable",
"out",
"of",
"a",
"variable",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L166-L175 |
150,442 | tideland/golib | monitoring/standardbackend.go | update | func (ssv *stdStaySetVariable) update(chg *stdSSVChange) {
ssv.count++
if chg.absolute {
ssv.actValue = chg.variable
} else {
ssv.actValue += chg.variable
}
ssv.total += chg.variable
if ssv.minValue > ssv.actValue {
ssv.minValue = ssv.actValue
}
if ssv.maxValue < ssv.actValue {
ssv.maxValue = ssv.actVal... | go | func (ssv *stdStaySetVariable) update(chg *stdSSVChange) {
ssv.count++
if chg.absolute {
ssv.actValue = chg.variable
} else {
ssv.actValue += chg.variable
}
ssv.total += chg.variable
if ssv.minValue > ssv.actValue {
ssv.minValue = ssv.actValue
}
if ssv.maxValue < ssv.actValue {
ssv.maxValue = ssv.actVal... | [
"func",
"(",
"ssv",
"*",
"stdStaySetVariable",
")",
"update",
"(",
"chg",
"*",
"stdSSVChange",
")",
"{",
"ssv",
".",
"count",
"++",
"\n",
"if",
"chg",
".",
"absolute",
"{",
"ssv",
".",
"actValue",
"=",
"chg",
".",
"variable",
"\n",
"}",
"else",
"{",
... | // update a stay-set variable with a change. | [
"update",
"a",
"stay",
"-",
"set",
"variable",
"with",
"a",
"change",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L196-L211 |
150,443 | tideland/golib | monitoring/standardbackend.go | NewStandardBackend | func NewStandardBackend() Backend {
m := &stdBackend{
measuringC: make(chan *stdMeasuring, 1024),
ssvChangeC: make(chan *stdSSVChange, 1024),
retrieverRegistrationC: make(chan *stdRetrieverRegistration),
commandC: make(chan *command),
}
m.backend = loop.GoRecoverable(m.b... | go | func NewStandardBackend() Backend {
m := &stdBackend{
measuringC: make(chan *stdMeasuring, 1024),
ssvChangeC: make(chan *stdSSVChange, 1024),
retrieverRegistrationC: make(chan *stdRetrieverRegistration),
commandC: make(chan *command),
}
m.backend = loop.GoRecoverable(m.b... | [
"func",
"NewStandardBackend",
"(",
")",
"Backend",
"{",
"m",
":=",
"&",
"stdBackend",
"{",
"measuringC",
":",
"make",
"(",
"chan",
"*",
"stdMeasuring",
",",
"1024",
")",
",",
"ssvChangeC",
":",
"make",
"(",
"chan",
"*",
"stdSSVChange",
",",
"1024",
")",
... | // NewStandardBackend starts the standard monitoring backend. | [
"NewStandardBackend",
"starts",
"the",
"standard",
"monitoring",
"backend",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L266-L275 |
150,444 | tideland/golib | monitoring/standardbackend.go | BeginMeasuring | func (b *stdBackend) BeginMeasuring(id string) Measuring {
if b.etmFilter != nil && !b.etmFilter(id) {
return &stdMeasuring{}
}
return &stdMeasuring{b, id, time.Now(), 0}
} | go | func (b *stdBackend) BeginMeasuring(id string) Measuring {
if b.etmFilter != nil && !b.etmFilter(id) {
return &stdMeasuring{}
}
return &stdMeasuring{b, id, time.Now(), 0}
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"BeginMeasuring",
"(",
"id",
"string",
")",
"Measuring",
"{",
"if",
"b",
".",
"etmFilter",
"!=",
"nil",
"&&",
"!",
"b",
".",
"etmFilter",
"(",
"id",
")",
"{",
"return",
"&",
"stdMeasuring",
"{",
"}",
"\n",
... | // BeginMeasuring implements the MonitorBackend interface. | [
"BeginMeasuring",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L278-L283 |
150,445 | tideland/golib | monitoring/standardbackend.go | ReadMeasuringPoint | func (b *stdBackend) ReadMeasuringPoint(id string) (MeasuringPoint, error) {
resp, err := b.command(cmdMeasuringPointRead, id)
if err != nil {
return nil, err
}
return resp.(MeasuringPoint), nil
} | go | func (b *stdBackend) ReadMeasuringPoint(id string) (MeasuringPoint, error) {
resp, err := b.command(cmdMeasuringPointRead, id)
if err != nil {
return nil, err
}
return resp.(MeasuringPoint), nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"ReadMeasuringPoint",
"(",
"id",
"string",
")",
"(",
"MeasuringPoint",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdMeasuringPointRead",
",",
"id",
")",
"\n",
"if",
"err",
"!=... | // ReadMeasuringPoint implements the MonitorBackend interface. | [
"ReadMeasuringPoint",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L286-L292 |
150,446 | tideland/golib | monitoring/standardbackend.go | MeasuringPointsDo | func (b *stdBackend) MeasuringPointsDo(f func(MeasuringPoint)) error {
resp, err := b.command(cmdMeasuringPointsReadAll, nil)
if err != nil {
return err
}
mps := resp.(MeasuringPoints)
for _, mp := range mps {
f(mp)
}
return nil
} | go | func (b *stdBackend) MeasuringPointsDo(f func(MeasuringPoint)) error {
resp, err := b.command(cmdMeasuringPointsReadAll, nil)
if err != nil {
return err
}
mps := resp.(MeasuringPoints)
for _, mp := range mps {
f(mp)
}
return nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"MeasuringPointsDo",
"(",
"f",
"func",
"(",
"MeasuringPoint",
")",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdMeasuringPointsReadAll",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"... | // MeasuringPointsDo implements the MonitorBackend interface. | [
"MeasuringPointsDo",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L295-L305 |
150,447 | tideland/golib | monitoring/standardbackend.go | SetVariable | func (b *stdBackend) SetVariable(id string, v int64) {
if b.ssvFilter != nil && !b.ssvFilter(id) {
return
}
b.ssvChangeC <- &stdSSVChange{id, true, v}
} | go | func (b *stdBackend) SetVariable(id string, v int64) {
if b.ssvFilter != nil && !b.ssvFilter(id) {
return
}
b.ssvChangeC <- &stdSSVChange{id, true, v}
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"SetVariable",
"(",
"id",
"string",
",",
"v",
"int64",
")",
"{",
"if",
"b",
".",
"ssvFilter",
"!=",
"nil",
"&&",
"!",
"b",
".",
"ssvFilter",
"(",
"id",
")",
"{",
"return",
"\n",
"}",
"\n",
"b",
".",
"ss... | // SetVariable implements the MonitorBackend interface. | [
"SetVariable",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L308-L313 |
150,448 | tideland/golib | monitoring/standardbackend.go | IncrVariable | func (b *stdBackend) IncrVariable(id string) {
if b.ssvFilter != nil && !b.ssvFilter(id) {
return
}
b.ssvChangeC <- &stdSSVChange{id, false, 1}
} | go | func (b *stdBackend) IncrVariable(id string) {
if b.ssvFilter != nil && !b.ssvFilter(id) {
return
}
b.ssvChangeC <- &stdSSVChange{id, false, 1}
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"IncrVariable",
"(",
"id",
"string",
")",
"{",
"if",
"b",
".",
"ssvFilter",
"!=",
"nil",
"&&",
"!",
"b",
".",
"ssvFilter",
"(",
"id",
")",
"{",
"return",
"\n",
"}",
"\n",
"b",
".",
"ssvChangeC",
"<-",
"&"... | // IncrVariable implements the MonitorBackend interface. | [
"IncrVariable",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L316-L321 |
150,449 | tideland/golib | monitoring/standardbackend.go | ReadVariable | func (b *stdBackend) ReadVariable(id string) (StaySetVariable, error) {
resp, err := b.command(cmdStaySetVariableRead, id)
if err != nil {
return nil, err
}
return resp.(StaySetVariable), nil
} | go | func (b *stdBackend) ReadVariable(id string) (StaySetVariable, error) {
resp, err := b.command(cmdStaySetVariableRead, id)
if err != nil {
return nil, err
}
return resp.(StaySetVariable), nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"ReadVariable",
"(",
"id",
"string",
")",
"(",
"StaySetVariable",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdStaySetVariableRead",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
... | // ReadVariable implements the MonitorBackend interface. | [
"ReadVariable",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L332-L338 |
150,450 | tideland/golib | monitoring/standardbackend.go | StaySetVariablesDo | func (b *stdBackend) StaySetVariablesDo(f func(StaySetVariable)) error {
resp, err := b.command(cmdStaySetVariablesReadAll, nil)
if err != nil {
return err
}
ssvs := resp.(StaySetVariables)
for _, ssv := range ssvs {
f(ssv)
}
return nil
} | go | func (b *stdBackend) StaySetVariablesDo(f func(StaySetVariable)) error {
resp, err := b.command(cmdStaySetVariablesReadAll, nil)
if err != nil {
return err
}
ssvs := resp.(StaySetVariables)
for _, ssv := range ssvs {
f(ssv)
}
return nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"StaySetVariablesDo",
"(",
"f",
"func",
"(",
"StaySetVariable",
")",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdStaySetVariablesReadAll",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
... | // StaySetVariablesDo implements the MonitorBackend interface. | [
"StaySetVariablesDo",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L341-L351 |
150,451 | tideland/golib | monitoring/standardbackend.go | Register | func (b *stdBackend) Register(id string, rf DynamicStatusRetriever) {
if b.dsrFilter != nil && !b.dsrFilter(id) {
return
}
b.retrieverRegistrationC <- &stdRetrieverRegistration{id, rf}
} | go | func (b *stdBackend) Register(id string, rf DynamicStatusRetriever) {
if b.dsrFilter != nil && !b.dsrFilter(id) {
return
}
b.retrieverRegistrationC <- &stdRetrieverRegistration{id, rf}
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"Register",
"(",
"id",
"string",
",",
"rf",
"DynamicStatusRetriever",
")",
"{",
"if",
"b",
".",
"dsrFilter",
"!=",
"nil",
"&&",
"!",
"b",
".",
"dsrFilter",
"(",
"id",
")",
"{",
"return",
"\n",
"}",
"\n",
"b... | // Register implements the MonitorBackend interface. | [
"Register",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L354-L359 |
150,452 | tideland/golib | monitoring/standardbackend.go | ReadStatus | func (b *stdBackend) ReadStatus(id string) (string, error) {
resp, err := b.command(cmdDynamicStatusRetrieverRead, id)
if err != nil {
return "", err
}
return resp.(string), nil
} | go | func (b *stdBackend) ReadStatus(id string) (string, error) {
resp, err := b.command(cmdDynamicStatusRetrieverRead, id)
if err != nil {
return "", err
}
return resp.(string), nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"ReadStatus",
"(",
"id",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdDynamicStatusRetrieverRead",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"ni... | // ReadStatus implements the MonitorBackend interface. | [
"ReadStatus",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L362-L368 |
150,453 | tideland/golib | monitoring/standardbackend.go | DynamicStatusValuesDo | func (b *stdBackend) DynamicStatusValuesDo(f func(DynamicStatusValue)) error {
resp, err := b.command(cmdDynamicStatusRetrieversReadAll, f)
if err != nil {
return err
}
dsvs := resp.(DynamicStatusValues)
for _, dsv := range dsvs {
f(dsv)
}
return nil
} | go | func (b *stdBackend) DynamicStatusValuesDo(f func(DynamicStatusValue)) error {
resp, err := b.command(cmdDynamicStatusRetrieversReadAll, f)
if err != nil {
return err
}
dsvs := resp.(DynamicStatusValues)
for _, dsv := range dsvs {
f(dsv)
}
return nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"DynamicStatusValuesDo",
"(",
"f",
"func",
"(",
"DynamicStatusValue",
")",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdDynamicStatusRetrieversReadAll",
",",
"f",
")",
"\n",
"if",
"err... | // DynamicStatusValuesDo implements the MonitorBackend interface. | [
"DynamicStatusValuesDo",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L371-L381 |
150,454 | tideland/golib | monitoring/standardbackend.go | SetMeasuringsFilter | func (b *stdBackend) SetMeasuringsFilter(f IDFilter) IDFilter {
old := b.etmFilter
b.etmFilter = f
return old
} | go | func (b *stdBackend) SetMeasuringsFilter(f IDFilter) IDFilter {
old := b.etmFilter
b.etmFilter = f
return old
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"SetMeasuringsFilter",
"(",
"f",
"IDFilter",
")",
"IDFilter",
"{",
"old",
":=",
"b",
".",
"etmFilter",
"\n",
"b",
".",
"etmFilter",
"=",
"f",
"\n",
"return",
"old",
"\n",
"}"
] | // SetMeasuringsFilter implements the MonitorBackend interface. | [
"SetMeasuringsFilter",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L384-L388 |
150,455 | tideland/golib | monitoring/standardbackend.go | SetVariablesFilter | func (b *stdBackend) SetVariablesFilter(f IDFilter) IDFilter {
old := b.ssvFilter
b.ssvFilter = f
return old
} | go | func (b *stdBackend) SetVariablesFilter(f IDFilter) IDFilter {
old := b.ssvFilter
b.ssvFilter = f
return old
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"SetVariablesFilter",
"(",
"f",
"IDFilter",
")",
"IDFilter",
"{",
"old",
":=",
"b",
".",
"ssvFilter",
"\n",
"b",
".",
"ssvFilter",
"=",
"f",
"\n",
"return",
"old",
"\n",
"}"
] | // SetVariablesFilter implements the MonitorBackend interface. | [
"SetVariablesFilter",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L391-L395 |
150,456 | tideland/golib | monitoring/standardbackend.go | SetRetrieversFilter | func (b *stdBackend) SetRetrieversFilter(f IDFilter) IDFilter {
old := b.dsrFilter
b.dsrFilter = f
return old
} | go | func (b *stdBackend) SetRetrieversFilter(f IDFilter) IDFilter {
old := b.dsrFilter
b.dsrFilter = f
return old
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"SetRetrieversFilter",
"(",
"f",
"IDFilter",
")",
"IDFilter",
"{",
"old",
":=",
"b",
".",
"dsrFilter",
"\n",
"b",
".",
"dsrFilter",
"=",
"f",
"\n",
"return",
"old",
"\n",
"}"
] | // SetRetrieversFilter implements the MonitorBackend interface. | [
"SetRetrieversFilter",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L398-L402 |
150,457 | tideland/golib | monitoring/standardbackend.go | Reset | func (b *stdBackend) Reset() error {
_, err := b.command(cmdReset, nil)
if err != nil {
return err
}
return nil
} | go | func (b *stdBackend) Reset() error {
_, err := b.command(cmdReset, nil)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"Reset",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"b",
".",
"command",
"(",
"cmdReset",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n... | // Reset implements the MonitorBackend interface. | [
"Reset",
"implements",
"the",
"MonitorBackend",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L405-L411 |
150,458 | tideland/golib | monitoring/standardbackend.go | command | func (b *stdBackend) command(opCode int, args interface{}) (interface{}, error) {
cmd := &command{opCode, args, make(chan interface{})}
b.commandC <- cmd
resp, ok := <-cmd.respChan
if !ok {
return nil, errors.New(ErrMonitoringPanicked, errorMessages)
}
if err, ok := resp.(error); ok {
return nil, err
}
retu... | go | func (b *stdBackend) command(opCode int, args interface{}) (interface{}, error) {
cmd := &command{opCode, args, make(chan interface{})}
b.commandC <- cmd
resp, ok := <-cmd.respChan
if !ok {
return nil, errors.New(ErrMonitoringPanicked, errorMessages)
}
if err, ok := resp.(error); ok {
return nil, err
}
retu... | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"command",
"(",
"opCode",
"int",
",",
"args",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"cmd",
":=",
"&",
"command",
"{",
"opCode",
",",
"args",
",",
"make",
"(",
"ch... | // command sends a command to the system monitor and waits for a response. | [
"command",
"sends",
"a",
"command",
"to",
"the",
"system",
"monitor",
"and",
"waits",
"for",
"a",
"response",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L419-L430 |
150,459 | tideland/golib | monitoring/standardbackend.go | init | func (b *stdBackend) init() {
b.etmData = make(map[string]*stdMeasuringPoint)
b.ssvData = make(map[string]*stdStaySetVariable)
b.dsrData = make(map[string]DynamicStatusRetriever)
} | go | func (b *stdBackend) init() {
b.etmData = make(map[string]*stdMeasuringPoint)
b.ssvData = make(map[string]*stdStaySetVariable)
b.dsrData = make(map[string]DynamicStatusRetriever)
} | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"init",
"(",
")",
"{",
"b",
".",
"etmData",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"stdMeasuringPoint",
")",
"\n",
"b",
".",
"ssvData",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"stdSta... | // init the system monitor. | [
"init",
"the",
"system",
"monitor",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L433-L437 |
150,460 | tideland/golib | monitoring/standardbackend.go | backendLoop | func (b *stdBackend) backendLoop(l loop.Loop) error {
// Init the monitor.
b.init()
// Run loop.
for {
select {
case <-l.ShallStop():
return nil
case measuring := <-b.measuringC:
// Received a new measuring.
if mp, ok := b.etmData[measuring.id]; ok {
mp.update(measuring)
} else {
b.etmData... | go | func (b *stdBackend) backendLoop(l loop.Loop) error {
// Init the monitor.
b.init()
// Run loop.
for {
select {
case <-l.ShallStop():
return nil
case measuring := <-b.measuringC:
// Received a new measuring.
if mp, ok := b.etmData[measuring.id]; ok {
mp.update(measuring)
} else {
b.etmData... | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"backendLoop",
"(",
"l",
"loop",
".",
"Loop",
")",
"error",
"{",
"// Init the monitor.",
"b",
".",
"init",
"(",
")",
"\n",
"// Run loop.",
"for",
"{",
"select",
"{",
"case",
"<-",
"l",
".",
"ShallStop",
"(",
... | // backendLoop runs the system monitor. | [
"backendLoop",
"runs",
"the",
"system",
"monitor",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L440-L470 |
150,461 | tideland/golib | monitoring/standardbackend.go | processCommand | func (b *stdBackend) processCommand(cmd *command) {
defer cmd.close()
switch cmd.opCode {
case cmdReset:
// Reset monitoring.
b.init()
cmd.ok()
case cmdMeasuringPointRead:
// Read just one measuring point.
id := cmd.args.(string)
if mp, ok := b.etmData[id]; ok {
// Measuring point found.
clone := ... | go | func (b *stdBackend) processCommand(cmd *command) {
defer cmd.close()
switch cmd.opCode {
case cmdReset:
// Reset monitoring.
b.init()
cmd.ok()
case cmdMeasuringPointRead:
// Read just one measuring point.
id := cmd.args.(string)
if mp, ok := b.etmData[id]; ok {
// Measuring point found.
clone := ... | [
"func",
"(",
"b",
"*",
"stdBackend",
")",
"processCommand",
"(",
"cmd",
"*",
"command",
")",
"{",
"defer",
"cmd",
".",
"close",
"(",
")",
"\n",
"switch",
"cmd",
".",
"opCode",
"{",
"case",
"cmdReset",
":",
"// Reset monitoring.",
"b",
".",
"init",
"(",... | // processCommand handles the received commands of the monitor. | [
"processCommand",
"handles",
"the",
"received",
"commands",
"of",
"the",
"monitor",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/standardbackend.go#L473-L549 |
150,462 | tideland/golib | errors/errors.go | Format | func (m Messages) Format(code int, args ...interface{}) string {
if m == nil || m[code] == "" {
if len(args) == 0 {
return fmt.Sprintf("[ERRORS:999] invalid error code '%d'", code)
}
format := fmt.Sprintf("%v", args[0])
return fmt.Sprintf(format, args[1:]...)
}
format := m[code]
return fmt.Sprintf(format... | go | func (m Messages) Format(code int, args ...interface{}) string {
if m == nil || m[code] == "" {
if len(args) == 0 {
return fmt.Sprintf("[ERRORS:999] invalid error code '%d'", code)
}
format := fmt.Sprintf("%v", args[0])
return fmt.Sprintf(format, args[1:]...)
}
format := m[code]
return fmt.Sprintf(format... | [
"func",
"(",
"m",
"Messages",
")",
"Format",
"(",
"code",
"int",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"string",
"{",
"if",
"m",
"==",
"nil",
"||",
"m",
"[",
"code",
"]",
"==",
"\"",
"\"",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"... | // Format returns the formatted error message for code with the
// given arguments. | [
"Format",
"returns",
"the",
"formatted",
"error",
"message",
"for",
"code",
"with",
"the",
"given",
"arguments",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L30-L40 |
150,463 | tideland/golib | errors/errors.go | newErrorBox | func newErrorBox(err error, code int, msgs Messages, args ...interface{}) *errorBox {
return &errorBox{
err: err,
code: code,
msg: msgs.Format(code, args...),
info: retrieveCallInfo(),
}
} | go | func newErrorBox(err error, code int, msgs Messages, args ...interface{}) *errorBox {
return &errorBox{
err: err,
code: code,
msg: msgs.Format(code, args...),
info: retrieveCallInfo(),
}
} | [
"func",
"newErrorBox",
"(",
"err",
"error",
",",
"code",
"int",
",",
"msgs",
"Messages",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"errorBox",
"{",
"return",
"&",
"errorBox",
"{",
"err",
":",
"err",
",",
"code",
":",
"code",
",",
"msg",
... | // newErrorBox creates an initialized error box. | [
"newErrorBox",
"creates",
"an",
"initialized",
"error",
"box",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L72-L79 |
150,464 | tideland/golib | errors/errors.go | Annotate | func Annotate(err error, code int, msgs Messages, args ...interface{}) error {
return newErrorBox(err, code, msgs, args...)
} | go | func Annotate(err error, code int, msgs Messages, args ...interface{}) error {
return newErrorBox(err, code, msgs, args...)
} | [
"func",
"Annotate",
"(",
"err",
"error",
",",
"code",
"int",
",",
"msgs",
"Messages",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"newErrorBox",
"(",
"err",
",",
"code",
",",
"msgs",
",",
"args",
"...",
")",
"\n",
"}"
] | // Annotate creates an error wrapping another one together with a
// a code. | [
"Annotate",
"creates",
"an",
"error",
"wrapping",
"another",
"one",
"together",
"with",
"a",
"a",
"code",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L105-L107 |
150,465 | tideland/golib | errors/errors.go | New | func New(code int, msgs Messages, args ...interface{}) error {
return newErrorBox(nil, code, msgs, args...)
} | go | func New(code int, msgs Messages, args ...interface{}) error {
return newErrorBox(nil, code, msgs, args...)
} | [
"func",
"New",
"(",
"code",
"int",
",",
"msgs",
"Messages",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"newErrorBox",
"(",
"nil",
",",
"code",
",",
"msgs",
",",
"args",
"...",
")",
"\n",
"}"
] | // New creates an error with the given code. | [
"New",
"creates",
"an",
"error",
"with",
"the",
"given",
"code",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L110-L112 |
150,466 | tideland/golib | errors/errors.go | IsError | func IsError(err error, code int) bool {
if e, ok := err.(*errorBox); ok {
return e.code == code
}
return false
} | go | func IsError(err error, code int) bool {
if e, ok := err.(*errorBox); ok {
return e.code == code
}
return false
} | [
"func",
"IsError",
"(",
"err",
"error",
",",
"code",
"int",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"errorBox",
")",
";",
"ok",
"{",
"return",
"e",
".",
"code",
"==",
"code",
"\n",
"}",
"\n",
"return",
"false",
"\n",... | // IsError checks if an error is one created by this
// package and has the passed code | [
"IsError",
"checks",
"if",
"an",
"error",
"is",
"one",
"created",
"by",
"this",
"package",
"and",
"has",
"the",
"passed",
"code"
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L130-L135 |
150,467 | tideland/golib | errors/errors.go | Annotated | func Annotated(err error) error {
if e, ok := err.(*errorBox); ok {
return e.err
}
return New(ErrInvalidErrorType, errorMessages, err, err)
} | go | func Annotated(err error) error {
if e, ok := err.(*errorBox); ok {
return e.err
}
return New(ErrInvalidErrorType, errorMessages, err, err)
} | [
"func",
"Annotated",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"errorBox",
")",
";",
"ok",
"{",
"return",
"e",
".",
"err",
"\n",
"}",
"\n",
"return",
"New",
"(",
"ErrInvalidErrorType",
",",
"errorMess... | // Annotated returns the possibly annotated error. In case of
// a different error an invalid type error is returned. | [
"Annotated",
"returns",
"the",
"possibly",
"annotated",
"error",
".",
"In",
"case",
"of",
"a",
"different",
"error",
"an",
"invalid",
"type",
"error",
"is",
"returned",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L139-L144 |
150,468 | tideland/golib | errors/errors.go | Location | func Location(err error) (string, string, int, error) {
if e, ok := err.(*errorBox); ok {
return e.info.packageName, e.info.fileName, e.info.line, nil
}
return "", "", 0, New(ErrInvalidErrorType, errorMessages, err, err)
} | go | func Location(err error) (string, string, int, error) {
if e, ok := err.(*errorBox); ok {
return e.info.packageName, e.info.fileName, e.info.line, nil
}
return "", "", 0, New(ErrInvalidErrorType, errorMessages, err, err)
} | [
"func",
"Location",
"(",
"err",
"error",
")",
"(",
"string",
",",
"string",
",",
"int",
",",
"error",
")",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"errorBox",
")",
";",
"ok",
"{",
"return",
"e",
".",
"info",
".",
"packageName",
"... | // Location returns the package and the file name as well as the line
// number of the error. | [
"Location",
"returns",
"the",
"package",
"and",
"the",
"file",
"name",
"as",
"well",
"as",
"the",
"line",
"number",
"of",
"the",
"error",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L148-L153 |
150,469 | tideland/golib | errors/errors.go | Stack | func Stack(err error) []error {
if eb, ok := err.(*errorBox); ok {
return append([]error{eb}, Stack(eb.err)...)
}
return []error{err}
} | go | func Stack(err error) []error {
if eb, ok := err.(*errorBox); ok {
return append([]error{eb}, Stack(eb.err)...)
}
return []error{err}
} | [
"func",
"Stack",
"(",
"err",
"error",
")",
"[",
"]",
"error",
"{",
"if",
"eb",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"errorBox",
")",
";",
"ok",
"{",
"return",
"append",
"(",
"[",
"]",
"error",
"{",
"eb",
"}",
",",
"Stack",
"(",
"eb",
".",
... | // Stack returns a slice of errors down to the first
// non-errors error in case of annotated errors. | [
"Stack",
"returns",
"a",
"slice",
"of",
"errors",
"down",
"to",
"the",
"first",
"non",
"-",
"errors",
"error",
"in",
"case",
"of",
"annotated",
"errors",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L157-L162 |
150,470 | tideland/golib | errors/errors.go | All | func All(err error) []error {
if ec, ok := err.(*errorCollection); ok {
all := make([]error, len(ec.errs))
copy(all, ec.errs)
return all
}
return []error{err}
} | go | func All(err error) []error {
if ec, ok := err.(*errorCollection); ok {
all := make([]error, len(ec.errs))
copy(all, ec.errs)
return all
}
return []error{err}
} | [
"func",
"All",
"(",
"err",
"error",
")",
"[",
"]",
"error",
"{",
"if",
"ec",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"errorCollection",
")",
";",
"ok",
"{",
"all",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"len",
"(",
"ec",
".",
"errs",
")",
... | // All returns a slice of errors in case of collected errors. | [
"All",
"returns",
"a",
"slice",
"of",
"errors",
"in",
"case",
"of",
"collected",
"errors",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L165-L172 |
150,471 | tideland/golib | errors/errors.go | DoAll | func DoAll(err error, f func(error)) {
switch terr := err.(type) {
case *errorBox:
for _, serr := range Stack(err) {
f(serr)
}
case *errorCollection:
for _, aerr := range All(err) {
f(aerr)
}
default:
f(terr)
}
} | go | func DoAll(err error, f func(error)) {
switch terr := err.(type) {
case *errorBox:
for _, serr := range Stack(err) {
f(serr)
}
case *errorCollection:
for _, aerr := range All(err) {
f(aerr)
}
default:
f(terr)
}
} | [
"func",
"DoAll",
"(",
"err",
"error",
",",
"f",
"func",
"(",
"error",
")",
")",
"{",
"switch",
"terr",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"*",
"errorBox",
":",
"for",
"_",
",",
"serr",
":=",
"range",
"Stack",
"(",
"err",
")",
"{",... | // DoAll iterates the passed function over all stacked
// or collected errors or simply the one that's passed. | [
"DoAll",
"iterates",
"the",
"passed",
"function",
"over",
"all",
"stacked",
"or",
"collected",
"errors",
"or",
"simply",
"the",
"one",
"that",
"s",
"passed",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/errors/errors.go#L176-L189 |
150,472 | tideland/golib | stringex/processor.go | WrapProcessorFunc | func WrapProcessorFunc(f func(fin string) string) ProcessorFunc {
return func(in string) (string, bool) {
return f(in), true
}
} | go | func WrapProcessorFunc(f func(fin string) string) ProcessorFunc {
return func(in string) (string, bool) {
return f(in), true
}
} | [
"func",
"WrapProcessorFunc",
"(",
"f",
"func",
"(",
"fin",
"string",
")",
"string",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"return",
"f",
"(",
"in",
")",
",",
"true",
"\n",
"}",
... | // WrapProcessorFunc takes a standard string processing function and
// returns it as a ProcessorFunc. | [
"WrapProcessorFunc",
"takes",
"a",
"standard",
"string",
"processing",
"function",
"and",
"returns",
"it",
"as",
"a",
"ProcessorFunc",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L46-L50 |
150,473 | tideland/golib | stringex/processor.go | errorProcessorFunc | func errorProcessorFunc(err error) ProcessorFunc {
return func(in string) (string, bool) {
return fmt.Sprintf("error processing '%s': %v", in, err), false
}
} | go | func errorProcessorFunc(err error) ProcessorFunc {
return func(in string) (string, bool) {
return fmt.Sprintf("error processing '%s': %v", in, err), false
}
} | [
"func",
"errorProcessorFunc",
"(",
"err",
"error",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"in",
",",
"err",
")",
",",
"false"... | // errorProcessorFunc returns a processor func used in case of failing
// preparation steps. | [
"errorProcessorFunc",
"returns",
"a",
"processor",
"func",
"used",
"in",
"case",
"of",
"failing",
"preparation",
"steps",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L54-L58 |
150,474 | tideland/golib | stringex/processor.go | NewConditionProcessor | func NewConditionProcessor(decider, affirmer, negater Processor) ProcessorFunc {
return func(in string) (string, bool) {
temp, ok := decider.Process(in)
if ok {
return affirmer.Process(temp)
}
return negater.Process(temp)
}
} | go | func NewConditionProcessor(decider, affirmer, negater Processor) ProcessorFunc {
return func(in string) (string, bool) {
temp, ok := decider.Process(in)
if ok {
return affirmer.Process(temp)
}
return negater.Process(temp)
}
} | [
"func",
"NewConditionProcessor",
"(",
"decider",
",",
"affirmer",
",",
"negater",
"Processor",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"temp",
",",
"ok",
":=",
"decider",
".",
"Process",
... | // NewConditionProcessor creates a processor taking the first processor
// for creating a temporary result and a decision. Based on the decision
// the temporary result is passed to an affirmer or a negater. | [
"NewConditionProcessor",
"creates",
"a",
"processor",
"taking",
"the",
"first",
"processor",
"for",
"creating",
"a",
"temporary",
"result",
"and",
"a",
"decision",
".",
"Based",
"on",
"the",
"decision",
"the",
"temporary",
"result",
"is",
"passed",
"to",
"an",
... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L82-L90 |
150,475 | tideland/golib | stringex/processor.go | NewSplitMapProcessor | func NewSplitMapProcessor(sep string, mapper Processor) ProcessorFunc {
return func(in string) (string, bool) {
parts := strings.Split(in, sep)
out := []string{}
for _, part := range parts {
if mp, ok := mapper.Process(part); ok {
out = append(out, mp)
}
}
return strings.Join(out, sep), true
}
} | go | func NewSplitMapProcessor(sep string, mapper Processor) ProcessorFunc {
return func(in string) (string, bool) {
parts := strings.Split(in, sep)
out := []string{}
for _, part := range parts {
if mp, ok := mapper.Process(part); ok {
out = append(out, mp)
}
}
return strings.Join(out, sep), true
}
} | [
"func",
"NewSplitMapProcessor",
"(",
"sep",
"string",
",",
"mapper",
"Processor",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"in",
",",
"sep",
... | // NewSplitMapProcessor creates a processor splitting the input and
// mapping the parts. It will only contain those where the mapper
// returns true. So it can be used as a filter too. Afterwards the
// collected mapped parts are joined again. | [
"NewSplitMapProcessor",
"creates",
"a",
"processor",
"splitting",
"the",
"input",
"and",
"mapping",
"the",
"parts",
".",
"It",
"will",
"only",
"contain",
"those",
"where",
"the",
"mapper",
"returns",
"true",
".",
"So",
"it",
"can",
"be",
"used",
"as",
"a",
... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L109-L120 |
150,476 | tideland/golib | stringex/processor.go | NewSubstringProcessor | func NewSubstringProcessor(index, length int) ProcessorFunc {
return func(in string) (string, bool) {
if length < 1 {
return "", false
}
if index < 0 {
index = 0
}
if index >= len(in) {
return "", true
}
out := in[index:]
if length > len(out) {
length = len(out)
}
return out[:length], t... | go | func NewSubstringProcessor(index, length int) ProcessorFunc {
return func(in string) (string, bool) {
if length < 1 {
return "", false
}
if index < 0 {
index = 0
}
if index >= len(in) {
return "", true
}
out := in[index:]
if length > len(out) {
length = len(out)
}
return out[:length], t... | [
"func",
"NewSubstringProcessor",
"(",
"index",
",",
"length",
"int",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"length",
"<",
"1",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
... | // NewSubstringProcessor returns a processor slicing the input
// based on the index and length. | [
"NewSubstringProcessor",
"returns",
"a",
"processor",
"slicing",
"the",
"input",
"based",
"on",
"the",
"index",
"and",
"length",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L124-L141 |
150,477 | tideland/golib | stringex/processor.go | NewMatchProcessor | func NewMatchProcessor(pattern string) ProcessorFunc {
r, err := regexp.Compile(pattern)
if err != nil {
return errorProcessorFunc(err)
}
return func(in string) (string, bool) {
return in, r.MatchString(in)
}
} | go | func NewMatchProcessor(pattern string) ProcessorFunc {
r, err := regexp.Compile(pattern)
if err != nil {
return errorProcessorFunc(err)
}
return func(in string) (string, bool) {
return in, r.MatchString(in)
}
} | [
"func",
"NewMatchProcessor",
"(",
"pattern",
"string",
")",
"ProcessorFunc",
"{",
"r",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"pattern",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errorProcessorFunc",
"(",
"err",
")",
"\n",
"}",
"\n",... | // NewMatchProcessor returns a processor evaluating the input
// against a given pattern and returns the input and true
// when it is matching. | [
"NewMatchProcessor",
"returns",
"a",
"processor",
"evaluating",
"the",
"input",
"against",
"a",
"given",
"pattern",
"and",
"returns",
"the",
"input",
"and",
"true",
"when",
"it",
"is",
"matching",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L146-L154 |
150,478 | tideland/golib | stringex/processor.go | NewTrimFuncProcessor | func NewTrimFuncProcessor(f func(r rune) bool) ProcessorFunc {
return func(in string) (string, bool) {
return strings.TrimFunc(in, f), true
}
} | go | func NewTrimFuncProcessor(f func(r rune) bool) ProcessorFunc {
return func(in string) (string, bool) {
return strings.TrimFunc(in, f), true
}
} | [
"func",
"NewTrimFuncProcessor",
"(",
"f",
"func",
"(",
"r",
"rune",
")",
"bool",
")",
"ProcessorFunc",
"{",
"return",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"return",
"strings",
".",
"TrimFunc",
"(",
"in",
",",
"f",
"... | // NewTrimFuncProcessor returns a processor trimming prefix and
// suffix of the input based on the return value of the passed
// function checking each rune. | [
"NewTrimFuncProcessor",
"returns",
"a",
"processor",
"trimming",
"prefix",
"and",
"suffix",
"of",
"the",
"input",
"based",
"on",
"the",
"return",
"value",
"of",
"the",
"passed",
"function",
"checking",
"each",
"rune",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L159-L163 |
150,479 | tideland/golib | stringex/processor.go | NewTrimPrefixProcessor | func NewTrimPrefixProcessor(prefix string) ProcessorFunc {
prefixTrimmer := func(in string) (string, bool) {
out := strings.TrimPrefix(in, prefix)
return out, out != in
}
return NewLoopProcessor(ProcessorFunc(prefixTrimmer))
} | go | func NewTrimPrefixProcessor(prefix string) ProcessorFunc {
prefixTrimmer := func(in string) (string, bool) {
out := strings.TrimPrefix(in, prefix)
return out, out != in
}
return NewLoopProcessor(ProcessorFunc(prefixTrimmer))
} | [
"func",
"NewTrimPrefixProcessor",
"(",
"prefix",
"string",
")",
"ProcessorFunc",
"{",
"prefixTrimmer",
":=",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"out",
":=",
"strings",
".",
"TrimPrefix",
"(",
"in",
",",
"prefix",
")",
... | // NewTrimPrefixProcessor returns a processor trimming a prefix of
// the input as long as it can find it. | [
"NewTrimPrefixProcessor",
"returns",
"a",
"processor",
"trimming",
"a",
"prefix",
"of",
"the",
"input",
"as",
"long",
"as",
"it",
"can",
"find",
"it",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L167-L173 |
150,480 | tideland/golib | stringex/processor.go | NewTrimSuffixProcessor | func NewTrimSuffixProcessor(prefix string) ProcessorFunc {
suffixTrimmer := func(in string) (string, bool) {
out := strings.TrimSuffix(in, prefix)
return out, out != in
}
return NewLoopProcessor(ProcessorFunc(suffixTrimmer))
} | go | func NewTrimSuffixProcessor(prefix string) ProcessorFunc {
suffixTrimmer := func(in string) (string, bool) {
out := strings.TrimSuffix(in, prefix)
return out, out != in
}
return NewLoopProcessor(ProcessorFunc(suffixTrimmer))
} | [
"func",
"NewTrimSuffixProcessor",
"(",
"prefix",
"string",
")",
"ProcessorFunc",
"{",
"suffixTrimmer",
":=",
"func",
"(",
"in",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"out",
":=",
"strings",
".",
"TrimSuffix",
"(",
"in",
",",
"prefix",
")",
... | // NewTrimSuffixProcessor returns a processor trimming a prefix of
// the input as long as it can find it. | [
"NewTrimSuffixProcessor",
"returns",
"a",
"processor",
"trimming",
"a",
"prefix",
"of",
"the",
"input",
"as",
"long",
"as",
"it",
"can",
"find",
"it",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/processor.go#L177-L183 |
150,481 | tideland/golib | scene/scene.go | StartLimited | func StartLimited(inactivity, absolute time.Duration) Scene {
s := &scene{
id: identifier.NewUUID(),
props: make(map[string]*box),
flags: make(map[string]bool),
signalings: make(map[string][]chan struct{}),
inactivity: inactivity,
absolute: absolute,
commandChan: make(chan *enve... | go | func StartLimited(inactivity, absolute time.Duration) Scene {
s := &scene{
id: identifier.NewUUID(),
props: make(map[string]*box),
flags: make(map[string]bool),
signalings: make(map[string][]chan struct{}),
inactivity: inactivity,
absolute: absolute,
commandChan: make(chan *enve... | [
"func",
"StartLimited",
"(",
"inactivity",
",",
"absolute",
"time",
".",
"Duration",
")",
"Scene",
"{",
"s",
":=",
"&",
"scene",
"{",
"id",
":",
"identifier",
".",
"NewUUID",
"(",
")",
",",
"props",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
... | // StartLimited creates and runs a new scene with an inactivity
// and an absolute timeout. They may be zero. | [
"StartLimited",
"creates",
"and",
"runs",
"a",
"new",
"scene",
"with",
"an",
"inactivity",
"and",
"an",
"absolute",
"timeout",
".",
"They",
"may",
"be",
"zero",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L152-L164 |
150,482 | tideland/golib | scene/scene.go | Store | func (s *scene) Store(key string, prop interface{}) error {
return s.StoreClean(key, prop, nil)
} | go | func (s *scene) Store(key string, prop interface{}) error {
return s.StoreClean(key, prop, nil)
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"Store",
"(",
"key",
"string",
",",
"prop",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"s",
".",
"StoreClean",
"(",
"key",
",",
"prop",
",",
"nil",
")",
"\n",
"}"
] | // Store is specified on the Scene interface. | [
"Store",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L192-L194 |
150,483 | tideland/golib | scene/scene.go | StoreAndFlag | func (s *scene) StoreAndFlag(key string, prop interface{}) error {
err := s.StoreClean(key, prop, nil)
if err != nil {
return err
}
return s.Flag(key)
} | go | func (s *scene) StoreAndFlag(key string, prop interface{}) error {
err := s.StoreClean(key, prop, nil)
if err != nil {
return err
}
return s.Flag(key)
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"StoreAndFlag",
"(",
"key",
"string",
",",
"prop",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"s",
".",
"StoreClean",
"(",
"key",
",",
"prop",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // StoreAndFlag is specified on the Scene interface. | [
"StoreAndFlag",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L197-L203 |
150,484 | tideland/golib | scene/scene.go | StoreClean | func (s *scene) StoreClean(key string, prop interface{}, cleanup CleanupFunc) error {
command := &envelope{
kind: storeProp,
box: &box{
key: key,
prop: prop,
cleanup: cleanup,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | go | func (s *scene) StoreClean(key string, prop interface{}, cleanup CleanupFunc) error {
command := &envelope{
kind: storeProp,
box: &box{
key: key,
prop: prop,
cleanup: cleanup,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"StoreClean",
"(",
"key",
"string",
",",
"prop",
"interface",
"{",
"}",
",",
"cleanup",
"CleanupFunc",
")",
"error",
"{",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"storeProp",
",",
"box",
":",
"&",
"box... | // StoreClean is specified on the Scene interface. | [
"StoreClean",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L206-L218 |
150,485 | tideland/golib | scene/scene.go | StoreCleanAndFlag | func (s *scene) StoreCleanAndFlag(key string, prop interface{}, cleanup CleanupFunc) error {
err := s.StoreClean(key, prop, cleanup)
if err != nil {
return err
}
return s.Flag(key)
} | go | func (s *scene) StoreCleanAndFlag(key string, prop interface{}, cleanup CleanupFunc) error {
err := s.StoreClean(key, prop, cleanup)
if err != nil {
return err
}
return s.Flag(key)
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"StoreCleanAndFlag",
"(",
"key",
"string",
",",
"prop",
"interface",
"{",
"}",
",",
"cleanup",
"CleanupFunc",
")",
"error",
"{",
"err",
":=",
"s",
".",
"StoreClean",
"(",
"key",
",",
"prop",
",",
"cleanup",
")",
"... | // StoreCleanAndFlag is specified on the Scene interface. | [
"StoreCleanAndFlag",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L221-L227 |
150,486 | tideland/golib | scene/scene.go | Fetch | func (s *scene) Fetch(key string) (interface{}, error) {
command := &envelope{
kind: fetchProp,
box: &box{
key: key,
},
respChan: make(chan *envelope, 1),
}
resp, err := s.command(command)
if err != nil {
return nil, err
}
return resp.box.prop, nil
} | go | func (s *scene) Fetch(key string) (interface{}, error) {
command := &envelope{
kind: fetchProp,
box: &box{
key: key,
},
respChan: make(chan *envelope, 1),
}
resp, err := s.command(command)
if err != nil {
return nil, err
}
return resp.box.prop, nil
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"Fetch",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"fetchProp",
",",
"box",
":",
"&",
"box",
"{",
"key",
":",
"key",
"... | // Fetch is specified on the Scene interface. | [
"Fetch",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L230-L243 |
150,487 | tideland/golib | scene/scene.go | Dispose | func (s *scene) Dispose(key string) (interface{}, error) {
command := &envelope{
kind: disposeProp,
box: &box{
key: key,
},
respChan: make(chan *envelope, 1),
}
resp, err := s.command(command)
if err != nil {
return nil, err
}
return resp.box.prop, nil
} | go | func (s *scene) Dispose(key string) (interface{}, error) {
command := &envelope{
kind: disposeProp,
box: &box{
key: key,
},
respChan: make(chan *envelope, 1),
}
resp, err := s.command(command)
if err != nil {
return nil, err
}
return resp.box.prop, nil
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"Dispose",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"disposeProp",
",",
"box",
":",
"&",
"box",
"{",
"key",
":",
"key",... | // Dispose is specified on the Scene interface. | [
"Dispose",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L246-L259 |
150,488 | tideland/golib | scene/scene.go | Flag | func (s *scene) Flag(topic string) error {
command := &envelope{
kind: flag,
signaling: &signaling{
topic: topic,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | go | func (s *scene) Flag(topic string) error {
command := &envelope{
kind: flag,
signaling: &signaling{
topic: topic,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"Flag",
"(",
"topic",
"string",
")",
"error",
"{",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"flag",
",",
"signaling",
":",
"&",
"signaling",
"{",
"topic",
":",
"topic",
",",
"}",
",",
"respChan",
":",... | // Flag is specified on the Scene interface. | [
"Flag",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L262-L272 |
150,489 | tideland/golib | scene/scene.go | Unflag | func (s *scene) Unflag(topic string) error {
command := &envelope{
kind: unflag,
signaling: &signaling{
topic: topic,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | go | func (s *scene) Unflag(topic string) error {
command := &envelope{
kind: unflag,
signaling: &signaling{
topic: topic,
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
return err
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"Unflag",
"(",
"topic",
"string",
")",
"error",
"{",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"unflag",
",",
"signaling",
":",
"&",
"signaling",
"{",
"topic",
":",
"topic",
",",
"}",
",",
"respChan",
... | // Unflag is specified on the Scene interface. | [
"Unflag",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L275-L285 |
150,490 | tideland/golib | scene/scene.go | WaitFlagAndFetch | func (s *scene) WaitFlagAndFetch(topic string) (interface{}, error) {
err := s.WaitFlag(topic)
if err != nil {
return nil, err
}
return s.Fetch(topic)
} | go | func (s *scene) WaitFlagAndFetch(topic string) (interface{}, error) {
err := s.WaitFlag(topic)
if err != nil {
return nil, err
}
return s.Fetch(topic)
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"WaitFlagAndFetch",
"(",
"topic",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"WaitFlag",
"(",
"topic",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // WaitFlagAndFetch is specified on the Scene interface. | [
"WaitFlagAndFetch",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L293-L299 |
150,491 | tideland/golib | scene/scene.go | WaitFlagLimited | func (s *scene) WaitFlagLimited(topic string, timeout time.Duration) error {
// Add signal channel.
command := &envelope{
kind: wait,
signaling: &signaling{
topic: topic,
signalChan: make(chan struct{}, 1),
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
if err != nil {
re... | go | func (s *scene) WaitFlagLimited(topic string, timeout time.Duration) error {
// Add signal channel.
command := &envelope{
kind: wait,
signaling: &signaling{
topic: topic,
signalChan: make(chan struct{}, 1),
},
respChan: make(chan *envelope, 1),
}
_, err := s.command(command)
if err != nil {
re... | [
"func",
"(",
"s",
"*",
"scene",
")",
"WaitFlagLimited",
"(",
"topic",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"// Add signal channel.",
"command",
":=",
"&",
"envelope",
"{",
"kind",
":",
"wait",
",",
"signaling",
":",
"&",
... | // WaitFlagLimited is specified on the Scene interface. | [
"WaitFlagLimited",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L302-L333 |
150,492 | tideland/golib | scene/scene.go | WaitFlagLimitedAndFetch | func (s *scene) WaitFlagLimitedAndFetch(topic string, timeout time.Duration) (interface{}, error) {
err := s.WaitFlagLimited(topic, timeout)
if err != nil {
return nil, err
}
return s.Fetch(topic)
} | go | func (s *scene) WaitFlagLimitedAndFetch(topic string, timeout time.Duration) (interface{}, error) {
err := s.WaitFlagLimited(topic, timeout)
if err != nil {
return nil, err
}
return s.Fetch(topic)
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"WaitFlagLimitedAndFetch",
"(",
"topic",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"WaitFlagLimited",
"(",
"topic",
",",
"time... | // WaitFlagLimitedAndFetch is specified on the Scene interface. | [
"WaitFlagLimitedAndFetch",
"is",
"specified",
"on",
"the",
"Scene",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L336-L342 |
150,493 | tideland/golib | scene/scene.go | command | func (s *scene) command(command *envelope) (*envelope, error) {
select {
case s.commandChan <- command:
case <-s.backend.IsStopping():
err := s.Wait()
if err == nil {
err = errors.New(ErrSceneEnded, errorMessages)
}
return nil, err
}
select {
case <-s.backend.IsStopping():
err := s.Wait()
if err ==... | go | func (s *scene) command(command *envelope) (*envelope, error) {
select {
case s.commandChan <- command:
case <-s.backend.IsStopping():
err := s.Wait()
if err == nil {
err = errors.New(ErrSceneEnded, errorMessages)
}
return nil, err
}
select {
case <-s.backend.IsStopping():
err := s.Wait()
if err ==... | [
"func",
"(",
"s",
"*",
"scene",
")",
"command",
"(",
"command",
"*",
"envelope",
")",
"(",
"*",
"envelope",
",",
"error",
")",
"{",
"select",
"{",
"case",
"s",
".",
"commandChan",
"<-",
"command",
":",
"case",
"<-",
"s",
".",
"backend",
".",
"IsSto... | // command sends a command envelope to the backend and
// waits for the response. | [
"command",
"sends",
"a",
"command",
"envelope",
"to",
"the",
"backend",
"and",
"waits",
"for",
"the",
"response",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L346-L369 |
150,494 | tideland/golib | scene/scene.go | backendLoop | func (s *scene) backendLoop(l loop.Loop) (err error) {
// Defer cleanup.
defer func() {
cerr := s.cleanupAllProps()
if err == nil {
err = cerr
}
}()
// Init timers.
var watchdog <-chan time.Time
var clapperboard <-chan time.Time
if s.absolute > 0 {
clapperboard = time.After(s.absolute)
}
// Run loop... | go | func (s *scene) backendLoop(l loop.Loop) (err error) {
// Defer cleanup.
defer func() {
cerr := s.cleanupAllProps()
if err == nil {
err = cerr
}
}()
// Init timers.
var watchdog <-chan time.Time
var clapperboard <-chan time.Time
if s.absolute > 0 {
clapperboard = time.After(s.absolute)
}
// Run loop... | [
"func",
"(",
"s",
"*",
"scene",
")",
"backendLoop",
"(",
"l",
"loop",
".",
"Loop",
")",
"(",
"err",
"error",
")",
"{",
"// Defer cleanup.",
"defer",
"func",
"(",
")",
"{",
"cerr",
":=",
"s",
".",
"cleanupAllProps",
"(",
")",
"\n",
"if",
"err",
"=="... | // backendLoop runs the backend loop of the scene. | [
"backendLoop",
"runs",
"the",
"backend",
"loop",
"of",
"the",
"scene",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L372-L402 |
150,495 | tideland/golib | scene/scene.go | processCommand | func (s *scene) processCommand(command *envelope) {
switch command.kind {
case storeProp:
// Add a new prop.
_, ok := s.props[command.box.key]
if ok {
command.err = errors.New(ErrPropAlreadyExist, errorMessages, command.box.key)
} else {
s.props[command.box.key] = command.box
}
case fetchProp:
// R... | go | func (s *scene) processCommand(command *envelope) {
switch command.kind {
case storeProp:
// Add a new prop.
_, ok := s.props[command.box.key]
if ok {
command.err = errors.New(ErrPropAlreadyExist, errorMessages, command.box.key)
} else {
s.props[command.box.key] = command.box
}
case fetchProp:
// R... | [
"func",
"(",
"s",
"*",
"scene",
")",
"processCommand",
"(",
"command",
"*",
"envelope",
")",
"{",
"switch",
"command",
".",
"kind",
"{",
"case",
"storeProp",
":",
"// Add a new prop.",
"_",
",",
"ok",
":=",
"s",
".",
"props",
"[",
"command",
".",
"box"... | // processCommand processes the sent commands. | [
"processCommand",
"processes",
"the",
"sent",
"commands",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L405-L466 |
150,496 | tideland/golib | scene/scene.go | cleanupAllProps | func (s *scene) cleanupAllProps() error {
for _, box := range s.props {
if box.cleanup != nil {
err := box.cleanup(box.key, box.prop)
if err != nil {
return errors.Annotate(err, ErrCleanupFailed, errorMessages, box.key)
}
}
}
return nil
} | go | func (s *scene) cleanupAllProps() error {
for _, box := range s.props {
if box.cleanup != nil {
err := box.cleanup(box.key, box.prop)
if err != nil {
return errors.Annotate(err, ErrCleanupFailed, errorMessages, box.key)
}
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"scene",
")",
"cleanupAllProps",
"(",
")",
"error",
"{",
"for",
"_",
",",
"box",
":=",
"range",
"s",
".",
"props",
"{",
"if",
"box",
".",
"cleanup",
"!=",
"nil",
"{",
"err",
":=",
"box",
".",
"cleanup",
"(",
"box",
".",
"... | // cleanupAllProps cleans all props. | [
"cleanupAllProps",
"cleans",
"all",
"props",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scene/scene.go#L469-L479 |
150,497 | tideland/golib | redis/options.go | Index | func Index(index int, password string) Option {
return func(d *Database) error {
if index < 0 {
return errors.New(ErrInvalidConfiguration, errorMessages, "index", index)
}
d.index = index
d.password = password
return nil
}
} | go | func Index(index int, password string) Option {
return func(d *Database) error {
if index < 0 {
return errors.New(ErrInvalidConfiguration, errorMessages, "index", index)
}
d.index = index
d.password = password
return nil
}
} | [
"func",
"Index",
"(",
"index",
"int",
",",
"password",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"Database",
")",
"error",
"{",
"if",
"index",
"<",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"ErrInvalidConfiguration",
",",
"err... | // Index selects the database and sets the authentication. The
// default database is the 0, the default password is empty. | [
"Index",
"selects",
"the",
"database",
"and",
"sets",
"the",
"authentication",
".",
"The",
"default",
"database",
"is",
"the",
"0",
"the",
"default",
"password",
"is",
"empty",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/options.go#L92-L101 |
150,498 | tideland/golib | redis/options.go | PoolSize | func PoolSize(poolsize int) Option {
return func(d *Database) error {
if poolsize < 0 {
return errors.New(ErrInvalidConfiguration, errorMessages, "pool size", poolsize)
} else if poolsize == 0 {
poolsize = defaultPoolSize
}
d.poolsize = poolsize
return nil
}
} | go | func PoolSize(poolsize int) Option {
return func(d *Database) error {
if poolsize < 0 {
return errors.New(ErrInvalidConfiguration, errorMessages, "pool size", poolsize)
} else if poolsize == 0 {
poolsize = defaultPoolSize
}
d.poolsize = poolsize
return nil
}
} | [
"func",
"PoolSize",
"(",
"poolsize",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"Database",
")",
"error",
"{",
"if",
"poolsize",
"<",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"ErrInvalidConfiguration",
",",
"errorMessages",
",",
"\... | // PoolSize sets the pool size of the database. The default is 10. | [
"PoolSize",
"sets",
"the",
"pool",
"size",
"of",
"the",
"database",
".",
"The",
"default",
"is",
"10",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/options.go#L104-L114 |
150,499 | tideland/golib | redis/options.go | Monitoring | func Monitoring(logging, monitoring bool) Option {
return func(d *Database) error {
d.logging = logging
d.monitoring = monitoring
return nil
}
} | go | func Monitoring(logging, monitoring bool) Option {
return func(d *Database) error {
d.logging = logging
d.monitoring = monitoring
return nil
}
} | [
"func",
"Monitoring",
"(",
"logging",
",",
"monitoring",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"d",
"*",
"Database",
")",
"error",
"{",
"d",
".",
"logging",
"=",
"logging",
"\n",
"d",
".",
"monitoring",
"=",
"monitoring",
"\n",
"return",
"... | // Monitoring sets logging and monitoring, logging and
// monitoring are switched off by default. | [
"Monitoring",
"sets",
"logging",
"and",
"monitoring",
"logging",
"and",
"monitoring",
"are",
"switched",
"off",
"by",
"default",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/options.go#L118-L124 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.