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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
151,300 | basho/riak-go-client | kv_commands.go | WithRange | func (builder *SecondaryIndexQueryCommandBuilder) WithRange(min string, max string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.RangeMin = []byte(min)
builder.protobuf.RangeMax = []byte(max)
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithRange(min string, max string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.RangeMin = []byte(min)
builder.protobuf.RangeMax = []byte(max)
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithRange",
"(",
"min",
"string",
",",
"max",
"string",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"RangeMin",
"=",
"[",
"]",
"byte",
"(",
"min",
... | // WithRange sets the range of index values to return | [
"WithRange",
"sets",
"the",
"range",
"of",
"index",
"values",
"to",
"return"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1348-L1352 |
151,301 | basho/riak-go-client | kv_commands.go | WithIntRange | func (builder *SecondaryIndexQueryCommandBuilder) WithIntRange(min int64, max int64) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.RangeMin = []byte(strconv.FormatInt(min, 10))
builder.protobuf.RangeMax = []byte(strconv.FormatInt(max, 10))
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithIntRange(min int64, max int64) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.RangeMin = []byte(strconv.FormatInt(min, 10))
builder.protobuf.RangeMax = []byte(strconv.FormatInt(max, 10))
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithIntRange",
"(",
"min",
"int64",
",",
"max",
"int64",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"RangeMin",
"=",
"[",
"]",
"byte",
"(",
"strconv... | // WithIntRange sets the range of integer type index values to return, useful when you want 1,3,5,11
// and not 1,11,3,5 | [
"WithIntRange",
"sets",
"the",
"range",
"of",
"integer",
"type",
"index",
"values",
"to",
"return",
"useful",
"when",
"you",
"want",
"1",
"3",
"5",
"11",
"and",
"not",
"1",
"11",
"3",
"5"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1356-L1360 |
151,302 | basho/riak-go-client | kv_commands.go | WithIndexKey | func (builder *SecondaryIndexQueryCommandBuilder) WithIndexKey(key string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Key = []byte(key)
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithIndexKey(key string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Key = []byte(key)
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithIndexKey",
"(",
"key",
"string",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Key",
"=",
"[",
"]",
"byte",
"(",
"key",
")",
"\n",
"return",
"bu... | // WithIndexKey defines the index to search against | [
"WithIndexKey",
"defines",
"the",
"index",
"to",
"search",
"against"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1363-L1366 |
151,303 | basho/riak-go-client | kv_commands.go | WithIntIndexKey | func (builder *SecondaryIndexQueryCommandBuilder) WithIntIndexKey(key int) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Key = []byte(strconv.Itoa(key))
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithIntIndexKey(key int) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Key = []byte(strconv.Itoa(key))
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithIntIndexKey",
"(",
"key",
"int",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Key",
"=",
"[",
"]",
"byte",
"(",
"strconv",
".",
"Itoa",
"(",
"k... | // WithIntIndexKey defines the integer index to search against | [
"WithIntIndexKey",
"defines",
"the",
"integer",
"index",
"to",
"search",
"against"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1369-L1372 |
151,304 | basho/riak-go-client | kv_commands.go | WithReturnKeyAndIndex | func (builder *SecondaryIndexQueryCommandBuilder) WithReturnKeyAndIndex(val bool) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.ReturnTerms = &val
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithReturnKeyAndIndex(val bool) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.ReturnTerms = &val
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithReturnKeyAndIndex",
"(",
"val",
"bool",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"ReturnTerms",
"=",
"&",
"val",
"\n",
"return",
"builder",
"\n",
... | // WithReturnKeyAndIndex set to true, the result set will include both index keys and object keys | [
"WithReturnKeyAndIndex",
"set",
"to",
"true",
"the",
"result",
"set",
"will",
"include",
"both",
"index",
"keys",
"and",
"object",
"keys"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1375-L1378 |
151,305 | basho/riak-go-client | kv_commands.go | WithPaginationSort | func (builder *SecondaryIndexQueryCommandBuilder) WithPaginationSort(paginationSort bool) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.PaginationSort = &paginationSort
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithPaginationSort(paginationSort bool) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.PaginationSort = &paginationSort
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithPaginationSort",
"(",
"paginationSort",
"bool",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"PaginationSort",
"=",
"&",
"paginationSort",
"\n",
"return",... | // WithPaginationSort set to true, the results of a non-paginated query will return sorted from Riak | [
"WithPaginationSort",
"set",
"to",
"true",
"the",
"results",
"of",
"a",
"non",
"-",
"paginated",
"query",
"will",
"return",
"sorted",
"from",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1397-L1400 |
151,306 | basho/riak-go-client | kv_commands.go | WithMaxResults | func (builder *SecondaryIndexQueryCommandBuilder) WithMaxResults(maxResults uint32) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.MaxResults = &maxResults
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithMaxResults(maxResults uint32) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.MaxResults = &maxResults
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithMaxResults",
"(",
"maxResults",
"uint32",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"MaxResults",
"=",
"&",
"maxResults",
"\n",
"return",
"builder",
... | // WithMaxResults sets the maximum number of values to return in the result set | [
"WithMaxResults",
"sets",
"the",
"maximum",
"number",
"of",
"values",
"to",
"return",
"in",
"the",
"result",
"set"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1403-L1406 |
151,307 | basho/riak-go-client | kv_commands.go | WithContinuation | func (builder *SecondaryIndexQueryCommandBuilder) WithContinuation(cont []byte) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Continuation = cont
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithContinuation(cont []byte) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.Continuation = cont
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithContinuation",
"(",
"cont",
"[",
"]",
"byte",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Continuation",
"=",
"cont",
"\n",
"return",
"builder",
"... | // WithContinuation sets the position at which the result set should continue from, value can be
// found within the result set of the previous page for the same query | [
"WithContinuation",
"sets",
"the",
"position",
"at",
"which",
"the",
"result",
"set",
"should",
"continue",
"from",
"value",
"can",
"be",
"found",
"within",
"the",
"result",
"set",
"of",
"the",
"previous",
"page",
"for",
"the",
"same",
"query"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1410-L1413 |
151,308 | basho/riak-go-client | kv_commands.go | WithTermRegex | func (builder *SecondaryIndexQueryCommandBuilder) WithTermRegex(regex string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.TermRegex = []byte(regex)
return builder
} | go | func (builder *SecondaryIndexQueryCommandBuilder) WithTermRegex(regex string) *SecondaryIndexQueryCommandBuilder {
builder.protobuf.TermRegex = []byte(regex)
return builder
} | [
"func",
"(",
"builder",
"*",
"SecondaryIndexQueryCommandBuilder",
")",
"WithTermRegex",
"(",
"regex",
"string",
")",
"*",
"SecondaryIndexQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"TermRegex",
"=",
"[",
"]",
"byte",
"(",
"regex",
")",
"\n",
"ret... | // WithTermRegex sets the regex pattern to filter the result set by | [
"WithTermRegex",
"sets",
"the",
"regex",
"pattern",
"to",
"filter",
"the",
"result",
"set",
"by"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1416-L1419 |
151,309 | basho/riak-go-client | kv_commands.go | WithQuery | func (builder *MapReduceCommandBuilder) WithQuery(query string) *MapReduceCommandBuilder {
builder.protobuf.Request = []byte(query)
return builder
} | go | func (builder *MapReduceCommandBuilder) WithQuery(query string) *MapReduceCommandBuilder {
builder.protobuf.Request = []byte(query)
return builder
} | [
"func",
"(",
"builder",
"*",
"MapReduceCommandBuilder",
")",
"WithQuery",
"(",
"query",
"string",
")",
"*",
"MapReduceCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Request",
"=",
"[",
"]",
"byte",
"(",
"query",
")",
"\n",
"return",
"builder",
"\n",... | // WithQuery sets the map reduce query to be executed on Riak | [
"WithQuery",
"sets",
"the",
"map",
"reduce",
"query",
"to",
"be",
"executed",
"on",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L1544-L1547 |
151,310 | basho/riak-go-client | object.go | AddToIntIndex | func (o *Object) AddToIntIndex(indexName string, indexValue int) {
o.AddToIndex(indexName, fmt.Sprintf("%v", indexValue))
} | go | func (o *Object) AddToIntIndex(indexName string, indexValue int) {
o.AddToIndex(indexName, fmt.Sprintf("%v", indexValue))
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"AddToIntIndex",
"(",
"indexName",
"string",
",",
"indexValue",
"int",
")",
"{",
"o",
".",
"AddToIndex",
"(",
"indexName",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"indexValue",
")",
")",
"\n",
"}"
] | // AddToIntIndex adds the object to the specified secondary index with the integer value to be used
// for index searches | [
"AddToIntIndex",
"adds",
"the",
"object",
"to",
"the",
"specified",
"secondary",
"index",
"with",
"the",
"integer",
"value",
"to",
"be",
"used",
"for",
"index",
"searches"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/object.go#L74-L76 |
151,311 | basho/riak-go-client | object.go | AddToIndex | func (o *Object) AddToIndex(indexName string, indexValue string) {
if o.Indexes == nil {
o.Indexes = make(map[string][]string)
}
if o.Indexes[indexName] == nil {
o.Indexes[indexName] = make([]string, 1)
o.Indexes[indexName][0] = indexValue
} else {
o.Indexes[indexName] = append(o.Indexes[indexName], indexValue)
}
} | go | func (o *Object) AddToIndex(indexName string, indexValue string) {
if o.Indexes == nil {
o.Indexes = make(map[string][]string)
}
if o.Indexes[indexName] == nil {
o.Indexes[indexName] = make([]string, 1)
o.Indexes[indexName][0] = indexValue
} else {
o.Indexes[indexName] = append(o.Indexes[indexName], indexValue)
}
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"AddToIndex",
"(",
"indexName",
"string",
",",
"indexValue",
"string",
")",
"{",
"if",
"o",
".",
"Indexes",
"==",
"nil",
"{",
"o",
".",
"Indexes",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string"... | // AddToIndex adds the object to the specified secondary index with the string value to be used for
// index searches | [
"AddToIndex",
"adds",
"the",
"object",
"to",
"the",
"specified",
"secondary",
"index",
"with",
"the",
"string",
"value",
"to",
"be",
"used",
"for",
"index",
"searches"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/object.go#L80-L90 |
151,312 | philippfranke/multipart-related | related/writer.go | SetBoundary | func (w *Writer) SetBoundary(boundary string) error {
return w.w.SetBoundary(boundary)
} | go | func (w *Writer) SetBoundary(boundary string) error {
return w.w.SetBoundary(boundary)
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"SetBoundary",
"(",
"boundary",
"string",
")",
"error",
"{",
"return",
"w",
".",
"w",
".",
"SetBoundary",
"(",
"boundary",
")",
"\n",
"}"
] | // SetBoundary is a wrapper around multipart's Writer.SetBoundary
//
// SetBoundary overrides the Writer's default randomly-generated
// boundary separator with an explicit value.
//
// SetBoundary must be called before any parts are created, may only
// contain certain ASCII characters, and must be 1-69 bytes long. | [
"SetBoundary",
"is",
"a",
"wrapper",
"around",
"multipart",
"s",
"Writer",
".",
"SetBoundary",
"SetBoundary",
"overrides",
"the",
"Writer",
"s",
"default",
"randomly",
"-",
"generated",
"boundary",
"separator",
"with",
"an",
"explicit",
"value",
".",
"SetBoundary"... | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L74-L76 |
151,313 | philippfranke/multipart-related | related/writer.go | SetStart | func (w *Writer) SetStart(contentId string) error {
cid, err := formatContentId(contentId)
if err != nil {
return err
}
w.start = cid
return nil
} | go | func (w *Writer) SetStart(contentId string) error {
cid, err := formatContentId(contentId)
if err != nil {
return err
}
w.start = cid
return nil
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"SetStart",
"(",
"contentId",
"string",
")",
"error",
"{",
"cid",
",",
"err",
":=",
"formatContentId",
"(",
"contentId",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"w",
".",
"... | // SetStart changes the compound object's "root" | [
"SetStart",
"changes",
"the",
"compound",
"object",
"s",
"root"
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L79-L87 |
151,314 | philippfranke/multipart-related | related/writer.go | formatContentId | func formatContentId(contentId string) (string, error) {
addr, err := mail.ParseAddress(contentId)
if err != nil {
return "", err
}
return fmt.Sprintf("<%s>", addr.Address), nil
} | go | func formatContentId(contentId string) (string, error) {
addr, err := mail.ParseAddress(contentId)
if err != nil {
return "", err
}
return fmt.Sprintf("<%s>", addr.Address), nil
} | [
"func",
"formatContentId",
"(",
"contentId",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"addr",
",",
"err",
":=",
"mail",
".",
"ParseAddress",
"(",
"contentId",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\... | // formatContentId parses given id and formats it as specified by
// RFC 5322 | [
"formatContentId",
"parses",
"given",
"id",
"and",
"formats",
"it",
"as",
"specified",
"by",
"RFC",
"5322"
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L91-L97 |
151,315 | philippfranke/multipart-related | related/writer.go | SetType | func (w *Writer) SetType(mediaType string) error {
if _, _, err := mime.ParseMediaType(mediaType); err != nil {
return err
}
w.mediaType = mediaType
return nil
} | go | func (w *Writer) SetType(mediaType string) error {
if _, _, err := mime.ParseMediaType(mediaType); err != nil {
return err
}
w.mediaType = mediaType
return nil
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"SetType",
"(",
"mediaType",
"string",
")",
"error",
"{",
"if",
"_",
",",
"_",
",",
"err",
":=",
"mime",
".",
"ParseMediaType",
"(",
"mediaType",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // SetType changes MIME mediaType of the compound object | [
"SetType",
"changes",
"MIME",
"mediaType",
"of",
"the",
"compound",
"object"
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L100-L107 |
151,316 | philippfranke/multipart-related | related/writer.go | CreatePart | func (w *Writer) CreatePart(
contentId string,
header textproto.MIMEHeader,
) (io.Writer, error) {
var mediaType = DefaultMediaType
if header == nil {
header = make(textproto.MIMEHeader)
header.Set("Content-Type", mediaType)
} else if header.Get("Content-Type") != "" {
mediaType = header.Get("Content-Type")
}
if contentId != "" {
cid, err := formatContentId(contentId)
if err != nil {
return nil, err
}
header.Set("Content-ID", cid)
}
if w.firstPart == false {
w.SetType(mediaType)
w.rootMediaType = w.mediaType
w.firstPart = true
}
return w.w.CreatePart(header)
} | go | func (w *Writer) CreatePart(
contentId string,
header textproto.MIMEHeader,
) (io.Writer, error) {
var mediaType = DefaultMediaType
if header == nil {
header = make(textproto.MIMEHeader)
header.Set("Content-Type", mediaType)
} else if header.Get("Content-Type") != "" {
mediaType = header.Get("Content-Type")
}
if contentId != "" {
cid, err := formatContentId(contentId)
if err != nil {
return nil, err
}
header.Set("Content-ID", cid)
}
if w.firstPart == false {
w.SetType(mediaType)
w.rootMediaType = w.mediaType
w.firstPart = true
}
return w.w.CreatePart(header)
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"CreatePart",
"(",
"contentId",
"string",
",",
"header",
"textproto",
".",
"MIMEHeader",
",",
")",
"(",
"io",
".",
"Writer",
",",
"error",
")",
"{",
"var",
"mediaType",
"=",
"DefaultMediaType",
"\n\n",
"if",
"header"... | // CreatePart is a wrapper around mulipart's Writer.CreatePart | [
"CreatePart",
"is",
"a",
"wrapper",
"around",
"mulipart",
"s",
"Writer",
".",
"CreatePart"
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L181-L209 |
151,317 | philippfranke/multipart-related | related/writer.go | Close | func (w *Writer) Close() error {
if w.mediaType != w.rootMediaType {
return ErrTypeMatch
}
return w.w.Close()
} | go | func (w *Writer) Close() error {
if w.mediaType != w.rootMediaType {
return ErrTypeMatch
}
return w.w.Close()
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"w",
".",
"mediaType",
"!=",
"w",
".",
"rootMediaType",
"{",
"return",
"ErrTypeMatch",
"\n",
"}",
"\n",
"return",
"w",
".",
"w",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close is a wrapper around multipart's Writer.Close with additional errors. | [
"Close",
"is",
"a",
"wrapper",
"around",
"multipart",
"s",
"Writer",
".",
"Close",
"with",
"additional",
"errors",
"."
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/writer.go#L212-L217 |
151,318 | basho/riak-go-client | node_manager.go | ExecuteOnNode | func (nm *defaultNodeManager) ExecuteOnNode(nodes []*Node, command Command, previous *Node) (bool, error) {
if nodes == nil {
panic("[defaultNodeManager] nil nodes argument")
}
if len(nodes) == 0 || nodes[0] == nil {
return false, ErrDefaultNodeManagerRequiresNode
}
var err error
executed := false
nm.RLock()
startingIndex := nm.nodeIndex
nm.RUnlock()
for {
nm.Lock()
if nm.nodeIndex >= len(nodes) {
nm.nodeIndex = 0
}
node := nodes[nm.nodeIndex]
nm.nodeIndex++
nm.Unlock()
// don't try the same node twice in a row if we have multiple nodes
if len(nodes) > 1 && previous != nil && previous == node {
continue
}
executed, err = node.execute(command)
if executed == true {
logDebug("[DefaultNodeManager]", "executed '%s' on node '%s', err '%v'", command.Name(), node, err)
break
}
nm.RLock()
if startingIndex == nm.nodeIndex {
nm.RUnlock()
// logDebug("[DefaultNodeManager]", "startingIndex %d nm.nodeIndex %d", startingIndex, nm.nodeIndex)
break
}
nm.RUnlock()
}
return executed, err
} | go | func (nm *defaultNodeManager) ExecuteOnNode(nodes []*Node, command Command, previous *Node) (bool, error) {
if nodes == nil {
panic("[defaultNodeManager] nil nodes argument")
}
if len(nodes) == 0 || nodes[0] == nil {
return false, ErrDefaultNodeManagerRequiresNode
}
var err error
executed := false
nm.RLock()
startingIndex := nm.nodeIndex
nm.RUnlock()
for {
nm.Lock()
if nm.nodeIndex >= len(nodes) {
nm.nodeIndex = 0
}
node := nodes[nm.nodeIndex]
nm.nodeIndex++
nm.Unlock()
// don't try the same node twice in a row if we have multiple nodes
if len(nodes) > 1 && previous != nil && previous == node {
continue
}
executed, err = node.execute(command)
if executed == true {
logDebug("[DefaultNodeManager]", "executed '%s' on node '%s', err '%v'", command.Name(), node, err)
break
}
nm.RLock()
if startingIndex == nm.nodeIndex {
nm.RUnlock()
// logDebug("[DefaultNodeManager]", "startingIndex %d nm.nodeIndex %d", startingIndex, nm.nodeIndex)
break
}
nm.RUnlock()
}
return executed, err
} | [
"func",
"(",
"nm",
"*",
"defaultNodeManager",
")",
"ExecuteOnNode",
"(",
"nodes",
"[",
"]",
"*",
"Node",
",",
"command",
"Command",
",",
"previous",
"*",
"Node",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"nodes",
"==",
"nil",
"{",
"panic",
"(",... | // ExecuteOnNode selects a Node from the pool and executes the provided Command on that Node. The
// defaultNodeManager uses a simple round robin approach to distributing load | [
"ExecuteOnNode",
"selects",
"a",
"Node",
"from",
"the",
"pool",
"and",
"executes",
"the",
"provided",
"Command",
"on",
"that",
"Node",
".",
"The",
"defaultNodeManager",
"uses",
"a",
"simple",
"round",
"robin",
"approach",
"to",
"distributing",
"load"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node_manager.go#L35-L80 |
151,319 | basho/riak-go-client | node.go | NewNode | func NewNode(options *NodeOptions) (*Node, error) {
if options == nil {
options = defaultNodeOptions
}
if options.RemoteAddress == "" {
options.RemoteAddress = defaultRemoteAddress
}
if options.MinConnections == 0 {
options.MinConnections = defaultMinConnections
}
if options.MaxConnections == 0 {
options.MaxConnections = defaultMaxConnections
}
if options.TempNetErrorRetries == 0 {
options.TempNetErrorRetries = defaultTempNetErrorRetries
}
if options.IdleTimeout == 0 {
options.IdleTimeout = defaultIdleTimeout
}
if options.ConnectTimeout == 0 {
options.ConnectTimeout = defaultConnectTimeout
}
if options.RequestTimeout == 0 {
options.RequestTimeout = defaultRequestTimeout
}
if options.HealthCheckInterval == 0 {
options.HealthCheckInterval = defaultHealthCheckInterval
}
var err error
var resolvedAddress *net.TCPAddr
resolvedAddress, err = net.ResolveTCPAddr("tcp", options.RemoteAddress)
if err == nil {
n := &Node{
stopChan: make(chan struct{}),
addr: resolvedAddress,
healthCheckInterval: options.HealthCheckInterval,
healthCheckBuilder: options.HealthCheckBuilder,
}
connMgrOpts := &connectionManagerOptions{
addr: resolvedAddress,
minConnections: options.MinConnections,
maxConnections: options.MaxConnections,
tempNetErrorRetries: options.TempNetErrorRetries,
idleTimeout: options.IdleTimeout,
connectTimeout: options.ConnectTimeout,
requestTimeout: options.RequestTimeout,
authOptions: options.AuthOptions,
}
var cm *connectionManager
if cm, err = newConnectionManager(connMgrOpts); err == nil {
n.cm = cm
n.initStateData("nodeCreated", "nodeRunning", "nodeHealthChecking", "nodeShuttingDown", "nodeShutdown", "nodeError")
n.setState(nodeCreated)
return n, nil
}
}
return nil, err
} | go | func NewNode(options *NodeOptions) (*Node, error) {
if options == nil {
options = defaultNodeOptions
}
if options.RemoteAddress == "" {
options.RemoteAddress = defaultRemoteAddress
}
if options.MinConnections == 0 {
options.MinConnections = defaultMinConnections
}
if options.MaxConnections == 0 {
options.MaxConnections = defaultMaxConnections
}
if options.TempNetErrorRetries == 0 {
options.TempNetErrorRetries = defaultTempNetErrorRetries
}
if options.IdleTimeout == 0 {
options.IdleTimeout = defaultIdleTimeout
}
if options.ConnectTimeout == 0 {
options.ConnectTimeout = defaultConnectTimeout
}
if options.RequestTimeout == 0 {
options.RequestTimeout = defaultRequestTimeout
}
if options.HealthCheckInterval == 0 {
options.HealthCheckInterval = defaultHealthCheckInterval
}
var err error
var resolvedAddress *net.TCPAddr
resolvedAddress, err = net.ResolveTCPAddr("tcp", options.RemoteAddress)
if err == nil {
n := &Node{
stopChan: make(chan struct{}),
addr: resolvedAddress,
healthCheckInterval: options.HealthCheckInterval,
healthCheckBuilder: options.HealthCheckBuilder,
}
connMgrOpts := &connectionManagerOptions{
addr: resolvedAddress,
minConnections: options.MinConnections,
maxConnections: options.MaxConnections,
tempNetErrorRetries: options.TempNetErrorRetries,
idleTimeout: options.IdleTimeout,
connectTimeout: options.ConnectTimeout,
requestTimeout: options.RequestTimeout,
authOptions: options.AuthOptions,
}
var cm *connectionManager
if cm, err = newConnectionManager(connMgrOpts); err == nil {
n.cm = cm
n.initStateData("nodeCreated", "nodeRunning", "nodeHealthChecking", "nodeShuttingDown", "nodeShutdown", "nodeError")
n.setState(nodeCreated)
return n, nil
}
}
return nil, err
} | [
"func",
"NewNode",
"(",
"options",
"*",
"NodeOptions",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"if",
"options",
"==",
"nil",
"{",
"options",
"=",
"defaultNodeOptions",
"\n",
"}",
"\n",
"if",
"options",
".",
"RemoteAddress",
"==",
"\"",
"\"",
"{"... | // NewNode is a factory function that takes a NodeOptions struct and returns a Node struct | [
"NewNode",
"is",
"a",
"factory",
"function",
"that",
"takes",
"a",
"NodeOptions",
"struct",
"and",
"returns",
"a",
"Node",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L70-L131 |
151,320 | basho/riak-go-client | node.go | String | func (n *Node) String() string {
return fmt.Sprintf("%v|%d|%d", n.addr, n.cm.count(), n.cm.q.count())
} | go | func (n *Node) String() string {
return fmt.Sprintf("%v|%d|%d", n.addr, n.cm.count(), n.cm.q.count())
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"n",
".",
"addr",
",",
"n",
".",
"cm",
".",
"count",
"(",
")",
",",
"n",
".",
"cm",
".",
"q",
".",
"count",
"(",
... | // String returns a formatted string including the remoteAddress for the Node and its current
// connection count | [
"String",
"returns",
"a",
"formatted",
"string",
"including",
"the",
"remoteAddress",
"for",
"the",
"Node",
"and",
"its",
"current",
"connection",
"count"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L135-L137 |
151,321 | basho/riak-go-client | node.go | start | func (n *Node) start() error {
if err := n.stateCheck(nodeCreated); err != nil {
return err
}
logDebug("[Node]", "(%v) starting", n)
if err := n.cm.start(); err != nil {
logErr("[Node]", err)
}
n.setState(nodeRunning)
logDebug("[Node]", "(%v) started", n)
return nil
} | go | func (n *Node) start() error {
if err := n.stateCheck(nodeCreated); err != nil {
return err
}
logDebug("[Node]", "(%v) starting", n)
if err := n.cm.start(); err != nil {
logErr("[Node]", err)
}
n.setState(nodeRunning)
logDebug("[Node]", "(%v) started", n)
return nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"start",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"n",
".",
"stateCheck",
"(",
"nodeCreated",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"logDebug",
"(",
"\"",
"\"",
",",
"\"",
"... | // Start opens a connection with Riak at the configured remoteAddress and adds the connections to the
// active pool | [
"Start",
"opens",
"a",
"connection",
"with",
"Riak",
"at",
"the",
"configured",
"remoteAddress",
"and",
"adds",
"the",
"connections",
"to",
"the",
"active",
"pool"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L141-L154 |
151,322 | basho/riak-go-client | node.go | stop | func (n *Node) stop() error {
if err := n.stateCheck(nodeRunning, nodeHealthChecking); err != nil {
return err
}
logDebug("[Node]", "(%v) shutting down.", n)
n.setState(nodeShuttingDown)
close(n.stopChan)
err := n.cm.stop()
if err == nil {
n.setState(nodeShutdown)
logDebug("[Node]", "(%v) shut down.", n)
} else {
n.setState(nodeError)
logErr("[Node]", err)
}
return err
} | go | func (n *Node) stop() error {
if err := n.stateCheck(nodeRunning, nodeHealthChecking); err != nil {
return err
}
logDebug("[Node]", "(%v) shutting down.", n)
n.setState(nodeShuttingDown)
close(n.stopChan)
err := n.cm.stop()
if err == nil {
n.setState(nodeShutdown)
logDebug("[Node]", "(%v) shut down.", n)
} else {
n.setState(nodeError)
logErr("[Node]", err)
}
return err
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"stop",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"n",
".",
"stateCheck",
"(",
"nodeRunning",
",",
"nodeHealthChecking",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"logDebug",
"(",
"\... | // Stop closes the connections with Riak at the configured remoteAddress and removes the connections
// from the active pool | [
"Stop",
"closes",
"the",
"connections",
"with",
"Riak",
"at",
"the",
"configured",
"remoteAddress",
"and",
"removes",
"the",
"connections",
"from",
"the",
"active",
"pool"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L158-L179 |
151,323 | basho/riak-go-client | node.go | execute | func (n *Node) execute(cmd Command) (bool, error) {
if err := n.stateCheck(nodeRunning, nodeHealthChecking); err != nil {
return false, err
}
if n.isCurrentState(nodeRunning) {
conn, err := n.cm.get()
if err != nil {
logErr("[Node]", err)
n.doHealthCheck()
return false, err
}
if conn == nil {
panic(fmt.Sprintf("[Node] (%v) expected non-nil connection", n))
}
if rc, ok := cmd.(retryableCommand); ok {
rc.setLastNode(n)
}
logDebug("[Node]", "(%v) - executing command '%v'", n, cmd.Name())
err = conn.execute(cmd)
if err == nil {
// NB: basically the success path of _responseReceived in Node.js client
if cmErr := n.cm.put(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
return true, nil
} else {
// NB: basically, this is _connectionClosed / _responseReceived in Node.js client
// must differentiate between Riak and non-Riak errors here and within execute() in connection
switch err.(type) {
case RiakError, ClientError:
// Riak and Client errors will not close connection
if cmErr := n.cm.put(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
return true, err
default:
// NB: must be a non-Riak, non-Client error, close the connection
if cmErr := n.cm.remove(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
if !isTemporaryNetError(err) {
n.doHealthCheck()
}
return true, err
}
}
} else {
return false, nil
}
} | go | func (n *Node) execute(cmd Command) (bool, error) {
if err := n.stateCheck(nodeRunning, nodeHealthChecking); err != nil {
return false, err
}
if n.isCurrentState(nodeRunning) {
conn, err := n.cm.get()
if err != nil {
logErr("[Node]", err)
n.doHealthCheck()
return false, err
}
if conn == nil {
panic(fmt.Sprintf("[Node] (%v) expected non-nil connection", n))
}
if rc, ok := cmd.(retryableCommand); ok {
rc.setLastNode(n)
}
logDebug("[Node]", "(%v) - executing command '%v'", n, cmd.Name())
err = conn.execute(cmd)
if err == nil {
// NB: basically the success path of _responseReceived in Node.js client
if cmErr := n.cm.put(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
return true, nil
} else {
// NB: basically, this is _connectionClosed / _responseReceived in Node.js client
// must differentiate between Riak and non-Riak errors here and within execute() in connection
switch err.(type) {
case RiakError, ClientError:
// Riak and Client errors will not close connection
if cmErr := n.cm.put(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
return true, err
default:
// NB: must be a non-Riak, non-Client error, close the connection
if cmErr := n.cm.remove(conn); cmErr != nil {
logErr("[Node]", cmErr)
}
if !isTemporaryNetError(err) {
n.doHealthCheck()
}
return true, err
}
}
} else {
return false, nil
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"execute",
"(",
"cmd",
"Command",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"err",
":=",
"n",
".",
"stateCheck",
"(",
"nodeRunning",
",",
"nodeHealthChecking",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"... | // Execute retrieves an available connection from the pool and executes the Command operation against
// Riak | [
"Execute",
"retrieves",
"an",
"available",
"connection",
"from",
"the",
"pool",
"and",
"executes",
"the",
"Command",
"operation",
"against",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L183-L236 |
151,324 | basho/riak-go-client | node.go | healthCheck | func (n *Node) healthCheck() {
logDebug("[Node]", "(%v) starting healthcheck routine", n)
healthCheckTicker := time.NewTicker(n.healthCheckInterval)
defer healthCheckTicker.Stop()
for {
if !n.ensureHealthCheckCanContinue() {
return
}
select {
case <-n.stopChan:
logDebug("[Node]", "(%v) healthcheck quitting", n)
return
case t := <-healthCheckTicker.C:
if !n.ensureHealthCheckCanContinue() {
return
}
logDebug("[Node]", "(%v) running healthcheck at %v", n, t)
conn, cerr := n.cm.createConnection()
if cerr != nil {
conn.close()
logError("[Node]", "(%v) failed healthcheck in createConnection, err: %v", n, cerr)
} else {
if !n.ensureHealthCheckCanContinue() {
conn.close()
return
}
hcmd := n.getHealthCheckCommand()
logDebug("[Node]", "(%v) healthcheck executing %v", n, hcmd.Name())
if hcerr := conn.execute(hcmd); hcerr != nil || !hcmd.Success() {
conn.close()
logError("[Node]", "(%v) failed healthcheck, err: %v", n, hcerr)
} else {
conn.close()
logDebug("[Node]", "(%v) healthcheck success, err: %v, success: %v", n, hcerr, hcmd.Success())
if n.ensureHealthCheckCanContinue() {
n.setState(nodeRunning)
}
return
}
}
}
}
} | go | func (n *Node) healthCheck() {
logDebug("[Node]", "(%v) starting healthcheck routine", n)
healthCheckTicker := time.NewTicker(n.healthCheckInterval)
defer healthCheckTicker.Stop()
for {
if !n.ensureHealthCheckCanContinue() {
return
}
select {
case <-n.stopChan:
logDebug("[Node]", "(%v) healthcheck quitting", n)
return
case t := <-healthCheckTicker.C:
if !n.ensureHealthCheckCanContinue() {
return
}
logDebug("[Node]", "(%v) running healthcheck at %v", n, t)
conn, cerr := n.cm.createConnection()
if cerr != nil {
conn.close()
logError("[Node]", "(%v) failed healthcheck in createConnection, err: %v", n, cerr)
} else {
if !n.ensureHealthCheckCanContinue() {
conn.close()
return
}
hcmd := n.getHealthCheckCommand()
logDebug("[Node]", "(%v) healthcheck executing %v", n, hcmd.Name())
if hcerr := conn.execute(hcmd); hcerr != nil || !hcmd.Success() {
conn.close()
logError("[Node]", "(%v) failed healthcheck, err: %v", n, hcerr)
} else {
conn.close()
logDebug("[Node]", "(%v) healthcheck success, err: %v, success: %v", n, hcerr, hcmd.Success())
if n.ensureHealthCheckCanContinue() {
n.setState(nodeRunning)
}
return
}
}
}
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"healthCheck",
"(",
")",
"{",
"logDebug",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"n",
")",
"\n\n",
"healthCheckTicker",
":=",
"time",
".",
"NewTicker",
"(",
"n",
".",
"healthCheckInterval",
")",
"\n",
"defer",
"hea... | // private goroutine funcs | [
"private",
"goroutine",
"funcs"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/node.go#L278-L322 |
151,325 | philippfranke/multipart-related | related/multipart.go | Read | func (oh *ObjectHeader) Read(b []byte) (n int, err error) {
if len(b) == 0 {
return 0, nil
}
if oh.i >= int64(len(oh.content)) {
return 0, io.EOF
}
n = copy(b, oh.content[oh.i:])
oh.i += int64(n)
return
} | go | func (oh *ObjectHeader) Read(b []byte) (n int, err error) {
if len(b) == 0 {
return 0, nil
}
if oh.i >= int64(len(oh.content)) {
return 0, io.EOF
}
n = copy(b, oh.content[oh.i:])
oh.i += int64(n)
return
} | [
"func",
"(",
"oh",
"*",
"ObjectHeader",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"b",
")",
"==",
"0",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"if",
"oh",
".",
... | // Read reads the content of a ObjectHeader. | [
"Read",
"reads",
"the",
"content",
"of",
"a",
"ObjectHeader",
"."
] | 01d28b2a17695d84345e063ff4a7658c15fb7f67 | https://github.com/philippfranke/multipart-related/blob/01d28b2a17695d84345e063ff4a7658c15fb7f67/related/multipart.go#L155-L165 |
151,326 | basho/riak-go-client | cluster.go | NewCluster | func NewCluster(options *ClusterOptions) (*Cluster, error) {
if options == nil {
options = defaultClusterOptions
}
if options.NodeManager == nil {
options.NodeManager = &defaultNodeManager{}
}
if options.ExecutionAttempts == 0 {
options.ExecutionAttempts = defaultExecutionAttempts
}
c := &Cluster{
executionAttempts: options.ExecutionAttempts,
nodeManager: options.NodeManager,
}
c.initStateData("clusterCreated", "clusterRunning", "clusterShuttingDown", "clusterShutdown", "clusterError")
if options.Nodes == nil {
c.nodes = make([]*Node, 0)
} else {
c.nodes = options.Nodes
}
if options.NoDefaultNode == false && len(c.nodes) == 0 {
defaultNode, nerr := NewNode(nil)
if nerr != nil {
return nil, nerr
}
c.nodes = append(c.nodes, defaultNode)
}
for _, node := range c.nodes {
if node == nil {
return nil, ErrClusterNodesMustBeNonNil
}
}
if options.QueueMaxDepth > 0 {
if options.QueueExecutionInterval == 0 {
options.QueueExecutionInterval = defaultQueueExecutionInterval
}
c.queueCommands = true
c.stopChan = make(chan struct{})
c.cq = newQueue(options.QueueMaxDepth)
c.commandQueueTicker = time.NewTicker(options.QueueExecutionInterval)
go c.executeEnqueuedCommands()
}
c.setState(clusterCreated)
return c, nil
} | go | func NewCluster(options *ClusterOptions) (*Cluster, error) {
if options == nil {
options = defaultClusterOptions
}
if options.NodeManager == nil {
options.NodeManager = &defaultNodeManager{}
}
if options.ExecutionAttempts == 0 {
options.ExecutionAttempts = defaultExecutionAttempts
}
c := &Cluster{
executionAttempts: options.ExecutionAttempts,
nodeManager: options.NodeManager,
}
c.initStateData("clusterCreated", "clusterRunning", "clusterShuttingDown", "clusterShutdown", "clusterError")
if options.Nodes == nil {
c.nodes = make([]*Node, 0)
} else {
c.nodes = options.Nodes
}
if options.NoDefaultNode == false && len(c.nodes) == 0 {
defaultNode, nerr := NewNode(nil)
if nerr != nil {
return nil, nerr
}
c.nodes = append(c.nodes, defaultNode)
}
for _, node := range c.nodes {
if node == nil {
return nil, ErrClusterNodesMustBeNonNil
}
}
if options.QueueMaxDepth > 0 {
if options.QueueExecutionInterval == 0 {
options.QueueExecutionInterval = defaultQueueExecutionInterval
}
c.queueCommands = true
c.stopChan = make(chan struct{})
c.cq = newQueue(options.QueueMaxDepth)
c.commandQueueTicker = time.NewTicker(options.QueueExecutionInterval)
go c.executeEnqueuedCommands()
}
c.setState(clusterCreated)
return c, nil
} | [
"func",
"NewCluster",
"(",
"options",
"*",
"ClusterOptions",
")",
"(",
"*",
"Cluster",
",",
"error",
")",
"{",
"if",
"options",
"==",
"nil",
"{",
"options",
"=",
"defaultClusterOptions",
"\n",
"}",
"\n",
"if",
"options",
".",
"NodeManager",
"==",
"nil",
... | // NewCluster generates a new Cluster object using the provided ClusterOptions object | [
"NewCluster",
"generates",
"a",
"new",
"Cluster",
"object",
"using",
"the",
"provided",
"ClusterOptions",
"object"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/cluster.go#L76-L126 |
151,327 | basho/riak-go-client | cluster.go | Start | func (c *Cluster) Start() error {
if c.isCurrentState(clusterRunning) {
logWarnln("[Cluster]", "cluster already running.")
return nil
}
if err := c.stateCheck(clusterCreated); err != nil {
return err
}
logDebug("[Cluster]", "starting")
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
if err := node.start(); err != nil {
return err
}
}
c.setState(clusterRunning)
logDebug("[Cluster]", "cluster started")
return nil
} | go | func (c *Cluster) Start() error {
if c.isCurrentState(clusterRunning) {
logWarnln("[Cluster]", "cluster already running.")
return nil
}
if err := c.stateCheck(clusterCreated); err != nil {
return err
}
logDebug("[Cluster]", "starting")
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
if err := node.start(); err != nil {
return err
}
}
c.setState(clusterRunning)
logDebug("[Cluster]", "cluster started")
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"c",
".",
"isCurrentState",
"(",
"clusterRunning",
")",
"{",
"logWarnln",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
... | // Start opens connections with your configured nodes and adds them to
// the active pool | [
"Start",
"opens",
"connections",
"with",
"your",
"configured",
"nodes",
"and",
"adds",
"them",
"to",
"the",
"active",
"pool"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/cluster.go#L135-L159 |
151,328 | basho/riak-go-client | cluster.go | Stop | func (c *Cluster) Stop() (err error) {
if err = c.stateCheck(clusterRunning); err != nil {
return
}
logDebug("[Cluster]", "shutting down")
c.setState(clusterShuttingDown)
if c.queueCommands {
close(c.stopChan)
c.commandQueueTicker.Stop()
qc := c.cq.count()
if qc > 0 {
logWarn("[Cluster]", "commands in queue during shutdown: %d", qc)
var f = func(v interface{}) (bool, bool) {
if v == nil {
return true, false
}
if a, ok := v.(*Async); ok {
a.done(ErrClusterShuttingDown)
}
return false, false
}
if qerr := c.cq.iterate(f); qerr != nil {
logErr("[Cluster]", qerr)
}
}
c.cq.destroy()
}
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
err = node.stop()
if err != nil {
logErr("[Cluster]", err)
}
}
allStopped := true
logDebug("[Cluster]", "checking to see if nodes are shut down")
for _, node := range c.nodes {
nodeState := node.getState()
if nodeState != nodeShutdown {
allStopped = false
break
}
}
if allStopped {
c.setState(clusterShutdown)
logDebug("[Cluster]", "cluster shut down")
} else {
panic("[Cluster] nodes still running when all should be stopped")
}
return
} | go | func (c *Cluster) Stop() (err error) {
if err = c.stateCheck(clusterRunning); err != nil {
return
}
logDebug("[Cluster]", "shutting down")
c.setState(clusterShuttingDown)
if c.queueCommands {
close(c.stopChan)
c.commandQueueTicker.Stop()
qc := c.cq.count()
if qc > 0 {
logWarn("[Cluster]", "commands in queue during shutdown: %d", qc)
var f = func(v interface{}) (bool, bool) {
if v == nil {
return true, false
}
if a, ok := v.(*Async); ok {
a.done(ErrClusterShuttingDown)
}
return false, false
}
if qerr := c.cq.iterate(f); qerr != nil {
logErr("[Cluster]", qerr)
}
}
c.cq.destroy()
}
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
err = node.stop()
if err != nil {
logErr("[Cluster]", err)
}
}
allStopped := true
logDebug("[Cluster]", "checking to see if nodes are shut down")
for _, node := range c.nodes {
nodeState := node.getState()
if nodeState != nodeShutdown {
allStopped = false
break
}
}
if allStopped {
c.setState(clusterShutdown)
logDebug("[Cluster]", "cluster shut down")
} else {
panic("[Cluster] nodes still running when all should be stopped")
}
return
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"Stop",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"c",
".",
"stateCheck",
"(",
"clusterRunning",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"logDebug",
"(",
"\"",
"\"",
... | // Stop closes the connections with your configured nodes and removes them from
// the active pool | [
"Stop",
"closes",
"the",
"connections",
"with",
"your",
"configured",
"nodes",
"and",
"removes",
"them",
"from",
"the",
"active",
"pool"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/cluster.go#L163-L221 |
151,329 | basho/riak-go-client | cluster.go | AddNode | func (c *Cluster) AddNode(n *Node) error {
if n == nil {
return ErrClusterNodeMustBeNonNil
}
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
if n == node {
return nil
}
}
if c.isCurrentState(clusterRunning) {
if err := n.start(); err != nil {
return err
}
}
c.nodes = append(c.nodes, n)
return nil
} | go | func (c *Cluster) AddNode(n *Node) error {
if n == nil {
return ErrClusterNodeMustBeNonNil
}
c.Lock()
defer c.Unlock()
for _, node := range c.nodes {
if n == node {
return nil
}
}
if c.isCurrentState(clusterRunning) {
if err := n.start(); err != nil {
return err
}
}
c.nodes = append(c.nodes, n)
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"AddNode",
"(",
"n",
"*",
"Node",
")",
"error",
"{",
"if",
"n",
"==",
"nil",
"{",
"return",
"ErrClusterNodeMustBeNonNil",
"\n",
"}",
"\n",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
... | // Adds a node to the cluster and starts it | [
"Adds",
"a",
"node",
"to",
"the",
"cluster",
"and",
"starts",
"it"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/cluster.go#L224-L242 |
151,330 | basho/riak-go-client | cluster.go | RemoveNode | func (c *Cluster) RemoveNode(n *Node) error {
if n == nil {
return ErrClusterNodeMustBeNonNil
}
c.Lock()
defer c.Unlock()
cn := c.nodes
for i, node := range c.nodes {
if n == node {
l := len(cn) - 1
cn[i], cn[l], c.nodes = cn[l], nil, cn[:l]
if !node.isCurrentState(nodeCreated) {
if err := node.stop(); err != nil {
return err
}
}
return nil
}
}
return nil
} | go | func (c *Cluster) RemoveNode(n *Node) error {
if n == nil {
return ErrClusterNodeMustBeNonNil
}
c.Lock()
defer c.Unlock()
cn := c.nodes
for i, node := range c.nodes {
if n == node {
l := len(cn) - 1
cn[i], cn[l], c.nodes = cn[l], nil, cn[:l]
if !node.isCurrentState(nodeCreated) {
if err := node.stop(); err != nil {
return err
}
}
return nil
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"RemoveNode",
"(",
"n",
"*",
"Node",
")",
"error",
"{",
"if",
"n",
"==",
"nil",
"{",
"return",
"ErrClusterNodeMustBeNonNil",
"\n",
"}",
"\n",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",... | // Stops the node and removes from the cluster | [
"Stops",
"the",
"node",
"and",
"removes",
"from",
"the",
"cluster"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/cluster.go#L245-L265 |
151,331 | basho/riak-go-client | crdt_commands.go | NewUpdateSetCommandBuilder | func NewUpdateSetCommandBuilder() *UpdateSetCommandBuilder {
return &UpdateSetCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
SetOp: &rpbRiakDT.SetOp{},
},
},
}
} | go | func NewUpdateSetCommandBuilder() *UpdateSetCommandBuilder {
return &UpdateSetCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
SetOp: &rpbRiakDT.SetOp{},
},
},
}
} | [
"func",
"NewUpdateSetCommandBuilder",
"(",
")",
"*",
"UpdateSetCommandBuilder",
"{",
"return",
"&",
"UpdateSetCommandBuilder",
"{",
"protobuf",
":",
"&",
"rpbRiakDT",
".",
"DtUpdateReq",
"{",
"Op",
":",
"&",
"rpbRiakDT",
".",
"DtOp",
"{",
"SetOp",
":",
"&",
"r... | // NewUpdateSetCommandBuilder is a factory function for generating the command builder struct | [
"NewUpdateSetCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L486-L494 |
151,332 | basho/riak-go-client | crdt_commands.go | WithRemovals | func (builder *UpdateSetCommandBuilder) WithRemovals(removals ...[]byte) *UpdateSetCommandBuilder {
opRemoves := builder.protobuf.Op.SetOp.Removes
opRemoves = append(opRemoves, removals...)
builder.protobuf.Op.SetOp.Removes = opRemoves
return builder
} | go | func (builder *UpdateSetCommandBuilder) WithRemovals(removals ...[]byte) *UpdateSetCommandBuilder {
opRemoves := builder.protobuf.Op.SetOp.Removes
opRemoves = append(opRemoves, removals...)
builder.protobuf.Op.SetOp.Removes = opRemoves
return builder
} | [
"func",
"(",
"builder",
"*",
"UpdateSetCommandBuilder",
")",
"WithRemovals",
"(",
"removals",
"...",
"[",
"]",
"byte",
")",
"*",
"UpdateSetCommandBuilder",
"{",
"opRemoves",
":=",
"builder",
".",
"protobuf",
".",
"Op",
".",
"SetOp",
".",
"Removes",
"\n",
"op... | // WithRemovals sets the set elements to be removed from the CRDT set via this update operation | [
"WithRemovals",
"sets",
"the",
"set",
"elements",
"to",
"be",
"removed",
"from",
"the",
"CRDT",
"set",
"via",
"this",
"update",
"operation"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L529-L534 |
151,333 | basho/riak-go-client | crdt_commands.go | NewUpdateGSetCommandBuilder | func NewUpdateGSetCommandBuilder() *UpdateGSetCommandBuilder {
return &UpdateGSetCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
GsetOp: &rpbRiakDT.GSetOp{},
},
},
}
} | go | func NewUpdateGSetCommandBuilder() *UpdateGSetCommandBuilder {
return &UpdateGSetCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
GsetOp: &rpbRiakDT.GSetOp{},
},
},
}
} | [
"func",
"NewUpdateGSetCommandBuilder",
"(",
")",
"*",
"UpdateGSetCommandBuilder",
"{",
"return",
"&",
"UpdateGSetCommandBuilder",
"{",
"protobuf",
":",
"&",
"rpbRiakDT",
".",
"DtUpdateReq",
"{",
"Op",
":",
"&",
"rpbRiakDT",
".",
"DtOp",
"{",
"GsetOp",
":",
"&",
... | // NewUpdateGSetCommandBuilder is a factory function for generating the command builder struct | [
"NewUpdateGSetCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L676-L684 |
151,334 | basho/riak-go-client | crdt_commands.go | IncrementCounter | func (mapOp *MapOperation) IncrementCounter(key string, increment int64) *MapOperation {
if mapOp.removeCounters != nil {
delete(mapOp.removeCounters, key)
}
if mapOp.incrementCounters == nil {
mapOp.incrementCounters = make(map[string]int64)
}
mapOp.incrementCounters[key] += increment
return mapOp
} | go | func (mapOp *MapOperation) IncrementCounter(key string, increment int64) *MapOperation {
if mapOp.removeCounters != nil {
delete(mapOp.removeCounters, key)
}
if mapOp.incrementCounters == nil {
mapOp.incrementCounters = make(map[string]int64)
}
mapOp.incrementCounters[key] += increment
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"IncrementCounter",
"(",
"key",
"string",
",",
"increment",
"int64",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeCounters",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeCounters",
",",
... | // IncrementCounter increments a child counter CRDT of the map at the specified key | [
"IncrementCounter",
"increments",
"a",
"child",
"counter",
"CRDT",
"of",
"the",
"map",
"at",
"the",
"specified",
"key"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1158-L1167 |
151,335 | basho/riak-go-client | crdt_commands.go | RemoveCounter | func (mapOp *MapOperation) RemoveCounter(key string) *MapOperation {
if mapOp.incrementCounters != nil {
delete(mapOp.incrementCounters, key)
}
if mapOp.removeCounters == nil {
mapOp.removeCounters = make(map[string]bool)
}
mapOp.removeCounters[key] = true
return mapOp
} | go | func (mapOp *MapOperation) RemoveCounter(key string) *MapOperation {
if mapOp.incrementCounters != nil {
delete(mapOp.incrementCounters, key)
}
if mapOp.removeCounters == nil {
mapOp.removeCounters = make(map[string]bool)
}
mapOp.removeCounters[key] = true
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveCounter",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"incrementCounters",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"incrementCounters",
",",
"key",
")",
"\n",
"}",
... | // RemoveCounter removes a child counter CRDT from the map at the specified key | [
"RemoveCounter",
"removes",
"a",
"child",
"counter",
"CRDT",
"from",
"the",
"map",
"at",
"the",
"specified",
"key"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1170-L1179 |
151,336 | basho/riak-go-client | crdt_commands.go | AddToSet | func (mapOp *MapOperation) AddToSet(key string, value []byte) *MapOperation {
if mapOp.removeSets != nil {
delete(mapOp.removeSets, key)
}
if mapOp.addToSets == nil {
mapOp.addToSets = make(map[string][][]byte)
}
mapOp.addToSets[key] = append(mapOp.addToSets[key], value)
return mapOp
} | go | func (mapOp *MapOperation) AddToSet(key string, value []byte) *MapOperation {
if mapOp.removeSets != nil {
delete(mapOp.removeSets, key)
}
if mapOp.addToSets == nil {
mapOp.addToSets = make(map[string][][]byte)
}
mapOp.addToSets[key] = append(mapOp.addToSets[key], value)
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"AddToSet",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeSets",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeSets",
",",
"key",
... | // AddToSet adds an element to the child set CRDT of the map at the specified key | [
"AddToSet",
"adds",
"an",
"element",
"to",
"the",
"child",
"set",
"CRDT",
"of",
"the",
"map",
"at",
"the",
"specified",
"key"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1182-L1191 |
151,337 | basho/riak-go-client | crdt_commands.go | RemoveFromSet | func (mapOp *MapOperation) RemoveFromSet(key string, value []byte) *MapOperation {
if mapOp.removeSets != nil {
delete(mapOp.removeSets, key)
}
if mapOp.removeFromSets == nil {
mapOp.removeFromSets = make(map[string][][]byte)
}
mapOp.removeFromSets[key] = append(mapOp.removeFromSets[key], value)
return mapOp
} | go | func (mapOp *MapOperation) RemoveFromSet(key string, value []byte) *MapOperation {
if mapOp.removeSets != nil {
delete(mapOp.removeSets, key)
}
if mapOp.removeFromSets == nil {
mapOp.removeFromSets = make(map[string][][]byte)
}
mapOp.removeFromSets[key] = append(mapOp.removeFromSets[key], value)
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveFromSet",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeSets",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeSets",
",",
"k... | // RemoveFromSet removes elements from the child set CRDT of the map at the specified key | [
"RemoveFromSet",
"removes",
"elements",
"from",
"the",
"child",
"set",
"CRDT",
"of",
"the",
"map",
"at",
"the",
"specified",
"key"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1194-L1203 |
151,338 | basho/riak-go-client | crdt_commands.go | RemoveSet | func (mapOp *MapOperation) RemoveSet(key string) *MapOperation {
if mapOp.addToSets != nil {
delete(mapOp.addToSets, key)
}
if mapOp.removeFromSets != nil {
delete(mapOp.removeFromSets, key)
}
if mapOp.removeSets == nil {
mapOp.removeSets = make(map[string]bool)
}
mapOp.removeSets[key] = true
return mapOp
} | go | func (mapOp *MapOperation) RemoveSet(key string) *MapOperation {
if mapOp.addToSets != nil {
delete(mapOp.addToSets, key)
}
if mapOp.removeFromSets != nil {
delete(mapOp.removeFromSets, key)
}
if mapOp.removeSets == nil {
mapOp.removeSets = make(map[string]bool)
}
mapOp.removeSets[key] = true
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveSet",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"addToSets",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"addToSets",
",",
"key",
")",
"\n",
"}",
"\n",
"if",
"ma... | // RemoveSet removes the child set CRDT from the map | [
"RemoveSet",
"removes",
"the",
"child",
"set",
"CRDT",
"from",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1206-L1218 |
151,339 | basho/riak-go-client | crdt_commands.go | SetRegister | func (mapOp *MapOperation) SetRegister(key string, value []byte) *MapOperation {
if mapOp.removeRegisters != nil {
delete(mapOp.removeRegisters, key)
}
if mapOp.registersToSet == nil {
mapOp.registersToSet = make(map[string][]byte)
}
mapOp.registersToSet[key] = value
return mapOp
} | go | func (mapOp *MapOperation) SetRegister(key string, value []byte) *MapOperation {
if mapOp.removeRegisters != nil {
delete(mapOp.removeRegisters, key)
}
if mapOp.registersToSet == nil {
mapOp.registersToSet = make(map[string][]byte)
}
mapOp.registersToSet[key] = value
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"SetRegister",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeRegisters",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeRegisters",
"... | // SetRegister sets a register CRDT on the map with the provided value | [
"SetRegister",
"sets",
"a",
"register",
"CRDT",
"on",
"the",
"map",
"with",
"the",
"provided",
"value"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1221-L1230 |
151,340 | basho/riak-go-client | crdt_commands.go | RemoveRegister | func (mapOp *MapOperation) RemoveRegister(key string) *MapOperation {
if mapOp.registersToSet != nil {
delete(mapOp.registersToSet, key)
}
if mapOp.removeRegisters == nil {
mapOp.removeRegisters = make(map[string]bool)
}
mapOp.removeRegisters[key] = true
return mapOp
} | go | func (mapOp *MapOperation) RemoveRegister(key string) *MapOperation {
if mapOp.registersToSet != nil {
delete(mapOp.registersToSet, key)
}
if mapOp.removeRegisters == nil {
mapOp.removeRegisters = make(map[string]bool)
}
mapOp.removeRegisters[key] = true
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveRegister",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"registersToSet",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"registersToSet",
",",
"key",
")",
"\n",
"}",
"\n"... | // RemoveRegister removes a register CRDT from the map | [
"RemoveRegister",
"removes",
"a",
"register",
"CRDT",
"from",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1233-L1242 |
151,341 | basho/riak-go-client | crdt_commands.go | SetFlag | func (mapOp *MapOperation) SetFlag(key string, value bool) *MapOperation {
if mapOp.removeFlags != nil {
delete(mapOp.removeFlags, key)
}
if mapOp.flagsToSet == nil {
mapOp.flagsToSet = make(map[string]bool)
}
mapOp.flagsToSet[key] = value
return mapOp
} | go | func (mapOp *MapOperation) SetFlag(key string, value bool) *MapOperation {
if mapOp.removeFlags != nil {
delete(mapOp.removeFlags, key)
}
if mapOp.flagsToSet == nil {
mapOp.flagsToSet = make(map[string]bool)
}
mapOp.flagsToSet[key] = value
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"SetFlag",
"(",
"key",
"string",
",",
"value",
"bool",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeFlags",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeFlags",
",",
"key",
")",
"\n"... | // SetFlag sets a flag CRDT on the map | [
"SetFlag",
"sets",
"a",
"flag",
"CRDT",
"on",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1245-L1254 |
151,342 | basho/riak-go-client | crdt_commands.go | RemoveFlag | func (mapOp *MapOperation) RemoveFlag(key string) *MapOperation {
if mapOp.flagsToSet != nil {
delete(mapOp.flagsToSet, key)
}
if mapOp.removeFlags == nil {
mapOp.removeFlags = make(map[string]bool)
}
mapOp.removeFlags[key] = true
return mapOp
} | go | func (mapOp *MapOperation) RemoveFlag(key string) *MapOperation {
if mapOp.flagsToSet != nil {
delete(mapOp.flagsToSet, key)
}
if mapOp.removeFlags == nil {
mapOp.removeFlags = make(map[string]bool)
}
mapOp.removeFlags[key] = true
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveFlag",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"flagsToSet",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"flagsToSet",
",",
"key",
")",
"\n",
"}",
"\n",
"if",
... | // RemoveFlag removes a flag CRDT from the map | [
"RemoveFlag",
"removes",
"a",
"flag",
"CRDT",
"from",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1257-L1266 |
151,343 | basho/riak-go-client | crdt_commands.go | Map | func (mapOp *MapOperation) Map(key string) *MapOperation {
if mapOp.removeMaps != nil {
delete(mapOp.removeMaps, key)
}
if mapOp.maps == nil {
mapOp.maps = make(map[string]*MapOperation)
}
innerMapOp, ok := mapOp.maps[key]
if ok {
return innerMapOp
}
innerMapOp = &MapOperation{}
mapOp.maps[key] = innerMapOp
return innerMapOp
} | go | func (mapOp *MapOperation) Map(key string) *MapOperation {
if mapOp.removeMaps != nil {
delete(mapOp.removeMaps, key)
}
if mapOp.maps == nil {
mapOp.maps = make(map[string]*MapOperation)
}
innerMapOp, ok := mapOp.maps[key]
if ok {
return innerMapOp
}
innerMapOp = &MapOperation{}
mapOp.maps[key] = innerMapOp
return innerMapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"Map",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"removeMaps",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"removeMaps",
",",
"key",
")",
"\n",
"}",
"\n",
"if",
"mapOp"... | // Map returns a nested map operation for manipulation | [
"Map",
"returns",
"a",
"nested",
"map",
"operation",
"for",
"manipulation"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1269-L1285 |
151,344 | basho/riak-go-client | crdt_commands.go | RemoveMap | func (mapOp *MapOperation) RemoveMap(key string) *MapOperation {
if mapOp.maps != nil {
delete(mapOp.maps, key)
}
if mapOp.removeMaps == nil {
mapOp.removeMaps = make(map[string]bool)
}
mapOp.removeMaps[key] = true
return mapOp
} | go | func (mapOp *MapOperation) RemoveMap(key string) *MapOperation {
if mapOp.maps != nil {
delete(mapOp.maps, key)
}
if mapOp.removeMaps == nil {
mapOp.removeMaps = make(map[string]bool)
}
mapOp.removeMaps[key] = true
return mapOp
} | [
"func",
"(",
"mapOp",
"*",
"MapOperation",
")",
"RemoveMap",
"(",
"key",
"string",
")",
"*",
"MapOperation",
"{",
"if",
"mapOp",
".",
"maps",
"!=",
"nil",
"{",
"delete",
"(",
"mapOp",
".",
"maps",
",",
"key",
")",
"\n",
"}",
"\n",
"if",
"mapOp",
".... | // RemoveMap removes a nested map from the map | [
"RemoveMap",
"removes",
"a",
"nested",
"map",
"from",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1288-L1297 |
151,345 | basho/riak-go-client | crdt_commands.go | WithContext | func (builder *UpdateMapCommandBuilder) WithContext(context []byte) *UpdateMapCommandBuilder {
builder.protobuf.Context = context
return builder
} | go | func (builder *UpdateMapCommandBuilder) WithContext(context []byte) *UpdateMapCommandBuilder {
builder.protobuf.Context = context
return builder
} | [
"func",
"(",
"builder",
"*",
"UpdateMapCommandBuilder",
")",
"WithContext",
"(",
"context",
"[",
"]",
"byte",
")",
"*",
"UpdateMapCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Context",
"=",
"context",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithContext sets the causal context needed to identify the state of the map when removing elements | [
"WithContext",
"sets",
"the",
"causal",
"context",
"needed",
"to",
"identify",
"the",
"state",
"of",
"the",
"map",
"when",
"removing",
"elements"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1416-L1419 |
151,346 | basho/riak-go-client | crdt_commands.go | WithMapOperation | func (builder *UpdateMapCommandBuilder) WithMapOperation(mapOperation *MapOperation) *UpdateMapCommandBuilder {
builder.mapOperation = mapOperation
return builder
} | go | func (builder *UpdateMapCommandBuilder) WithMapOperation(mapOperation *MapOperation) *UpdateMapCommandBuilder {
builder.mapOperation = mapOperation
return builder
} | [
"func",
"(",
"builder",
"*",
"UpdateMapCommandBuilder",
")",
"WithMapOperation",
"(",
"mapOperation",
"*",
"MapOperation",
")",
"*",
"UpdateMapCommandBuilder",
"{",
"builder",
".",
"mapOperation",
"=",
"mapOperation",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithMapOperation provides the details of what is supposed to be updated on the map | [
"WithMapOperation",
"provides",
"the",
"details",
"of",
"what",
"is",
"supposed",
"to",
"be",
"updated",
"on",
"the",
"map"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1422-L1425 |
151,347 | basho/riak-go-client | crdt_commands.go | NewUpdateHllCommandBuilder | func NewUpdateHllCommandBuilder() *UpdateHllCommandBuilder {
return &UpdateHllCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
HllOp: &rpbRiakDT.HllOp{},
},
},
}
} | go | func NewUpdateHllCommandBuilder() *UpdateHllCommandBuilder {
return &UpdateHllCommandBuilder{
protobuf: &rpbRiakDT.DtUpdateReq{
Op: &rpbRiakDT.DtOp{
HllOp: &rpbRiakDT.HllOp{},
},
},
}
} | [
"func",
"NewUpdateHllCommandBuilder",
"(",
")",
"*",
"UpdateHllCommandBuilder",
"{",
"return",
"&",
"UpdateHllCommandBuilder",
"{",
"protobuf",
":",
"&",
"rpbRiakDT",
".",
"DtUpdateReq",
"{",
"Op",
":",
"&",
"rpbRiakDT",
".",
"DtOp",
"{",
"HllOp",
":",
"&",
"r... | // NewUpdateHllCommandBuilder is a factory function for generating the command builder struct | [
"NewUpdateHllCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1733-L1741 |
151,348 | basho/riak-go-client | crdt_commands.go | WithAdditions | func (builder *UpdateHllCommandBuilder) WithAdditions(adds ...[]byte) *UpdateHllCommandBuilder {
opAdds := builder.protobuf.Op.HllOp.Adds
opAdds = append(opAdds, adds...)
builder.protobuf.Op.HllOp.Adds = opAdds
return builder
} | go | func (builder *UpdateHllCommandBuilder) WithAdditions(adds ...[]byte) *UpdateHllCommandBuilder {
opAdds := builder.protobuf.Op.HllOp.Adds
opAdds = append(opAdds, adds...)
builder.protobuf.Op.HllOp.Adds = opAdds
return builder
} | [
"func",
"(",
"builder",
"*",
"UpdateHllCommandBuilder",
")",
"WithAdditions",
"(",
"adds",
"...",
"[",
"]",
"byte",
")",
"*",
"UpdateHllCommandBuilder",
"{",
"opAdds",
":=",
"builder",
".",
"protobuf",
".",
"Op",
".",
"HllOp",
".",
"Adds",
"\n",
"opAdds",
... | // WithAdditions sets the Hll elements to be added to the Hll Data Type via this update operation | [
"WithAdditions",
"sets",
"the",
"Hll",
"elements",
"to",
"be",
"added",
"to",
"the",
"Hll",
"Data",
"Type",
"via",
"this",
"update",
"operation"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/crdt_commands.go#L1762-L1767 |
151,349 | basho/riak-go-client | client.go | NewClient | func NewClient(opts *NewClientOptions) (*Client, error) {
if opts == nil {
return nil, ErrClientOptionsRequired
}
if opts.Cluster != nil {
return newClientUsingCluster(opts.Cluster)
}
if opts.RemoteAddresses != nil {
return newClientUsingAddresses(opts.Port, opts.RemoteAddresses)
}
return nil, ErrClientMissingRequiredData
} | go | func NewClient(opts *NewClientOptions) (*Client, error) {
if opts == nil {
return nil, ErrClientOptionsRequired
}
if opts.Cluster != nil {
return newClientUsingCluster(opts.Cluster)
}
if opts.RemoteAddresses != nil {
return newClientUsingAddresses(opts.Port, opts.RemoteAddresses)
}
return nil, ErrClientMissingRequiredData
} | [
"func",
"NewClient",
"(",
"opts",
"*",
"NewClientOptions",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrClientOptionsRequired",
"\n",
"}",
"\n",
"if",
"opts",
".",
"Cluster",
"!=",
"nil",
"{... | // NewClient generates a new Client object using the provided options | [
"NewClient",
"generates",
"a",
"new",
"Client",
"object",
"using",
"the",
"provided",
"options"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/client.go#L43-L54 |
151,350 | basho/riak-go-client | client.go | Ping | func (c *Client) Ping() (bool, error) {
cmd := &PingCommand{}
err := c.cluster.Execute(cmd)
return cmd.Success(), err
} | go | func (c *Client) Ping() (bool, error) {
cmd := &PingCommand{}
err := c.cluster.Execute(cmd)
return cmd.Success(), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Ping",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cmd",
":=",
"&",
"PingCommand",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"cluster",
".",
"Execute",
"(",
"cmd",
")",
"\n",
"return",
"cmd",
".",
"Succes... | // Pings the cluster | [
"Pings",
"the",
"cluster"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/client.go#L71-L75 |
151,351 | basho/riak-go-client | misc_commands.go | NewStoreBucketTypePropsCommandBuilder | func NewStoreBucketTypePropsCommandBuilder() *StoreBucketTypePropsCommandBuilder {
props := &rpbRiak.RpbBucketProps{}
protobuf := &rpbRiak.RpbSetBucketTypeReq{
Props: props,
}
builder := &StoreBucketTypePropsCommandBuilder{protobuf: protobuf, props: props}
return builder
} | go | func NewStoreBucketTypePropsCommandBuilder() *StoreBucketTypePropsCommandBuilder {
props := &rpbRiak.RpbBucketProps{}
protobuf := &rpbRiak.RpbSetBucketTypeReq{
Props: props,
}
builder := &StoreBucketTypePropsCommandBuilder{protobuf: protobuf, props: props}
return builder
} | [
"func",
"NewStoreBucketTypePropsCommandBuilder",
"(",
")",
"*",
"StoreBucketTypePropsCommandBuilder",
"{",
"props",
":=",
"&",
"rpbRiak",
".",
"RpbBucketProps",
"{",
"}",
"\n",
"protobuf",
":=",
"&",
"rpbRiak",
".",
"RpbSetBucketTypeReq",
"{",
"Props",
":",
"props",... | // NewStoreBucketTypePropsCommandBuilder is a factory function for generating the command builder struct | [
"NewStoreBucketTypePropsCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/misc_commands.go#L514-L521 |
151,352 | basho/riak-go-client | misc_commands.go | WithChashKeyFun | func (builder *StoreBucketTypePropsCommandBuilder) WithChashKeyFun(val *ModFun) *StoreBucketTypePropsCommandBuilder {
builder.props.ChashKeyfun = &rpbRiak.RpbModFun{
Module: []byte(val.Module),
Function: []byte(val.Function),
}
return builder
} | go | func (builder *StoreBucketTypePropsCommandBuilder) WithChashKeyFun(val *ModFun) *StoreBucketTypePropsCommandBuilder {
builder.props.ChashKeyfun = &rpbRiak.RpbModFun{
Module: []byte(val.Module),
Function: []byte(val.Function),
}
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreBucketTypePropsCommandBuilder",
")",
"WithChashKeyFun",
"(",
"val",
"*",
"ModFun",
")",
"*",
"StoreBucketTypePropsCommandBuilder",
"{",
"builder",
".",
"props",
".",
"ChashKeyfun",
"=",
"&",
"rpbRiak",
".",
"RpbModFun",
"{",
"Mod... | // WithChashKeyFun sets the chash_keyfun property on the bucket which allows custom hashing functions
// Please note, this is an advanced feature, only use with caution | [
"WithChashKeyFun",
"sets",
"the",
"chash_keyfun",
"property",
"on",
"the",
"bucket",
"which",
"allows",
"custom",
"hashing",
"functions",
"Please",
"note",
"this",
"is",
"an",
"advanced",
"feature",
"only",
"use",
"with",
"caution"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/misc_commands.go#L686-L692 |
151,353 | basho/riak-go-client | misc_commands.go | NewStoreBucketPropsCommandBuilder | func NewStoreBucketPropsCommandBuilder() *StoreBucketPropsCommandBuilder {
props := &rpbRiak.RpbBucketProps{}
protobuf := &rpbRiak.RpbSetBucketReq{
Props: props,
}
builder := &StoreBucketPropsCommandBuilder{protobuf: protobuf, props: props}
return builder
} | go | func NewStoreBucketPropsCommandBuilder() *StoreBucketPropsCommandBuilder {
props := &rpbRiak.RpbBucketProps{}
protobuf := &rpbRiak.RpbSetBucketReq{
Props: props,
}
builder := &StoreBucketPropsCommandBuilder{protobuf: protobuf, props: props}
return builder
} | [
"func",
"NewStoreBucketPropsCommandBuilder",
"(",
")",
"*",
"StoreBucketPropsCommandBuilder",
"{",
"props",
":=",
"&",
"rpbRiak",
".",
"RpbBucketProps",
"{",
"}",
"\n",
"protobuf",
":=",
"&",
"rpbRiak",
".",
"RpbSetBucketReq",
"{",
"Props",
":",
"props",
",",
"}... | // NewStoreBucketPropsCommandBuilder is a factory function for generating the command builder struct | [
"NewStoreBucketPropsCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/misc_commands.go#L727-L734 |
151,354 | basho/riak-go-client | yz_commands.go | NewStoreIndexCommandBuilder | func NewStoreIndexCommandBuilder() *StoreIndexCommandBuilder {
protobuf := &rpbRiakYZ.RpbYokozunaIndexPutReq{
Index: &rpbRiakYZ.RpbYokozunaIndex{},
}
builder := &StoreIndexCommandBuilder{protobuf: protobuf}
return builder
} | go | func NewStoreIndexCommandBuilder() *StoreIndexCommandBuilder {
protobuf := &rpbRiakYZ.RpbYokozunaIndexPutReq{
Index: &rpbRiakYZ.RpbYokozunaIndex{},
}
builder := &StoreIndexCommandBuilder{protobuf: protobuf}
return builder
} | [
"func",
"NewStoreIndexCommandBuilder",
"(",
")",
"*",
"StoreIndexCommandBuilder",
"{",
"protobuf",
":=",
"&",
"rpbRiakYZ",
".",
"RpbYokozunaIndexPutReq",
"{",
"Index",
":",
"&",
"rpbRiakYZ",
".",
"RpbYokozunaIndex",
"{",
"}",
",",
"}",
"\n",
"builder",
":=",
"&"... | // NewStoreIndexCommandBuilder is a factory function for generating the command builder struct | [
"NewStoreIndexCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L92-L98 |
151,355 | basho/riak-go-client | yz_commands.go | NewStoreSchemaCommandBuilder | func NewStoreSchemaCommandBuilder() *StoreSchemaCommandBuilder {
protobuf := &rpbRiakYZ.RpbYokozunaSchemaPutReq{
Schema: &rpbRiakYZ.RpbYokozunaSchema{},
}
builder := &StoreSchemaCommandBuilder{protobuf: protobuf}
return builder
} | go | func NewStoreSchemaCommandBuilder() *StoreSchemaCommandBuilder {
protobuf := &rpbRiakYZ.RpbYokozunaSchemaPutReq{
Schema: &rpbRiakYZ.RpbYokozunaSchema{},
}
builder := &StoreSchemaCommandBuilder{protobuf: protobuf}
return builder
} | [
"func",
"NewStoreSchemaCommandBuilder",
"(",
")",
"*",
"StoreSchemaCommandBuilder",
"{",
"protobuf",
":=",
"&",
"rpbRiakYZ",
".",
"RpbYokozunaSchemaPutReq",
"{",
"Schema",
":",
"&",
"rpbRiakYZ",
".",
"RpbYokozunaSchema",
"{",
"}",
",",
"}",
"\n",
"builder",
":=",
... | // NewStoreSchemaCommandBuilder is a factory function for generating the command builder struct | [
"NewStoreSchemaCommandBuilder",
"is",
"a",
"factory",
"function",
"for",
"generating",
"the",
"command",
"builder",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L345-L351 |
151,356 | basho/riak-go-client | yz_commands.go | WithSchemaName | func (builder *StoreSchemaCommandBuilder) WithSchemaName(schemaName string) *StoreSchemaCommandBuilder {
builder.protobuf.Schema.Name = []byte(schemaName)
return builder
} | go | func (builder *StoreSchemaCommandBuilder) WithSchemaName(schemaName string) *StoreSchemaCommandBuilder {
builder.protobuf.Schema.Name = []byte(schemaName)
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreSchemaCommandBuilder",
")",
"WithSchemaName",
"(",
"schemaName",
"string",
")",
"*",
"StoreSchemaCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Schema",
".",
"Name",
"=",
"[",
"]",
"byte",
"(",
"schemaName",
")",
"\n... | // WithSchemaName sets the name for the schema to be stored | [
"WithSchemaName",
"sets",
"the",
"name",
"for",
"the",
"schema",
"to",
"be",
"stored"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L354-L357 |
151,357 | basho/riak-go-client | yz_commands.go | WithSchema | func (builder *StoreSchemaCommandBuilder) WithSchema(schema string) *StoreSchemaCommandBuilder {
builder.protobuf.Schema.Content = []byte(schema)
return builder
} | go | func (builder *StoreSchemaCommandBuilder) WithSchema(schema string) *StoreSchemaCommandBuilder {
builder.protobuf.Schema.Content = []byte(schema)
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreSchemaCommandBuilder",
")",
"WithSchema",
"(",
"schema",
"string",
")",
"*",
"StoreSchemaCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Schema",
".",
"Content",
"=",
"[",
"]",
"byte",
"(",
"schema",
")",
"\n",
"ret... | // WithSchema sets the actual schema that solr will use for indexing and queries | [
"WithSchema",
"sets",
"the",
"actual",
"schema",
"that",
"solr",
"will",
"use",
"for",
"indexing",
"and",
"queries"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L360-L363 |
151,358 | basho/riak-go-client | yz_commands.go | WithQuery | func (builder *SearchCommandBuilder) WithQuery(query string) *SearchCommandBuilder {
builder.protobuf.Q = []byte(query)
return builder
} | go | func (builder *SearchCommandBuilder) WithQuery(query string) *SearchCommandBuilder {
builder.protobuf.Q = []byte(query)
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithQuery",
"(",
"query",
"string",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Q",
"=",
"[",
"]",
"byte",
"(",
"query",
")",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithQuery sets the solr query to be executed on Riak | [
"WithQuery",
"sets",
"the",
"solr",
"query",
"to",
"be",
"executed",
"on",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L585-L588 |
151,359 | basho/riak-go-client | yz_commands.go | WithNumRows | func (builder *SearchCommandBuilder) WithNumRows(numRows uint32) *SearchCommandBuilder {
builder.protobuf.Rows = &numRows
return builder
} | go | func (builder *SearchCommandBuilder) WithNumRows(numRows uint32) *SearchCommandBuilder {
builder.protobuf.Rows = &numRows
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithNumRows",
"(",
"numRows",
"uint32",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Rows",
"=",
"&",
"numRows",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithNumRows sets the number of documents to be returned by Riak | [
"WithNumRows",
"sets",
"the",
"number",
"of",
"documents",
"to",
"be",
"returned",
"by",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L591-L594 |
151,360 | basho/riak-go-client | yz_commands.go | WithStart | func (builder *SearchCommandBuilder) WithStart(start uint32) *SearchCommandBuilder {
builder.protobuf.Start = &start
return builder
} | go | func (builder *SearchCommandBuilder) WithStart(start uint32) *SearchCommandBuilder {
builder.protobuf.Start = &start
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithStart",
"(",
"start",
"uint32",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Start",
"=",
"&",
"start",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithStart sets the document to start the result set with | [
"WithStart",
"sets",
"the",
"document",
"to",
"start",
"the",
"result",
"set",
"with"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L597-L600 |
151,361 | basho/riak-go-client | yz_commands.go | WithSortField | func (builder *SearchCommandBuilder) WithSortField(sortField string) *SearchCommandBuilder {
builder.protobuf.Sort = []byte(sortField)
return builder
} | go | func (builder *SearchCommandBuilder) WithSortField(sortField string) *SearchCommandBuilder {
builder.protobuf.Sort = []byte(sortField)
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithSortField",
"(",
"sortField",
"string",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Sort",
"=",
"[",
"]",
"byte",
"(",
"sortField",
")",
"\n",
"return",
"builder",
"\... | // WithSortField defines which field should be used for sorting the result set | [
"WithSortField",
"defines",
"which",
"field",
"should",
"be",
"used",
"for",
"sorting",
"the",
"result",
"set"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L603-L606 |
151,362 | basho/riak-go-client | yz_commands.go | WithFilterQuery | func (builder *SearchCommandBuilder) WithFilterQuery(filterQuery string) *SearchCommandBuilder {
builder.protobuf.Filter = []byte(filterQuery)
return builder
} | go | func (builder *SearchCommandBuilder) WithFilterQuery(filterQuery string) *SearchCommandBuilder {
builder.protobuf.Filter = []byte(filterQuery)
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithFilterQuery",
"(",
"filterQuery",
"string",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Filter",
"=",
"[",
"]",
"byte",
"(",
"filterQuery",
")",
"\n",
"return",
"builde... | // WithFilterQuery sets the solr filter query to be used, the main query runs first, the filter
// query reduces the scope of the result set even further | [
"WithFilterQuery",
"sets",
"the",
"solr",
"filter",
"query",
"to",
"be",
"used",
"the",
"main",
"query",
"runs",
"first",
"the",
"filter",
"query",
"reduces",
"the",
"scope",
"of",
"the",
"result",
"set",
"even",
"further"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L610-L613 |
151,363 | basho/riak-go-client | yz_commands.go | WithReturnFields | func (builder *SearchCommandBuilder) WithReturnFields(fields ...string) *SearchCommandBuilder {
builder.protobuf.Fl = make([][]byte, len(fields))
for i, f := range fields {
builder.protobuf.Fl[i] = []byte(f)
}
return builder
} | go | func (builder *SearchCommandBuilder) WithReturnFields(fields ...string) *SearchCommandBuilder {
builder.protobuf.Fl = make([][]byte, len(fields))
for i, f := range fields {
builder.protobuf.Fl[i] = []byte(f)
}
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithReturnFields",
"(",
"fields",
"...",
"string",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Fl",
"=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"len",
"(",
"fi... | // WithReturnFields sets the fields to be returned within each document | [
"WithReturnFields",
"sets",
"the",
"fields",
"to",
"be",
"returned",
"within",
"each",
"document"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L632-L638 |
151,364 | basho/riak-go-client | yz_commands.go | WithPresort | func (builder *SearchCommandBuilder) WithPresort(presort string) *SearchCommandBuilder {
builder.protobuf.Presort = []byte(presort)
return builder
} | go | func (builder *SearchCommandBuilder) WithPresort(presort string) *SearchCommandBuilder {
builder.protobuf.Presort = []byte(presort)
return builder
} | [
"func",
"(",
"builder",
"*",
"SearchCommandBuilder",
")",
"WithPresort",
"(",
"presort",
"string",
")",
"*",
"SearchCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Presort",
"=",
"[",
"]",
"byte",
"(",
"presort",
")",
"\n",
"return",
"builder",
"\n",... | // WithPresort allows you to configure Riak to presort the result set by Key or Score | [
"WithPresort",
"allows",
"you",
"to",
"configure",
"Riak",
"to",
"presort",
"the",
"result",
"set",
"by",
"Key",
"or",
"Score"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/yz_commands.go#L641-L644 |
151,365 | ClusterHQ/flocker-go | client.go | NewClient | func NewClient(host string, port int, clientIP string, caCertPath, keyPath, certPath string) (*Client, error) {
client, err := newTLSClient(caCertPath, keyPath, certPath)
if err != nil {
return nil, err
}
return &Client{
Client: client,
schema: "https",
host: host,
port: port,
version: "v1",
maximumSize: defaultVolumeSize,
clientIP: clientIP,
}, nil
} | go | func NewClient(host string, port int, clientIP string, caCertPath, keyPath, certPath string) (*Client, error) {
client, err := newTLSClient(caCertPath, keyPath, certPath)
if err != nil {
return nil, err
}
return &Client{
Client: client,
schema: "https",
host: host,
port: port,
version: "v1",
maximumSize: defaultVolumeSize,
clientIP: clientIP,
}, nil
} | [
"func",
"NewClient",
"(",
"host",
"string",
",",
"port",
"int",
",",
"clientIP",
"string",
",",
"caCertPath",
",",
"keyPath",
",",
"certPath",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"newTLSClient",
"(",
"... | // NewClient creates a wrapper over http.Client to communicate with the flocker control service. | [
"NewClient",
"creates",
"a",
"wrapper",
"over",
"http",
".",
"Client",
"to",
"communicate",
"with",
"the",
"flocker",
"control",
"service",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L66-L81 |
151,366 | ClusterHQ/flocker-go | client.go | post | func (c Client) post(url string, payload interface{}) (*http.Response, error) {
return c.request("POST", url, payload)
} | go | func (c Client) post(url string, payload interface{}) (*http.Response, error) {
return c.request("POST", url, payload)
} | [
"func",
"(",
"c",
"Client",
")",
"post",
"(",
"url",
"string",
",",
"payload",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"url",
",",
"payload",
")",... | // post performs a post request with the indicated payload | [
"post",
"performs",
"a",
"post",
"request",
"with",
"the",
"indicated",
"payload"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L114-L116 |
151,367 | ClusterHQ/flocker-go | client.go | get | func (c Client) get(url string) (*http.Response, error) {
return c.request("GET", url, nil)
} | go | func (c Client) get(url string) (*http.Response, error) {
return c.request("GET", url, nil)
} | [
"func",
"(",
"c",
"Client",
")",
"get",
"(",
"url",
"string",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"url",
",",
"nil",
")",
"\n",
"}"
] | // get performs a get request | [
"get",
"performs",
"a",
"get",
"request"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L124-L126 |
151,368 | ClusterHQ/flocker-go | client.go | getURL | func (c Client) getURL(path string) string {
return fmt.Sprintf("%s://%s:%d/%s/%s", c.schema, c.host, c.port, c.version, path)
} | go | func (c Client) getURL(path string) string {
return fmt.Sprintf("%s://%s:%d/%s/%s", c.schema, c.host, c.port, c.version, path)
} | [
"func",
"(",
"c",
"Client",
")",
"getURL",
"(",
"path",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"schema",
",",
"c",
".",
"host",
",",
"c",
".",
"port",
",",
"c",
".",
"version",
",",
"path"... | // getURL returns a full URI to the control service | [
"getURL",
"returns",
"a",
"full",
"URI",
"to",
"the",
"control",
"service"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L129-L131 |
151,369 | ClusterHQ/flocker-go | client.go | findIDInConfigurationsPayload | func (c Client) findIDInConfigurationsPayload(body io.ReadCloser, name string) (datasetID string, err error) {
var configurations []configurationPayload
if err = json.NewDecoder(body).Decode(&configurations); err == nil {
for _, r := range configurations {
if r.Metadata.Name == name {
return r.DatasetID, nil
}
}
return "", errConfigurationNotFound
}
return "", err
} | go | func (c Client) findIDInConfigurationsPayload(body io.ReadCloser, name string) (datasetID string, err error) {
var configurations []configurationPayload
if err = json.NewDecoder(body).Decode(&configurations); err == nil {
for _, r := range configurations {
if r.Metadata.Name == name {
return r.DatasetID, nil
}
}
return "", errConfigurationNotFound
}
return "", err
} | [
"func",
"(",
"c",
"Client",
")",
"findIDInConfigurationsPayload",
"(",
"body",
"io",
".",
"ReadCloser",
",",
"name",
"string",
")",
"(",
"datasetID",
"string",
",",
"err",
"error",
")",
"{",
"var",
"configurations",
"[",
"]",
"configurationPayload",
"\n",
"i... | // findIDInConfigurationsPayload returns the datasetID if it was found in the
// configurations payload, otherwise it will return an error. | [
"findIDInConfigurationsPayload",
"returns",
"the",
"datasetID",
"if",
"it",
"was",
"found",
"in",
"the",
"configurations",
"payload",
"otherwise",
"it",
"will",
"return",
"an",
"error",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L170-L181 |
151,370 | ClusterHQ/flocker-go | client.go | ListNodes | func (c *Client) ListNodes() (nodes []NodeState, err error) {
resp, err := c.get(c.getURL("state/nodes"))
if err != nil {
return []NodeState{}, err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return []NodeState{}, fmt.Errorf("Expected: {1,2}xx listing nodes, got: %d", resp.StatusCode)
}
err = json.NewDecoder(resp.Body).Decode(&nodes)
if err != nil {
return []NodeState{}, err
}
return nodes, err
} | go | func (c *Client) ListNodes() (nodes []NodeState, err error) {
resp, err := c.get(c.getURL("state/nodes"))
if err != nil {
return []NodeState{}, err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return []NodeState{}, fmt.Errorf("Expected: {1,2}xx listing nodes, got: %d", resp.StatusCode)
}
err = json.NewDecoder(resp.Body).Decode(&nodes)
if err != nil {
return []NodeState{}, err
}
return nodes, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListNodes",
"(",
")",
"(",
"nodes",
"[",
"]",
"NodeState",
",",
"err",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"get",
"(",
"c",
".",
"getURL",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",... | // ListNodes returns a list of dataset agent nodes from Flocker Control Service | [
"ListNodes",
"returns",
"a",
"list",
"of",
"dataset",
"agent",
"nodes",
"from",
"Flocker",
"Control",
"Service"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L184-L199 |
151,371 | ClusterHQ/flocker-go | client.go | GetPrimaryUUID | func (c Client) GetPrimaryUUID() (uuid string, err error) {
states, err := c.ListNodes()
if err != nil {
return "", err
}
for _, s := range states {
if s.Host == c.clientIP {
return s.UUID, nil
}
}
return "", fmt.Errorf("No node found with IP '%s', available nodes %+v", c.clientIP, states)
} | go | func (c Client) GetPrimaryUUID() (uuid string, err error) {
states, err := c.ListNodes()
if err != nil {
return "", err
}
for _, s := range states {
if s.Host == c.clientIP {
return s.UUID, nil
}
}
return "", fmt.Errorf("No node found with IP '%s', available nodes %+v", c.clientIP, states)
} | [
"func",
"(",
"c",
"Client",
")",
"GetPrimaryUUID",
"(",
")",
"(",
"uuid",
"string",
",",
"err",
"error",
")",
"{",
"states",
",",
"err",
":=",
"c",
".",
"ListNodes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",... | // GetPrimaryUUID returns the UUID of the primary Flocker Control Service for
// the given host. | [
"GetPrimaryUUID",
"returns",
"the",
"UUID",
"of",
"the",
"primary",
"Flocker",
"Control",
"Service",
"for",
"the",
"given",
"host",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L203-L215 |
151,372 | ClusterHQ/flocker-go | client.go | DeleteDataset | func (c *Client) DeleteDataset(datasetID string) error {
url := c.getURL(fmt.Sprintf("configuration/datasets/%s", datasetID))
resp, err := c.delete(url, nil)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("Expected: {1,2}xx deleting the dataset %s, got: %d", datasetID, resp.StatusCode)
}
return nil
} | go | func (c *Client) DeleteDataset(datasetID string) error {
url := c.getURL(fmt.Sprintf("configuration/datasets/%s", datasetID))
resp, err := c.delete(url, nil)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("Expected: {1,2}xx deleting the dataset %s, got: %d", datasetID, resp.StatusCode)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteDataset",
"(",
"datasetID",
"string",
")",
"error",
"{",
"url",
":=",
"c",
".",
"getURL",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"datasetID",
")",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
"... | // DeleteDataset performs a delete request to the given datasetID | [
"DeleteDataset",
"performs",
"a",
"delete",
"request",
"to",
"the",
"given",
"datasetID"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L218-L231 |
151,373 | ClusterHQ/flocker-go | client.go | GetDatasetState | func (c Client) GetDatasetState(datasetID string) (*DatasetState, error) {
resp, err := c.get(c.getURL("state/datasets"))
if err != nil {
return nil, err
}
defer resp.Body.Close()
var states []datasetStatePayload
if err = json.NewDecoder(resp.Body).Decode(&states); err == nil {
for _, s := range states {
if s.DatasetID == datasetID {
return s.DatasetState, nil
}
}
return nil, errStateNotFound
}
return nil, err
} | go | func (c Client) GetDatasetState(datasetID string) (*DatasetState, error) {
resp, err := c.get(c.getURL("state/datasets"))
if err != nil {
return nil, err
}
defer resp.Body.Close()
var states []datasetStatePayload
if err = json.NewDecoder(resp.Body).Decode(&states); err == nil {
for _, s := range states {
if s.DatasetID == datasetID {
return s.DatasetState, nil
}
}
return nil, errStateNotFound
}
return nil, err
} | [
"func",
"(",
"c",
"Client",
")",
"GetDatasetState",
"(",
"datasetID",
"string",
")",
"(",
"*",
"DatasetState",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"get",
"(",
"c",
".",
"getURL",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"err... | // GetDatasetState performs a get request to get the state of the given datasetID, if
// something goes wrong or the datasetID was not found it returns an error. | [
"GetDatasetState",
"performs",
"a",
"get",
"request",
"to",
"get",
"the",
"state",
"of",
"the",
"given",
"datasetID",
"if",
"something",
"goes",
"wrong",
"or",
"the",
"datasetID",
"was",
"not",
"found",
"it",
"returns",
"an",
"error",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L235-L253 |
151,374 | ClusterHQ/flocker-go | client.go | UpdatePrimaryForDataset | func (c Client) UpdatePrimaryForDataset(newPrimaryUUID, datasetID string) (*DatasetState, error) {
payload := struct {
Primary string `json:"primary"`
}{
Primary: newPrimaryUUID,
}
url := c.getURL(fmt.Sprintf("configuration/datasets/%s", datasetID))
resp, err := c.post(url, payload)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return nil, errUpdatingDataset
}
var s DatasetState
if err := json.NewDecoder(resp.Body).Decode(&s); err != nil {
return nil, err
}
return &s, nil
} | go | func (c Client) UpdatePrimaryForDataset(newPrimaryUUID, datasetID string) (*DatasetState, error) {
payload := struct {
Primary string `json:"primary"`
}{
Primary: newPrimaryUUID,
}
url := c.getURL(fmt.Sprintf("configuration/datasets/%s", datasetID))
resp, err := c.post(url, payload)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return nil, errUpdatingDataset
}
var s DatasetState
if err := json.NewDecoder(resp.Body).Decode(&s); err != nil {
return nil, err
}
return &s, nil
} | [
"func",
"(",
"c",
"Client",
")",
"UpdatePrimaryForDataset",
"(",
"newPrimaryUUID",
",",
"datasetID",
"string",
")",
"(",
"*",
"DatasetState",
",",
"error",
")",
"{",
"payload",
":=",
"struct",
"{",
"Primary",
"string",
"`json:\"primary\"`",
"\n",
"}",
"{",
"... | // UpdatePrimaryForDataset will update the Primary for the given dataset
// returning the current DatasetState. | [
"UpdatePrimaryForDataset",
"will",
"update",
"the",
"Primary",
"for",
"the",
"given",
"dataset",
"returning",
"the",
"current",
"DatasetState",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L332-L356 |
151,375 | ClusterHQ/flocker-go | client.go | GetDatasetID | func (c Client) GetDatasetID(metaName string) (datasetID string, err error) {
resp, err := c.get(c.getURL("configuration/datasets"))
if err != nil {
return "", err
}
defer resp.Body.Close()
var configurations []configurationPayload
if err = json.NewDecoder(resp.Body).Decode(&configurations); err == nil {
for _, c := range configurations {
if c.Metadata.Name == metaName && c.Deleted == false {
return c.DatasetID, nil
}
}
return "", errConfigurationNotFound
}
return "", err
} | go | func (c Client) GetDatasetID(metaName string) (datasetID string, err error) {
resp, err := c.get(c.getURL("configuration/datasets"))
if err != nil {
return "", err
}
defer resp.Body.Close()
var configurations []configurationPayload
if err = json.NewDecoder(resp.Body).Decode(&configurations); err == nil {
for _, c := range configurations {
if c.Metadata.Name == metaName && c.Deleted == false {
return c.DatasetID, nil
}
}
return "", errConfigurationNotFound
}
return "", err
} | [
"func",
"(",
"c",
"Client",
")",
"GetDatasetID",
"(",
"metaName",
"string",
")",
"(",
"datasetID",
"string",
",",
"err",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"get",
"(",
"c",
".",
"getURL",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",... | // GetDatasetID will return the DatasetID found for the given metadata name. | [
"GetDatasetID",
"will",
"return",
"the",
"DatasetID",
"found",
"for",
"the",
"given",
"metadata",
"name",
"."
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/client.go#L359-L376 |
151,376 | ClusterHQ/flocker-go | util.go | newTLSClient | func newTLSClient(caCertPath, keyPath, certPath string) (*http.Client, error) {
// Client certificate
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, err
}
// CA certificate
caCert, err := ioutil.ReadFile(caCertPath)
if err != nil {
return nil, err
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{TLSClientConfig: tlsConfig}
return &http.Client{Transport: transport}, nil
} | go | func newTLSClient(caCertPath, keyPath, certPath string) (*http.Client, error) {
// Client certificate
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, err
}
// CA certificate
caCert, err := ioutil.ReadFile(caCertPath)
if err != nil {
return nil, err
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{TLSClientConfig: tlsConfig}
return &http.Client{Transport: transport}, nil
} | [
"func",
"newTLSClient",
"(",
"caCertPath",
",",
"keyPath",
",",
"certPath",
"string",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"// Client certificate",
"cert",
",",
"err",
":=",
"tls",
".",
"LoadX509KeyPair",
"(",
"certPath",
",",
"key... | // newTLSClient returns a new TLS http client | [
"newTLSClient",
"returns",
"a",
"new",
"TLS",
"http",
"client"
] | 2b8b7259d3139c96c4a6871031355808ab3fd3b3 | https://github.com/ClusterHQ/flocker-go/blob/2b8b7259d3139c96c4a6871031355808ab3fd3b3/util.go#L11-L34 |
151,377 | ghetzel/argonaut | argonaut.go | Marshal | func Marshal(v interface{}) ([]byte, error) {
if command, sep, err := generateCommand(v, true); err == nil {
return []byte(strings.Join(command, sep)), nil
} else {
return nil, err
}
} | go | func Marshal(v interface{}) ([]byte, error) {
if command, sep, err := generateCommand(v, true); err == nil {
return []byte(strings.Join(command, sep)), nil
} else {
return nil, err
}
} | [
"func",
"Marshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"command",
",",
"sep",
",",
"err",
":=",
"generateCommand",
"(",
"v",
",",
"true",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"[",
"... | // Marshals a given struct into a shell-ready command line string. | [
"Marshals",
"a",
"given",
"struct",
"into",
"a",
"shell",
"-",
"ready",
"command",
"line",
"string",
"."
] | c300c7c6d23d13384f0e1261a8584d8d18cc6884 | https://github.com/ghetzel/argonaut/blob/c300c7c6d23d13384f0e1261a8584d8d18cc6884/argonaut.go#L58-L64 |
151,378 | go-humble/locstor | local_storage.go | SetItem | func SetItem(key, item string) (err error) {
if localStorage == nil || localStorage == js.Undefined {
return ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
}
}()
localStorage.Call("setItem", key, item)
return nil
} | go | func SetItem(key, item string) (err error) {
if localStorage == nil || localStorage == js.Undefined {
return ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
}
}()
localStorage.Call("setItem", key, item)
return nil
} | [
"func",
"SetItem",
"(",
"key",
",",
"item",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"localStorage",
"==",
"nil",
"||",
"localStorage",
"==",
"js",
".",
"Undefined",
"{",
"return",
"ErrLocalStorageNotSupported",
"\n",
"}",
"\n",
"defer",
"func",... | // SetItem saves the given item in localStorage under the given key. | [
"SetItem",
"saves",
"the",
"given",
"item",
"in",
"localStorage",
"under",
"the",
"given",
"key",
"."
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/local_storage.go#L72-L88 |
151,379 | go-humble/locstor | local_storage.go | GetItem | func GetItem(key string) (s string, err error) {
if localStorage == nil || localStorage == js.Undefined {
return "", ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
s = ""
}
}()
item := localStorage.Call("getItem", key)
if item == js.Undefined || item == nil {
err = newItemNotFoundError(
"Could not find an item with the given key: %s", key)
} else {
s = item.String()
}
return s, err
} | go | func GetItem(key string) (s string, err error) {
if localStorage == nil || localStorage == js.Undefined {
return "", ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
s = ""
}
}()
item := localStorage.Call("getItem", key)
if item == js.Undefined || item == nil {
err = newItemNotFoundError(
"Could not find an item with the given key: %s", key)
} else {
s = item.String()
}
return s, err
} | [
"func",
"GetItem",
"(",
"key",
"string",
")",
"(",
"s",
"string",
",",
"err",
"error",
")",
"{",
"if",
"localStorage",
"==",
"nil",
"||",
"localStorage",
"==",
"js",
".",
"Undefined",
"{",
"return",
"\"",
"\"",
",",
"ErrLocalStorageNotSupported",
"\n",
"... | // GetItem finds and returns the item identified by key. If there is no item in
// localStorage with the given key, GetItem will return an ItemNotFoundError. | [
"GetItem",
"finds",
"and",
"returns",
"the",
"item",
"identified",
"by",
"key",
".",
"If",
"there",
"is",
"no",
"item",
"in",
"localStorage",
"with",
"the",
"given",
"key",
"GetItem",
"will",
"return",
"an",
"ItemNotFoundError",
"."
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/local_storage.go#L92-L115 |
151,380 | go-humble/locstor | local_storage.go | Length | func Length() (l int, err error) {
if localStorage == nil || localStorage == js.Undefined {
return 0, ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
l = 0
}
}()
length := localStorage.Get("length")
return length.Int(), nil
} | go | func Length() (l int, err error) {
if localStorage == nil || localStorage == js.Undefined {
return 0, ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
l = 0
}
}()
length := localStorage.Get("length")
return length.Int(), nil
} | [
"func",
"Length",
"(",
")",
"(",
"l",
"int",
",",
"err",
"error",
")",
"{",
"if",
"localStorage",
"==",
"nil",
"||",
"localStorage",
"==",
"js",
".",
"Undefined",
"{",
"return",
"0",
",",
"ErrLocalStorageNotSupported",
"\n",
"}",
"\n",
"defer",
"func",
... | // Length returns the number of items currently in localStorage. | [
"Length",
"returns",
"the",
"number",
"of",
"items",
"currently",
"in",
"localStorage",
"."
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/local_storage.go#L164-L181 |
151,381 | go-humble/locstor | local_storage.go | Clear | func Clear() (err error) {
if localStorage == nil || localStorage == js.Undefined {
return ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
}
}()
localStorage.Call("clear")
return nil
} | go | func Clear() (err error) {
if localStorage == nil || localStorage == js.Undefined {
return ErrLocalStorageNotSupported
}
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("could not use local storage: %v", r)
}
}
}()
localStorage.Call("clear")
return nil
} | [
"func",
"Clear",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"localStorage",
"==",
"nil",
"||",
"localStorage",
"==",
"js",
".",
"Undefined",
"{",
"return",
"ErrLocalStorageNotSupported",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
"... | // Clear removes all items from localStorage. | [
"Clear",
"removes",
"all",
"items",
"from",
"localStorage",
"."
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/local_storage.go#L184-L200 |
151,382 | bradhe/stopwatch | watch.go | String | func (s *watch) String() string {
// if the watch isn't stopped yet...
if s.stop.IsZero() {
return "0m0.00s"
}
return s.duration().String()
} | go | func (s *watch) String() string {
// if the watch isn't stopped yet...
if s.stop.IsZero() {
return "0m0.00s"
}
return s.duration().String()
} | [
"func",
"(",
"s",
"*",
"watch",
")",
"String",
"(",
")",
"string",
"{",
"// if the watch isn't stopped yet...",
"if",
"s",
".",
"stop",
".",
"IsZero",
"(",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"duration",
"(",
")",
"... | // String returns a human-readable representation of the stopwatch's duration. | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"representation",
"of",
"the",
"stopwatch",
"s",
"duration",
"."
] | fd55e776a960ff999fa1dc7f2a64e0a82d8b1f07 | https://github.com/bradhe/stopwatch/blob/fd55e776a960ff999fa1dc7f2a64e0a82d8b1f07/watch.go#L67-L74 |
151,383 | bradhe/stopwatch | stopwatch.go | Start | func Start() Watch {
watch := &watch{time.Time{}, time.Time{}}
return watch.Start()
} | go | func Start() Watch {
watch := &watch{time.Time{}, time.Time{}}
return watch.Start()
} | [
"func",
"Start",
"(",
")",
"Watch",
"{",
"watch",
":=",
"&",
"watch",
"{",
"time",
".",
"Time",
"{",
"}",
",",
"time",
".",
"Time",
"{",
"}",
"}",
"\n",
"return",
"watch",
".",
"Start",
"(",
")",
"\n",
"}"
] | // Start starts a new Watch for you. | [
"Start",
"starts",
"a",
"new",
"Watch",
"for",
"you",
"."
] | fd55e776a960ff999fa1dc7f2a64e0a82d8b1f07 | https://github.com/bradhe/stopwatch/blob/fd55e776a960ff999fa1dc7f2a64e0a82d8b1f07/stopwatch.go#L8-L11 |
151,384 | go-humble/locstor | data_store.go | Save | func (store DataStore) Save(key string, item interface{}) error {
encodedItem, err := store.Encoding.Encode(item)
if err != nil {
return err
}
return SetItem(key, string(encodedItem))
} | go | func (store DataStore) Save(key string, item interface{}) error {
encodedItem, err := store.Encoding.Encode(item)
if err != nil {
return err
}
return SetItem(key, string(encodedItem))
} | [
"func",
"(",
"store",
"DataStore",
")",
"Save",
"(",
"key",
"string",
",",
"item",
"interface",
"{",
"}",
")",
"error",
"{",
"encodedItem",
",",
"err",
":=",
"store",
".",
"Encoding",
".",
"Encode",
"(",
"item",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Save saves the given item under the given key in localStorage. | [
"Save",
"saves",
"the",
"given",
"item",
"under",
"the",
"given",
"key",
"in",
"localStorage",
"."
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/data_store.go#L23-L29 |
151,385 | go-humble/locstor | data_store.go | Find | func (store DataStore) Find(key string, holder interface{}) error {
encodedItem, err := GetItem(key)
if err != nil {
return err
}
return store.Encoding.Decode([]byte(encodedItem), holder)
} | go | func (store DataStore) Find(key string, holder interface{}) error {
encodedItem, err := GetItem(key)
if err != nil {
return err
}
return store.Encoding.Decode([]byte(encodedItem), holder)
} | [
"func",
"(",
"store",
"DataStore",
")",
"Find",
"(",
"key",
"string",
",",
"holder",
"interface",
"{",
"}",
")",
"error",
"{",
"encodedItem",
",",
"err",
":=",
"GetItem",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // Find finds the item with the given key in localStorage and scans it into
// holder. holder must be a pointer to some data structure which is capable of
// holding the item. In general holder should be the same type as the item that
// was passed to Save. | [
"Find",
"finds",
"the",
"item",
"with",
"the",
"given",
"key",
"in",
"localStorage",
"and",
"scans",
"it",
"into",
"holder",
".",
"holder",
"must",
"be",
"a",
"pointer",
"to",
"some",
"data",
"structure",
"which",
"is",
"capable",
"of",
"holding",
"the",
... | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/data_store.go#L35-L41 |
151,386 | go-humble/locstor | encode.go | Encode | func (b binaryEncoderDecoder) Encode(v interface{}) ([]byte, error) {
buf := bytes.NewBuffer([]byte{})
enc := gob.NewEncoder(buf)
if err := enc.Encode(v); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func (b binaryEncoderDecoder) Encode(v interface{}) ([]byte, error) {
buf := bytes.NewBuffer([]byte{})
enc := gob.NewEncoder(buf)
if err := enc.Encode(v); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"(",
"b",
"binaryEncoderDecoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"[",
"]",
"byte",
"{",
"}",
")",
"\n",
"enc",
":=",
"gob",
... | // Encode implements the Encode method of Encoder | [
"Encode",
"implements",
"the",
"Encode",
"method",
"of",
"Encoder"
] | d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a | https://github.com/go-humble/locstor/blob/d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a/encode.go#L62-L69 |
151,387 | dutchcoders/go-virustotal | virustotal.go | newfileUploadRequest | func newfileUploadRequest(uri string, params map[string]string, path string, file io.Reader) (*http.Request, error) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
for key, val := range params {
_ = writer.WriteField(key, val)
}
part, err := writer.CreateFormFile("file", filepath.Base(path))
if err != nil {
return nil, err
}
_, err = io.Copy(part, file)
err = writer.Close()
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", uri, body)
req.Header.Set("Content-Type", writer.FormDataContentType())
return req, err
} | go | func newfileUploadRequest(uri string, params map[string]string, path string, file io.Reader) (*http.Request, error) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
for key, val := range params {
_ = writer.WriteField(key, val)
}
part, err := writer.CreateFormFile("file", filepath.Base(path))
if err != nil {
return nil, err
}
_, err = io.Copy(part, file)
err = writer.Close()
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", uri, body)
req.Header.Set("Content-Type", writer.FormDataContentType())
return req, err
} | [
"func",
"newfileUploadRequest",
"(",
"uri",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
",",
"path",
"string",
",",
"file",
"io",
".",
"Reader",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"body",
":=",
"&",
"byte... | // Creates a new file upload http request with optional extra params | [
"Creates",
"a",
"new",
"file",
"upload",
"http",
"request",
"with",
"optional",
"extra",
"params"
] | 24cc8e6fa329f020c70a3b32330b5743f1ba7971 | https://github.com/dutchcoders/go-virustotal/blob/24cc8e6fa329f020c70a3b32330b5743f1ba7971/virustotal.go#L337-L361 |
151,388 | jacobsa/reqtrace | trace_state.go | CreateSpan | func (ts *traceState) CreateSpan(desc string) (report ReportFunc) {
ts.mu.Lock()
defer ts.mu.Unlock()
index := len(ts.spans)
ts.spans = append(ts.spans, &span{desc: desc, start: time.Now()})
report = func(err error) { ts.report(index, err) }
return
} | go | func (ts *traceState) CreateSpan(desc string) (report ReportFunc) {
ts.mu.Lock()
defer ts.mu.Unlock()
index := len(ts.spans)
ts.spans = append(ts.spans, &span{desc: desc, start: time.Now()})
report = func(err error) { ts.report(index, err) }
return
} | [
"func",
"(",
"ts",
"*",
"traceState",
")",
"CreateSpan",
"(",
"desc",
"string",
")",
"(",
"report",
"ReportFunc",
")",
"{",
"ts",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ts",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"index",
":=",
"l... | // Associate a new span with the trace. Return a function that will report its
// completion. | [
"Associate",
"a",
"new",
"span",
"with",
"the",
"trace",
".",
"Return",
"a",
"function",
"that",
"will",
"report",
"its",
"completion",
"."
] | 245c9e0234cb2ad542483a336324e982f1a22934 | https://github.com/jacobsa/reqtrace/blob/245c9e0234cb2ad542483a336324e982f1a22934/trace_state.go#L63-L72 |
151,389 | jacobsa/reqtrace | trace_state.go | Log | func (ts *traceState) Log() {
ts.mu.Lock()
defer ts.mu.Unlock()
gLogger.Println()
// Special case: we require at least one span.
if len(ts.spans) == 0 {
return
}
// Print a banner for this trace.
const bannerHalfLength = 45
gLogger.Println()
gLogger.Printf(
"%s %s %s",
strings.Repeat("=", bannerHalfLength),
ts.spans[0].desc,
strings.Repeat("=", bannerHalfLength))
gLogger.Printf("Start time: %v", ts.spans[0].start.Format(time.RFC3339Nano))
gLogger.Println()
// Find the minimum start time and maximum end time of all durations.
var minStart time.Time
var maxEnd time.Time
for _, s := range ts.spans {
if !s.finished {
continue
}
if minStart.IsZero() || s.start.Before(minStart) {
minStart = s.start
}
if maxEnd.Before(s.end) {
maxEnd = s.end
}
}
// Bail out if something weird happened.
//
// TODO(jacobsa): Be more graceful.
totalDuration := maxEnd.Sub(minStart)
if minStart.IsZero() || maxEnd.IsZero() || totalDuration <= 0 {
gLogger.Println("(Weird trace)")
return
}
// Calculate the number of nanoseconds elapsed, as a floating point number.
totalNs := float64(totalDuration / time.Nanosecond)
// Log each span with some ASCII art showing its length relative to the
// total.
const totalNumCols float64 = 120
for _, s := range ts.spans {
if !s.finished {
gLogger.Printf("(Unfinished: %s)", s.desc)
gLogger.Println()
continue
}
// Calculate the duration of the span, and its width relative to the
// longest span.
d := s.end.Sub(s.start)
if d <= 0 {
gLogger.Println("(Weird duration)")
gLogger.Println()
continue
}
durationRatio := float64(d/time.Nanosecond) / totalNs
// We will offset the label and banner proportional to the time since the
// start of the earliest span.
offsetRatio := float64(s.start.Sub(minStart)/time.Nanosecond) / totalNs
offsetChars := int(round(offsetRatio * totalNumCols))
offsetStr := strings.Repeat(" ", offsetChars)
// Print the description and duration.
gLogger.Printf("%s%v", offsetStr, s.desc)
gLogger.Printf("%s%v", offsetStr, d)
// Print a banner showing the duration graphically.
bannerChars := int(round(durationRatio * totalNumCols))
var dashes string
if bannerChars > 2 {
dashes = strings.Repeat("-", bannerChars-2)
}
gLogger.Printf("%s|%s|", offsetStr, dashes)
gLogger.Println()
}
} | go | func (ts *traceState) Log() {
ts.mu.Lock()
defer ts.mu.Unlock()
gLogger.Println()
// Special case: we require at least one span.
if len(ts.spans) == 0 {
return
}
// Print a banner for this trace.
const bannerHalfLength = 45
gLogger.Println()
gLogger.Printf(
"%s %s %s",
strings.Repeat("=", bannerHalfLength),
ts.spans[0].desc,
strings.Repeat("=", bannerHalfLength))
gLogger.Printf("Start time: %v", ts.spans[0].start.Format(time.RFC3339Nano))
gLogger.Println()
// Find the minimum start time and maximum end time of all durations.
var minStart time.Time
var maxEnd time.Time
for _, s := range ts.spans {
if !s.finished {
continue
}
if minStart.IsZero() || s.start.Before(minStart) {
minStart = s.start
}
if maxEnd.Before(s.end) {
maxEnd = s.end
}
}
// Bail out if something weird happened.
//
// TODO(jacobsa): Be more graceful.
totalDuration := maxEnd.Sub(minStart)
if minStart.IsZero() || maxEnd.IsZero() || totalDuration <= 0 {
gLogger.Println("(Weird trace)")
return
}
// Calculate the number of nanoseconds elapsed, as a floating point number.
totalNs := float64(totalDuration / time.Nanosecond)
// Log each span with some ASCII art showing its length relative to the
// total.
const totalNumCols float64 = 120
for _, s := range ts.spans {
if !s.finished {
gLogger.Printf("(Unfinished: %s)", s.desc)
gLogger.Println()
continue
}
// Calculate the duration of the span, and its width relative to the
// longest span.
d := s.end.Sub(s.start)
if d <= 0 {
gLogger.Println("(Weird duration)")
gLogger.Println()
continue
}
durationRatio := float64(d/time.Nanosecond) / totalNs
// We will offset the label and banner proportional to the time since the
// start of the earliest span.
offsetRatio := float64(s.start.Sub(minStart)/time.Nanosecond) / totalNs
offsetChars := int(round(offsetRatio * totalNumCols))
offsetStr := strings.Repeat(" ", offsetChars)
// Print the description and duration.
gLogger.Printf("%s%v", offsetStr, s.desc)
gLogger.Printf("%s%v", offsetStr, d)
// Print a banner showing the duration graphically.
bannerChars := int(round(durationRatio * totalNumCols))
var dashes string
if bannerChars > 2 {
dashes = strings.Repeat("-", bannerChars-2)
}
gLogger.Printf("%s|%s|", offsetStr, dashes)
gLogger.Println()
}
} | [
"func",
"(",
"ts",
"*",
"traceState",
")",
"Log",
"(",
")",
"{",
"ts",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ts",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"gLogger",
".",
"Println",
"(",
")",
"\n\n",
"// Special case: we require at least... | // Log information about the spans in this trace. | [
"Log",
"information",
"about",
"the",
"spans",
"in",
"this",
"trace",
"."
] | 245c9e0234cb2ad542483a336324e982f1a22934 | https://github.com/jacobsa/reqtrace/blob/245c9e0234cb2ad542483a336324e982f1a22934/trace_state.go#L83-L175 |
151,390 | jacobsa/reqtrace | reqtrace.go | StartSpan | func StartSpan(
parent context.Context,
desc string) (ctx context.Context, report ReportFunc) {
// Look for the trace state.
val := parent.Value(traceStateKey)
if val == nil {
// Nothing to do.
ctx = parent
report = func(err error) {}
return
}
ts := val.(*traceState)
// Set up the report function.
report = ts.CreateSpan(desc)
// For now we don't do anything interesting with the context. In the future,
// we may use it to record span hierarchy.
ctx = parent
return
} | go | func StartSpan(
parent context.Context,
desc string) (ctx context.Context, report ReportFunc) {
// Look for the trace state.
val := parent.Value(traceStateKey)
if val == nil {
// Nothing to do.
ctx = parent
report = func(err error) {}
return
}
ts := val.(*traceState)
// Set up the report function.
report = ts.CreateSpan(desc)
// For now we don't do anything interesting with the context. In the future,
// we may use it to record span hierarchy.
ctx = parent
return
} | [
"func",
"StartSpan",
"(",
"parent",
"context",
".",
"Context",
",",
"desc",
"string",
")",
"(",
"ctx",
"context",
".",
"Context",
",",
"report",
"ReportFunc",
")",
"{",
"// Look for the trace state.",
"val",
":=",
"parent",
".",
"Value",
"(",
"traceStateKey",
... | // Begin a span within the current trace. Return a new context that should be
// used for operations that logically occur within the span, and a report
// function that must be called with the outcome of the logical operation
// represented by the span.
//
// If no trace is active, no span will be created but ctx and report will still
// be valid. | [
"Begin",
"a",
"span",
"within",
"the",
"current",
"trace",
".",
"Return",
"a",
"new",
"context",
"that",
"should",
"be",
"used",
"for",
"operations",
"that",
"logically",
"occur",
"within",
"the",
"span",
"and",
"a",
"report",
"function",
"that",
"must",
"... | 245c9e0234cb2ad542483a336324e982f1a22934 | https://github.com/jacobsa/reqtrace/blob/245c9e0234cb2ad542483a336324e982f1a22934/reqtrace.go#L51-L73 |
151,391 | jacobsa/reqtrace | reqtrace.go | Trace | func Trace(
parent context.Context,
desc string) (ctx context.Context, report ReportFunc) {
// If tracing is disabled, this is a no-op.
if !*fEnabled {
ctx = parent
report = func(err error) {}
return
}
// Is this context already being traced? If so, simply add a span.
if parent.Value(traceStateKey) != nil {
ctx, report = StartSpan(parent, desc)
return
}
// Set up a new trace state.
ts := new(traceState)
baseReport := ts.CreateSpan(desc)
// Log when finished.
report = func(err error) {
baseReport(err)
ts.Log()
}
// Set up the context.
ctx = context.WithValue(parent, traceStateKey, ts)
return
} | go | func Trace(
parent context.Context,
desc string) (ctx context.Context, report ReportFunc) {
// If tracing is disabled, this is a no-op.
if !*fEnabled {
ctx = parent
report = func(err error) {}
return
}
// Is this context already being traced? If so, simply add a span.
if parent.Value(traceStateKey) != nil {
ctx, report = StartSpan(parent, desc)
return
}
// Set up a new trace state.
ts := new(traceState)
baseReport := ts.CreateSpan(desc)
// Log when finished.
report = func(err error) {
baseReport(err)
ts.Log()
}
// Set up the context.
ctx = context.WithValue(parent, traceStateKey, ts)
return
} | [
"func",
"Trace",
"(",
"parent",
"context",
".",
"Context",
",",
"desc",
"string",
")",
"(",
"ctx",
"context",
".",
"Context",
",",
"report",
"ReportFunc",
")",
"{",
"// If tracing is disabled, this is a no-op.",
"if",
"!",
"*",
"fEnabled",
"{",
"ctx",
"=",
"... | // Like StartSpan, but begins a root span for a new trace if no trace is active
// in the supplied context and tracing is enabled for the process. | [
"Like",
"StartSpan",
"but",
"begins",
"a",
"root",
"span",
"for",
"a",
"new",
"trace",
"if",
"no",
"trace",
"is",
"active",
"in",
"the",
"supplied",
"context",
"and",
"tracing",
"is",
"enabled",
"for",
"the",
"process",
"."
] | 245c9e0234cb2ad542483a336324e982f1a22934 | https://github.com/jacobsa/reqtrace/blob/245c9e0234cb2ad542483a336324e982f1a22934/reqtrace.go#L102-L132 |
151,392 | nmiyake/pkg | dirs/dirs.go | MustGetwdEvalSymLinks | func MustGetwdEvalSymLinks() string {
physicalWd, err := GetwdEvalSymLinks()
if err != nil {
panic(fmt.Sprintf("failed to get real path to wd: %v", err))
}
return physicalWd
} | go | func MustGetwdEvalSymLinks() string {
physicalWd, err := GetwdEvalSymLinks()
if err != nil {
panic(fmt.Sprintf("failed to get real path to wd: %v", err))
}
return physicalWd
} | [
"func",
"MustGetwdEvalSymLinks",
"(",
")",
"string",
"{",
"physicalWd",
",",
"err",
":=",
"GetwdEvalSymLinks",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
")",
")",
"\n",
"}",
"\n",... | // MustGetwdEvalSymLinks returns the result of GetwdEvalSymLinks. If GetwdEvalSymLinks returns an error, panics. | [
"MustGetwdEvalSymLinks",
"returns",
"the",
"result",
"of",
"GetwdEvalSymLinks",
".",
"If",
"GetwdEvalSymLinks",
"returns",
"an",
"error",
"panics",
"."
] | ae0375219445def9b33b6fcbf5eb8f4dd68ea561 | https://github.com/nmiyake/pkg/blob/ae0375219445def9b33b6fcbf5eb8f4dd68ea561/dirs/dirs.go#L90-L96 |
151,393 | martinusso/go-docs | cnpj/cnpj.go | AssertValid | func AssertValid(cnpj string) (bool, error) {
cnpj = sanitize(cnpj)
if len(cnpj) != cnpjValidLength {
return false, errors.New(invalidLength)
}
for i := 0; i <= 9; i++ {
if cnpj == strings.Repeat(strconv.Itoa(i), cnpjValidLength) {
return false, errors.New(repeatedDigits)
}
}
return checkDigits(cnpj), nil
} | go | func AssertValid(cnpj string) (bool, error) {
cnpj = sanitize(cnpj)
if len(cnpj) != cnpjValidLength {
return false, errors.New(invalidLength)
}
for i := 0; i <= 9; i++ {
if cnpj == strings.Repeat(strconv.Itoa(i), cnpjValidLength) {
return false, errors.New(repeatedDigits)
}
}
return checkDigits(cnpj), nil
} | [
"func",
"AssertValid",
"(",
"cnpj",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cnpj",
"=",
"sanitize",
"(",
"cnpj",
")",
"\n\n",
"if",
"len",
"(",
"cnpj",
")",
"!=",
"cnpjValidLength",
"{",
"return",
"false",
",",
"errors",
".",
"New",
"(",... | // AssertValid validates the CNPJ returning a boolean and the error if any | [
"AssertValid",
"validates",
"the",
"CNPJ",
"returning",
"a",
"boolean",
"and",
"the",
"error",
"if",
"any"
] | 84299b8633b3adbaa5cf9696455795c2b1eb023e | https://github.com/martinusso/go-docs/blob/84299b8633b3adbaa5cf9696455795c2b1eb023e/cnpj/cnpj.go#L30-L44 |
151,394 | martinusso/go-docs | cnpj/cnpj.go | Generate | func Generate() string {
rand.Seed(time.Now().UTC().UnixNano())
cnpj := make([]int, 12)
for i := 0; i < 12; i++ {
cnpj[i] = rand.Intn(9)
}
checkDigit1 := computeCheckDigit(cnpj)
cnpj = append(cnpj, checkDigit1)
checkDigit2 := computeCheckDigit(cnpj)
cnpj = append(cnpj, checkDigit2)
var str string
for _, value := range cnpj {
str += strconv.Itoa(value)
}
return str
} | go | func Generate() string {
rand.Seed(time.Now().UTC().UnixNano())
cnpj := make([]int, 12)
for i := 0; i < 12; i++ {
cnpj[i] = rand.Intn(9)
}
checkDigit1 := computeCheckDigit(cnpj)
cnpj = append(cnpj, checkDigit1)
checkDigit2 := computeCheckDigit(cnpj)
cnpj = append(cnpj, checkDigit2)
var str string
for _, value := range cnpj {
str += strconv.Itoa(value)
}
return str
} | [
"func",
"Generate",
"(",
")",
"string",
"{",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
"\n\n",
"cnpj",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"12",
")",
"\n",
"for",
"i",
... | // Generate returns a random valid CNPJ | [
"Generate",
"returns",
"a",
"random",
"valid",
"CNPJ"
] | 84299b8633b3adbaa5cf9696455795c2b1eb023e | https://github.com/martinusso/go-docs/blob/84299b8633b3adbaa5cf9696455795c2b1eb023e/cnpj/cnpj.go#L47-L64 |
151,395 | fanout/go-pubcontrol | pubcontrol.go | NewPubControl | func NewPubControl(config []map[string]interface{}) *PubControl {
pc := new(PubControl)
pc.clients = make([]*PubControlClient, 0)
if config != nil && len(config) > 0 {
pc.ApplyConfig(config)
}
return pc
} | go | func NewPubControl(config []map[string]interface{}) *PubControl {
pc := new(PubControl)
pc.clients = make([]*PubControlClient, 0)
if config != nil && len(config) > 0 {
pc.ApplyConfig(config)
}
return pc
} | [
"func",
"NewPubControl",
"(",
"config",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"PubControl",
"{",
"pc",
":=",
"new",
"(",
"PubControl",
")",
"\n",
"pc",
".",
"clients",
"=",
"make",
"(",
"[",
"]",
"*",
"PubControlClient... | // Initialize with or without a configuration. A configuration can be applied
// after initialization via the apply_config method. | [
"Initialize",
"with",
"or",
"without",
"a",
"configuration",
".",
"A",
"configuration",
"can",
"be",
"applied",
"after",
"initialization",
"via",
"the",
"apply_config",
"method",
"."
] | 6700863ff8fe6be673bfa0c25c391077b328a8c4 | https://github.com/fanout/go-pubcontrol/blob/6700863ff8fe6be673bfa0c25c391077b328a8c4/pubcontrol.go#L29-L36 |
151,396 | fanout/go-pubcontrol | pubcontrol.go | RemoveAllClients | func (pc *PubControl) RemoveAllClients() {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
pc.clients = make([]*PubControlClient, 0)
} | go | func (pc *PubControl) RemoveAllClients() {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
pc.clients = make([]*PubControlClient, 0)
} | [
"func",
"(",
"pc",
"*",
"PubControl",
")",
"RemoveAllClients",
"(",
")",
"{",
"pc",
".",
"clientsRWLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pc",
".",
"clientsRWLock",
".",
"Unlock",
"(",
")",
"\n",
"pc",
".",
"clients",
"=",
"make",
"(",
"[",
... | // Remove all of the configured PubControlClient instances. | [
"Remove",
"all",
"of",
"the",
"configured",
"PubControlClient",
"instances",
"."
] | 6700863ff8fe6be673bfa0c25c391077b328a8c4 | https://github.com/fanout/go-pubcontrol/blob/6700863ff8fe6be673bfa0c25c391077b328a8c4/pubcontrol.go#L39-L43 |
151,397 | fanout/go-pubcontrol | pubcontrol.go | AddClient | func (pc *PubControl) AddClient(pcc *PubControlClient) {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
pc.clients = append(pc.clients, pcc)
} | go | func (pc *PubControl) AddClient(pcc *PubControlClient) {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
pc.clients = append(pc.clients, pcc)
} | [
"func",
"(",
"pc",
"*",
"PubControl",
")",
"AddClient",
"(",
"pcc",
"*",
"PubControlClient",
")",
"{",
"pc",
".",
"clientsRWLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pc",
".",
"clientsRWLock",
".",
"Unlock",
"(",
")",
"\n",
"pc",
".",
"clients",
... | // Add the specified PubControlClient instance. | [
"Add",
"the",
"specified",
"PubControlClient",
"instance",
"."
] | 6700863ff8fe6be673bfa0c25c391077b328a8c4 | https://github.com/fanout/go-pubcontrol/blob/6700863ff8fe6be673bfa0c25c391077b328a8c4/pubcontrol.go#L46-L50 |
151,398 | fanout/go-pubcontrol | pubcontrol.go | ApplyConfig | func (pc *PubControl) ApplyConfig(config []map[string]interface{}) {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
for _, entry := range config {
if _, ok := entry["uri"]; !ok {
continue
}
pcc := NewPubControlClient(entry["uri"].(string))
if _, ok := entry["iss"]; ok {
claim := make(map[string]interface{})
claim["iss"] = entry["iss"]
switch entry["key"].(type) {
case string:
pcc.SetAuthJwt(claim, []byte(entry["key"].(string)))
case []byte:
pcc.SetAuthJwt(claim, entry["key"].([]byte))
}
}
pc.clients = append(pc.clients, pcc)
}
} | go | func (pc *PubControl) ApplyConfig(config []map[string]interface{}) {
pc.clientsRWLock.Lock()
defer pc.clientsRWLock.Unlock()
for _, entry := range config {
if _, ok := entry["uri"]; !ok {
continue
}
pcc := NewPubControlClient(entry["uri"].(string))
if _, ok := entry["iss"]; ok {
claim := make(map[string]interface{})
claim["iss"] = entry["iss"]
switch entry["key"].(type) {
case string:
pcc.SetAuthJwt(claim, []byte(entry["key"].(string)))
case []byte:
pcc.SetAuthJwt(claim, entry["key"].([]byte))
}
}
pc.clients = append(pc.clients, pcc)
}
} | [
"func",
"(",
"pc",
"*",
"PubControl",
")",
"ApplyConfig",
"(",
"config",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"pc",
".",
"clientsRWLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pc",
".",
"clientsRWLock",
".",
"Unlock"... | // Apply the specified configuration to this PubControl instance. The
// configuration object can either be a hash or an array of hashes where
// each hash corresponds to a single PubControlClient instance. Each hash
// will be parsed and a PubControlClient will be created either using just
// a URI or a URI and JWT authentication information. | [
"Apply",
"the",
"specified",
"configuration",
"to",
"this",
"PubControl",
"instance",
".",
"The",
"configuration",
"object",
"can",
"either",
"be",
"a",
"hash",
"or",
"an",
"array",
"of",
"hashes",
"where",
"each",
"hash",
"corresponds",
"to",
"a",
"single",
... | 6700863ff8fe6be673bfa0c25c391077b328a8c4 | https://github.com/fanout/go-pubcontrol/blob/6700863ff8fe6be673bfa0c25c391077b328a8c4/pubcontrol.go#L57-L77 |
151,399 | nmiyake/pkg | errorstringer/errorstringer.go | SingleStack | func SingleStack(err error) string {
var stackErrs []errWithStack
errCause := err
for errCause != nil {
if s, ok := errCause.(stackTracer); ok {
stackErrs = append(stackErrs, errWithStack{
err: errCause,
msg: errCause.Error(),
stack: s.StackTrace(),
})
}
if c, ok := errCause.(causer); ok {
errCause = c.Cause()
} else {
break
}
}
if len(stackErrs) == 0 {
return fmt.Sprintf("%+v", err)
}
singleStack := true
for i := len(stackErrs) - 1; i > 0; i-- {
if !hasSuffix(stackErrs[i].stack, stackErrs[i-1].stack) {
singleStack = false
break
}
}
if !singleStack {
return fmt.Sprintf("%+v", err)
}
for i := 0; i < len(stackErrs)-1; i++ {
stackErrs[i].msg = currErrMsg(stackErrs[i].err, stackErrs[i+1].err)
}
var errs []string
if errCause != nil {
// if root cause is non-nil, print its error message if it differs from cause
stackErrs[len(stackErrs)-1].msg = currErrMsg(stackErrs[len(stackErrs)-1].err, errCause)
rootErr := errCause.Error()
if rootErr != stackErrs[len(stackErrs)-1].msg {
errs = append(errs, errCause.Error())
}
}
for i := len(stackErrs) - 1; i >= 0; i-- {
errs = append(errs, fmt.Sprintf("%v", stackErrs[i].msg))
}
return strings.Join(errs, "\n") + fmt.Sprintf("%+v", stackErrs[len(stackErrs)-1].stack)
} | go | func SingleStack(err error) string {
var stackErrs []errWithStack
errCause := err
for errCause != nil {
if s, ok := errCause.(stackTracer); ok {
stackErrs = append(stackErrs, errWithStack{
err: errCause,
msg: errCause.Error(),
stack: s.StackTrace(),
})
}
if c, ok := errCause.(causer); ok {
errCause = c.Cause()
} else {
break
}
}
if len(stackErrs) == 0 {
return fmt.Sprintf("%+v", err)
}
singleStack := true
for i := len(stackErrs) - 1; i > 0; i-- {
if !hasSuffix(stackErrs[i].stack, stackErrs[i-1].stack) {
singleStack = false
break
}
}
if !singleStack {
return fmt.Sprintf("%+v", err)
}
for i := 0; i < len(stackErrs)-1; i++ {
stackErrs[i].msg = currErrMsg(stackErrs[i].err, stackErrs[i+1].err)
}
var errs []string
if errCause != nil {
// if root cause is non-nil, print its error message if it differs from cause
stackErrs[len(stackErrs)-1].msg = currErrMsg(stackErrs[len(stackErrs)-1].err, errCause)
rootErr := errCause.Error()
if rootErr != stackErrs[len(stackErrs)-1].msg {
errs = append(errs, errCause.Error())
}
}
for i := len(stackErrs) - 1; i >= 0; i-- {
errs = append(errs, fmt.Sprintf("%v", stackErrs[i].msg))
}
return strings.Join(errs, "\n") + fmt.Sprintf("%+v", stackErrs[len(stackErrs)-1].stack)
} | [
"func",
"SingleStack",
"(",
"err",
"error",
")",
"string",
"{",
"var",
"stackErrs",
"[",
"]",
"errWithStack",
"\n",
"errCause",
":=",
"err",
"\n",
"for",
"errCause",
"!=",
"nil",
"{",
"if",
"s",
",",
"ok",
":=",
"errCause",
".",
"(",
"stackTracer",
")"... | // SingleStack prints the representation of the provided error in the form of all of its messages followed by a single
// stack trace if the error supports such a representation. If the error implements causer and consists of stackTracer
// errors that are all part of the same stack trace, the string will contain all of the messages followed by the longest
// stack trace. If the error cannot be represented in this manner, the returned string is the provided error's "%+v"
// string representation. | [
"SingleStack",
"prints",
"the",
"representation",
"of",
"the",
"provided",
"error",
"in",
"the",
"form",
"of",
"all",
"of",
"its",
"messages",
"followed",
"by",
"a",
"single",
"stack",
"trace",
"if",
"the",
"error",
"supports",
"such",
"a",
"representation",
... | ae0375219445def9b33b6fcbf5eb8f4dd68ea561 | https://github.com/nmiyake/pkg/blob/ae0375219445def9b33b6fcbf5eb8f4dd68ea561/errorstringer/errorstringer.go#L50-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.