id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
132,700
go-chef/chef
http.go
Buffer
func (body *Body) Buffer() *bytes.Buffer { var b bytes.Buffer if body.Reader == nil { return &b } b.ReadFrom(body.Reader) _, err := body.Reader.(io.Seeker).Seek(0, 0) if err != nil { log.Fatal(err) } return &b }
go
func (body *Body) Buffer() *bytes.Buffer { var b bytes.Buffer if body.Reader == nil { return &b } b.ReadFrom(body.Reader) _, err := body.Reader.(io.Seeker).Seek(0, 0) if err != nil { log.Fatal(err) } return &b }
[ "func", "(", "body", "*", "Body", ")", "Buffer", "(", ")", "*", "bytes", ".", "Buffer", "{", "var", "b", "bytes", ".", "Buffer", "\n", "if", "body", ".", "Reader", "==", "nil", "{", "return", "&", "b", "\n", "}", "\n\n", "b", ".", "ReadFrom", "...
// Buffer creates a byte.Buffer copy from a io.Reader resets read on reader to 0,0
[ "Buffer", "creates", "a", "byte", ".", "Buffer", "copy", "from", "a", "io", ".", "Reader", "resets", "read", "on", "reader", "to", "0", "0" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L82-L94
132,701
go-chef/chef
http.go
Hash
func (body *Body) Hash() (h string) { b := body.Buffer() // empty buffs should return a empty string if b.Len() == 0 { h = HashStr("") } h = HashStr(b.String()) return }
go
func (body *Body) Hash() (h string) { b := body.Buffer() // empty buffs should return a empty string if b.Len() == 0 { h = HashStr("") } h = HashStr(b.String()) return }
[ "func", "(", "body", "*", "Body", ")", "Hash", "(", ")", "(", "h", "string", ")", "{", "b", ":=", "body", ".", "Buffer", "(", ")", "\n", "// empty buffs should return a empty string", "if", "b", ".", "Len", "(", ")", "==", "0", "{", "h", "=", "Hash...
// Hash calculates the body content hash
[ "Hash", "calculates", "the", "body", "content", "hash" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L97-L105
132,702
go-chef/chef
http.go
NewClient
func NewClient(cfg *Config) (*Client, error) { pk, err := PrivateKeyFromString([]byte(cfg.Key)) if err != nil { return nil, err } baseUrl, _ := url.Parse(cfg.BaseURL) tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second,...
go
func NewClient(cfg *Config) (*Client, error) { pk, err := PrivateKeyFromString([]byte(cfg.Key)) if err != nil { return nil, err } baseUrl, _ := url.Parse(cfg.BaseURL) tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second,...
[ "func", "NewClient", "(", "cfg", "*", "Config", ")", "(", "*", "Client", ",", "error", ")", "{", "pk", ",", "err", ":=", "PrivateKeyFromString", "(", "[", "]", "byte", "(", "cfg", ".", "Key", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// NewClient is the client generator used to instantiate a client for talking to a chef-server // It is a simple constructor for the Client struct intended as a easy interface for issuing // signed requests
[ "NewClient", "is", "the", "client", "generator", "used", "to", "instantiate", "a", "client", "for", "talking", "to", "a", "chef", "-", "server", "It", "is", "a", "simple", "constructor", "for", "the", "Client", "struct", "intended", "as", "a", "easy", "int...
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L124-L164
132,703
go-chef/chef
http.go
magicRequestDecoder
func (c *Client) magicRequestDecoder(method, path string, body io.Reader, v interface{}) error { req, err := c.NewRequest(method, path, body) if err != nil { return err } debug("Request: %+v \n", req) res, err := c.Do(req, v) if res != nil { defer res.Body.Close() } debug("Response: %+v \n", res) if err !...
go
func (c *Client) magicRequestDecoder(method, path string, body io.Reader, v interface{}) error { req, err := c.NewRequest(method, path, body) if err != nil { return err } debug("Request: %+v \n", req) res, err := c.Do(req, v) if res != nil { defer res.Body.Close() } debug("Response: %+v \n", res) if err !...
[ "func", "(", "c", "*", "Client", ")", "magicRequestDecoder", "(", "method", ",", "path", "string", ",", "body", "io", ".", "Reader", ",", "v", "interface", "{", "}", ")", "error", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "method", ...
// magicRequestDecoder performs a request on an endpoint, and decodes the response into the passed in Type
[ "magicRequestDecoder", "performs", "a", "request", "on", "an", "endpoint", "and", "decodes", "the", "response", "into", "the", "passed", "in", "Type" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L167-L183
132,704
go-chef/chef
http.go
NewRequest
func (c *Client) NewRequest(method string, requestUrl string, body io.Reader) (*http.Request, error) { relativeUrl, err := url.Parse(requestUrl) if err != nil { return nil, err } u := c.BaseURL.ResolveReference(relativeUrl) // NewRequest uses a new value object of body req, err := http.NewRequest(method, u.Str...
go
func (c *Client) NewRequest(method string, requestUrl string, body io.Reader) (*http.Request, error) { relativeUrl, err := url.Parse(requestUrl) if err != nil { return nil, err } u := c.BaseURL.ResolveReference(relativeUrl) // NewRequest uses a new value object of body req, err := http.NewRequest(method, u.Str...
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", "string", ",", "requestUrl", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "relativeUrl", ",", "err", ":=", "url", ".", ...
// NewRequest returns a signed request suitable for the chef server
[ "NewRequest", "returns", "a", "signed", "request", "suitable", "for", "the", "chef", "server" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L186-L217
132,705
go-chef/chef
http.go
CheckResponse
func CheckResponse(r *http.Response) error { if c := r.StatusCode; 200 <= c && c <= 299 { return nil } errorResponse := &ErrorResponse{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && data != nil { json.Unmarshal(data, errorResponse) } return errorResponse }
go
func CheckResponse(r *http.Response) error { if c := r.StatusCode; 200 <= c && c <= 299 { return nil } errorResponse := &ErrorResponse{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && data != nil { json.Unmarshal(data, errorResponse) } return errorResponse }
[ "func", "CheckResponse", "(", "r", "*", "http", ".", "Response", ")", "error", "{", "if", "c", ":=", "r", ".", "StatusCode", ";", "200", "<=", "c", "&&", "c", "<=", "299", "{", "return", "nil", "\n", "}", "\n", "errorResponse", ":=", "&", "ErrorRes...
// CheckResponse receives a pointer to a http.Response and generates an Error via unmarshalling
[ "CheckResponse", "receives", "a", "pointer", "to", "a", "http", ".", "Response", "and", "generates", "an", "Error", "via", "unmarshalling" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L220-L230
132,706
go-chef/chef
http.go
Do
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { res, err := c.client.Do(req) if err != nil { return nil, err } // BUG(fujin) tightly coupled err = CheckResponse(res) // <-- if err != nil { return res, err } if v != nil { if w, ok := v.(io.Writer); ok { io.Copy(w, res.B...
go
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { res, err := c.client.Do(req) if err != nil { return nil, err } // BUG(fujin) tightly coupled err = CheckResponse(res) // <-- if err != nil { return res, err } if v != nil { if w, ok := v.(io.Writer); ok { io.Copy(w, res.B...
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "req", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "client", ".", "Do", "(",...
// Do is used either internally via our magic request shite or a user may use it
[ "Do", "is", "used", "either", "internally", "via", "our", "magic", "request", "shite", "or", "a", "user", "may", "use", "it" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L233-L256
132,707
go-chef/chef
http.go
SignRequest
func (ac AuthConfig) SignRequest(request *http.Request) error { // sanitize the path for the chef-server // chef-server doesn't support '//' in the Hash Path. var endpoint string if request.URL.Path != "" { endpoint = path.Clean(request.URL.Path) request.URL.Path = endpoint } else { endpoint = request.URL.Pa...
go
func (ac AuthConfig) SignRequest(request *http.Request) error { // sanitize the path for the chef-server // chef-server doesn't support '//' in the Hash Path. var endpoint string if request.URL.Path != "" { endpoint = path.Clean(request.URL.Path) request.URL.Path = endpoint } else { endpoint = request.URL.Pa...
[ "func", "(", "ac", "AuthConfig", ")", "SignRequest", "(", "request", "*", "http", ".", "Request", ")", "error", "{", "// sanitize the path for the chef-server", "// chef-server doesn't support '//' in the Hash Path.", "var", "endpoint", "string", "\n", "if", "request", ...
// SignRequest modifies headers of an http.Request
[ "SignRequest", "modifies", "headers", "of", "an", "http", ".", "Request" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L259-L309
132,708
go-chef/chef
http.go
PrivateKeyFromString
func PrivateKeyFromString(key []byte) (*rsa.PrivateKey, error) { block, _ := pem.Decode(key) if block == nil { return nil, fmt.Errorf("private key block size invalid") } rsaKey, err := x509.ParsePKCS1PrivateKey(block.Bytes) if err != nil { return nil, err } return rsaKey, nil }
go
func PrivateKeyFromString(key []byte) (*rsa.PrivateKey, error) { block, _ := pem.Decode(key) if block == nil { return nil, fmt.Errorf("private key block size invalid") } rsaKey, err := x509.ParsePKCS1PrivateKey(block.Bytes) if err != nil { return nil, err } return rsaKey, nil }
[ "func", "PrivateKeyFromString", "(", "key", "[", "]", "byte", ")", "(", "*", "rsa", ".", "PrivateKey", ",", "error", ")", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "key", ")", "\n", "if", "block", "==", "nil", "{", "return", "nil", ...
// PrivateKeyFromString parses an RSA private key from a string
[ "PrivateKeyFromString", "parses", "an", "RSA", "private", "key", "from", "a", "string" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/http.go#L312-L322
132,709
go-chef/chef
search.go
String
func (q SearchQuery) String() string { return fmt.Sprintf("%s?q=%s&rows=%d&sort=%s&start=%d", q.Index, q.Query, q.Rows, q.SortBy, q.Start) }
go
func (q SearchQuery) String() string { return fmt.Sprintf("%s?q=%s&rows=%d&sort=%s&start=%d", q.Index, q.Query, q.Rows, q.SortBy, q.Start) }
[ "func", "(", "q", "SearchQuery", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "q", ".", "Index", ",", "q", ".", "Query", ",", "q", ".", "Rows", ",", "q", ".", "SortBy", ",", "q", ".", "Start", ...
// String implements the Stringer Interface for the SearchQuery
[ "String", "implements", "the", "Stringer", "Interface", "for", "the", "SearchQuery" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/search.go#L32-L34
132,710
go-chef/chef
search.go
Do
func (q SearchQuery) Do(client *Client) (res SearchResult, err error) { fullUrl := fmt.Sprintf("search/%s", q) err = client.magicRequestDecoder("GET", fullUrl, nil, &res) return }
go
func (q SearchQuery) Do(client *Client) (res SearchResult, err error) { fullUrl := fmt.Sprintf("search/%s", q) err = client.magicRequestDecoder("GET", fullUrl, nil, &res) return }
[ "func", "(", "q", "SearchQuery", ")", "Do", "(", "client", "*", "Client", ")", "(", "res", "SearchResult", ",", "err", "error", ")", "{", "fullUrl", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "q", ")", "\n", "err", "=", "client", ".", "ma...
// Do will execute the search query on the client
[ "Do", "will", "execute", "the", "search", "query", "on", "the", "client" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/search.go#L44-L48
132,711
go-chef/chef
search.go
DoPartial
func (q SearchQuery) DoPartial(client *Client, params map[string]interface{}) (res SearchResult, err error) { fullUrl := fmt.Sprintf("search/%s", q) body, err := JSONReader(params) if err != nil { debug("Problem encoding params for body", err.Error()) return } err = client.magicRequestDecoder("POST", fullUrl...
go
func (q SearchQuery) DoPartial(client *Client, params map[string]interface{}) (res SearchResult, err error) { fullUrl := fmt.Sprintf("search/%s", q) body, err := JSONReader(params) if err != nil { debug("Problem encoding params for body", err.Error()) return } err = client.magicRequestDecoder("POST", fullUrl...
[ "func", "(", "q", "SearchQuery", ")", "DoPartial", "(", "client", "*", "Client", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "res", "SearchResult", ",", "err", "error", ")", "{", "fullUrl", ":=", "fmt", ".", "Sprintf", ...
// DoPartial will execute the search query on the client with partal mapping
[ "DoPartial", "will", "execute", "the", "search", "query", "on", "the", "client", "with", "partal", "mapping" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/search.go#L51-L62
132,712
go-chef/chef
search.go
NewQuery
func (e SearchService) NewQuery(idx, statement string) (query SearchQuery, err error) { // validate statement if !strings.Contains(statement, ":") { err = errors.New("statement is malformed") return } query = SearchQuery{ Index: idx, Query: statement, // These are the defaults in chef: https://github.com...
go
func (e SearchService) NewQuery(idx, statement string) (query SearchQuery, err error) { // validate statement if !strings.Contains(statement, ":") { err = errors.New("statement is malformed") return } query = SearchQuery{ Index: idx, Query: statement, // These are the defaults in chef: https://github.com...
[ "func", "(", "e", "SearchService", ")", "NewQuery", "(", "idx", ",", "statement", "string", ")", "(", "query", "SearchQuery", ",", "err", "error", ")", "{", "// validate statement", "if", "!", "strings", ".", "Contains", "(", "statement", ",", "\"", "\"", ...
// NewSearch is a constructor for a SearchQuery struct. This is used by other search service methods to perform search requests on the server
[ "NewSearch", "is", "a", "constructor", "for", "a", "SearchQuery", "struct", ".", "This", "is", "used", "by", "other", "search", "service", "methods", "to", "perform", "search", "requests", "on", "the", "server" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/search.go#L65-L82
132,713
go-chef/chef
search.go
PartialExec
func (e SearchService) PartialExec(idx, statement string, params map[string]interface{}) (res SearchResult, err error) { query := SearchQuery{ Index: idx, Query: statement, // These are the defaults in chef: https://github.com/opscode/chef/blob/master/lib/chef/search/query.rb#L102-L105 SortBy: "X_CHEF_id_CHEF_...
go
func (e SearchService) PartialExec(idx, statement string, params map[string]interface{}) (res SearchResult, err error) { query := SearchQuery{ Index: idx, Query: statement, // These are the defaults in chef: https://github.com/opscode/chef/blob/master/lib/chef/search/query.rb#L102-L105 SortBy: "X_CHEF_id_CHEF_...
[ "func", "(", "e", "SearchService", ")", "PartialExec", "(", "idx", ",", "statement", "string", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "res", "SearchResult", ",", "err", "error", ")", "{", "query", ":=", "SearchQuery", ...
// PartialExec Executes a partial search based on passed in params and the query.
[ "PartialExec", "Executes", "a", "partial", "search", "based", "on", "passed", "in", "params", "and", "the", "query", "." ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/search.go#L120-L140
132,714
go-chef/chef
sandbox.go
Put
func (s SandboxService) Put(id string) (box Sandbox, err error) { answer := make(map[string]bool) answer["is_completed"] = true body, err := JSONReader(answer) if id == "" { return box, fmt.Errorf("must supply sandbox id to PUT request.") } err = s.client.magicRequestDecoder("PUT", "/sandboxes/"+id, body, &bo...
go
func (s SandboxService) Put(id string) (box Sandbox, err error) { answer := make(map[string]bool) answer["is_completed"] = true body, err := JSONReader(answer) if id == "" { return box, fmt.Errorf("must supply sandbox id to PUT request.") } err = s.client.magicRequestDecoder("PUT", "/sandboxes/"+id, body, &bo...
[ "func", "(", "s", "SandboxService", ")", "Put", "(", "id", "string", ")", "(", "box", "Sandbox", ",", "err", "error", ")", "{", "answer", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "answer", "[", "\"", "\"", "]", "=", "true"...
// Put is used to commit a sandbox ID to the chef server. To singal that the sandox you have Posted is now uploaded.
[ "Put", "is", "used", "to", "commit", "a", "sandbox", "ID", "to", "the", "chef", "server", ".", "To", "singal", "that", "the", "sandox", "you", "have", "Posted", "is", "now", "uploaded", "." ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/sandbox.go#L59-L70
132,715
go-chef/chef
cookbook.go
String
func (c CookbookListResult) String() (out string) { for k, v := range c { out += fmt.Sprintf("%s => %s\n", k, v.Url) for _, i := range v.Versions { out += fmt.Sprintf(" * %s\n", i.Version) } } return out }
go
func (c CookbookListResult) String() (out string) { for k, v := range c { out += fmt.Sprintf("%s => %s\n", k, v.Url) for _, i := range v.Versions { out += fmt.Sprintf(" * %s\n", i.Version) } } return out }
[ "func", "(", "c", "CookbookListResult", ")", "String", "(", ")", "(", "out", "string", ")", "{", "for", "k", ",", "v", ":=", "range", "c", "{", "out", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "k", ",", "v", ".", "Url", ")", "...
// String makes CookbookListResult implement the string result
[ "String", "makes", "CookbookListResult", "implement", "the", "string", "result" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/cookbook.go#L81-L89
132,716
go-chef/chef
cookbook.go
versionParams
func versionParams(path, numVersions string) string { if numVersions == "0" { numVersions = "all" } // need to optionally add numVersion args to the request if len(numVersions) > 0 { path = fmt.Sprintf("%s?num_versions=%s", path, numVersions) } return path }
go
func versionParams(path, numVersions string) string { if numVersions == "0" { numVersions = "all" } // need to optionally add numVersion args to the request if len(numVersions) > 0 { path = fmt.Sprintf("%s?num_versions=%s", path, numVersions) } return path }
[ "func", "versionParams", "(", "path", ",", "numVersions", "string", ")", "string", "{", "if", "numVersions", "==", "\"", "\"", "{", "numVersions", "=", "\"", "\"", "\n", "}", "\n\n", "// need to optionally add numVersion args to the request", "if", "len", "(", "...
// versionParams assembles a querystring for the chef api's num_versions // This is used to restrict the number of versions returned in the reponse
[ "versionParams", "assembles", "a", "querystring", "for", "the", "chef", "api", "s", "num_versions", "This", "is", "used", "to", "restrict", "the", "number", "of", "versions", "returned", "in", "the", "reponse" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/cookbook.go#L93-L103
132,717
go-chef/chef
cookbook.go
GetAvailableVersions
func (c *CookbookService) GetAvailableVersions(name, numVersions string) (data CookbookListResult, err error) { path := versionParams(fmt.Sprintf("cookbooks/%s", name), numVersions) err = c.client.magicRequestDecoder("GET", path, nil, &data) return }
go
func (c *CookbookService) GetAvailableVersions(name, numVersions string) (data CookbookListResult, err error) { path := versionParams(fmt.Sprintf("cookbooks/%s", name), numVersions) err = c.client.magicRequestDecoder("GET", path, nil, &data) return }
[ "func", "(", "c", "*", "CookbookService", ")", "GetAvailableVersions", "(", "name", ",", "numVersions", "string", ")", "(", "data", "CookbookListResult", ",", "err", "error", ")", "{", "path", ":=", "versionParams", "(", "fmt", ".", "Sprintf", "(", "\"", "...
// GetAvailable returns the versions of a coookbook available on a server
[ "GetAvailable", "returns", "the", "versions", "of", "a", "coookbook", "available", "on", "a", "server" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/cookbook.go#L114-L118
132,718
go-chef/chef
cookbook.go
Delete
func (c *CookbookService) Delete(name, version string) (err error) { path := fmt.Sprintf("cookbooks/%s/%s", name, version) err = c.client.magicRequestDecoder("DELETE", path, nil, nil) return }
go
func (c *CookbookService) Delete(name, version string) (err error) { path := fmt.Sprintf("cookbooks/%s/%s", name, version) err = c.client.magicRequestDecoder("DELETE", path, nil, nil) return }
[ "func", "(", "c", "*", "CookbookService", ")", "Delete", "(", "name", ",", "version", "string", ")", "(", "err", "error", ")", "{", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ",", "version", ")", "\n", "err", "=", "c", "."...
// DeleteVersion removes a version of a cook from a server
[ "DeleteVersion", "removes", "a", "version", "of", "a", "cook", "from", "a", "server" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/cookbook.go#L152-L156
132,719
go-chef/chef
databag.go
String
func (d DataBagListResult) String() (out string) { for k, v := range d { out += fmt.Sprintf("%s => %s\n", k, v) } return out }
go
func (d DataBagListResult) String() (out string) { for k, v := range d { out += fmt.Sprintf("%s => %s\n", k, v) } return out }
[ "func", "(", "d", "DataBagListResult", ")", "String", "(", ")", "(", "out", "string", ")", "{", "for", "k", ",", "v", ":=", "range", "d", "{", "out", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "k", ",", "v", ")", "\n", "}", "\n...
// String makes DataBagListResult implement the string result
[ "String", "makes", "DataBagListResult", "implement", "the", "string", "result" ]
cfd55cf96411cfa6ea658a3904fbcb8e40843e68
https://github.com/go-chef/chef/blob/cfd55cf96411cfa6ea658a3904fbcb8e40843e68/databag.go#L29-L34
132,720
mndrix/ps
list.go
ForEach
func (self *list) ForEach(f func(interface{})) { if self.IsNil() { return } f(self.Head()) self.Tail().ForEach(f) }
go
func (self *list) ForEach(f func(interface{})) { if self.IsNil() { return } f(self.Head()) self.Tail().ForEach(f) }
[ "func", "(", "self", "*", "list", ")", "ForEach", "(", "f", "func", "(", "interface", "{", "}", ")", ")", "{", "if", "self", ".", "IsNil", "(", ")", "{", "return", "\n", "}", "\n", "f", "(", "self", ".", "Head", "(", ")", ")", "\n", "self", ...
// ForEach executes a callback for each value in the list
[ "ForEach", "executes", "a", "callback", "for", "each", "value", "in", "the", "list" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/list.go#L80-L86
132,721
mndrix/ps
list.go
Reverse
func (self *list) Reverse() List { reversed := NewList() self.ForEach(func(v interface{}) { reversed = reversed.Cons(v) }) return reversed }
go
func (self *list) Reverse() List { reversed := NewList() self.ForEach(func(v interface{}) { reversed = reversed.Cons(v) }) return reversed }
[ "func", "(", "self", "*", "list", ")", "Reverse", "(", ")", "List", "{", "reversed", ":=", "NewList", "(", ")", "\n", "self", ".", "ForEach", "(", "func", "(", "v", "interface", "{", "}", ")", "{", "reversed", "=", "reversed", ".", "Cons", "(", "...
// Reverse returns a list with elements in opposite order as this list
[ "Reverse", "returns", "a", "list", "with", "elements", "in", "opposite", "order", "as", "this", "list" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/list.go#L89-L93
132,722
mndrix/ps
map.go
hashKey
func hashKey(key string) uint64 { hash := offset64 for _, b := range bytesView(key) { hash ^= uint64(b) hash *= prime64 } return hash }
go
func hashKey(key string) uint64 { hash := offset64 for _, b := range bytesView(key) { hash ^= uint64(b) hash *= prime64 } return hash }
[ "func", "hashKey", "(", "key", "string", ")", "uint64", "{", "hash", ":=", "offset64", "\n\n", "for", "_", ",", "b", ":=", "range", "bytesView", "(", "key", ")", "{", "hash", "^=", "uint64", "(", "b", ")", "\n", "hash", "*=", "prime64", "\n", "}", ...
// hashKey returns a hash code for a given string
[ "hashKey", "returns", "a", "hash", "code", "for", "a", "given", "string" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L134-L142
132,723
mndrix/ps
map.go
Set
func (self *tree) Set(key string, value interface{}) Map { hash := hashKey(key) return setLowLevel(self, hash, hash, key, value) }
go
func (self *tree) Set(key string, value interface{}) Map { hash := hashKey(key) return setLowLevel(self, hash, hash, key, value) }
[ "func", "(", "self", "*", "tree", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "Map", "{", "hash", ":=", "hashKey", "(", "key", ")", "\n", "return", "setLowLevel", "(", "self", ",", "hash", ",", "hash", ",", "key", ...
// Set returns a new map similar to this one but with key and value // associated. If the key didn't exist, it's created; otherwise, the // associated value is changed.
[ "Set", "returns", "a", "new", "map", "similar", "to", "this", "one", "but", "with", "key", "and", "value", "associated", ".", "If", "the", "key", "didn", "t", "exist", "it", "s", "created", ";", "otherwise", "the", "associated", "value", "is", "changed",...
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L147-L150
132,724
mndrix/ps
map.go
UnsafeMutableSet
func (self *tree) UnsafeMutableSet(key string, value interface{}) Map { hash := hashKey(key) return mutableSetLowLevel(self, hash, hash, key, value) }
go
func (self *tree) UnsafeMutableSet(key string, value interface{}) Map { hash := hashKey(key) return mutableSetLowLevel(self, hash, hash, key, value) }
[ "func", "(", "self", "*", "tree", ")", "UnsafeMutableSet", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "Map", "{", "hash", ":=", "hashKey", "(", "key", ")", "\n", "return", "mutableSetLowLevel", "(", "self", ",", "hash", ",", "hash"...
// UnsafeMutableSet is the in-place mutable version of Set. Only use if // you are the only reference-holder of the Map.
[ "UnsafeMutableSet", "is", "the", "in", "-", "place", "mutable", "version", "of", "Set", ".", "Only", "use", "if", "you", "are", "the", "only", "reference", "-", "holder", "of", "the", "Map", "." ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L187-L190
132,725
mndrix/ps
map.go
recalculateCount
func recalculateCount(m *tree) { count := 0 for _, t := range m.children { count += t.Size() } m.count = count + 1 // add one to count ourself }
go
func recalculateCount(m *tree) { count := 0 for _, t := range m.children { count += t.Size() } m.count = count + 1 // add one to count ourself }
[ "func", "recalculateCount", "(", "m", "*", "tree", ")", "{", "count", ":=", "0", "\n", "for", "_", ",", "t", ":=", "range", "m", ".", "children", "{", "count", "+=", "t", ".", "Size", "(", ")", "\n", "}", "\n", "m", ".", "count", "=", "count", ...
// modifies a map by recalculating its key count based on the counts // of its subtrees
[ "modifies", "a", "map", "by", "recalculating", "its", "key", "count", "based", "on", "the", "counts", "of", "its", "subtrees" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L226-L232
132,726
mndrix/ps
map.go
deleteLeftmost
func (m *tree) deleteLeftmost() (*tree, *tree) { if m.isLeaf() { return m, nilMap } for i, t := range m.children { if t != nilMap { deleted, child := t.deleteLeftmost() newMap := m.clone() newMap.children[i] = child recalculateCount(newMap) return deleted, newMap } } panic("Tree isn't a leaf ...
go
func (m *tree) deleteLeftmost() (*tree, *tree) { if m.isLeaf() { return m, nilMap } for i, t := range m.children { if t != nilMap { deleted, child := t.deleteLeftmost() newMap := m.clone() newMap.children[i] = child recalculateCount(newMap) return deleted, newMap } } panic("Tree isn't a leaf ...
[ "func", "(", "m", "*", "tree", ")", "deleteLeftmost", "(", ")", "(", "*", "tree", ",", "*", "tree", ")", "{", "if", "m", ".", "isLeaf", "(", ")", "{", "return", "m", ",", "nilMap", "\n", "}", "\n\n", "for", "i", ",", "t", ":=", "range", "m", ...
// delete the leftmost node in a tree returning the node that // was deleted and the tree left over after its deletion
[ "delete", "the", "leftmost", "node", "in", "a", "tree", "returning", "the", "node", "that", "was", "deleted", "and", "the", "tree", "left", "over", "after", "its", "deletion" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L299-L314
132,727
mndrix/ps
map.go
subtreeCount
func (m *tree) subtreeCount() int { count := 0 for _, t := range m.children { if t != nilMap { count++ } } return count }
go
func (m *tree) subtreeCount() int { count := 0 for _, t := range m.children { if t != nilMap { count++ } } return count }
[ "func", "(", "m", "*", "tree", ")", "subtreeCount", "(", ")", "int", "{", "count", ":=", "0", "\n", "for", "_", ",", "t", ":=", "range", "m", ".", "children", "{", "if", "t", "!=", "nilMap", "{", "count", "++", "\n", "}", "\n", "}", "\n", "re...
// returns the number of child subtrees we have
[ "returns", "the", "number", "of", "child", "subtrees", "we", "have" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L322-L330
132,728
mndrix/ps
map.go
String
func (m *tree) String() string { keys := m.Keys() buf := bytes.NewBufferString("{") for _, key := range keys { val, _ := m.Lookup(key) fmt.Fprintf(buf, "%s: %s, ", key, val) } fmt.Fprintf(buf, "}\n") return buf.String() }
go
func (m *tree) String() string { keys := m.Keys() buf := bytes.NewBufferString("{") for _, key := range keys { val, _ := m.Lookup(key) fmt.Fprintf(buf, "%s: %s, ", key, val) } fmt.Fprintf(buf, "}\n") return buf.String() }
[ "func", "(", "m", "*", "tree", ")", "String", "(", ")", "string", "{", "keys", ":=", "m", ".", "Keys", "(", ")", "\n", "buf", ":=", "bytes", ".", "NewBufferString", "(", "\"", "\"", ")", "\n", "for", "_", ",", "key", ":=", "range", "keys", "{",...
// make it easier to display maps for debugging
[ "make", "it", "easier", "to", "display", "maps", "for", "debugging" ]
18e65badd6ab498ebf91777d2123a17d5f6b08b6
https://github.com/mndrix/ps/blob/18e65badd6ab498ebf91777d2123a17d5f6b08b6/map.go#L382-L391
132,729
osamingo/indigo
indigo.go
New
func New(enc Encoder, options ...func(*sonyflake.Settings)) *Generator { if enc == nil { enc = base58.MustNewEncoder(base58.StdSource()) } s := sonyflake.Settings{} for i := range options { options[i](&s) } return &Generator{ sf: sonyflake.NewSonyflake(s), enc: enc, } }
go
func New(enc Encoder, options ...func(*sonyflake.Settings)) *Generator { if enc == nil { enc = base58.MustNewEncoder(base58.StdSource()) } s := sonyflake.Settings{} for i := range options { options[i](&s) } return &Generator{ sf: sonyflake.NewSonyflake(s), enc: enc, } }
[ "func", "New", "(", "enc", "Encoder", ",", "options", "...", "func", "(", "*", "sonyflake", ".", "Settings", ")", ")", "*", "Generator", "{", "if", "enc", "==", "nil", "{", "enc", "=", "base58", ".", "MustNewEncoder", "(", "base58", ".", "StdSource", ...
// New settings new a indigo.Generator.
[ "New", "settings", "new", "a", "indigo", ".", "Generator", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L29-L41
132,730
osamingo/indigo
indigo.go
StartTime
func StartTime(t time.Time) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.StartTime = t } }
go
func StartTime(t time.Time) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.StartTime = t } }
[ "func", "StartTime", "(", "t", "time", ".", "Time", ")", "func", "(", "*", "sonyflake", ".", "Settings", ")", "{", "return", "func", "(", "s", "*", "sonyflake", ".", "Settings", ")", "{", "s", ".", "StartTime", "=", "t", "\n", "}", "\n", "}" ]
// StartTime is optional function for indigo.Generator.
[ "StartTime", "is", "optional", "function", "for", "indigo", ".", "Generator", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L44-L48
132,731
osamingo/indigo
indigo.go
MachineID
func MachineID(f func() (uint16, error)) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.MachineID = f } }
go
func MachineID(f func() (uint16, error)) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.MachineID = f } }
[ "func", "MachineID", "(", "f", "func", "(", ")", "(", "uint16", ",", "error", ")", ")", "func", "(", "*", "sonyflake", ".", "Settings", ")", "{", "return", "func", "(", "s", "*", "sonyflake", ".", "Settings", ")", "{", "s", ".", "MachineID", "=", ...
// MachineID is optional function for indigo.Generator.
[ "MachineID", "is", "optional", "function", "for", "indigo", ".", "Generator", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L51-L55
132,732
osamingo/indigo
indigo.go
CheckMachineID
func CheckMachineID(f func(uint16) bool) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.CheckMachineID = f } }
go
func CheckMachineID(f func(uint16) bool) func(*sonyflake.Settings) { return func(s *sonyflake.Settings) { s.CheckMachineID = f } }
[ "func", "CheckMachineID", "(", "f", "func", "(", "uint16", ")", "bool", ")", "func", "(", "*", "sonyflake", ".", "Settings", ")", "{", "return", "func", "(", "s", "*", "sonyflake", ".", "Settings", ")", "{", "s", ".", "CheckMachineID", "=", "f", "\n"...
// CheckMachineID is optional function for indigo.Generator.
[ "CheckMachineID", "is", "optional", "function", "for", "indigo", ".", "Generator", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L58-L62
132,733
osamingo/indigo
indigo.go
NextID
func (g *Generator) NextID() (string, error) { n, err := g.sf.NextID() if err != nil { return "", err } return g.enc.Encode(n), nil }
go
func (g *Generator) NextID() (string, error) { n, err := g.sf.NextID() if err != nil { return "", err } return g.enc.Encode(n), nil }
[ "func", "(", "g", "*", "Generator", ")", "NextID", "(", ")", "(", "string", ",", "error", ")", "{", "n", ",", "err", ":=", "g", ".", "sf", ".", "NextID", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", ...
// NextID generates a next unique ID.
[ "NextID", "generates", "a", "next", "unique", "ID", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L65-L71
132,734
osamingo/indigo
indigo.go
Decompose
func (g *Generator) Decompose(id string) (map[string]uint64, error) { b, err := g.enc.Decode(id) if err != nil { return nil, err } return sonyflake.Decompose(b), nil }
go
func (g *Generator) Decompose(id string) (map[string]uint64, error) { b, err := g.enc.Decode(id) if err != nil { return nil, err } return sonyflake.Decompose(b), nil }
[ "func", "(", "g", "*", "Generator", ")", "Decompose", "(", "id", "string", ")", "(", "map", "[", "string", "]", "uint64", ",", "error", ")", "{", "b", ",", "err", ":=", "g", ".", "enc", ".", "Decode", "(", "id", ")", "\n", "if", "err", "!=", ...
// Decompose returns a set of sonyflake ID parts.
[ "Decompose", "returns", "a", "set", "of", "sonyflake", "ID", "parts", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/indigo.go#L74-L80
132,735
osamingo/indigo
base58/base58.go
MustNewEncoder
func MustNewEncoder(source string) *Encoder { enc, err := NewEncoder(source) if err != nil { panic(err) } return enc }
go
func MustNewEncoder(source string) *Encoder { enc, err := NewEncoder(source) if err != nil { panic(err) } return enc }
[ "func", "MustNewEncoder", "(", "source", "string", ")", "*", "Encoder", "{", "enc", ",", "err", ":=", "NewEncoder", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "enc", "\n", "}" ]
// MustNewEncoder returns new base58.Encoder.
[ "MustNewEncoder", "returns", "new", "base58", ".", "Encoder", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/base58/base58.go#L23-L29
132,736
osamingo/indigo
base58/base58.go
NewEncoder
func NewEncoder(source string) (*Encoder, error) { if len(source) != 58 { return nil, errors.New("base58: encoding source is not 58-bytes long") } enc := new(Encoder) for i := range enc.decodeMap { enc.decodeMap[i] = -1 } for i := range source { enc.encode[i] = source[i] enc.decodeMap[enc.encode[i]] =...
go
func NewEncoder(source string) (*Encoder, error) { if len(source) != 58 { return nil, errors.New("base58: encoding source is not 58-bytes long") } enc := new(Encoder) for i := range enc.decodeMap { enc.decodeMap[i] = -1 } for i := range source { enc.encode[i] = source[i] enc.decodeMap[enc.encode[i]] =...
[ "func", "NewEncoder", "(", "source", "string", ")", "(", "*", "Encoder", ",", "error", ")", "{", "if", "len", "(", "source", ")", "!=", "58", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "enc", ":=", ...
// NewEncoder returns new base58.Encoder.
[ "NewEncoder", "returns", "new", "base58", ".", "Encoder", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/base58/base58.go#L32-L50
132,737
osamingo/indigo
base58/base58.go
Encode
func (enc *Encoder) Encode(id uint64) string { if id == 0 { return string(enc.encode[:1]) } bin := make([]byte, 0, binary.MaxVarintLen64) for id > 0 { bin = append(bin, enc.encode[id%58]) id /= 58 } for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 { bin[i], bin[j] = bin[j], bin[i] } return string(b...
go
func (enc *Encoder) Encode(id uint64) string { if id == 0 { return string(enc.encode[:1]) } bin := make([]byte, 0, binary.MaxVarintLen64) for id > 0 { bin = append(bin, enc.encode[id%58]) id /= 58 } for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 { bin[i], bin[j] = bin[j], bin[i] } return string(b...
[ "func", "(", "enc", "*", "Encoder", ")", "Encode", "(", "id", "uint64", ")", "string", "{", "if", "id", "==", "0", "{", "return", "string", "(", "enc", ".", "encode", "[", ":", "1", "]", ")", "\n", "}", "\n\n", "bin", ":=", "make", "(", "[", ...
// Encode returns encoded string by Base58.
[ "Encode", "returns", "encoded", "string", "by", "Base58", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/base58/base58.go#L53-L70
132,738
osamingo/indigo
base58/base58.go
Decode
func (enc *Encoder) Decode(id string) (uint64, error) { if id == "" { return 0, errors.New("base58: id should not be empty") } var n uint64 for i := range id { u := enc.decodeMap[id[i]] if u < 0 { return 0, errors.New("base58: invalid character - " + string(id[i])) } n = n*58 + uint64(u) } return ...
go
func (enc *Encoder) Decode(id string) (uint64, error) { if id == "" { return 0, errors.New("base58: id should not be empty") } var n uint64 for i := range id { u := enc.decodeMap[id[i]] if u < 0 { return 0, errors.New("base58: invalid character - " + string(id[i])) } n = n*58 + uint64(u) } return ...
[ "func", "(", "enc", "*", "Encoder", ")", "Decode", "(", "id", "string", ")", "(", "uint64", ",", "error", ")", "{", "if", "id", "==", "\"", "\"", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "...
// Decode returns decoded unsigned int64 by Base58.
[ "Decode", "returns", "decoded", "unsigned", "int64", "by", "Base58", "." ]
2d5843fcd458e87b90758a69b3659f78920f2c11
https://github.com/osamingo/indigo/blob/2d5843fcd458e87b90758a69b3659f78920f2c11/base58/base58.go#L73-L89
132,739
bitrise-io/stepman
stepman/paths.go
GetStepCacheDirPath
func GetStepCacheDirPath(route SteplibRoute, id, version string) string { return path.Join(GetCacheBaseDir(route), id, version) }
go
func GetStepCacheDirPath(route SteplibRoute, id, version string) string { return path.Join(GetCacheBaseDir(route), id, version) }
[ "func", "GetStepCacheDirPath", "(", "route", "SteplibRoute", ",", "id", ",", "version", "string", ")", "string", "{", "return", "path", ".", "Join", "(", "GetCacheBaseDir", "(", "route", ")", ",", "id", ",", "version", ")", "\n", "}" ]
// GetStepCacheDirPath ... // Step's Cache dir path, where it's code lives.
[ "GetStepCacheDirPath", "...", "Step", "s", "Cache", "dir", "path", "where", "it", "s", "code", "lives", "." ]
8cd3398fab6c211eef53502b65ec7ad5510f556a
https://github.com/bitrise-io/stepman/blob/8cd3398fab6c211eef53502b65ec7ad5510f556a/stepman/paths.go#L221-L223
132,740
dcos/dcos-metrics
config.go
newConfig
func newConfig() Config { return Config{ Collector: CollectorConfig{ HTTPProfiler: false, Framework: &framework.Collector{ ListenEndpointFlag: "127.0.0.1:8124", RecordInputLogFlag: false, InputLimitAmountKBytesFlag: 20480, InputLimitPeriodFlag: 60, }, MesosAgent: &me...
go
func newConfig() Config { return Config{ Collector: CollectorConfig{ HTTPProfiler: false, Framework: &framework.Collector{ ListenEndpointFlag: "127.0.0.1:8124", RecordInputLogFlag: false, InputLimitAmountKBytesFlag: 20480, InputLimitPeriodFlag: 60, }, MesosAgent: &me...
[ "func", "newConfig", "(", ")", "Config", "{", "return", "Config", "{", "Collector", ":", "CollectorConfig", "{", "HTTPProfiler", ":", "false", ",", "Framework", ":", "&", "framework", ".", "Collector", "{", "ListenEndpointFlag", ":", "\"", "\"", ",", "Record...
// newConfig establishes our default, base configuration.
[ "newConfig", "establishes", "our", "default", "base", "configuration", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/config.go#L180-L212
132,741
dcos/dcos-metrics
producers/http/http.go
Run
func (p *producerImpl) Run() error { httpLog.Info("Starting HTTP producer garbage collection service") go p.janitor() go func() { httpLog.Debug("HTTP producer listening for incoming messages on metricsChan") for { // read messages off the channel, // and give them a unique name in the store message := ...
go
func (p *producerImpl) Run() error { httpLog.Info("Starting HTTP producer garbage collection service") go p.janitor() go func() { httpLog.Debug("HTTP producer listening for incoming messages on metricsChan") for { // read messages off the channel, // and give them a unique name in the store message := ...
[ "func", "(", "p", "*", "producerImpl", ")", "Run", "(", ")", "error", "{", "httpLog", ".", "Info", "(", "\"", "\"", ")", "\n", "go", "p", ".", "janitor", "(", ")", "\n\n", "go", "func", "(", ")", "{", "httpLog", ".", "Debug", "(", "\"", "\"", ...
// Run a HTTP server and serve the various metrics API endpoints. // This function should be run in its own goroutine.
[ "Run", "a", "HTTP", "server", "and", "serve", "the", "various", "metrics", "API", "endpoints", ".", "This", "function", "should", "be", "run", "in", "its", "own", "goroutine", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/http/http.go#L65-L117
132,742
dcos/dcos-metrics
producers/http/http.go
writeObjectToStore
func (p *producerImpl) writeObjectToStore(d producers.Datapoint, m producers.MetricsMessage, prefix string) { newMessage := producers.MetricsMessage{ Name: m.Name, Datapoints: []producers.Datapoint{d}, Dimensions: m.Dimensions, Timestamp: m.Timestamp, } // e.g. dcos.metrics.app.[ContainerId].kafka.ser...
go
func (p *producerImpl) writeObjectToStore(d producers.Datapoint, m producers.MetricsMessage, prefix string) { newMessage := producers.MetricsMessage{ Name: m.Name, Datapoints: []producers.Datapoint{d}, Dimensions: m.Dimensions, Timestamp: m.Timestamp, } // e.g. dcos.metrics.app.[ContainerId].kafka.ser...
[ "func", "(", "p", "*", "producerImpl", ")", "writeObjectToStore", "(", "d", "producers", ".", "Datapoint", ",", "m", "producers", ".", "MetricsMessage", ",", "prefix", "string", ")", "{", "newMessage", ":=", "producers", ".", "MetricsMessage", "{", "Name", "...
// writeObjectToStore writes a prefixed datapoint into the store.
[ "writeObjectToStore", "writes", "a", "prefixed", "datapoint", "into", "the", "store", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/http/http.go#L120-L138
132,743
dcos/dcos-metrics
producers/http/http.go
janitor
func (p *producerImpl) janitor() { ticker := time.NewTicker(p.janitorRunInterval) for { select { case _ = <-ticker.C: for k, v := range p.store.Objects() { o := v.(producers.MetricsMessage) age := time.Now().Sub(time.Unix(o.Timestamp, 0)) if age > p.config.CacheExpiry { httpLog.Debugf("Removi...
go
func (p *producerImpl) janitor() { ticker := time.NewTicker(p.janitorRunInterval) for { select { case _ = <-ticker.C: for k, v := range p.store.Objects() { o := v.(producers.MetricsMessage) age := time.Now().Sub(time.Unix(o.Timestamp, 0)) if age > p.config.CacheExpiry { httpLog.Debugf("Removi...
[ "func", "(", "p", "*", "producerImpl", ")", "janitor", "(", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "p", ".", "janitorRunInterval", ")", "\n", "for", "{", "select", "{", "case", "_", "=", "<-", "ticker", ".", "C", ":", "for", "k", ...
// janitor analyzes the objects in the store and removes stale objects. An // object is considered stale when the top-level timestamp of its MetricsMessage // has exceeded the CacheExpiry, which is calculated as a multiple of the // collector's polling period. This function should be run in its own goroutine.
[ "janitor", "analyzes", "the", "objects", "in", "the", "store", "and", "removes", "stale", "objects", ".", "An", "object", "is", "considered", "stale", "when", "the", "top", "-", "level", "timestamp", "of", "its", "MetricsMessage", "has", "exceeded", "the", "...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/http/http.go#L149-L165
132,744
dcos/dcos-metrics
collectors/mesos/agent/agent.go
Get
func (ctr *ContainerTaskRels) Get(containerID string) *TaskInfo { ctr.Lock() defer ctr.Unlock() return ctr.rels[containerID] }
go
func (ctr *ContainerTaskRels) Get(containerID string) *TaskInfo { ctr.Lock() defer ctr.Unlock() return ctr.rels[containerID] }
[ "func", "(", "ctr", "*", "ContainerTaskRels", ")", "Get", "(", "containerID", "string", ")", "*", "TaskInfo", "{", "ctr", ".", "Lock", "(", ")", "\n", "defer", "ctr", ".", "Unlock", "(", ")", "\n", "return", "ctr", ".", "rels", "[", "containerID", "]...
// Get is a utility method which handles the mutex lock and abstracts the inner // map in ContainerTaskRels away. If no task info is available for the supplied // containerID, returns nil.
[ "Get", "is", "a", "utility", "method", "which", "handles", "the", "mutex", "lock", "and", "abstracts", "the", "inner", "map", "in", "ContainerTaskRels", "away", ".", "If", "no", "task", "info", "is", "available", "for", "the", "supplied", "containerID", "ret...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L89-L93
132,745
dcos/dcos-metrics
collectors/mesos/agent/agent.go
Set
func (ctr *ContainerTaskRels) Set(containerID string, info *TaskInfo) { ctr.Lock() defer ctr.Unlock() ctr.rels[containerID] = info }
go
func (ctr *ContainerTaskRels) Set(containerID string, info *TaskInfo) { ctr.Lock() defer ctr.Unlock() ctr.rels[containerID] = info }
[ "func", "(", "ctr", "*", "ContainerTaskRels", ")", "Set", "(", "containerID", "string", ",", "info", "*", "TaskInfo", ")", "{", "ctr", ".", "Lock", "(", ")", "\n", "defer", "ctr", ".", "Unlock", "(", ")", "\n", "ctr", ".", "rels", "[", "containerID",...
// Set adds or updates an entry to ContainerTaskRels and, if necessary, // initiates the inner map. It is only currently used in tests.
[ "Set", "adds", "or", "updates", "an", "entry", "to", "ContainerTaskRels", "and", "if", "necessary", "initiates", "the", "inner", "map", ".", "It", "is", "only", "currently", "used", "in", "tests", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L97-L101
132,746
dcos/dcos-metrics
collectors/mesos/agent/agent.go
RunPoller
func (c *Collector) RunPoller() { for { c.pollMesosAgent() for _, m := range c.metricsMessages() { c.log.Debugf("Sending container metrics to metric chan:\n%+v", m) c.metricsChan <- m } time.Sleep(c.PollPeriod) } }
go
func (c *Collector) RunPoller() { for { c.pollMesosAgent() for _, m := range c.metricsMessages() { c.log.Debugf("Sending container metrics to metric chan:\n%+v", m) c.metricsChan <- m } time.Sleep(c.PollPeriod) } }
[ "func", "(", "c", "*", "Collector", ")", "RunPoller", "(", ")", "{", "for", "{", "c", ".", "pollMesosAgent", "(", ")", "\n", "for", "_", ",", "m", ":=", "range", "c", ".", "metricsMessages", "(", ")", "{", "c", ".", "log", ".", "Debugf", "(", "...
// RunPoller continually polls the agent on a set interval. This should be run in its own goroutine.
[ "RunPoller", "continually", "polls", "the", "agent", "on", "a", "set", "interval", ".", "This", "should", "be", "run", "in", "its", "own", "goroutine", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L136-L145
132,747
dcos/dcos-metrics
collectors/mesos/agent/agent.go
getFrameworkInfoByFrameworkID
func getFrameworkInfoByFrameworkID(frameworkID string, frameworks []frameworkInfo) *frameworkInfo { for _, framework := range frameworks { if framework.ID == frameworkID { return &framework } } return nil }
go
func getFrameworkInfoByFrameworkID(frameworkID string, frameworks []frameworkInfo) *frameworkInfo { for _, framework := range frameworks { if framework.ID == frameworkID { return &framework } } return nil }
[ "func", "getFrameworkInfoByFrameworkID", "(", "frameworkID", "string", ",", "frameworks", "[", "]", "frameworkInfo", ")", "*", "frameworkInfo", "{", "for", "_", ",", "framework", ":=", "range", "frameworks", "{", "if", "framework", ".", "ID", "==", "frameworkID"...
// getFrameworkInfoByFrameworkID returns the FrameworkInfo struct given its ID.
[ "getFrameworkInfoByFrameworkID", "returns", "the", "FrameworkInfo", "struct", "given", "its", "ID", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L233-L240
132,748
dcos/dcos-metrics
collectors/mesos/agent/agent.go
getExecutorInfoByExecutorID
func getExecutorInfoByExecutorID(executorID string, executors []executorInfo) *executorInfo { for _, executor := range executors { if executor.ID == executorID { return &executor } } return nil }
go
func getExecutorInfoByExecutorID(executorID string, executors []executorInfo) *executorInfo { for _, executor := range executors { if executor.ID == executorID { return &executor } } return nil }
[ "func", "getExecutorInfoByExecutorID", "(", "executorID", "string", ",", "executors", "[", "]", "executorInfo", ")", "*", "executorInfo", "{", "for", "_", ",", "executor", ":=", "range", "executors", "{", "if", "executor", ".", "ID", "==", "executorID", "{", ...
// getExecutorInfoByExecutorID returns the executorInfo struct given its ID.
[ "getExecutorInfoByExecutorID", "returns", "the", "executorInfo", "struct", "given", "its", "ID", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L243-L250
132,749
dcos/dcos-metrics
collectors/mesos/agent/agent.go
getTaskInfoByContainerID
func getTaskInfoByContainerID(containerID string, tasks []TaskInfo) *TaskInfo { for _, task := range tasks { if len(task.Statuses) > 0 && task.Statuses[0].ContainerStatusInfo.ID.Value == containerID { return &task } } return nil }
go
func getTaskInfoByContainerID(containerID string, tasks []TaskInfo) *TaskInfo { for _, task := range tasks { if len(task.Statuses) > 0 && task.Statuses[0].ContainerStatusInfo.ID.Value == containerID { return &task } } return nil }
[ "func", "getTaskInfoByContainerID", "(", "containerID", "string", ",", "tasks", "[", "]", "TaskInfo", ")", "*", "TaskInfo", "{", "for", "_", ",", "task", ":=", "range", "tasks", "{", "if", "len", "(", "task", ".", "Statuses", ")", ">", "0", "&&", "task...
// getTaskInfoByContainerID returns the TaskInfo struct matching the given cID.
[ "getTaskInfoByContainerID", "returns", "the", "TaskInfo", "struct", "matching", "the", "given", "cID", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L253-L260
132,750
dcos/dcos-metrics
collectors/mesos/agent/agent.go
getLabelsByContainerID
func getLabelsByContainerID(containerID string, frameworks []frameworkInfo, log *logrus.Entry) map[string]string { labels := map[string]string{} for _, framework := range frameworks { log.Debugf("Attempting to add labels to %v framework", framework) for _, executor := range framework.Executors { log.Debugf("Fo...
go
func getLabelsByContainerID(containerID string, frameworks []frameworkInfo, log *logrus.Entry) map[string]string { labels := map[string]string{} for _, framework := range frameworks { log.Debugf("Attempting to add labels to %v framework", framework) for _, executor := range framework.Executors { log.Debugf("Fo...
[ "func", "getLabelsByContainerID", "(", "containerID", "string", ",", "frameworks", "[", "]", "frameworkInfo", ",", "log", "*", "logrus", ".", "Entry", ")", "map", "[", "string", "]", "string", "{", "labels", ":=", "map", "[", "string", "]", "string", "{", ...
// getLabelsByContainerID returns a map of labels, as specified by the framework // that created the executor. In the case of Marathon, the framework allows the // user to specify their own arbitrary labels per application.
[ "getLabelsByContainerID", "returns", "a", "map", "of", "labels", "as", "specified", "by", "the", "framework", "that", "created", "the", "executor", ".", "In", "the", "case", "of", "Marathon", "the", "framework", "allows", "the", "user", "to", "specify", "their...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/agent.go#L265-L290
132,751
dcos/dcos-metrics
plugins/stdout/stdout.go
stdoutConnector
func stdoutConnector(metrics []producers.MetricsMessage, c *cli.Context) error { if len(metrics) == 0 { log.Info("No messages received from metrics service") return nil } for _, message := range metrics { dimensions := &message.Dimensions // we print a few potentially interesting dimensions log.Infof("Met...
go
func stdoutConnector(metrics []producers.MetricsMessage, c *cli.Context) error { if len(metrics) == 0 { log.Info("No messages received from metrics service") return nil } for _, message := range metrics { dimensions := &message.Dimensions // we print a few potentially interesting dimensions log.Infof("Met...
[ "func", "stdoutConnector", "(", "metrics", "[", "]", "producers", ".", "MetricsMessage", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "if", "len", "(", "metrics", ")", "==", "0", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "ret...
// stdoutConnector will be called each time a new set of metrics messages // is received. It simply prints each message.
[ "stdoutConnector", "will", "be", "called", "each", "time", "a", "new", "set", "of", "metrics", "messages", "is", "received", ".", "It", "simply", "prints", "each", "message", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/stdout/stdout.go#L43-L65
132,752
dcos/dcos-metrics
collectors/mesos/agent/container.go
getContainerMetrics
func (c *Collector) getContainerMetrics() error { u := url.URL{ Scheme: c.RequestProtocol, Host: net.JoinHostPort(c.nodeInfo.IPAddress, strconv.Itoa(c.Port)), Path: "/containers", } c.HTTPClient.Timeout = c.RequestTimeout return client.Fetch(c.HTTPClient, u, &c.containerMetrics) }
go
func (c *Collector) getContainerMetrics() error { u := url.URL{ Scheme: c.RequestProtocol, Host: net.JoinHostPort(c.nodeInfo.IPAddress, strconv.Itoa(c.Port)), Path: "/containers", } c.HTTPClient.Timeout = c.RequestTimeout return client.Fetch(c.HTTPClient, u, &c.containerMetrics) }
[ "func", "(", "c", "*", "Collector", ")", "getContainerMetrics", "(", ")", "error", "{", "u", ":=", "url", ".", "URL", "{", "Scheme", ":", "c", ".", "RequestProtocol", ",", "Host", ":", "net", ".", "JoinHostPort", "(", "c", ".", "nodeInfo", ".", "IPAd...
// poll queries an agent for container-level metrics, such as // CPU, memory, disk, and network usage.
[ "poll", "queries", "an", "agent", "for", "container", "-", "level", "metrics", "such", "as", "CPU", "memory", "disk", "and", "network", "usage", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/container.go#L130-L140
132,753
dcos/dcos-metrics
collectors/framework/record.go
convertLabels
func convertLabels(newLabels []mesosAgent.KeyValue) map[string]string { result := map[string]string{} for _, l := range newLabels { // Remove blacklisted cosmos labels if _, inSlice := cosmosLabels[l.Key]; inSlice { continue } result[l.Key] = l.Value } return result }
go
func convertLabels(newLabels []mesosAgent.KeyValue) map[string]string { result := map[string]string{} for _, l := range newLabels { // Remove blacklisted cosmos labels if _, inSlice := cosmosLabels[l.Key]; inSlice { continue } result[l.Key] = l.Value } return result }
[ "func", "convertLabels", "(", "newLabels", "[", "]", "mesosAgent", ".", "KeyValue", ")", "map", "[", "string", "]", "string", "{", "result", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "for", "_", ",", "l", ":=", "range", "newLabels", ...
// convertLabels converts each keyValue to an entry in a map
[ "convertLabels", "converts", "each", "keyValue", "to", "an", "entry", "in", "a", "map" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/framework/record.go#L134-L145
132,754
dcos/dcos-metrics
util/http/helpers/helpers.go
loadCAPool
func loadCAPool(path string) (*x509.CertPool, error) { caPool := x509.NewCertPool() f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() b, err := ioutil.ReadAll(f) if err != nil { return nil, err } if !caPool.AppendCertsFromPEM(b) { return nil, errors.New("CACertFile parsing faile...
go
func loadCAPool(path string) (*x509.CertPool, error) { caPool := x509.NewCertPool() f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() b, err := ioutil.ReadAll(f) if err != nil { return nil, err } if !caPool.AppendCertsFromPEM(b) { return nil, errors.New("CACertFile parsing faile...
[ "func", "loadCAPool", "(", "path", "string", ")", "(", "*", "x509", ".", "CertPool", ",", "error", ")", "{", "caPool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err"...
// loadCAPool will load a valid x509 cert.
[ "loadCAPool", "will", "load", "a", "valid", "x509", "cert", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/util/http/helpers/helpers.go#L30-L48
132,755
dcos/dcos-metrics
plugins/plugin.go
New
func New(options ...Option) (*Plugin, error) { newPlugin := &Plugin{ Name: "default", PollingInterval: 10, } newPlugin.App = cli.NewApp() newPlugin.App.Version = version newPlugin.App.Flags = []cli.Flag{ cli.IntFlag{ Name: "polling-interval", Value: newPlugin.PollingInterval, ...
go
func New(options ...Option) (*Plugin, error) { newPlugin := &Plugin{ Name: "default", PollingInterval: 10, } newPlugin.App = cli.NewApp() newPlugin.App.Version = version newPlugin.App.Flags = []cli.Flag{ cli.IntFlag{ Name: "polling-interval", Value: newPlugin.PollingInterval, ...
[ "func", "New", "(", "options", "...", "Option", ")", "(", "*", "Plugin", ",", "error", ")", "{", "newPlugin", ":=", "&", "Plugin", "{", "Name", ":", "\"", "\"", ",", "PollingInterval", ":", "10", ",", "}", "\n\n", "newPlugin", ".", "App", "=", "cli...
// New returns a mandatory plugin config which every plugin for // metrics will need
[ "New", "returns", "a", "mandatory", "plugin", "config", "which", "every", "plugin", "for", "metrics", "will", "need" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/plugin.go#L54-L86
132,756
dcos/dcos-metrics
plugins/plugin.go
Metrics
func (p *Plugin) Metrics() ([]producers.MetricsMessage, error) { var messages []producers.MetricsMessage // Fetch node metrics nodeMetrics, err := p.getNodeMetrics() if err != nil { return nil, err } messages = append(messages, nodeMetrics) // Master only collects node metrics; return without checking contai...
go
func (p *Plugin) Metrics() ([]producers.MetricsMessage, error) { var messages []producers.MetricsMessage // Fetch node metrics nodeMetrics, err := p.getNodeMetrics() if err != nil { return nil, err } messages = append(messages, nodeMetrics) // Master only collects node metrics; return without checking contai...
[ "func", "(", "p", "*", "Plugin", ")", "Metrics", "(", ")", "(", "[", "]", "producers", ".", "MetricsMessage", ",", "error", ")", "{", "var", "messages", "[", "]", "producers", ".", "MetricsMessage", "\n\n", "// Fetch node metrics", "nodeMetrics", ",", "err...
// Metrics queries the local dcos-metrics API and returns a slice of // producers.MetricsMessage.
[ "Metrics", "queries", "the", "local", "dcos", "-", "metrics", "API", "and", "returns", "a", "slice", "of", "producers", ".", "MetricsMessage", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/plugin.go#L134-L156
132,757
dcos/dcos-metrics
plugins/plugin.go
createClient
func (p *Plugin) createClient() error { network := "unix" address := "/run/dcos/dcos-metrics-agent.sock" if runtime.GOOS == "windows" { network = "tcp" address = "localhost:9000" } if p.Role == dcos.RoleMaster { address = "/run/dcos/dcos-metrics-master.sock" } p.Log.Infof("Creating metrics API client via ...
go
func (p *Plugin) createClient() error { network := "unix" address := "/run/dcos/dcos-metrics-agent.sock" if runtime.GOOS == "windows" { network = "tcp" address = "localhost:9000" } if p.Role == dcos.RoleMaster { address = "/run/dcos/dcos-metrics-master.sock" } p.Log.Infof("Creating metrics API client via ...
[ "func", "(", "p", "*", "Plugin", ")", "createClient", "(", ")", "error", "{", "network", ":=", "\"", "\"", "\n", "address", ":=", "\"", "\"", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "network", "=", "\"", "\"", "\n", "address", ...
// createClient creates an HTTP Client which uses the unix file socket // appropriate to the plugin's role
[ "createClient", "creates", "an", "HTTP", "Client", "which", "uses", "the", "unix", "file", "socket", "appropriate", "to", "the", "plugin", "s", "role" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/plugin.go#L231-L252
132,758
dcos/dcos-metrics
plugins/prometheus/prometheus.go
messageToPromText
func messageToPromText(message producers.MetricsMessage) string { var buffer bytes.Buffer for _, d := range message.Datapoints { name := sanitizeName(d.Name) labels := getLabelsForDatapoint(message.Dimensions, d.Tags) t, err := time.Parse(time.RFC3339, d.Timestamp) if err != nil { log.Warnf("Encountered b...
go
func messageToPromText(message producers.MetricsMessage) string { var buffer bytes.Buffer for _, d := range message.Datapoints { name := sanitizeName(d.Name) labels := getLabelsForDatapoint(message.Dimensions, d.Tags) t, err := time.Parse(time.RFC3339, d.Timestamp) if err != nil { log.Warnf("Encountered b...
[ "func", "messageToPromText", "(", "message", "producers", ".", "MetricsMessage", ")", "string", "{", "var", "buffer", "bytes", ".", "Buffer", "\n\n", "for", "_", ",", "d", ":=", "range", "message", ".", "Datapoints", "{", "name", ":=", "sanitizeName", "(", ...
// messageToPromText converts a single metrics message to prometheus-formatted // newline-separate strings
[ "messageToPromText", "converts", "a", "single", "metrics", "message", "to", "prometheus", "-", "formatted", "newline", "-", "separate", "strings" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/prometheus/prometheus.go#L129-L145
132,759
dcos/dcos-metrics
plugins/prometheus/prometheus.go
getLabelsForDatapoint
func getLabelsForDatapoint(dimensions producers.Dimensions, tags map[string]string) string { allDimensions := map[string]string{} if dimensions.Labels != nil { allDimensions = dimensions.Labels } allDimensions["mesos_id"] = dimensions.MesosID allDimensions["cluster_id"] = dimensions.ClusterID allDimensions["co...
go
func getLabelsForDatapoint(dimensions producers.Dimensions, tags map[string]string) string { allDimensions := map[string]string{} if dimensions.Labels != nil { allDimensions = dimensions.Labels } allDimensions["mesos_id"] = dimensions.MesosID allDimensions["cluster_id"] = dimensions.ClusterID allDimensions["co...
[ "func", "getLabelsForDatapoint", "(", "dimensions", "producers", ".", "Dimensions", ",", "tags", "map", "[", "string", "]", "string", ")", "string", "{", "allDimensions", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "if", "dimensions", ".", "...
// getLabelsForDatapoint returns prometheus-formatted labels from a // datapoint's dimensions and tags
[ "getLabelsForDatapoint", "returns", "prometheus", "-", "formatted", "labels", "from", "a", "datapoint", "s", "dimensions", "and", "tags" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/prometheus/prometheus.go#L149-L182
132,760
dcos/dcos-metrics
plugins/prometheus/prometheus.go
sanitizeName
func sanitizeName(name string) string { output := strings.ToLower(illegalChars.ReplaceAllString(name, "_")) if legalLabel.MatchString(output) { return output } // Prefix name with _ if it begins with a number return "_" + output }
go
func sanitizeName(name string) string { output := strings.ToLower(illegalChars.ReplaceAllString(name, "_")) if legalLabel.MatchString(output) { return output } // Prefix name with _ if it begins with a number return "_" + output }
[ "func", "sanitizeName", "(", "name", "string", ")", "string", "{", "output", ":=", "strings", ".", "ToLower", "(", "illegalChars", ".", "ReplaceAllString", "(", "name", ",", "\"", "\"", ")", ")", "\n\n", "if", "legalLabel", ".", "MatchString", "(", "output...
// sanitizeName returns a metric or label name which is safe for use // in prometheus output
[ "sanitizeName", "returns", "a", "metric", "or", "label", "name", "which", "is", "safe", "for", "use", "in", "prometheus", "output" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/prometheus/prometheus.go#L186-L194
132,761
dcos/dcos-metrics
util/http/profiler/profiler.go
RunHTTPProfAccess
func RunHTTPProfAccess() { // listen on an ephemeral port, then print the port listener, err := net.Listen("tcp", ":0") if err != nil { log.Printf("Unable to open profile access listener: %s\n", err) } else { log.Printf("Enabling profile access at http://%s/debug/pprof\n", listener.Addr()) log.Println(http.Se...
go
func RunHTTPProfAccess() { // listen on an ephemeral port, then print the port listener, err := net.Listen("tcp", ":0") if err != nil { log.Printf("Unable to open profile access listener: %s\n", err) } else { log.Printf("Enabling profile access at http://%s/debug/pprof\n", listener.Addr()) log.Println(http.Se...
[ "func", "RunHTTPProfAccess", "(", ")", "{", "// listen on an ephemeral port, then print the port", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\...
// RunHTTPProfAccess runs an HTTP listener on a random ephemeral port which allows pprof access. // This function should be run as a gofunc.
[ "RunHTTPProfAccess", "runs", "an", "HTTP", "listener", "on", "a", "random", "ephemeral", "port", "which", "allows", "pprof", "access", ".", "This", "function", "should", "be", "run", "as", "a", "gofunc", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/util/http/profiler/profiler.go#L27-L36
132,762
dcos/dcos-metrics
producers/prometheus/prometheus.go
New
func New(cfg Config) (producers.MetricsProducer, chan producers.MetricsMessage) { p := promProducer{ config: cfg, store: store.New(), metricsChan: make(chan producers.MetricsMessage), janitorRunInterval: 60 * time.Second, } return &p, p.metricsChan }
go
func New(cfg Config) (producers.MetricsProducer, chan producers.MetricsMessage) { p := promProducer{ config: cfg, store: store.New(), metricsChan: make(chan producers.MetricsMessage), janitorRunInterval: 60 * time.Second, } return &p, p.metricsChan }
[ "func", "New", "(", "cfg", "Config", ")", "(", "producers", ".", "MetricsProducer", ",", "chan", "producers", ".", "MetricsMessage", ")", "{", "p", ":=", "promProducer", "{", "config", ":", "cfg", ",", "store", ":", "store", ".", "New", "(", ")", ",", ...
// New returns a prometheus producer and a channel for passing in metrics
[ "New", "returns", "a", "prometheus", "producer", "and", "a", "channel", "for", "passing", "in", "metrics" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L64-L72
132,763
dcos/dcos-metrics
producers/prometheus/prometheus.go
Collect
func (p *promProducer) Collect(ch chan<- prometheus.Metric) { for name, datapointsLabels := range datapointLabelsByName(p.store) { variableLabels := getLabelNames(datapointsLabels) desc := prometheus.NewDesc(sanitize(name), "DC/OS Metrics Datapoint", sanitizeSlice(variableLabels), nil) // Publish a metric for e...
go
func (p *promProducer) Collect(ch chan<- prometheus.Metric) { for name, datapointsLabels := range datapointLabelsByName(p.store) { variableLabels := getLabelNames(datapointsLabels) desc := prometheus.NewDesc(sanitize(name), "DC/OS Metrics Datapoint", sanitizeSlice(variableLabels), nil) // Publish a metric for e...
[ "func", "(", "p", "*", "promProducer", ")", "Collect", "(", "ch", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "for", "name", ",", "datapointsLabels", ":=", "range", "datapointLabelsByName", "(", "p", ".", "store", ")", "{", "variableLabels", ":=",...
// Collect iterates over all the metrics available in the store, converting // them to prometheus.Metric and passing them into the prometheus producer // channel, where they will be served to consumers.
[ "Collect", "iterates", "over", "all", "the", "metrics", "available", "in", "the", "store", "converting", "them", "to", "prometheus", ".", "Metric", "and", "passing", "them", "into", "the", "prometheus", "producer", "channel", "where", "they", "will", "be", "se...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L136-L169
132,764
dcos/dcos-metrics
producers/prometheus/prometheus.go
writeObjectToStore
func (p *promProducer) writeObjectToStore(d producers.Datapoint, m producers.MetricsMessage, prefix string) { newMessage := producers.MetricsMessage{ Name: m.Name, Datapoints: []producers.Datapoint{d}, Dimensions: m.Dimensions, Timestamp: m.Timestamp, } // e.g. dcos.metrics.app.[ContainerId].kafka.ser...
go
func (p *promProducer) writeObjectToStore(d producers.Datapoint, m producers.MetricsMessage, prefix string) { newMessage := producers.MetricsMessage{ Name: m.Name, Datapoints: []producers.Datapoint{d}, Dimensions: m.Dimensions, Timestamp: m.Timestamp, } // e.g. dcos.metrics.app.[ContainerId].kafka.ser...
[ "func", "(", "p", "*", "promProducer", ")", "writeObjectToStore", "(", "d", "producers", ".", "Datapoint", ",", "m", "producers", ".", "MetricsMessage", ",", "prefix", "string", ")", "{", "newMessage", ":=", "producers", ".", "MetricsMessage", "{", "Name", "...
// - helpers - // writeObjectToStore writes a prefixed datapoint into the store.
[ "-", "helpers", "-", "writeObjectToStore", "writes", "a", "prefixed", "datapoint", "into", "the", "store", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L174-L190
132,765
dcos/dcos-metrics
producers/prometheus/prometheus.go
coerceToFloat
func coerceToFloat(unk interface{}) (float64, error) { switch i := unk.(type) { case float64: if math.IsNaN(i) { return i, errors.New("value was NaN") } return i, nil case float32: return float64(i), nil case int: return float64(i), nil case int32: return float64(i), nil case int64: return float6...
go
func coerceToFloat(unk interface{}) (float64, error) { switch i := unk.(type) { case float64: if math.IsNaN(i) { return i, errors.New("value was NaN") } return i, nil case float32: return float64(i), nil case int: return float64(i), nil case int32: return float64(i), nil case int64: return float6...
[ "func", "coerceToFloat", "(", "unk", "interface", "{", "}", ")", "(", "float64", ",", "error", ")", "{", "switch", "i", ":=", "unk", ".", "(", "type", ")", "{", "case", "float64", ":", "if", "math", ".", "IsNaN", "(", "i", ")", "{", "return", "i"...
// coerceToFloat attempts to convert an interface to float64. It should succeed // with any numeric input.
[ "coerceToFloat", "attempts", "to", "convert", "an", "interface", "to", "float64", ".", "It", "should", "succeed", "with", "any", "numeric", "input", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L242-L266
132,766
dcos/dcos-metrics
producers/prometheus/prometheus.go
dimsToMap
func dimsToMap(dims producers.Dimensions) map[string]string { results := map[string]string{ "mesos_id": dims.MesosID, "cluster_id": dims.ClusterID, "container_id": dims.ContainerID, "executor_id": dims.ExecutorID, "framework_name": dims.FrameworkName, "framework_id":...
go
func dimsToMap(dims producers.Dimensions) map[string]string { results := map[string]string{ "mesos_id": dims.MesosID, "cluster_id": dims.ClusterID, "container_id": dims.ContainerID, "executor_id": dims.ExecutorID, "framework_name": dims.FrameworkName, "framework_id":...
[ "func", "dimsToMap", "(", "dims", "producers", ".", "Dimensions", ")", "map", "[", "string", "]", "string", "{", "results", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "dims", ".", "MesosID", ",", "\"", "\"", ":", "dims", ".", ...
// dimsToMap converts a Dimensions object to a flat map of strings to strings
[ "dimsToMap", "converts", "a", "Dimensions", "object", "to", "a", "flat", "map", "of", "strings", "to", "strings" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L269-L287
132,767
dcos/dcos-metrics
producers/prometheus/prometheus.go
datapointLabelsByName
func datapointLabelsByName(s store.Store) map[string][]datapointLabels { rval := map[string][]datapointLabels{} for _, obj := range s.Objects() { m, ok := obj.(producers.MetricsMessage) if !ok { promLog.Warnf("Unsupported message type %T", obj) continue } // For each datapoint, collect its labels and ...
go
func datapointLabelsByName(s store.Store) map[string][]datapointLabels { rval := map[string][]datapointLabels{} for _, obj := range s.Objects() { m, ok := obj.(producers.MetricsMessage) if !ok { promLog.Warnf("Unsupported message type %T", obj) continue } // For each datapoint, collect its labels and ...
[ "func", "datapointLabelsByName", "(", "s", "store", ".", "Store", ")", "map", "[", "string", "]", "[", "]", "datapointLabels", "{", "rval", ":=", "map", "[", "string", "]", "[", "]", "datapointLabels", "{", "}", "\n\n", "for", "_", ",", "obj", ":=", ...
// datapointLabelsByName returns a mapping of datapoint names to a slice of structs pairing producers.Datapoints by that // name with their corresponding labels. Labels are derived from MetricsMessage dimensions and Datapoint tags.
[ "datapointLabelsByName", "returns", "a", "mapping", "of", "datapoint", "names", "to", "a", "slice", "of", "structs", "pairing", "producers", ".", "Datapoints", "by", "that", "name", "with", "their", "corresponding", "labels", ".", "Labels", "are", "derived", "fr...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L291-L316
132,768
dcos/dcos-metrics
producers/prometheus/prometheus.go
getLabelNames
func getLabelNames(datapointsLabels []datapointLabels) []string { // Collect all label names used among datapointsLabels. nameMap := map[string]bool{} for _, kv := range datapointsLabels { for k := range kv.labels { nameMap[k] = true } } // Return a slice of nameMap keys. names := []string{} for n := ran...
go
func getLabelNames(datapointsLabels []datapointLabels) []string { // Collect all label names used among datapointsLabels. nameMap := map[string]bool{} for _, kv := range datapointsLabels { for k := range kv.labels { nameMap[k] = true } } // Return a slice of nameMap keys. names := []string{} for n := ran...
[ "func", "getLabelNames", "(", "datapointsLabels", "[", "]", "datapointLabels", ")", "[", "]", "string", "{", "// Collect all label names used among datapointsLabels.", "nameMap", ":=", "map", "[", "string", "]", "bool", "{", "}", "\n", "for", "_", ",", "kv", ":=...
// getLabelNames returns the names of all labels among datapointsLabels.
[ "getLabelNames", "returns", "the", "names", "of", "all", "labels", "among", "datapointsLabels", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/producers/prometheus/prometheus.go#L319-L334
132,769
dcos/dcos-metrics
collectors/node/node.go
New
func New(cfg Collector, nodeInfo collectors.NodeInfo) (Collector, chan producers.MetricsMessage) { c := Collector{ PollPeriod: cfg.PollPeriod, MetricsChan: make(chan producers.MetricsMessage), log: log.WithFields(log.Fields{"collector": "node"}), nodeInfo: nodeInfo, } return c, c.MetricsChan }
go
func New(cfg Collector, nodeInfo collectors.NodeInfo) (Collector, chan producers.MetricsMessage) { c := Collector{ PollPeriod: cfg.PollPeriod, MetricsChan: make(chan producers.MetricsMessage), log: log.WithFields(log.Fields{"collector": "node"}), nodeInfo: nodeInfo, } return c, c.MetricsChan }
[ "func", "New", "(", "cfg", "Collector", ",", "nodeInfo", "collectors", ".", "NodeInfo", ")", "(", "Collector", ",", "chan", "producers", ".", "MetricsMessage", ")", "{", "c", ":=", "Collector", "{", "PollPeriod", ":", "cfg", ".", "PollPeriod", ",", "Metric...
// New returns a new instance of the node metrics collector and a metrics chan.
[ "New", "returns", "a", "new", "instance", "of", "the", "node", "metrics", "collector", "and", "a", "metrics", "chan", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/node/node.go#L44-L52
132,770
dcos/dcos-metrics
collectors/node/node.go
RunPoller
func (c *Collector) RunPoller() { for { c.pollHost() for _, m := range c.transform() { c.MetricsChan <- m } time.Sleep(c.PollPeriod) } }
go
func (c *Collector) RunPoller() { for { c.pollHost() for _, m := range c.transform() { c.MetricsChan <- m } time.Sleep(c.PollPeriod) } }
[ "func", "(", "c", "*", "Collector", ")", "RunPoller", "(", ")", "{", "for", "{", "c", ".", "pollHost", "(", ")", "\n", "for", "_", ",", "m", ":=", "range", "c", ".", "transform", "(", ")", "{", "c", ".", "MetricsChan", "<-", "m", "\n", "}", "...
// RunPoller periodiclly polls the HTTP APIs of a Mesos agent. This function // should be run in its own goroutine.
[ "RunPoller", "periodiclly", "polls", "the", "HTTP", "APIs", "of", "a", "Mesos", "agent", ".", "This", "function", "should", "be", "run", "in", "its", "own", "goroutine", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/node/node.go#L56-L64
132,771
dcos/dcos-metrics
collectors/node/node.go
transform
func (c *Collector) transform() (out []producers.MetricsMessage) { var msg producers.MetricsMessage t := time.Unix(c.timestamp, 0) // Produce node metrics msg = producers.MetricsMessage{ Name: producers.NodeMetricPrefix, Datapoints: c.nodeMetrics, Dimensions: producers.Dimensions{ MesosID: c.nodeI...
go
func (c *Collector) transform() (out []producers.MetricsMessage) { var msg producers.MetricsMessage t := time.Unix(c.timestamp, 0) // Produce node metrics msg = producers.MetricsMessage{ Name: producers.NodeMetricPrefix, Datapoints: c.nodeMetrics, Dimensions: producers.Dimensions{ MesosID: c.nodeI...
[ "func", "(", "c", "*", "Collector", ")", "transform", "(", ")", "(", "out", "[", "]", "producers", ".", "MetricsMessage", ")", "{", "var", "msg", "producers", ".", "MetricsMessage", "\n", "t", ":=", "time", ".", "Unix", "(", "c", ".", "timestamp", ",...
// transform will take metrics retrieved from the agent and perform any // transformations necessary to make the data fit the output expected by // producers.MetricsMessage.
[ "transform", "will", "take", "metrics", "retrieved", "from", "the", "agent", "and", "perform", "any", "transformations", "necessary", "to", "make", "the", "data", "fit", "the", "output", "expected", "by", "producers", ".", "MetricsMessage", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/node/node.go#L86-L104
132,772
dcos/dcos-metrics
plugins/statsd/statsd.go
statsdConnector
func statsdConnector(metrics []producers.MetricsMessage, c *cli.Context) error { once.Do(func() { statsdHost := c.String("statsd-udp-host") statsdPort := c.Int("statsd-udp-port") log.Infof("Setting up new statsd client %s:%d", statsdHost, statsdPort) statsdClient = statsd.New(statsdHost, statsdPort) }) if ...
go
func statsdConnector(metrics []producers.MetricsMessage, c *cli.Context) error { once.Do(func() { statsdHost := c.String("statsd-udp-host") statsdPort := c.Int("statsd-udp-port") log.Infof("Setting up new statsd client %s:%d", statsdHost, statsdPort) statsdClient = statsd.New(statsdHost, statsdPort) }) if ...
[ "func", "statsdConnector", "(", "metrics", "[", "]", "producers", ".", "MetricsMessage", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "once", ".", "Do", "(", "func", "(", ")", "{", "statsdHost", ":=", "c", ".", "String", "(", "\"", "\"", ...
// statsdConnector is the method called by the plugin every time it retrieves // metrics from the API.
[ "statsdConnector", "is", "the", "method", "called", "by", "the", "plugin", "every", "time", "it", "retrieves", "metrics", "from", "the", "API", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/statsd/statsd.go#L67-L86
132,773
dcos/dcos-metrics
plugins/statsd/statsd.go
emitDatapointsOverStatsd
func emitDatapointsOverStatsd(datapoints []producers.Datapoint, client *statsd.StatsdClient) error { data := make(map[string]string) for _, dp := range datapoints { name, val, ok := convertDatapointToStatsd(dp) // we silently drop metrics which could not be converted if ok { data[name] = val } } client.S...
go
func emitDatapointsOverStatsd(datapoints []producers.Datapoint, client *statsd.StatsdClient) error { data := make(map[string]string) for _, dp := range datapoints { name, val, ok := convertDatapointToStatsd(dp) // we silently drop metrics which could not be converted if ok { data[name] = val } } client.S...
[ "func", "emitDatapointsOverStatsd", "(", "datapoints", "[", "]", "producers", ".", "Datapoint", ",", "client", "*", "statsd", ".", "StatsdClient", ")", "error", "{", "data", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", "...
// emitDatapointsOverStatsd converts datapoints to statsd format and dispatches // them in a batch to the statsd server
[ "emitDatapointsOverStatsd", "converts", "datapoints", "to", "statsd", "format", "and", "dispatches", "them", "in", "a", "batch", "to", "the", "statsd", "server" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/statsd/statsd.go#L90-L101
132,774
dcos/dcos-metrics
plugins/statsd/statsd.go
convertDatapointToStatsd
func convertDatapointToStatsd(datapoint producers.Datapoint) (string, string, bool) { val, err := normalize(datapoint.Value) if err != nil { // This is only debug-level because we expect many NaNs in regular usage log.Debugf("Metric %s failed to convert: %q", datapoint.Name, err) return "", "", false } return...
go
func convertDatapointToStatsd(datapoint producers.Datapoint) (string, string, bool) { val, err := normalize(datapoint.Value) if err != nil { // This is only debug-level because we expect many NaNs in regular usage log.Debugf("Metric %s failed to convert: %q", datapoint.Name, err) return "", "", false } return...
[ "func", "convertDatapointToStatsd", "(", "datapoint", "producers", ".", "Datapoint", ")", "(", "string", ",", "string", ",", "bool", ")", "{", "val", ",", "err", ":=", "normalize", "(", "datapoint", ".", "Value", ")", "\n", "if", "err", "!=", "nil", "{",...
// convertDatapointToStatsd attempts to convert a datapoint to a statsd format // name + value, returning a false ok flag if the conversion failed.
[ "convertDatapointToStatsd", "attempts", "to", "convert", "a", "datapoint", "to", "a", "statsd", "format", "name", "+", "value", "returning", "a", "false", "ok", "flag", "if", "the", "conversion", "failed", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/statsd/statsd.go#L105-L113
132,775
dcos/dcos-metrics
plugins/statsd/statsd.go
normalize
func normalize(i interface{}) (int, error) { switch v := i.(type) { case int: return v, nil case int32: return int(v), nil case int64: return int(v), nil case float32: return int(v + 0.5), nil case float64: // We need this check here because NaN can be a float. Casting NaN to // int results in a large...
go
func normalize(i interface{}) (int, error) { switch v := i.(type) { case int: return v, nil case int32: return int(v), nil case int64: return int(v), nil case float32: return int(v + 0.5), nil case float64: // We need this check here because NaN can be a float. Casting NaN to // int results in a large...
[ "func", "normalize", "(", "i", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "switch", "v", ":=", "i", ".", "(", "type", ")", "{", "case", "int", ":", "return", "v", ",", "nil", "\n", "case", "int32", ":", "return", "int", "("...
// normalize converts ints, floats and strings to rounded ints // It errors on other types and NaNs.
[ "normalize", "converts", "ints", "floats", "and", "strings", "to", "rounded", "ints", "It", "errors", "on", "other", "types", "and", "NaNs", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/statsd/statsd.go#L117-L143
132,776
dcos/dcos-metrics
collectors/framework/framework.go
New
func New(cfg Collector, nodeInfo collectors.NodeInfo, ctr *mesosAgent.ContainerTaskRels) (Collector, chan producers.MetricsMessage) { c := cfg c.nodeInfo = nodeInfo c.metricsChan = make(chan producers.MetricsMessage) c.containerTaskRels = ctr return c, c.metricsChan }
go
func New(cfg Collector, nodeInfo collectors.NodeInfo, ctr *mesosAgent.ContainerTaskRels) (Collector, chan producers.MetricsMessage) { c := cfg c.nodeInfo = nodeInfo c.metricsChan = make(chan producers.MetricsMessage) c.containerTaskRels = ctr return c, c.metricsChan }
[ "func", "New", "(", "cfg", "Collector", ",", "nodeInfo", "collectors", ".", "NodeInfo", ",", "ctr", "*", "mesosAgent", ".", "ContainerTaskRels", ")", "(", "Collector", ",", "chan", "producers", ".", "MetricsMessage", ")", "{", "c", ":=", "cfg", "\n", "c", ...
// New returns a new instance of the framework collector.
[ "New", "returns", "a", "new", "instance", "of", "the", "framework", "collector", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/framework/framework.go#L71-L77
132,777
dcos/dcos-metrics
collectors/framework/framework.go
RunFrameworkTCPListener
func (c *Collector) RunFrameworkTCPListener() { fwColLog.Info("Starting TCP listener for framework metric collection") addr, err := net.ResolveTCPAddr("tcp", c.ListenEndpointFlag) if err != nil { fwColLog.Errorf("Failed to parse TCP endpoint '%s': %s", c.ListenEndpointFlag, err) } fwColLog.Debugf("Attempting to ...
go
func (c *Collector) RunFrameworkTCPListener() { fwColLog.Info("Starting TCP listener for framework metric collection") addr, err := net.ResolveTCPAddr("tcp", c.ListenEndpointFlag) if err != nil { fwColLog.Errorf("Failed to parse TCP endpoint '%s': %s", c.ListenEndpointFlag, err) } fwColLog.Debugf("Attempting to ...
[ "func", "(", "c", "*", "Collector", ")", "RunFrameworkTCPListener", "(", ")", "{", "fwColLog", ".", "Info", "(", "\"", "\"", ")", "\n", "addr", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "\"", "\"", ",", "c", ".", "ListenEndpointFlag", ")", ...
// RunFrameworkTCPListener runs a TCP socket listener which produces Avro // records sent to that socket. Expects input which has been formatted in the // Avro ODF standard. This function should be run as a gofunc.
[ "RunFrameworkTCPListener", "runs", "a", "TCP", "socket", "listener", "which", "produces", "Avro", "records", "sent", "to", "that", "socket", ".", "Expects", "input", "which", "has", "been", "formatted", "in", "the", "Avro", "ODF", "standard", ".", "This", "fun...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/framework/framework.go#L82-L103
132,778
dcos/dcos-metrics
collectors/framework/framework.go
handleConnection
func (c *Collector) handleConnection(conn net.Conn) { defer conn.Close() reader := &countingReader{conn, 0} avroReader, err := goavro.NewReader(goavro.FromReader(reader)) if err != nil { fwColLog.Errorf("Failed to create avro reader: %s", err) return // close connection } defer func() { if err := avroReader...
go
func (c *Collector) handleConnection(conn net.Conn) { defer conn.Close() reader := &countingReader{conn, 0} avroReader, err := goavro.NewReader(goavro.FromReader(reader)) if err != nil { fwColLog.Errorf("Failed to create avro reader: %s", err) return // close connection } defer func() { if err := avroReader...
[ "func", "(", "c", "*", "Collector", ")", "handleConnection", "(", "conn", "net", ".", "Conn", ")", "{", "defer", "conn", ".", "Close", "(", ")", "\n", "reader", ":=", "&", "countingReader", "{", "conn", ",", "0", "}", "\n", "avroReader", ",", "err", ...
// handleConnection reads records from a TCP session. // This function should be run as a gofunc.
[ "handleConnection", "reads", "records", "from", "a", "TCP", "session", ".", "This", "function", "should", "be", "run", "as", "a", "gofunc", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/framework/framework.go#L107-L182
132,779
dcos/dcos-metrics
collectors/framework/framework.go
getTopic
func getTopic(obj interface{}) (string, bool) { record, ok := obj.(*goavro.Record) if !ok { return "UNKNOWN_RECORD_TYPE", false } topicObj, err := record.Get("topic") if err != nil { return "UNKNOWN_TOPIC_VAL", false } topicStr, ok := topicObj.(string) if !ok { return "UNKNOWN_TOPIC_TYPE", false } retur...
go
func getTopic(obj interface{}) (string, bool) { record, ok := obj.(*goavro.Record) if !ok { return "UNKNOWN_RECORD_TYPE", false } topicObj, err := record.Get("topic") if err != nil { return "UNKNOWN_TOPIC_VAL", false } topicStr, ok := topicObj.(string) if !ok { return "UNKNOWN_TOPIC_TYPE", false } retur...
[ "func", "getTopic", "(", "obj", "interface", "{", "}", ")", "(", "string", ",", "bool", ")", "{", "record", ",", "ok", ":=", "obj", ".", "(", "*", "goavro", ".", "Record", ")", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "false", "\n...
// getTopic returns the requested topic from an Avro record.
[ "getTopic", "returns", "the", "requested", "topic", "from", "an", "Avro", "record", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/framework/framework.go#L292-L306
132,780
dcos/dcos-metrics
plugins/option.go
ExtraFlags
func ExtraFlags(extraFlags []cli.Flag) Option { return func(p *Plugin) error { for _, f := range extraFlags { p.App.Flags = append(p.App.Flags, f) } return nil } }
go
func ExtraFlags(extraFlags []cli.Flag) Option { return func(p *Plugin) error { for _, f := range extraFlags { p.App.Flags = append(p.App.Flags, f) } return nil } }
[ "func", "ExtraFlags", "(", "extraFlags", "[", "]", "cli", ".", "Flag", ")", "Option", "{", "return", "func", "(", "p", "*", "Plugin", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "extraFlags", "{", "p", ".", "App", ".", "Flags", "=", "...
// ExtraFlags sets additional cli.Flag's on the Plugin
[ "ExtraFlags", "sets", "additional", "cli", ".", "Flag", "s", "on", "the", "Plugin" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/option.go#L28-L35
132,781
dcos/dcos-metrics
plugins/option.go
PollingInterval
func PollingInterval(i int) Option { return func(p *Plugin) error { p.PollingInterval = i return nil } }
go
func PollingInterval(i int) Option { return func(p *Plugin) error { p.PollingInterval = i return nil } }
[ "func", "PollingInterval", "(", "i", "int", ")", "Option", "{", "return", "func", "(", "p", "*", "Plugin", ")", "error", "{", "p", ".", "PollingInterval", "=", "i", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// PollingInterval sets the polling interval to the supplied value.
[ "PollingInterval", "sets", "the", "polling", "interval", "to", "the", "supplied", "value", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/option.go#L38-L43
132,782
dcos/dcos-metrics
plugins/option.go
ConnectorFunc
func ConnectorFunc(connect func([]producers.MetricsMessage, *cli.Context) error) Option { return func(p *Plugin) error { p.ConnectorFunc = connect return nil } }
go
func ConnectorFunc(connect func([]producers.MetricsMessage, *cli.Context) error) Option { return func(p *Plugin) error { p.ConnectorFunc = connect return nil } }
[ "func", "ConnectorFunc", "(", "connect", "func", "(", "[", "]", "producers", ".", "MetricsMessage", ",", "*", "cli", ".", "Context", ")", "error", ")", "Option", "{", "return", "func", "(", "p", "*", "Plugin", ")", "error", "{", "p", ".", "ConnectorFun...
// ConnectorFunc is what the plugin framework will call once it has gathered // metrics. It is expected that this function will convert these messages to // a 3rd party format and then send the metrics to that service.
[ "ConnectorFunc", "is", "what", "the", "plugin", "framework", "will", "call", "once", "it", "has", "gathered", "metrics", ".", "It", "is", "expected", "that", "this", "function", "will", "convert", "these", "messages", "to", "a", "3rd", "party", "format", "an...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/option.go#L48-L53
132,783
dcos/dcos-metrics
plugins/option.go
Name
func Name(n string) Option { return func(p *Plugin) error { p.Name = n return nil } }
go
func Name(n string) Option { return func(p *Plugin) error { p.Name = n return nil } }
[ "func", "Name", "(", "n", "string", ")", "Option", "{", "return", "func", "(", "p", "*", "Plugin", ")", "error", "{", "p", ".", "Name", "=", "n", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Name allows the plugin to set a custom name for itself.
[ "Name", "allows", "the", "plugin", "to", "set", "a", "custom", "name", "for", "itself", "." ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/plugins/option.go#L56-L61
132,784
dcos/dcos-metrics
dcos-metrics.go
broadcast
func broadcast(msg producers.MetricsMessage, producers []chan<- producers.MetricsMessage) { for _, producer := range producers { producer <- msg } }
go
func broadcast(msg producers.MetricsMessage, producers []chan<- producers.MetricsMessage) { for _, producer := range producers { producer <- msg } }
[ "func", "broadcast", "(", "msg", "producers", ".", "MetricsMessage", ",", "producers", "[", "]", "chan", "<-", "producers", ".", "MetricsMessage", ")", "{", "for", "_", ",", "producer", ":=", "range", "producers", "{", "producer", "<-", "msg", "\n", "}", ...
// broadcast sends a MetricsMessage to a range of producer chans
[ "broadcast", "sends", "a", "MetricsMessage", "to", "a", "range", "of", "producer", "chans" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/dcos-metrics.go#L110-L114
132,785
dcos/dcos-metrics
collectors/node/cpu.go
calculatePcts
func calculatePcts(lastTimes cpu.TimesStat, curTimes cpu.TimesStat) cpu.TimesStat { totalDelta := curTimes.Total() - lastTimes.Total() return cpu.TimesStat{ User: formatPct(curTimes.User-lastTimes.User, totalDelta), System: formatPct(curTimes.System-lastTimes.System, totalDelta), Idle: formatPct(cu...
go
func calculatePcts(lastTimes cpu.TimesStat, curTimes cpu.TimesStat) cpu.TimesStat { totalDelta := curTimes.Total() - lastTimes.Total() return cpu.TimesStat{ User: formatPct(curTimes.User-lastTimes.User, totalDelta), System: formatPct(curTimes.System-lastTimes.System, totalDelta), Idle: formatPct(cu...
[ "func", "calculatePcts", "(", "lastTimes", "cpu", ".", "TimesStat", ",", "curTimes", "cpu", ".", "TimesStat", ")", "cpu", ".", "TimesStat", "{", "totalDelta", ":=", "curTimes", ".", "Total", "(", ")", "-", "lastTimes", ".", "Total", "(", ")", "\n", "retu...
// calculatePct returns the percent utilization for CPU states. 100.00 => 100.00%
[ "calculatePct", "returns", "the", "percent", "utilization", "for", "CPU", "states", ".", "100", ".", "00", "=", ">", "100", ".", "00%" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/node/cpu.go#L145-L160
132,786
dcos/dcos-metrics
collectors/mesos/agent/metrics.go
deviceStatsToDatapoints
func deviceStatsToDatapoints(stats []IODeviceStats, prefix string, baseTags map[string]string, ts string) []producers.Datapoint { var datapoints []producers.Datapoint for _, stat := range stats { dev := devTotal if stat.Device.Major > 0 { dev = fmt.Sprintf("%d:%d", stat.Device.Major, stat.Device.Minor) } ...
go
func deviceStatsToDatapoints(stats []IODeviceStats, prefix string, baseTags map[string]string, ts string) []producers.Datapoint { var datapoints []producers.Datapoint for _, stat := range stats { dev := devTotal if stat.Device.Major > 0 { dev = fmt.Sprintf("%d:%d", stat.Device.Major, stat.Device.Minor) } ...
[ "func", "deviceStatsToDatapoints", "(", "stats", "[", "]", "IODeviceStats", ",", "prefix", "string", ",", "baseTags", "map", "[", "string", "]", "string", ",", "ts", "string", ")", "[", "]", "producers", ".", "Datapoint", "{", "var", "datapoints", "[", "]"...
// deviceStatsToDatapoints flattens the nested blkio stats into a list of // clearly-named datapoints. All units are bytes, therefore all values are // integers. Datapoints from throttled devices are tagged with their origin.
[ "deviceStatsToDatapoints", "flattens", "the", "nested", "blkio", "stats", "into", "a", "list", "of", "clearly", "-", "named", "datapoints", ".", "All", "units", "are", "bytes", "therefore", "all", "values", "are", "integers", ".", "Datapoints", "from", "throttle...
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/metrics.go#L294-L316
132,787
dcos/dcos-metrics
collectors/mesos/agent/metrics.go
statValuesToDatapoints
func statValuesToDatapoints(vals []IOStatValue, prefix string, tags map[string]string, ts string) []producers.Datapoint { var datapoints []producers.Datapoint for _, s := range vals { op := strings.ToLower(s.Operation) d := producers.Datapoint{ Name: prefix + "." + op, Value: s.Value, Tags: ...
go
func statValuesToDatapoints(vals []IOStatValue, prefix string, tags map[string]string, ts string) []producers.Datapoint { var datapoints []producers.Datapoint for _, s := range vals { op := strings.ToLower(s.Operation) d := producers.Datapoint{ Name: prefix + "." + op, Value: s.Value, Tags: ...
[ "func", "statValuesToDatapoints", "(", "vals", "[", "]", "IOStatValue", ",", "prefix", "string", ",", "tags", "map", "[", "string", "]", "string", ",", "ts", "string", ")", "[", "]", "producers", ".", "Datapoint", "{", "var", "datapoints", "[", "]", "pro...
// statValuesToDatapoints converts a list of IO stats to a list of datapoints
[ "statValuesToDatapoints", "converts", "a", "list", "of", "IO", "stats", "to", "a", "list", "of", "datapoints" ]
d56806e5335baf0f12fec2278f9526d77ec0bb1e
https://github.com/dcos/dcos-metrics/blob/d56806e5335baf0f12fec2278f9526d77ec0bb1e/collectors/mesos/agent/metrics.go#L319-L333
132,788
jdxcode/netrc
netrc.go
Parse
func Parse(path string) (*Netrc, error) { file, err := read(path) if err != nil { return nil, err } netrc, err := parse(lex(file)) if err != nil { return nil, err } netrc.Path = path return netrc, nil }
go
func Parse(path string) (*Netrc, error) { file, err := read(path) if err != nil { return nil, err } netrc, err := parse(lex(file)) if err != nil { return nil, err } netrc.Path = path return netrc, nil }
[ "func", "Parse", "(", "path", "string", ")", "(", "*", "Netrc", ",", "error", ")", "{", "file", ",", "err", ":=", "read", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "netrc", ",", "err", ...
// Parse the netrc file at the given path // It returns a Netrc instance
[ "Parse", "the", "netrc", "file", "at", "the", "given", "path", "It", "returns", "a", "Netrc", "instance" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L35-L46
132,789
jdxcode/netrc
netrc.go
Machine
func (n *Netrc) Machine(name string) *Machine { for _, m := range n.machines { if m.Name == name { return m } } return nil }
go
func (n *Netrc) Machine(name string) *Machine { for _, m := range n.machines { if m.Name == name { return m } } return nil }
[ "func", "(", "n", "*", "Netrc", ")", "Machine", "(", "name", "string", ")", "*", "Machine", "{", "for", "_", ",", "m", ":=", "range", "n", ".", "machines", "{", "if", "m", ".", "Name", "==", "name", "{", "return", "m", "\n", "}", "\n", "}", "...
// Machine gets a machine by name
[ "Machine", "gets", "a", "machine", "by", "name" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L49-L56
132,790
jdxcode/netrc
netrc.go
AddMachine
func (n *Netrc) AddMachine(name, login, password string) { machine := n.Machine(name) if machine == nil { machine = &Machine{} n.machines = append(n.machines, machine) } machine.Name = name machine.tokens = []string{"machine ", name, "\n"} machine.Set("login", login) machine.Set("password", password) }
go
func (n *Netrc) AddMachine(name, login, password string) { machine := n.Machine(name) if machine == nil { machine = &Machine{} n.machines = append(n.machines, machine) } machine.Name = name machine.tokens = []string{"machine ", name, "\n"} machine.Set("login", login) machine.Set("password", password) }
[ "func", "(", "n", "*", "Netrc", ")", "AddMachine", "(", "name", ",", "login", ",", "password", "string", ")", "{", "machine", ":=", "n", ".", "Machine", "(", "name", ")", "\n", "if", "machine", "==", "nil", "{", "machine", "=", "&", "Machine", "{",...
// AddMachine adds a machine
[ "AddMachine", "adds", "a", "machine" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L59-L69
132,791
jdxcode/netrc
netrc.go
RemoveMachine
func (n *Netrc) RemoveMachine(name string) { for i, machine := range n.machines { if machine.Name == name { n.machines = append(n.machines[:i], n.machines[i+1:]...) // continue removing but start over since the indexes changed n.RemoveMachine(name) return } } }
go
func (n *Netrc) RemoveMachine(name string) { for i, machine := range n.machines { if machine.Name == name { n.machines = append(n.machines[:i], n.machines[i+1:]...) // continue removing but start over since the indexes changed n.RemoveMachine(name) return } } }
[ "func", "(", "n", "*", "Netrc", ")", "RemoveMachine", "(", "name", "string", ")", "{", "for", "i", ",", "machine", ":=", "range", "n", ".", "machines", "{", "if", "machine", ".", "Name", "==", "name", "{", "n", ".", "machines", "=", "append", "(", ...
// RemoveMachine remove a machine
[ "RemoveMachine", "remove", "a", "machine" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L72-L81
132,792
jdxcode/netrc
netrc.go
Render
func (n *Netrc) Render() string { var b bytes.Buffer for _, token := range n.tokens { b.WriteString(token) } for _, machine := range n.machines { for _, token := range machine.tokens { b.WriteString(token) } } return b.String() }
go
func (n *Netrc) Render() string { var b bytes.Buffer for _, token := range n.tokens { b.WriteString(token) } for _, machine := range n.machines { for _, token := range machine.tokens { b.WriteString(token) } } return b.String() }
[ "func", "(", "n", "*", "Netrc", ")", "Render", "(", ")", "string", "{", "var", "b", "bytes", ".", "Buffer", "\n", "for", "_", ",", "token", ":=", "range", "n", ".", "tokens", "{", "b", ".", "WriteString", "(", "token", ")", "\n", "}", "\n", "fo...
// Render out the netrc file to a string
[ "Render", "out", "the", "netrc", "file", "to", "a", "string" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L84-L95
132,793
jdxcode/netrc
netrc.go
Save
func (n *Netrc) Save() error { body := []byte(n.Render()) if filepath.Ext(n.Path) == ".gpg" { cmd := exec.Command("gpg", "-a", "--batch", "--default-recipient-self", "-e") stdin, err := cmd.StdinPipe() if err != nil { return err } stdin.Write(body) stdin.Close() cmd.Stderr = os.Stderr body, err = c...
go
func (n *Netrc) Save() error { body := []byte(n.Render()) if filepath.Ext(n.Path) == ".gpg" { cmd := exec.Command("gpg", "-a", "--batch", "--default-recipient-self", "-e") stdin, err := cmd.StdinPipe() if err != nil { return err } stdin.Write(body) stdin.Close() cmd.Stderr = os.Stderr body, err = c...
[ "func", "(", "n", "*", "Netrc", ")", "Save", "(", ")", "error", "{", "body", ":=", "[", "]", "byte", "(", "n", ".", "Render", "(", ")", ")", "\n", "if", "filepath", ".", "Ext", "(", "n", ".", "Path", ")", "==", "\"", "\"", "{", "cmd", ":=",...
// Save the file to disk
[ "Save", "the", "file", "to", "disk" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L98-L115
132,794
jdxcode/netrc
netrc.go
Get
func (m *Machine) Get(name string) string { i := 4 if m.IsDefault { i = 2 } for { if i+2 >= len(m.tokens) { return "" } if m.tokens[i] == name { return m.tokens[i+2] } i = i + 4 } }
go
func (m *Machine) Get(name string) string { i := 4 if m.IsDefault { i = 2 } for { if i+2 >= len(m.tokens) { return "" } if m.tokens[i] == name { return m.tokens[i+2] } i = i + 4 } }
[ "func", "(", "m", "*", "Machine", ")", "Get", "(", "name", "string", ")", "string", "{", "i", ":=", "4", "\n", "if", "m", ".", "IsDefault", "{", "i", "=", "2", "\n", "}", "\n", "for", "{", "if", "i", "+", "2", ">=", "len", "(", "m", ".", ...
// Get a property from a machine
[ "Get", "a", "property", "from", "a", "machine" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L208-L222
132,795
jdxcode/netrc
netrc.go
Set
func (m *Machine) Set(name, value string) { i := 4 if m.IsDefault { i = 2 } for i+2 < len(m.tokens) { if m.tokens[i] == name { m.tokens[i+2] = value return } i = i + 4 } m.tokens = append(m.tokens, " ", name, " ", value, "\n") }
go
func (m *Machine) Set(name, value string) { i := 4 if m.IsDefault { i = 2 } for i+2 < len(m.tokens) { if m.tokens[i] == name { m.tokens[i+2] = value return } i = i + 4 } m.tokens = append(m.tokens, " ", name, " ", value, "\n") }
[ "func", "(", "m", "*", "Machine", ")", "Set", "(", "name", ",", "value", "string", ")", "{", "i", ":=", "4", "\n", "if", "m", ".", "IsDefault", "{", "i", "=", "2", "\n", "}", "\n", "for", "i", "+", "2", "<", "len", "(", "m", ".", "tokens", ...
// Set a property on the machine
[ "Set", "a", "property", "on", "the", "machine" ]
b36f1c51d91d72f03887952fff1a6be7f700da0d
https://github.com/jdxcode/netrc/blob/b36f1c51d91d72f03887952fff1a6be7f700da0d/netrc.go#L225-L238
132,796
cloudfoundry/cfhttp
v2/client.go
WithStreamingDefaults
func WithStreamingDefaults() Option { return func(c *config) { c.tcpKeepAliveTimeout = 30 * time.Second c.disableKeepAlives = false c.requestTimeout = 0 } }
go
func WithStreamingDefaults() Option { return func(c *config) { c.tcpKeepAliveTimeout = 30 * time.Second c.disableKeepAlives = false c.requestTimeout = 0 } }
[ "func", "WithStreamingDefaults", "(", ")", "Option", "{", "return", "func", "(", "c", "*", "config", ")", "{", "c", ".", "tcpKeepAliveTimeout", "=", "30", "*", "time", ".", "Second", "\n", "c", ".", "disableKeepAlives", "=", "false", "\n", "c", ".", "r...
// WithStreamingDefaults modifies the HTTP client with defaults that are more // suitable for consuming server-sent events on persistent connections.
[ "WithStreamingDefaults", "modifies", "the", "HTTP", "client", "with", "defaults", "that", "are", "more", "suitable", "for", "consuming", "server", "-", "sent", "events", "on", "persistent", "connections", "." ]
1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71
https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L29-L35
132,797
cloudfoundry/cfhttp
v2/client.go
WithRequestTimeout
func WithRequestTimeout(t time.Duration) Option { return func(c *config) { c.requestTimeout = t } }
go
func WithRequestTimeout(t time.Duration) Option { return func(c *config) { c.requestTimeout = t } }
[ "func", "WithRequestTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "config", ")", "{", "c", ".", "requestTimeout", "=", "t", "\n", "}", "\n", "}" ]
// WithRequestTimeout sets the total time limit for requests made by this Client. // // A setting of 0 means no timeout.
[ "WithRequestTimeout", "sets", "the", "total", "time", "limit", "for", "requests", "made", "by", "this", "Client", ".", "A", "setting", "of", "0", "means", "no", "timeout", "." ]
1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71
https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L40-L44
132,798
cloudfoundry/cfhttp
v2/client.go
WithDialTimeout
func WithDialTimeout(t time.Duration) Option { return func(c *config) { c.dialTimeout = t } }
go
func WithDialTimeout(t time.Duration) Option { return func(c *config) { c.dialTimeout = t } }
[ "func", "WithDialTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "config", ")", "{", "c", ".", "dialTimeout", "=", "t", "\n", "}", "\n", "}" ]
// WithDialTimeout sets the time limit for connecting to the remote address. This // includes DNS resolution and retries on multiple IP addresses. // // A setting of 0 means no timeout.
[ "WithDialTimeout", "sets", "the", "time", "limit", "for", "connecting", "to", "the", "remote", "address", ".", "This", "includes", "DNS", "resolution", "and", "retries", "on", "multiple", "IP", "addresses", ".", "A", "setting", "of", "0", "means", "no", "tim...
1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71
https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L50-L54
132,799
cloudfoundry/cfhttp
v2/client.go
WithTCPKeepAliveTimeout
func WithTCPKeepAliveTimeout(t time.Duration) Option { return func(c *config) { c.tcpKeepAliveTimeout = t } }
go
func WithTCPKeepAliveTimeout(t time.Duration) Option { return func(c *config) { c.tcpKeepAliveTimeout = t } }
[ "func", "WithTCPKeepAliveTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "config", ")", "{", "c", ".", "tcpKeepAliveTimeout", "=", "t", "\n", "}", "\n", "}" ]
// WithTCPKeepAliveTimeout sets the keep-alive period for an active TCP // connection. // // A setting of 0 disables TCP keep-alives.
[ "WithTCPKeepAliveTimeout", "sets", "the", "keep", "-", "alive", "period", "for", "an", "active", "TCP", "connection", ".", "A", "setting", "of", "0", "disables", "TCP", "keep", "-", "alives", "." ]
1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71
https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L60-L64