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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,800 | likexian/whois-parser-go | utils.go | FixNameServers | func FixNameServers(nservers string) string {
servers := strings.Split(nservers, ",")
for k, v := range servers {
names := strings.Split(strings.TrimSpace(v), " ")
servers[k] = strings.Trim(names[0], ".")
}
return strings.Join(servers, ",")
} | go | func FixNameServers(nservers string) string {
servers := strings.Split(nservers, ",")
for k, v := range servers {
names := strings.Split(strings.TrimSpace(v), " ")
servers[k] = strings.Trim(names[0], ".")
}
return strings.Join(servers, ",")
} | [
"func",
"FixNameServers",
"(",
"nservers",
"string",
")",
"string",
"{",
"servers",
":=",
"strings",
".",
"Split",
"(",
"nservers",
",",
"\"",
"\"",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"servers",
"{",
"names",
":=",
"strings",
".",
"Split",... | // FixNameServers returns fixed name servers | [
"FixNameServers",
"returns",
"fixed",
"name",
"servers"
] | 0aa0498833b2f39c0a4f0ac0f6b5ddcf605fcf87 | https://github.com/likexian/whois-parser-go/blob/0aa0498833b2f39c0a4f0ac0f6b5ddcf605fcf87/utils.go#L116-L124 |
17,801 | russellcardullo/go-pingdom | pingdom/api_responses.go | UnmarshalJSON | func (c *CheckResponseType) UnmarshalJSON(b []byte) error {
var raw interface{}
err := json.Unmarshal(b, &raw)
if err != nil {
return err
}
switch v := raw.(type) {
case string:
c.Name = v
case map[string]interface{}:
if len(v) != 1 {
return fmt.Errorf("Check detailed response `check.type` contains mo... | go | func (c *CheckResponseType) UnmarshalJSON(b []byte) error {
var raw interface{}
err := json.Unmarshal(b, &raw)
if err != nil {
return err
}
switch v := raw.(type) {
case string:
c.Name = v
case map[string]interface{}:
if len(v) != 1 {
return fmt.Errorf("Check detailed response `check.type` contains mo... | [
"func",
"(",
"c",
"*",
"CheckResponseType",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"raw",
"interface",
"{",
"}",
"\n\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"raw",
")",
"\n",
"if",
"err",
... | // UnmarshalJSON converts a byte array into a CheckResponseType. | [
"UnmarshalJSON",
"converts",
"a",
"byte",
"array",
"into",
"a",
"CheckResponseType",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/api_responses.go#L178-L210 |
17,802 | russellcardullo/go-pingdom | pingdom/api_responses.go | Error | func (r *PingdomError) Error() string {
return fmt.Sprintf("%d %v: %v", r.StatusCode, r.StatusDesc, r.Message)
} | go | func (r *PingdomError) Error() string {
return fmt.Sprintf("%d %v: %v", r.StatusCode, r.StatusDesc, r.Message)
} | [
"func",
"(",
"r",
"*",
"PingdomError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"StatusCode",
",",
"r",
".",
"StatusDesc",
",",
"r",
".",
"Message",
")",
"\n",
"}"
] | // Return string representation of the PingdomError. | [
"Return",
"string",
"representation",
"of",
"the",
"PingdomError",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/api_responses.go#L233-L235 |
17,803 | russellcardullo/go-pingdom | pingdom/public_report.go | List | func (cs *PublicReportService) List() ([]PublicReportResponse, error) {
req, err := cs.client.NewRequest("GET", "/reports.public", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err !=... | go | func (cs *PublicReportService) List() ([]PublicReportResponse, error) {
req, err := cs.client.NewRequest("GET", "/reports.public", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err !=... | [
"func",
"(",
"cs",
"*",
"PublicReportService",
")",
"List",
"(",
")",
"(",
"[",
"]",
"PublicReportResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",... | // List return a list of reports from Pingdom. | [
"List",
"return",
"a",
"list",
"of",
"reports",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/public_report.go#L15-L38 |
17,804 | russellcardullo/go-pingdom | pingdom/public_report.go | PublishCheck | func (cs *PublicReportService) PublishCheck(id int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("PUT", "/reports.public/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &PingdomResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | go | func (cs *PublicReportService) PublishCheck(id int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("PUT", "/reports.public/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &PingdomResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | [
"func",
"(",
"cs",
"*",
"PublicReportService",
")",
"PublishCheck",
"(",
"id",
"int",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
... | // PublishCheck is used to activate a check on the public report. | [
"PublishCheck",
"is",
"used",
"to",
"activate",
"a",
"check",
"on",
"the",
"public",
"report",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/public_report.go#L41-L53 |
17,805 | russellcardullo/go-pingdom | pingdom/team_types.go | PutParams | func (ck *TeamData) PutParams() map[string]string {
t := map[string]string{
"name": ck.Name,
}
// Ignore if not defined
if ck.UserIds != "" {
t["userids"] = ck.UserIds
}
return t
} | go | func (ck *TeamData) PutParams() map[string]string {
t := map[string]string{
"name": ck.Name,
}
// Ignore if not defined
if ck.UserIds != "" {
t["userids"] = ck.UserIds
}
return t
} | [
"func",
"(",
"ck",
"*",
"TeamData",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"t",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"Name",
",",
"}",
"\n\n",
"// Ignore if not defined",
"if",
"... | // PutParams returns a map of parameters for an Team that can be sent along. | [
"PutParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"an",
"Team",
"that",
"can",
"be",
"sent",
"along",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team_types.go#L14-L25 |
17,806 | russellcardullo/go-pingdom | pingdom/probe.go | List | func (cs *ProbeService) List(params ...map[string]string) ([]ProbeResponse, error) {
param := map[string]string{}
if len(params) == 1 {
param = params[0]
}
req, err := cs.client.NewRequest("GET", "/probes", param)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
ret... | go | func (cs *ProbeService) List(params ...map[string]string) ([]ProbeResponse, error) {
param := map[string]string{}
if len(params) == 1 {
param = params[0]
}
req, err := cs.client.NewRequest("GET", "/probes", param)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
ret... | [
"func",
"(",
"cs",
"*",
"ProbeService",
")",
"List",
"(",
"params",
"...",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"ProbeResponse",
",",
"error",
")",
"{",
"param",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"if",
... | // List return a list of probes from Pingdom. | [
"List",
"return",
"a",
"list",
"of",
"probes",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/probe.go#L14-L41 |
17,807 | russellcardullo/go-pingdom | pingdom/user_types.go | ValidContact | func (c *Contact) ValidContact() error {
if c.Email == "" && c.Number == "" {
return fmt.Errorf("you must provide either an Email or a Phone Number to create a contact target")
}
if c.Number != "" && c.CountryCode == "" {
return fmt.Errorf("you must provide a Country Code if providing a phone number")
}
if c... | go | func (c *Contact) ValidContact() error {
if c.Email == "" && c.Number == "" {
return fmt.Errorf("you must provide either an Email or a Phone Number to create a contact target")
}
if c.Number != "" && c.CountryCode == "" {
return fmt.Errorf("you must provide a Country Code if providing a phone number")
}
if c... | [
"func",
"(",
"c",
"*",
"Contact",
")",
"ValidContact",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Email",
"==",
"\"",
"\"",
"&&",
"c",
".",
"Number",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // ValidContact determines whether a Contact contains valid fields. | [
"ValidContact",
"determines",
"whether",
"a",
"Contact",
"contains",
"valid",
"fields",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user_types.go#L49-L63 |
17,808 | russellcardullo/go-pingdom | pingdom/user_types.go | PostParams | func (u *User) PostParams() map[string]string {
m := map[string]string{
"name": u.Username,
}
return m
} | go | func (u *User) PostParams() map[string]string {
m := map[string]string{
"name": u.Username,
}
return m
} | [
"func",
"(",
"u",
"*",
"User",
")",
"PostParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"u",
".",
"Username",
",",
"}",
"\n\n",
"return",
"m",
"\n",
"}"
] | // PostParams returns a map of params that are sent with an HTTP POST request for a User. | [
"PostParams",
"returns",
"a",
"map",
"of",
"params",
"that",
"are",
"sent",
"with",
"an",
"HTTP",
"POST",
"request",
"for",
"a",
"User",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user_types.go#L66-L72 |
17,809 | russellcardullo/go-pingdom | pingdom/user_types.go | PostContactParams | func (c *Contact) PostContactParams() map[string]string {
m := map[string]string{}
// Ignore if not defined
if c.Email != "" {
m["email"] = c.Email
}
if c.Number != "" {
m["number"] = c.Number
}
if c.CountryCode != "" {
m["countrycode"] = c.CountryCode
}
if c.Severity != "" {
m["severitylevel"] = c... | go | func (c *Contact) PostContactParams() map[string]string {
m := map[string]string{}
// Ignore if not defined
if c.Email != "" {
m["email"] = c.Email
}
if c.Number != "" {
m["number"] = c.Number
}
if c.CountryCode != "" {
m["countrycode"] = c.CountryCode
}
if c.Severity != "" {
m["severitylevel"] = c... | [
"func",
"(",
"c",
"*",
"Contact",
")",
"PostContactParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n\n",
"// Ignore if not defined",
"if",
"c",
".",
"Email",
"!=",
"\"",
"\"",
"... | // PostContactParams returns a map of params that are sent with an HTTP POST request for a Contact. | [
"PostContactParams",
"returns",
"a",
"map",
"of",
"params",
"that",
"are",
"sent",
"with",
"an",
"HTTP",
"POST",
"request",
"for",
"a",
"Contact",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user_types.go#L75-L100 |
17,810 | russellcardullo/go-pingdom | pingdom/user_types.go | PutParams | func (u *User) PutParams() map[string]string {
m := map[string]string{
"name": u.Username,
}
if u.Primary != "" {
m["primary"] = u.Primary
}
if u.Paused != "" {
m["paused"] = u.Paused
}
return m
} | go | func (u *User) PutParams() map[string]string {
m := map[string]string{
"name": u.Username,
}
if u.Primary != "" {
m["primary"] = u.Primary
}
if u.Paused != "" {
m["paused"] = u.Paused
}
return m
} | [
"func",
"(",
"u",
"*",
"User",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"u",
".",
"Username",
",",
"}",
"\n\n",
"if",
"u",
".",
"Primary",
"!=",
... | // PutParams returns a map of params that are sent with an HTTP PUT request for a User. | [
"PutParams",
"returns",
"a",
"map",
"of",
"params",
"that",
"are",
"sent",
"with",
"an",
"HTTP",
"PUT",
"request",
"for",
"a",
"User",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user_types.go#L103-L117 |
17,811 | russellcardullo/go-pingdom | pingdom/maintenance.go | List | func (cs *MaintenanceService) List(params ...map[string]string) ([]MaintenanceResponse, error) {
param := map[string]string{}
if len(params) != 0 {
for _, m := range params {
for k, v := range m {
param[k] = v
}
}
}
req, err := cs.client.NewRequest("GET", "/maintenance", param)
if err != nil {
retu... | go | func (cs *MaintenanceService) List(params ...map[string]string) ([]MaintenanceResponse, error) {
param := map[string]string{}
if len(params) != 0 {
for _, m := range params {
for k, v := range m {
param[k] = v
}
}
}
req, err := cs.client.NewRequest("GET", "/maintenance", param)
if err != nil {
retu... | [
"func",
"(",
"cs",
"*",
"MaintenanceService",
")",
"List",
"(",
"params",
"...",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"MaintenanceResponse",
",",
"error",
")",
"{",
"param",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n... | // List returns the response holding a list of Maintenance windows. | [
"List",
"returns",
"the",
"response",
"holding",
"a",
"list",
"of",
"Maintenance",
"windows",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance.go#L28-L59 |
17,812 | russellcardullo/go-pingdom | pingdom/maintenance.go | Read | func (cs *MaintenanceService) Read(id int) (*MaintenanceResponse, error) {
req, err := cs.client.NewRequest("GET", "/maintenance/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
m := &maintenanceDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
return m.Mainte... | go | func (cs *MaintenanceService) Read(id int) (*MaintenanceResponse, error) {
req, err := cs.client.NewRequest("GET", "/maintenance/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
m := &maintenanceDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
return m.Mainte... | [
"func",
"(",
"cs",
"*",
"MaintenanceService",
")",
"Read",
"(",
"id",
"int",
")",
"(",
"*",
"MaintenanceResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"strc... | // Read returns a Maintenance for a given ID. | [
"Read",
"returns",
"a",
"Maintenance",
"for",
"a",
"given",
"ID",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance.go#L62-L75 |
17,813 | russellcardullo/go-pingdom | pingdom/maintenance.go | Create | func (cs *MaintenanceService) Create(maintenance Maintenance) (*MaintenanceResponse, error) {
if err := maintenance.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/maintenance", maintenance.PostParams())
if err != nil {
return nil, err
}
m := &maintenanceDetailsJSONRespons... | go | func (cs *MaintenanceService) Create(maintenance Maintenance) (*MaintenanceResponse, error) {
if err := maintenance.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/maintenance", maintenance.PostParams())
if err != nil {
return nil, err
}
m := &maintenanceDetailsJSONRespons... | [
"func",
"(",
"cs",
"*",
"MaintenanceService",
")",
"Create",
"(",
"maintenance",
"Maintenance",
")",
"(",
"*",
"MaintenanceResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"maintenance",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return"... | // Create creates a new Maintenance. | [
"Create",
"creates",
"a",
"new",
"Maintenance",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance.go#L78-L94 |
17,814 | russellcardullo/go-pingdom | pingdom/maintenance.go | Update | func (cs *MaintenanceService) Update(id int, maintenance Maintenance) (*PingdomResponse, error) {
if err := maintenance.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/maintenance/"+strconv.Itoa(id), maintenance.PutParams())
if err != nil {
return nil, err
}
m := &PingdomRe... | go | func (cs *MaintenanceService) Update(id int, maintenance Maintenance) (*PingdomResponse, error) {
if err := maintenance.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/maintenance/"+strconv.Itoa(id), maintenance.PutParams())
if err != nil {
return nil, err
}
m := &PingdomRe... | [
"func",
"(",
"cs",
"*",
"MaintenanceService",
")",
"Update",
"(",
"id",
"int",
",",
"maintenance",
"Maintenance",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"maintenance",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil... | // Update is used to update an existing Maintenance. Only the 'Description',
// and 'To' fields can be updated. | [
"Update",
"is",
"used",
"to",
"update",
"an",
"existing",
"Maintenance",
".",
"Only",
"the",
"Description",
"and",
"To",
"fields",
"can",
"be",
"updated",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance.go#L98-L114 |
17,815 | russellcardullo/go-pingdom | pingdom/maintenance.go | MultiDelete | func (cs *MaintenanceService) MultiDelete(maintenance MaintenanceDelete) (*PingdomResponse, error) {
if err := maintenance.ValidDelete(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("DELETE", "/maintenance/", maintenance.DeleteParams())
if err != nil {
return nil, err
}
m := &PingdomResp... | go | func (cs *MaintenanceService) MultiDelete(maintenance MaintenanceDelete) (*PingdomResponse, error) {
if err := maintenance.ValidDelete(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("DELETE", "/maintenance/", maintenance.DeleteParams())
if err != nil {
return nil, err
}
m := &PingdomResp... | [
"func",
"(",
"cs",
"*",
"MaintenanceService",
")",
"MultiDelete",
"(",
"maintenance",
"MaintenanceDelete",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"maintenance",
".",
"ValidDelete",
"(",
")",
";",
"err",
"!=",
"nil",
"{... | // MultiDelete will delete the Maintenance for the given ID. | [
"MultiDelete",
"will",
"delete",
"the",
"Maintenance",
"for",
"the",
"given",
"ID",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance.go#L117-L133 |
17,816 | russellcardullo/go-pingdom | pingdom/user.go | List | func (cs *UserService) List() ([]UsersResponse, error) {
req, err := cs.client.NewRequest("GET", "/users", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return nil, er... | go | func (cs *UserService) List() ([]UsersResponse, error) {
req, err := cs.client.NewRequest("GET", "/users", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return nil, er... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"List",
"(",
")",
"(",
"[",
"]",
"UsersResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if"... | // List returns a list of all users and their contact details. | [
"List",
"returns",
"a",
"list",
"of",
"all",
"users",
"and",
"their",
"contact",
"details",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L23-L47 |
17,817 | russellcardullo/go-pingdom | pingdom/user.go | Read | func (cs *UserService) Read(userID int) (*UsersResponse, error) {
users, err := cs.List()
if err != nil {
return nil, err
}
for i := range users {
if users[i].Id == userID {
return &users[i], nil
}
}
return nil, fmt.Errorf("UserId: " + strconv.Itoa(userID) + " not found")
} | go | func (cs *UserService) Read(userID int) (*UsersResponse, error) {
users, err := cs.List()
if err != nil {
return nil, err
}
for i := range users {
if users[i].Id == userID {
return &users[i], nil
}
}
return nil, fmt.Errorf("UserId: " + strconv.Itoa(userID) + " not found")
} | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"Read",
"(",
"userID",
"int",
")",
"(",
"*",
"UsersResponse",
",",
"error",
")",
"{",
"users",
",",
"err",
":=",
"cs",
".",
"List",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // Read return a user object from Pingdom. | [
"Read",
"return",
"a",
"user",
"object",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L50-L63 |
17,818 | russellcardullo/go-pingdom | pingdom/user.go | Create | func (cs *UserService) Create(user UserApi) (*UsersResponse, error) {
if err := user.ValidUser(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/users", user.PostParams())
if err != nil {
return nil, err
}
m := &createUserJSONResponse{}
_, err = cs.client.Do(req, m)
if err != ni... | go | func (cs *UserService) Create(user UserApi) (*UsersResponse, error) {
if err := user.ValidUser(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/users", user.PostParams())
if err != nil {
return nil, err
}
m := &createUserJSONResponse{}
_, err = cs.client.Do(req, m)
if err != ni... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"Create",
"(",
"user",
"UserApi",
")",
"(",
"*",
"UsersResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"user",
".",
"ValidUser",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // Create adds a new user. | [
"Create",
"adds",
"a",
"new",
"user",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L66-L82 |
17,819 | russellcardullo/go-pingdom | pingdom/user.go | CreateContact | func (cs *UserService) CreateContact(userID int, contact Contact) (*CreateUserContactResponse, error) {
if err := contact.ValidContact(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/users/"+strconv.Itoa(userID), contact.PostContactParams())
if err != nil {
return nil, err
}
m :... | go | func (cs *UserService) CreateContact(userID int, contact Contact) (*CreateUserContactResponse, error) {
if err := contact.ValidContact(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/users/"+strconv.Itoa(userID), contact.PostContactParams())
if err != nil {
return nil, err
}
m :... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"CreateContact",
"(",
"userID",
"int",
",",
"contact",
"Contact",
")",
"(",
"*",
"CreateUserContactResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"contact",
".",
"ValidContact",
"(",
")",
";",
"err",
"!=... | // CreateContact adds a contact target to an existing user. | [
"CreateContact",
"adds",
"a",
"contact",
"target",
"to",
"an",
"existing",
"user",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L85-L101 |
17,820 | russellcardullo/go-pingdom | pingdom/user.go | Update | func (cs *UserService) Update(id int, user UserApi) (*PingdomResponse, error) {
if err := user.ValidUser(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/users/"+strconv.Itoa(id), user.PutParams())
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(re... | go | func (cs *UserService) Update(id int, user UserApi) (*PingdomResponse, error) {
if err := user.ValidUser(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/users/"+strconv.Itoa(id), user.PutParams())
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(re... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"Update",
"(",
"id",
"int",
",",
"user",
"UserApi",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"user",
".",
"ValidUser",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",... | // Update a user's core properties not contact targets. | [
"Update",
"a",
"user",
"s",
"core",
"properties",
"not",
"contact",
"targets",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L104-L120 |
17,821 | russellcardullo/go-pingdom | pingdom/user.go | UpdateContact | func (cs *UserService) UpdateContact(userID int, contactID int, contact Contact) (*PingdomResponse, error) {
if err := contact.ValidContact(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/users/"+strconv.Itoa(userID)+"/"+strconv.Itoa(contactID), contact.PutContactParams())
if err != n... | go | func (cs *UserService) UpdateContact(userID int, contactID int, contact Contact) (*PingdomResponse, error) {
if err := contact.ValidContact(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/users/"+strconv.Itoa(userID)+"/"+strconv.Itoa(contactID), contact.PutContactParams())
if err != n... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"UpdateContact",
"(",
"userID",
"int",
",",
"contactID",
"int",
",",
"contact",
"Contact",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"contact",
".",
"ValidContact",
"(",
")",
... | // UpdateContact updates a contact by id, will change an email to sms or sms to email
// if you provide an id for the other. | [
"UpdateContact",
"updates",
"a",
"contact",
"by",
"id",
"will",
"change",
"an",
"email",
"to",
"sms",
"or",
"sms",
"to",
"email",
"if",
"you",
"provide",
"an",
"id",
"for",
"the",
"other",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L124-L140 |
17,822 | russellcardullo/go-pingdom | pingdom/user.go | DeleteContact | func (cs *UserService) DeleteContact(userID int, contactID int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/users/"+strconv.Itoa(userID)+"/"+strconv.Itoa(contactID), nil)
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
retur... | go | func (cs *UserService) DeleteContact(userID int, contactID int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/users/"+strconv.Itoa(userID)+"/"+strconv.Itoa(contactID), nil)
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
retur... | [
"func",
"(",
"cs",
"*",
"UserService",
")",
"DeleteContact",
"(",
"userID",
"int",
",",
"contactID",
"int",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",... | // DeleteContact deletes a contact target from a user, either an email or sms property of a user. | [
"DeleteContact",
"deletes",
"a",
"contact",
"target",
"from",
"a",
"user",
"either",
"an",
"email",
"or",
"sms",
"property",
"of",
"a",
"user",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/user.go#L158-L170 |
17,823 | russellcardullo/go-pingdom | pingdom/team.go | List | func (cs *TeamService) List() ([]TeamResponse, error) {
req, err := cs.client.NewRequest("GET", "/teams", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return nil, err
... | go | func (cs *TeamService) List() ([]TeamResponse, error) {
req, err := cs.client.NewRequest("GET", "/teams", nil)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return nil, err
... | [
"func",
"(",
"cs",
"*",
"TeamService",
")",
"List",
"(",
")",
"(",
"[",
"]",
"TeamResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",... | // List return a list of teams from Pingdom. | [
"List",
"return",
"a",
"list",
"of",
"teams",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team.go#L22-L45 |
17,824 | russellcardullo/go-pingdom | pingdom/team.go | Read | func (cs *TeamService) Read(id int) (*TeamResponse, error) {
req, err := cs.client.NewRequest("GET", "/teams/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &teamDetailsJSONResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t.Team, err
} | go | func (cs *TeamService) Read(id int) (*TeamResponse, error) {
req, err := cs.client.NewRequest("GET", "/teams/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &teamDetailsJSONResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t.Team, err
} | [
"func",
"(",
"cs",
"*",
"TeamService",
")",
"Read",
"(",
"id",
"int",
")",
"(",
"*",
"TeamResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"strconv",
".",
... | // Read return a team object from Pingdom. | [
"Read",
"return",
"a",
"team",
"object",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team.go#L48-L61 |
17,825 | russellcardullo/go-pingdom | pingdom/team.go | Create | func (cs *TeamService) Create(team Team) (*TeamResponse, error) {
if err := team.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/teams", team.PostParams())
if err != nil {
return nil, err
}
t := &TeamResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, ... | go | func (cs *TeamService) Create(team Team) (*TeamResponse, error) {
if err := team.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/teams", team.PostParams())
if err != nil {
return nil, err
}
t := &TeamResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, ... | [
"func",
"(",
"cs",
"*",
"TeamService",
")",
"Create",
"(",
"team",
"Team",
")",
"(",
"*",
"TeamResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"team",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // Create is used to create a new team. | [
"Create",
"is",
"used",
"to",
"create",
"a",
"new",
"team",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team.go#L64-L80 |
17,826 | russellcardullo/go-pingdom | pingdom/team.go | Update | func (cs *TeamService) Update(id int, team Team) (*TeamResponse, error) {
req, err := cs.client.NewRequest("PUT", "/teams/"+strconv.Itoa(id), team.PutParams())
if err != nil {
return nil, err
}
t := &TeamResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | go | func (cs *TeamService) Update(id int, team Team) (*TeamResponse, error) {
req, err := cs.client.NewRequest("PUT", "/teams/"+strconv.Itoa(id), team.PutParams())
if err != nil {
return nil, err
}
t := &TeamResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | [
"func",
"(",
"cs",
"*",
"TeamService",
")",
"Update",
"(",
"id",
"int",
",",
"team",
"Team",
")",
"(",
"*",
"TeamResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",... | // Update is used to update existing team. | [
"Update",
"is",
"used",
"to",
"update",
"existing",
"team",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team.go#L83-L95 |
17,827 | russellcardullo/go-pingdom | pingdom/team.go | Delete | func (cs *TeamService) Delete(id int) (*TeamDeleteResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/teams/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &TeamDeleteResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | go | func (cs *TeamService) Delete(id int) (*TeamDeleteResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/teams/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
t := &TeamDeleteResponse{}
_, err = cs.client.Do(req, t)
if err != nil {
return nil, err
}
return t, err
} | [
"func",
"(",
"cs",
"*",
"TeamService",
")",
"Delete",
"(",
"id",
"int",
")",
"(",
"*",
"TeamDeleteResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"strconv",
... | // Delete will delete the Team for the given ID. | [
"Delete",
"will",
"delete",
"the",
"Team",
"for",
"the",
"given",
"ID",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/team.go#L98-L110 |
17,828 | russellcardullo/go-pingdom | pingdom/maintenance_type.go | PutParams | func (ck *MaintenanceWindow) PutParams() map[string]string {
m := map[string]string{
"description": ck.Description,
"from": strconv.FormatInt(ck.From, 10),
"to": strconv.FormatInt(ck.To, 10),
}
// Ignore if not defined
if ck.RecurrenceType != "" {
m["recurrencetype"] = ck.RecurrenceType
}
... | go | func (ck *MaintenanceWindow) PutParams() map[string]string {
m := map[string]string{
"description": ck.Description,
"from": strconv.FormatInt(ck.From, 10),
"to": strconv.FormatInt(ck.To, 10),
}
// Ignore if not defined
if ck.RecurrenceType != "" {
m["recurrencetype"] = ck.RecurrenceType
}
... | [
"func",
"(",
"ck",
"*",
"MaintenanceWindow",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"Description",
",",
"\"",
"\"",
":",
"strconv",
".",... | // PutParams returns a map of parameters for an MaintenanceWindow that can be sent along. | [
"PutParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"an",
"MaintenanceWindow",
"that",
"can",
"be",
"sent",
"along",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance_type.go#L26-L55 |
17,829 | russellcardullo/go-pingdom | pingdom/maintenance_type.go | Valid | func (ck *MaintenanceWindow) Valid() error {
if ck.Description == "" {
return fmt.Errorf("Invalid value for `Description`. Must contain non-empty string")
}
if ck.From == 0 {
return fmt.Errorf("Invalid value for `From`. Must contain time")
}
if ck.To == 0 {
return fmt.Errorf("Invalid value for `To`. Mus... | go | func (ck *MaintenanceWindow) Valid() error {
if ck.Description == "" {
return fmt.Errorf("Invalid value for `Description`. Must contain non-empty string")
}
if ck.From == 0 {
return fmt.Errorf("Invalid value for `From`. Must contain time")
}
if ck.To == 0 {
return fmt.Errorf("Invalid value for `To`. Mus... | [
"func",
"(",
"ck",
"*",
"MaintenanceWindow",
")",
"Valid",
"(",
")",
"error",
"{",
"if",
"ck",
".",
"Description",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"ck",
".",
"From",
"==",
"0",... | // Valid determines whether the MaintenanceWindow contains valid fields. This can be
// used to guard against sending illegal values to the Pingdom API. | [
"Valid",
"determines",
"whether",
"the",
"MaintenanceWindow",
"contains",
"valid",
"fields",
".",
"This",
"can",
"be",
"used",
"to",
"guard",
"against",
"sending",
"illegal",
"values",
"to",
"the",
"Pingdom",
"API",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance_type.go#L74-L88 |
17,830 | russellcardullo/go-pingdom | pingdom/maintenance_type.go | DeleteParams | func (ck *MaintenanceWindowDelete) DeleteParams() map[string]string {
m := map[string]string{
"maintenanceids": ck.MaintenanceIDs,
}
return m
} | go | func (ck *MaintenanceWindowDelete) DeleteParams() map[string]string {
m := map[string]string{
"maintenanceids": ck.MaintenanceIDs,
}
return m
} | [
"func",
"(",
"ck",
"*",
"MaintenanceWindowDelete",
")",
"DeleteParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"MaintenanceIDs",
",",
"}",
"\n\n",
"return",
... | // DeleteParams returns a map of parameters for an MaintenanceWindow that can be sent along. | [
"DeleteParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"an",
"MaintenanceWindow",
"that",
"can",
"be",
"sent",
"along",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/maintenance_type.go#L91-L97 |
17,831 | russellcardullo/go-pingdom | pingdom/check.go | List | func (cs *CheckService) List(params ...map[string]string) ([]CheckResponse, error) {
param := map[string]string{}
if len(params) == 1 {
param = params[0]
}
req, err := cs.client.NewRequest("GET", "/checks", param)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
ret... | go | func (cs *CheckService) List(params ...map[string]string) ([]CheckResponse, error) {
param := map[string]string{}
if len(params) == 1 {
param = params[0]
}
req, err := cs.client.NewRequest("GET", "/checks", param)
if err != nil {
return nil, err
}
resp, err := cs.client.client.Do(req)
if err != nil {
ret... | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"List",
"(",
"params",
"...",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"CheckResponse",
",",
"error",
")",
"{",
"param",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"if",
... | // List returns a list of checks from Pingdom.
// This returns type CheckResponse rather than Check since the
// Pingdom API does not return a complete representation of a check. | [
"List",
"returns",
"a",
"list",
"of",
"checks",
"from",
"Pingdom",
".",
"This",
"returns",
"type",
"CheckResponse",
"rather",
"than",
"Check",
"since",
"the",
"Pingdom",
"API",
"does",
"not",
"return",
"a",
"complete",
"representation",
"of",
"a",
"check",
"... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L25-L51 |
17,832 | russellcardullo/go-pingdom | pingdom/check.go | Create | func (cs *CheckService) Create(check Check) (*CheckResponse, error) {
if err := check.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/checks", check.PostParams())
if err != nil {
return nil, err
}
m := &checkDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != n... | go | func (cs *CheckService) Create(check Check) (*CheckResponse, error) {
if err := check.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("POST", "/checks", check.PostParams())
if err != nil {
return nil, err
}
m := &checkDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != n... | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"Create",
"(",
"check",
"Check",
")",
"(",
"*",
"CheckResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"check",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"... | // Create a new check. This function will validate the given check param
// to ensure that it contains correct values before submitting the request
// Returns a CheckResponse object representing the response from Pingdom.
// Note that Pingdom does not return a full check object so in the returned
// object you should o... | [
"Create",
"a",
"new",
"check",
".",
"This",
"function",
"will",
"validate",
"the",
"given",
"check",
"param",
"to",
"ensure",
"that",
"it",
"contains",
"correct",
"values",
"before",
"submitting",
"the",
"request",
"Returns",
"a",
"CheckResponse",
"object",
"r... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L58-L74 |
17,833 | russellcardullo/go-pingdom | pingdom/check.go | Read | func (cs *CheckService) Read(id int) (*CheckResponse, error) {
req, err := cs.client.NewRequest("GET", "/checks/"+strconv.Itoa(id)+"?include_teams=true", nil)
if err != nil {
return nil, err
}
m := &checkDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
m.Check.TeamIds =... | go | func (cs *CheckService) Read(id int) (*CheckResponse, error) {
req, err := cs.client.NewRequest("GET", "/checks/"+strconv.Itoa(id)+"?include_teams=true", nil)
if err != nil {
return nil, err
}
m := &checkDetailsJSONResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
m.Check.TeamIds =... | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"Read",
"(",
"id",
"int",
")",
"(",
"*",
"CheckResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"strconv",
".",... | // ReadCheck returns detailed information about a pingdom check given its ID.
// This returns type CheckResponse rather than Check since the
// pingdom API does not return a complete representation of a check. | [
"ReadCheck",
"returns",
"detailed",
"information",
"about",
"a",
"pingdom",
"check",
"given",
"its",
"ID",
".",
"This",
"returns",
"type",
"CheckResponse",
"rather",
"than",
"Check",
"since",
"the",
"pingdom",
"API",
"does",
"not",
"return",
"a",
"complete",
"... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L79-L96 |
17,834 | russellcardullo/go-pingdom | pingdom/check.go | Update | func (cs *CheckService) Update(id int, check Check) (*PingdomResponse, error) {
if err := check.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/checks/"+strconv.Itoa(id), check.PutParams())
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req... | go | func (cs *CheckService) Update(id int, check Check) (*PingdomResponse, error) {
if err := check.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("PUT", "/checks/"+strconv.Itoa(id), check.PutParams())
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req... | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"Update",
"(",
"id",
"int",
",",
"check",
"Check",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"check",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // Update will update the check represented by the given ID with the values
// in the given check. You should submit the complete list of values in
// the given check parameter, not just those that have changed. | [
"Update",
"will",
"update",
"the",
"check",
"represented",
"by",
"the",
"given",
"ID",
"with",
"the",
"values",
"in",
"the",
"given",
"check",
".",
"You",
"should",
"submit",
"the",
"complete",
"list",
"of",
"values",
"in",
"the",
"given",
"check",
"parame... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L101-L117 |
17,835 | russellcardullo/go-pingdom | pingdom/check.go | Delete | func (cs *CheckService) Delete(id int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/checks/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
return m, err
} | go | func (cs *CheckService) Delete(id int) (*PingdomResponse, error) {
req, err := cs.client.NewRequest("DELETE", "/checks/"+strconv.Itoa(id), nil)
if err != nil {
return nil, err
}
m := &PingdomResponse{}
_, err = cs.client.Do(req, m)
if err != nil {
return nil, err
}
return m, err
} | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"Delete",
"(",
"id",
"int",
")",
"(",
"*",
"PingdomResponse",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"cs",
".",
"client",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"strconv",
... | // Delete will delete the check for the given ID. | [
"Delete",
"will",
"delete",
"the",
"check",
"for",
"the",
"given",
"ID",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L120-L132 |
17,836 | russellcardullo/go-pingdom | pingdom/check.go | SummaryPerformance | func (cs *CheckService) SummaryPerformance(request SummaryPerformanceRequest) (*SummaryPerformanceResponse, error) {
if err := request.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("GET", "/summary.performance/"+strconv.Itoa(request.Id), request.GetParams())
if err != nil {
return ni... | go | func (cs *CheckService) SummaryPerformance(request SummaryPerformanceRequest) (*SummaryPerformanceResponse, error) {
if err := request.Valid(); err != nil {
return nil, err
}
req, err := cs.client.NewRequest("GET", "/summary.performance/"+strconv.Itoa(request.Id), request.GetParams())
if err != nil {
return ni... | [
"func",
"(",
"cs",
"*",
"CheckService",
")",
"SummaryPerformance",
"(",
"request",
"SummaryPerformanceRequest",
")",
"(",
"*",
"SummaryPerformanceResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"request",
".",
"Valid",
"(",
")",
";",
"err",
"!=",
"nil"... | // SummaryPerformance returns a performance summary from Pingdom. | [
"SummaryPerformance",
"returns",
"a",
"performance",
"summary",
"from",
"Pingdom",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check.go#L135-L151 |
17,837 | russellcardullo/go-pingdom | pingdom/pingdom.go | NewClientWithConfig | func NewClientWithConfig(config ClientConfig) (*Client, error) {
var baseURL *url.URL
var err error
if config.BaseURL != "" {
baseURL, err = url.Parse(config.BaseURL)
} else {
baseURL, err = url.Parse(defaultBaseURL)
}
if err != nil {
return nil, err
}
c := &Client{
User: config.User,
Passwor... | go | func NewClientWithConfig(config ClientConfig) (*Client, error) {
var baseURL *url.URL
var err error
if config.BaseURL != "" {
baseURL, err = url.Parse(config.BaseURL)
} else {
baseURL, err = url.Parse(defaultBaseURL)
}
if err != nil {
return nil, err
}
c := &Client{
User: config.User,
Passwor... | [
"func",
"NewClientWithConfig",
"(",
"config",
"ClientConfig",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"var",
"baseURL",
"*",
"url",
".",
"URL",
"\n",
"var",
"err",
"error",
"\n",
"if",
"config",
".",
"BaseURL",
"!=",
"\"",
"\"",
"{",
"baseURL"... | // NewClientWithConfig returns a Pingdom client. | [
"NewClientWithConfig",
"returns",
"a",
"Pingdom",
"client",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/pingdom.go#L44-L77 |
17,838 | russellcardullo/go-pingdom | pingdom/pingdom.go | NewRequest | func (pc *Client) NewRequest(method string, rsc string, params map[string]string) (*http.Request, error) {
baseURL, err := url.Parse(pc.BaseURL.String() + rsc)
if err != nil {
return nil, err
}
if params != nil {
ps := url.Values{}
for k, v := range params {
ps.Set(k, v)
}
baseURL.RawQuery = ps.Encode... | go | func (pc *Client) NewRequest(method string, rsc string, params map[string]string) (*http.Request, error) {
baseURL, err := url.Parse(pc.BaseURL.String() + rsc)
if err != nil {
return nil, err
}
if params != nil {
ps := url.Values{}
for k, v := range params {
ps.Set(k, v)
}
baseURL.RawQuery = ps.Encode... | [
"func",
"(",
"pc",
"*",
"Client",
")",
"NewRequest",
"(",
"method",
"string",
",",
"rsc",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"baseURL",
",",
"err",
":=",
"url... | // NewRequest makes a new HTTP Request. The method param should be an HTTP method in
// all caps such as GET, POST, PUT, DELETE. The rsc param should correspond with
// a restful resource. Params can be passed in as a map of strings
// Usually users of the client can use one of the convenience methods such as
// Lis... | [
"NewRequest",
"makes",
"a",
"new",
"HTTP",
"Request",
".",
"The",
"method",
"param",
"should",
"be",
"an",
"HTTP",
"method",
"in",
"all",
"caps",
"such",
"as",
"GET",
"POST",
"PUT",
"DELETE",
".",
"The",
"rsc",
"param",
"should",
"correspond",
"with",
"a... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/pingdom.go#L110-L131 |
17,839 | russellcardullo/go-pingdom | pingdom/pingdom.go | Do | func (pc *Client) Do(req *http.Request, v interface{}) (*http.Response, error) {
resp, err := pc.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return resp, err
}
err = decodeResponse(resp, v)
return resp, err
} | go | func (pc *Client) Do(req *http.Request, v interface{}) (*http.Response, error) {
resp, err := pc.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := validateResponse(resp); err != nil {
return resp, err
}
err = decodeResponse(resp, v)
return resp, err
} | [
"func",
"(",
"pc",
"*",
"Client",
")",
"Do",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"pc",
".",
"client",
".",
"Do",
"... | // Do makes an HTTP request and will unmarshal the JSON response in to the
// passed in interface. If the HTTP response is outside of the 2xx range the
// response will be returned along with the error. | [
"Do",
"makes",
"an",
"HTTP",
"request",
"and",
"will",
"unmarshal",
"the",
"JSON",
"response",
"in",
"to",
"the",
"passed",
"in",
"interface",
".",
"If",
"the",
"HTTP",
"response",
"is",
"outside",
"of",
"the",
"2xx",
"range",
"the",
"response",
"will",
... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/pingdom.go#L136-L150 |
17,840 | russellcardullo/go-pingdom | pingdom/pingdom.go | validateResponse | func validateResponse(r *http.Response) error {
if c := r.StatusCode; 200 <= c && c <= 299 {
return nil
}
bodyBytes, _ := ioutil.ReadAll(r.Body)
bodyString := string(bodyBytes)
m := &errorJSONResponse{}
err := json.Unmarshal([]byte(bodyString), &m)
if err != nil {
return err
}
return m.Error
} | go | func validateResponse(r *http.Response) error {
if c := r.StatusCode; 200 <= c && c <= 299 {
return nil
}
bodyBytes, _ := ioutil.ReadAll(r.Body)
bodyString := string(bodyBytes)
m := &errorJSONResponse{}
err := json.Unmarshal([]byte(bodyString), &m)
if err != nil {
return err
}
return m.Error
} | [
"func",
"validateResponse",
"(",
"r",
"*",
"http",
".",
"Response",
")",
"error",
"{",
"if",
"c",
":=",
"r",
".",
"StatusCode",
";",
"200",
"<=",
"c",
"&&",
"c",
"<=",
"299",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"bodyBytes",
",",
"_",
":=",
"... | // Takes an HTTP response and determines whether it was successful.
// Returns nil if the HTTP status code is within the 2xx range. Returns
// an error otherwise. | [
"Takes",
"an",
"HTTP",
"response",
"and",
"determines",
"whether",
"it",
"was",
"successful",
".",
"Returns",
"nil",
"if",
"the",
"HTTP",
"status",
"code",
"is",
"within",
"the",
"2xx",
"range",
".",
"Returns",
"an",
"error",
"otherwise",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/pingdom.go#L166-L180 |
17,841 | russellcardullo/go-pingdom | pingdom/check_types.go | PutParams | func (ck *HttpCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenba... | go | func (ck *HttpCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenba... | [
"func",
"(",
"ck",
"*",
"HttpCheck",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"Name",
",",
"\"",
"\"",
":",
"ck",
".",
"Hostname",
","... | // PutParams returns a map of parameters for an HttpCheck that can be sent along
// with an HTTP PUT request. | [
"PutParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"an",
"HttpCheck",
"that",
"can",
"be",
"sent",
"along",
"with",
"an",
"HTTP",
"PUT",
"request",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L84-L139 |
17,842 | russellcardullo/go-pingdom | pingdom/check_types.go | PostParams | func (ck *HttpCheck) PostParams() map[string]string {
params := ck.PutParams()
for k, v := range params {
if v == "" {
delete(params, k)
}
}
params["type"] = "http"
return params
} | go | func (ck *HttpCheck) PostParams() map[string]string {
params := ck.PutParams()
for k, v := range params {
if v == "" {
delete(params, k)
}
}
params["type"] = "http"
return params
} | [
"func",
"(",
"ck",
"*",
"HttpCheck",
")",
"PostParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"params",
":=",
"ck",
".",
"PutParams",
"(",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"params",
"{",
"if",
"v",
"==",
"\"",
"\"",... | // PostParams returns a map of parameters for an HttpCheck that can be sent along
// with an HTTP POST request. They are the same than the Put params, but
// empty strings cleared out, to avoid Pingdom API reject the request. | [
"PostParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"an",
"HttpCheck",
"that",
"can",
"be",
"sent",
"along",
"with",
"an",
"HTTP",
"POST",
"request",
".",
"They",
"are",
"the",
"same",
"than",
"the",
"Put",
"params",
"but",
"empty",
"strings",
... | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L144-L155 |
17,843 | russellcardullo/go-pingdom | pingdom/check_types.go | Valid | func (ck *HttpCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("Invalid value for `Name`. Must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("Invalid value for `Hostname`. Must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15... | go | func (ck *HttpCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("Invalid value for `Name`. Must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("Invalid value for `Hostname`. Must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15... | [
"func",
"(",
"ck",
"*",
"HttpCheck",
")",
"Valid",
"(",
")",
"error",
"{",
"if",
"ck",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"ck",
".",
"Hostname",
"==",
"\"",
"\"",
... | // Valid determines whether the HttpCheck contains valid fields. This can be
// used to guard against sending illegal values to the Pingdom API. | [
"Valid",
"determines",
"whether",
"the",
"HttpCheck",
"contains",
"valid",
"fields",
".",
"This",
"can",
"be",
"used",
"to",
"guard",
"against",
"sending",
"illegal",
"values",
"to",
"the",
"Pingdom",
"API",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L159-L178 |
17,844 | russellcardullo/go-pingdom | pingdom/check_types.go | PutParams | func (ck *PingCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenba... | go | func (ck *PingCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenba... | [
"func",
"(",
"ck",
"*",
"PingCheck",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"Name",
",",
"\"",
"\"",
":",
"ck",
".",
"Hostname",
","... | // PutParams returns a map of parameters for a PingCheck that can be sent along
// with an HTTP PUT request. | [
"PutParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"a",
"PingCheck",
"that",
"can",
"be",
"sent",
"along",
"with",
"an",
"HTTP",
"PUT",
"request",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L182-L205 |
17,845 | russellcardullo/go-pingdom | pingdom/check_types.go | Valid | func (ck *PingCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("Invalid value for `Name`. Must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("Invalid value for `Hostname`. Must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15... | go | func (ck *PingCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("Invalid value for `Name`. Must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("Invalid value for `Hostname`. Must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15... | [
"func",
"(",
"ck",
"*",
"PingCheck",
")",
"Valid",
"(",
")",
"error",
"{",
"if",
"ck",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"ck",
".",
"Hostname",
"==",
"\"",
"\"",
... | // Valid determines whether the PingCheck contains valid fields. This can be
// used to guard against sending illegal values to the Pingdom API. | [
"Valid",
"determines",
"whether",
"the",
"PingCheck",
"contains",
"valid",
"fields",
".",
"This",
"can",
"be",
"used",
"to",
"guard",
"against",
"sending",
"illegal",
"values",
"to",
"the",
"Pingdom",
"API",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L224-L238 |
17,846 | russellcardullo/go-pingdom | pingdom/check_types.go | PutParams | func (ck *TCPCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenbac... | go | func (ck *TCPCheck) PutParams() map[string]string {
m := map[string]string{
"name": ck.Name,
"host": ck.Hostname,
"resolution": strconv.Itoa(ck.Resolution),
"paused": strconv.FormatBool(ck.Paused),
"notifyagainevery": strconv.Itoa(ck.NotifyAgainEvery),
"notifywhenbac... | [
"func",
"(",
"ck",
"*",
"TCPCheck",
")",
"PutParams",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"ck",
".",
"Name",
",",
"\"",
"\"",
":",
"ck",
".",
"Hostname",
",",... | // PutParams returns a map of parameters for a TCPCheck that can be sent along
// with an HTTP PUT request. | [
"PutParams",
"returns",
"a",
"map",
"of",
"parameters",
"for",
"a",
"TCPCheck",
"that",
"can",
"be",
"sent",
"along",
"with",
"an",
"HTTP",
"PUT",
"request",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L242-L271 |
17,847 | russellcardullo/go-pingdom | pingdom/check_types.go | Valid | func (ck *TCPCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("invalid value for `Name`, must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("invalid value for `Hostname`, must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15 &&... | go | func (ck *TCPCheck) Valid() error {
if ck.Name == "" {
return fmt.Errorf("invalid value for `Name`, must contain non-empty string")
}
if ck.Hostname == "" {
return fmt.Errorf("invalid value for `Hostname`, must contain non-empty string")
}
if ck.Resolution != 1 && ck.Resolution != 5 && ck.Resolution != 15 &&... | [
"func",
"(",
"ck",
"*",
"TCPCheck",
")",
"Valid",
"(",
")",
"error",
"{",
"if",
"ck",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"ck",
".",
"Hostname",
"==",
"\"",
"\"",
... | // Valid determines whether the TCPCheck contains valid fields. This can be
// used to guard against sending illegal values to the Pingdom API. | [
"Valid",
"determines",
"whether",
"the",
"TCPCheck",
"contains",
"valid",
"fields",
".",
"This",
"can",
"be",
"used",
"to",
"guard",
"against",
"sending",
"illegal",
"values",
"to",
"the",
"Pingdom",
"API",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L290-L309 |
17,848 | russellcardullo/go-pingdom | pingdom/check_types.go | Valid | func (csr SummaryPerformanceRequest) Valid() error {
if csr.Id == 0 {
return ErrMissingId
}
if csr.Resolution != "" && csr.Resolution != "hour" && csr.Resolution != "day" && csr.Resolution != "week" {
return ErrBadResolution
}
return nil
} | go | func (csr SummaryPerformanceRequest) Valid() error {
if csr.Id == 0 {
return ErrMissingId
}
if csr.Resolution != "" && csr.Resolution != "hour" && csr.Resolution != "day" && csr.Resolution != "week" {
return ErrBadResolution
}
return nil
} | [
"func",
"(",
"csr",
"SummaryPerformanceRequest",
")",
"Valid",
"(",
")",
"error",
"{",
"if",
"csr",
".",
"Id",
"==",
"0",
"{",
"return",
"ErrMissingId",
"\n",
"}",
"\n\n",
"if",
"csr",
".",
"Resolution",
"!=",
"\"",
"\"",
"&&",
"csr",
".",
"Resolution"... | // Valid determines whether a SummaryPerformanceRequest contains valid fields for the Pingdom API. | [
"Valid",
"determines",
"whether",
"a",
"SummaryPerformanceRequest",
"contains",
"valid",
"fields",
"for",
"the",
"Pingdom",
"API",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L324-L333 |
17,849 | russellcardullo/go-pingdom | pingdom/check_types.go | GetParams | func (csr SummaryPerformanceRequest) GetParams() (params map[string]string) {
params = make(map[string]string)
if csr.Resolution != "" {
params["resolution"] = csr.Resolution
}
if csr.IncludeUptime {
params["includeuptime"] = "true"
}
return
} | go | func (csr SummaryPerformanceRequest) GetParams() (params map[string]string) {
params = make(map[string]string)
if csr.Resolution != "" {
params["resolution"] = csr.Resolution
}
if csr.IncludeUptime {
params["includeuptime"] = "true"
}
return
} | [
"func",
"(",
"csr",
"SummaryPerformanceRequest",
")",
"GetParams",
"(",
")",
"(",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"params",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"if",
"csr",
".",
"Resolution",
"!=... | // GetParams returns a map of params for a Pingdom SummaryPerformanceRequest. | [
"GetParams",
"returns",
"a",
"map",
"of",
"params",
"for",
"a",
"Pingdom",
"SummaryPerformanceRequest",
"."
] | 017c8281f6d1a98515f8575e5152e02f545a5553 | https://github.com/russellcardullo/go-pingdom/blob/017c8281f6d1a98515f8575e5152e02f545a5553/pingdom/check_types.go#L336-L348 |
17,850 | multiformats/go-multiaddr-dns | resolve.go | matchDnsaddr | func matchDnsaddr(maddr ma.Multiaddr, trailer []ma.Multiaddr) bool {
parts := ma.Split(maddr)
if ma.Join(parts[len(parts)-len(trailer):]...).Equal(ma.Join(trailer...)) {
return true
}
return false
} | go | func matchDnsaddr(maddr ma.Multiaddr, trailer []ma.Multiaddr) bool {
parts := ma.Split(maddr)
if ma.Join(parts[len(parts)-len(trailer):]...).Equal(ma.Join(trailer...)) {
return true
}
return false
} | [
"func",
"matchDnsaddr",
"(",
"maddr",
"ma",
".",
"Multiaddr",
",",
"trailer",
"[",
"]",
"ma",
".",
"Multiaddr",
")",
"bool",
"{",
"parts",
":=",
"ma",
".",
"Split",
"(",
"maddr",
")",
"\n",
"if",
"ma",
".",
"Join",
"(",
"parts",
"[",
"len",
"(",
... | // XXX probably insecure | [
"XXX",
"probably",
"insecure"
] | 7d0de25ce05c9294aa44f320c03c7e85e11bbb0b | https://github.com/multiformats/go-multiaddr-dns/blob/7d0de25ce05c9294aa44f320c03c7e85e11bbb0b/resolve.go#L175-L181 |
17,851 | fd/go-nat | nat.go | DiscoverGateway | func DiscoverGateway() (NAT, error) {
select {
case nat := <-discoverUPNP_IG1():
return nat, nil
case nat := <-discoverUPNP_IG2():
return nat, nil
case nat := <-discoverUPNP_GenIGDev():
return nat, nil
case nat := <-discoverNATPMP():
return nat, nil
case <-time.After(10 * time.Second):
return nil, ErrNo... | go | func DiscoverGateway() (NAT, error) {
select {
case nat := <-discoverUPNP_IG1():
return nat, nil
case nat := <-discoverUPNP_IG2():
return nat, nil
case nat := <-discoverUPNP_GenIGDev():
return nat, nil
case nat := <-discoverNATPMP():
return nat, nil
case <-time.After(10 * time.Second):
return nil, ErrNo... | [
"func",
"DiscoverGateway",
"(",
")",
"(",
"NAT",
",",
"error",
")",
"{",
"select",
"{",
"case",
"nat",
":=",
"<-",
"discoverUPNP_IG1",
"(",
")",
":",
"return",
"nat",
",",
"nil",
"\n",
"case",
"nat",
":=",
"<-",
"discoverUPNP_IG2",
"(",
")",
":",
"re... | // DiscoverGateway attempts to find a gateway device. | [
"DiscoverGateway",
"attempts",
"to",
"find",
"a",
"gateway",
"device",
"."
] | 51722233f3430d9a1218f4a47ae2dfa3a762428b | https://github.com/fd/go-nat/blob/51722233f3430d9a1218f4a47ae2dfa3a762428b/nat.go#L38-L51 |
17,852 | argusdusty/Ferret | ferret.go | Insert | func (IS *InvertedSuffix) Insert(Word, Result string, Data interface{}) {
Query := IS.Converter(Word)
low, high := IS.Search(Query)
for k := low; k < high; k++ {
if IS.Results[IS.WordIndex[k]] == Word {
IS.Values[IS.WordIndex[k]] = Data
return
}
}
i := len(IS.Words)
IS.Words = append(IS.Words, Query)
L... | go | func (IS *InvertedSuffix) Insert(Word, Result string, Data interface{}) {
Query := IS.Converter(Word)
low, high := IS.Search(Query)
for k := low; k < high; k++ {
if IS.Results[IS.WordIndex[k]] == Word {
IS.Values[IS.WordIndex[k]] = Data
return
}
}
i := len(IS.Words)
IS.Words = append(IS.Words, Query)
L... | [
"func",
"(",
"IS",
"*",
"InvertedSuffix",
")",
"Insert",
"(",
"Word",
",",
"Result",
"string",
",",
"Data",
"interface",
"{",
"}",
")",
"{",
"Query",
":=",
"IS",
".",
"Converter",
"(",
"Word",
")",
"\n",
"low",
",",
"high",
":=",
"IS",
".",
"Search... | // Insert adds a word to the dictionary that IS was built on.
// This is pretty slow, because of linear-time insertion into an array,
// so stick to New when you can | [
"Insert",
"adds",
"a",
"word",
"to",
"the",
"dictionary",
"that",
"IS",
"was",
"built",
"on",
".",
"This",
"is",
"pretty",
"slow",
"because",
"of",
"linear",
"-",
"time",
"insertion",
"into",
"an",
"array",
"so",
"stick",
"to",
"New",
"when",
"you",
"c... | 14de0b6c044512adfb53edf8f2b1578a621280fa | https://github.com/argusdusty/Ferret/blob/14de0b6c044512adfb53edf8f2b1578a621280fa/ferret.go#L102-L125 |
17,853 | argusdusty/Ferret | errorcorrect.go | ErrorCorrect | func ErrorCorrect(Word []byte, AllowedBytes []byte) [][]byte {
results := make([][]byte, 0)
N := len(Word)
for i := 0; i < N; i++ {
t := Word[i]
// Remove Character
temp := make([]byte, N)
copy(temp, Word)
temp = append(temp[:i], temp[i+1:]...)
results = append(results, temp)
if i != 0 {
// Add Char... | go | func ErrorCorrect(Word []byte, AllowedBytes []byte) [][]byte {
results := make([][]byte, 0)
N := len(Word)
for i := 0; i < N; i++ {
t := Word[i]
// Remove Character
temp := make([]byte, N)
copy(temp, Word)
temp = append(temp[:i], temp[i+1:]...)
results = append(results, temp)
if i != 0 {
// Add Char... | [
"func",
"ErrorCorrect",
"(",
"Word",
"[",
"]",
"byte",
",",
"AllowedBytes",
"[",
"]",
"byte",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"results",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"0",
")",
"\n",
"N",
":=",
"len",
"(",
"Word",
... | // ErrorCorrect returns all byte-arrays which are Levenshtein distance of 1 away from Word
// within an allowed array of byte characters. | [
"ErrorCorrect",
"returns",
"all",
"byte",
"-",
"arrays",
"which",
"are",
"Levenshtein",
"distance",
"of",
"1",
"away",
"from",
"Word",
"within",
"an",
"allowed",
"array",
"of",
"byte",
"characters",
"."
] | 14de0b6c044512adfb53edf8f2b1578a621280fa | https://github.com/argusdusty/Ferret/blob/14de0b6c044512adfb53edf8f2b1578a621280fa/errorcorrect.go#L60-L96 |
17,854 | argusdusty/Ferret | unicodeconvert.go | ToASCII | func ToASCII(r rune) rune {
a, ok := UnicodeToASCII[r]
if ok {
return a
}
return r
} | go | func ToASCII(r rune) rune {
a, ok := UnicodeToASCII[r]
if ok {
return a
}
return r
} | [
"func",
"ToASCII",
"(",
"r",
"rune",
")",
"rune",
"{",
"a",
",",
"ok",
":=",
"UnicodeToASCII",
"[",
"r",
"]",
"\n",
"if",
"ok",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] | // ToASCII converts a single unicode rune to the ASCII equivalent using the UnicodeToASCII table | [
"ToASCII",
"converts",
"a",
"single",
"unicode",
"rune",
"to",
"the",
"ASCII",
"equivalent",
"using",
"the",
"UnicodeToASCII",
"table"
] | 14de0b6c044512adfb53edf8f2b1578a621280fa | https://github.com/argusdusty/Ferret/blob/14de0b6c044512adfb53edf8f2b1578a621280fa/unicodeconvert.go#L48-L54 |
17,855 | argusdusty/Ferret | unicodeconvert.go | UnicodeToLowerASCII | func UnicodeToLowerASCII(s string) []byte {
return []byte(strings.Map(func(r rune) rune { return unicode.ToLower(ToASCII(r)) }, s))
} | go | func UnicodeToLowerASCII(s string) []byte {
return []byte(strings.Map(func(r rune) rune { return unicode.ToLower(ToASCII(r)) }, s))
} | [
"func",
"UnicodeToLowerASCII",
"(",
"s",
"string",
")",
"[",
"]",
"byte",
"{",
"return",
"[",
"]",
"byte",
"(",
"strings",
".",
"Map",
"(",
"func",
"(",
"r",
"rune",
")",
"rune",
"{",
"return",
"unicode",
".",
"ToLower",
"(",
"ToASCII",
"(",
"r",
"... | // UnicodeToLowerASCII converts a unicode string to ASCII bytes using the UnicodeToASCII table | [
"UnicodeToLowerASCII",
"converts",
"a",
"unicode",
"string",
"to",
"ASCII",
"bytes",
"using",
"the",
"UnicodeToASCII",
"table"
] | 14de0b6c044512adfb53edf8f2b1578a621280fa | https://github.com/argusdusty/Ferret/blob/14de0b6c044512adfb53edf8f2b1578a621280fa/unicodeconvert.go#L57-L59 |
17,856 | libopenstorage/gossip | api.go | New | func New(
ip string,
selfNodeId types.NodeId,
genNumber uint64,
gossipIntervals types.GossipIntervals,
gossipVersion string,
clusterId string,
selfFailureDomain string,
) Gossiper {
g := new(proto.GossiperImpl)
g.Init(ip, selfNodeId, genNumber, gossipIntervals, gossipVersion, clusterId, selfFailureDomain)
ret... | go | func New(
ip string,
selfNodeId types.NodeId,
genNumber uint64,
gossipIntervals types.GossipIntervals,
gossipVersion string,
clusterId string,
selfFailureDomain string,
) Gossiper {
g := new(proto.GossiperImpl)
g.Init(ip, selfNodeId, genNumber, gossipIntervals, gossipVersion, clusterId, selfFailureDomain)
ret... | [
"func",
"New",
"(",
"ip",
"string",
",",
"selfNodeId",
"types",
".",
"NodeId",
",",
"genNumber",
"uint64",
",",
"gossipIntervals",
"types",
".",
"GossipIntervals",
",",
"gossipVersion",
"string",
",",
"clusterId",
"string",
",",
"selfFailureDomain",
"string",
",... | // New returns an initialized Gossip node
// which identifies itself with the given ip | [
"New",
"returns",
"an",
"initialized",
"Gossip",
"node",
"which",
"identifies",
"itself",
"with",
"the",
"given",
"ip"
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/api.go#L99-L111 |
17,857 | libopenstorage/gossip | proto/gossip_delegates.go | NodeMeta | func (gd *GossipDelegate) NodeMeta(limit int) []byte {
msg := gd.MetaInfo()
msgBytes, _ := gd.convertToBytes(msg)
return msgBytes
} | go | func (gd *GossipDelegate) NodeMeta(limit int) []byte {
msg := gd.MetaInfo()
msgBytes, _ := gd.convertToBytes(msg)
return msgBytes
} | [
"func",
"(",
"gd",
"*",
"GossipDelegate",
")",
"NodeMeta",
"(",
"limit",
"int",
")",
"[",
"]",
"byte",
"{",
"msg",
":=",
"gd",
".",
"MetaInfo",
"(",
")",
"\n",
"msgBytes",
",",
"_",
":=",
"gd",
".",
"convertToBytes",
"(",
"msg",
")",
"\n",
"return"... | // NodeMeta is used to retrieve meta-data about the current node
// when broadcasting an alive message. It's length is limited to
// the given byte size. This metadata is available in the Node structure. | [
"NodeMeta",
"is",
"used",
"to",
"retrieve",
"meta",
"-",
"data",
"about",
"the",
"current",
"node",
"when",
"broadcasting",
"an",
"alive",
"message",
".",
"It",
"s",
"length",
"is",
"limited",
"to",
"the",
"given",
"byte",
"size",
".",
"This",
"metadata",
... | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/gossip_delegates.go#L131-L135 |
17,858 | libopenstorage/gossip | proto/gossip_delegates.go | NotifyJoin | func (gd *GossipDelegate) NotifyJoin(node *memberlist.Node) {
// Ignore self NotifyJoin
nodeName := gd.parseMemberlistNodeName(node.Name)
if nodeName == gd.nodeId {
return
}
gd.updateGossipTs()
// NotifyAlive should remove a node from memberlist if the
// gossip version mismatches.
// Nevertheless we are do... | go | func (gd *GossipDelegate) NotifyJoin(node *memberlist.Node) {
// Ignore self NotifyJoin
nodeName := gd.parseMemberlistNodeName(node.Name)
if nodeName == gd.nodeId {
return
}
gd.updateGossipTs()
// NotifyAlive should remove a node from memberlist if the
// gossip version mismatches.
// Nevertheless we are do... | [
"func",
"(",
"gd",
"*",
"GossipDelegate",
")",
"NotifyJoin",
"(",
"node",
"*",
"memberlist",
".",
"Node",
")",
"{",
"// Ignore self NotifyJoin",
"nodeName",
":=",
"gd",
".",
"parseMemberlistNodeName",
"(",
"node",
".",
"Name",
")",
"\n",
"if",
"nodeName",
"=... | // NotifyJoin is invoked when a node is detected to have joined.
// The Node argument must not be modified. | [
"NotifyJoin",
"is",
"invoked",
"when",
"a",
"node",
"is",
"detected",
"to",
"have",
"joined",
".",
"The",
"Node",
"argument",
"must",
"not",
"be",
"modified",
"."
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/gossip_delegates.go#L206-L221 |
17,859 | libopenstorage/gossip | proto/gossip_delegates.go | NotifyLeave | func (gd *GossipDelegate) NotifyLeave(node *memberlist.Node) {
nodeName := gd.parseMemberlistNodeName(node.Name)
if nodeName == gd.nodeId {
gd.triggerStateEvent(types.SELF_LEAVE)
} else {
if gd.quorumProvider.Type() == types.QUORUM_PROVIDER_FAILURE_DOMAINS {
go func() {
isSuspect := gd.isClusterDomainSusp... | go | func (gd *GossipDelegate) NotifyLeave(node *memberlist.Node) {
nodeName := gd.parseMemberlistNodeName(node.Name)
if nodeName == gd.nodeId {
gd.triggerStateEvent(types.SELF_LEAVE)
} else {
if gd.quorumProvider.Type() == types.QUORUM_PROVIDER_FAILURE_DOMAINS {
go func() {
isSuspect := gd.isClusterDomainSusp... | [
"func",
"(",
"gd",
"*",
"GossipDelegate",
")",
"NotifyLeave",
"(",
"node",
"*",
"memberlist",
".",
"Node",
")",
"{",
"nodeName",
":=",
"gd",
".",
"parseMemberlistNodeName",
"(",
"node",
".",
"Name",
")",
"\n",
"if",
"nodeName",
"==",
"gd",
".",
"nodeId",... | // NotifyLeave is invoked when a node is detected to have left.
// The Node argument must not be modified. | [
"NotifyLeave",
"is",
"invoked",
"when",
"a",
"node",
"is",
"detected",
"to",
"have",
"left",
".",
"The",
"Node",
"argument",
"must",
"not",
"be",
"modified",
"."
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/gossip_delegates.go#L225-L246 |
17,860 | libopenstorage/gossip | proto/gossip_delegates.go | isClusterDomainSuspectDown | func (gd *GossipDelegate) isClusterDomainSuspectDown(nodeId types.NodeId) bool {
nodeInfo, err := gd.GetLocalNodeInfo(nodeId)
if err != nil {
// Node not found in our map
// No need of putting it as a suspect
// We will mark it as Offline immediately
return false
}
if !gd.quorumProvider.IsDomainActive(nodeI... | go | func (gd *GossipDelegate) isClusterDomainSuspectDown(nodeId types.NodeId) bool {
nodeInfo, err := gd.GetLocalNodeInfo(nodeId)
if err != nil {
// Node not found in our map
// No need of putting it as a suspect
// We will mark it as Offline immediately
return false
}
if !gd.quorumProvider.IsDomainActive(nodeI... | [
"func",
"(",
"gd",
"*",
"GossipDelegate",
")",
"isClusterDomainSuspectDown",
"(",
"nodeId",
"types",
".",
"NodeId",
")",
"bool",
"{",
"nodeInfo",
",",
"err",
":=",
"gd",
".",
"GetLocalNodeInfo",
"(",
"nodeId",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"/... | // isClusterDomainSuspectDown returns truewhen a peer node should be put in suspected offline state
// For the given nodeId, it finds out all its peers from
// the same cluster domain. If even one ping to such peer node succeeds it assumes that
// only the suspected node is down and the whole cluster domain is still op... | [
"isClusterDomainSuspectDown",
"returns",
"truewhen",
"a",
"peer",
"node",
"should",
"be",
"put",
"in",
"suspected",
"offline",
"state",
"For",
"the",
"given",
"nodeId",
"it",
"finds",
"out",
"all",
"its",
"peers",
"from",
"the",
"same",
"cluster",
"domain",
".... | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/gossip_delegates.go#L429-L472 |
17,861 | libopenstorage/gossip | pkg/probation/probation.go | NewProbationManager | func NewProbationManager(
name string,
probationTimeout time.Duration,
pcf CallbackFn,
) Probation {
if sched.Instance() == nil {
sched.Init(1 * time.Second)
}
p := &probation{
name: name,
probationTimeout: probationTimeout,
pcf: pcf,
probationTasks: make(map[string]sched.Task... | go | func NewProbationManager(
name string,
probationTimeout time.Duration,
pcf CallbackFn,
) Probation {
if sched.Instance() == nil {
sched.Init(1 * time.Second)
}
p := &probation{
name: name,
probationTimeout: probationTimeout,
pcf: pcf,
probationTasks: make(map[string]sched.Task... | [
"func",
"NewProbationManager",
"(",
"name",
"string",
",",
"probationTimeout",
"time",
".",
"Duration",
",",
"pcf",
"CallbackFn",
",",
")",
"Probation",
"{",
"if",
"sched",
".",
"Instance",
"(",
")",
"==",
"nil",
"{",
"sched",
".",
"Init",
"(",
"1",
"*",... | // NewProbationManager returns the default implementation of Probation interface
// It takes in a name to be associated with this probation manager and a
// ProbationCallbackFn | [
"NewProbationManager",
"returns",
"the",
"default",
"implementation",
"of",
"Probation",
"interface",
"It",
"takes",
"in",
"a",
"name",
"to",
"be",
"associated",
"with",
"this",
"probation",
"manager",
"and",
"a",
"ProbationCallbackFn"
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/pkg/probation/probation.go#L43-L59 |
17,862 | libopenstorage/gossip | proto/state/quorum_failure_domains.go | isDomainActive | func (f *failureDomainsQuorum) isDomainActive(ipDomain string) bool {
isActive, _ := f.activeMap[ipDomain]
if isActive == types.CLUSTER_DOMAIN_STATE_ACTIVE {
return true
}
return false
} | go | func (f *failureDomainsQuorum) isDomainActive(ipDomain string) bool {
isActive, _ := f.activeMap[ipDomain]
if isActive == types.CLUSTER_DOMAIN_STATE_ACTIVE {
return true
}
return false
} | [
"func",
"(",
"f",
"*",
"failureDomainsQuorum",
")",
"isDomainActive",
"(",
"ipDomain",
"string",
")",
"bool",
"{",
"isActive",
",",
"_",
":=",
"f",
".",
"activeMap",
"[",
"ipDomain",
"]",
"\n",
"if",
"isActive",
"==",
"types",
".",
"CLUSTER_DOMAIN_STATE_ACTI... | // isDomainActive returns true if the input failure domains is a part of
// of an active domain list | [
"isDomainActive",
"returns",
"true",
"if",
"the",
"input",
"failure",
"domains",
"is",
"a",
"part",
"of",
"of",
"an",
"active",
"domain",
"list"
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/state/quorum_failure_domains.go#L65-L71 |
17,863 | libopenstorage/gossip | proto/state/quorum.go | NewQuorumProvider | func NewQuorumProvider(
selfId types.NodeId,
provider types.QuorumProvider,
) Quorum {
if provider == types.QUORUM_PROVIDER_DEFAULT {
return &defaultQuorum{
selfId: selfId,
}
}
return &failureDomainsQuorum{
selfId: selfId,
}
} | go | func NewQuorumProvider(
selfId types.NodeId,
provider types.QuorumProvider,
) Quorum {
if provider == types.QUORUM_PROVIDER_DEFAULT {
return &defaultQuorum{
selfId: selfId,
}
}
return &failureDomainsQuorum{
selfId: selfId,
}
} | [
"func",
"NewQuorumProvider",
"(",
"selfId",
"types",
".",
"NodeId",
",",
"provider",
"types",
".",
"QuorumProvider",
",",
")",
"Quorum",
"{",
"if",
"provider",
"==",
"types",
".",
"QUORUM_PROVIDER_DEFAULT",
"{",
"return",
"&",
"defaultQuorum",
"{",
"selfId",
"... | // NewQuorumProvider returns tan implementation of Quorum interface based on
// the input type | [
"NewQuorumProvider",
"returns",
"tan",
"implementation",
"of",
"Quorum",
"interface",
"based",
"on",
"the",
"input",
"type"
] | 618a8c84303a0bd7cd56637c579b216294301586 | https://github.com/libopenstorage/gossip/blob/618a8c84303a0bd7cd56637c579b216294301586/proto/state/quorum.go#L27-L39 |
17,864 | hhkbp2/go-logging | handler_timed_rotating_file.go | computeRolloverTime | func (self *TimedRotatingFileHandler) computeRolloverTime(
currentTime time.Time) time.Time {
result := currentTime.Add(self.interval)
// If we are rolling over at midnight or weekly, then the interval is
// already known. What we need to figure out is WHEN the next interval is.
// In other words, if you are rol... | go | func (self *TimedRotatingFileHandler) computeRolloverTime(
currentTime time.Time) time.Time {
result := currentTime.Add(self.interval)
// If we are rolling over at midnight or weekly, then the interval is
// already known. What we need to figure out is WHEN the next interval is.
// In other words, if you are rol... | [
"func",
"(",
"self",
"*",
"TimedRotatingFileHandler",
")",
"computeRolloverTime",
"(",
"currentTime",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"result",
":=",
"currentTime",
".",
"Add",
"(",
"self",
".",
"interval",
")",
"\n",
"// If we are rolling ... | // Work out the rollover time based on the specified time. | [
"Work",
"out",
"the",
"rollover",
"time",
"based",
"on",
"the",
"specified",
"time",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_timed_rotating_file.go#L125-L180 |
17,865 | hhkbp2/go-logging | handler_timed_rotating_file.go | ShouldRollover | func (self *TimedRotatingFileHandler) ShouldRollover(
record *LogRecord) (bool, string) {
overTime := time.Now().After(self.rolloverTime)
return overTime, self.Format(record)
} | go | func (self *TimedRotatingFileHandler) ShouldRollover(
record *LogRecord) (bool, string) {
overTime := time.Now().After(self.rolloverTime)
return overTime, self.Format(record)
} | [
"func",
"(",
"self",
"*",
"TimedRotatingFileHandler",
")",
"ShouldRollover",
"(",
"record",
"*",
"LogRecord",
")",
"(",
"bool",
",",
"string",
")",
"{",
"overTime",
":=",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"self",
".",
"rolloverTime",
")",
... | // Determine if rollover should occur. | [
"Determine",
"if",
"rollover",
"should",
"occur",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_timed_rotating_file.go#L183-L188 |
17,866 | hhkbp2/go-logging | handler_timed_rotating_file.go | getFilesToDelete | func (self *TimedRotatingFileHandler) getFilesToDelete() ([]string, error) {
dirName, baseName := filepath.Split(self.GetFilePath())
fileInfos, err := ioutil.ReadDir(dirName)
if err != nil {
return nil, err
}
prefix := baseName + "."
pattern, err := regexp.Compile(self.extMatch)
if err != nil {
return nil, e... | go | func (self *TimedRotatingFileHandler) getFilesToDelete() ([]string, error) {
dirName, baseName := filepath.Split(self.GetFilePath())
fileInfos, err := ioutil.ReadDir(dirName)
if err != nil {
return nil, err
}
prefix := baseName + "."
pattern, err := regexp.Compile(self.extMatch)
if err != nil {
return nil, e... | [
"func",
"(",
"self",
"*",
"TimedRotatingFileHandler",
")",
"getFilesToDelete",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"dirName",
",",
"baseName",
":=",
"filepath",
".",
"Split",
"(",
"self",
".",
"GetFilePath",
"(",
")",
")",
"\n",
... | // Determine the files to delete when rolling over. | [
"Determine",
"the",
"files",
"to",
"delete",
"when",
"rolling",
"over",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_timed_rotating_file.go#L191-L222 |
17,867 | hhkbp2/go-logging | handler_syslog.go | Emit | func (self *SyslogHandler) Emit(record *LogRecord) error {
message := self.BaseHandler.Format(record)
var err error
switch record.Level {
case LevelFatal:
err = self.writer.Crit(message)
case LevelError:
err = self.writer.Err(message)
case LevelWarn:
err = self.writer.Warning(message)
case LevelInfo:
err... | go | func (self *SyslogHandler) Emit(record *LogRecord) error {
message := self.BaseHandler.Format(record)
var err error
switch record.Level {
case LevelFatal:
err = self.writer.Crit(message)
case LevelError:
err = self.writer.Err(message)
case LevelWarn:
err = self.writer.Warning(message)
case LevelInfo:
err... | [
"func",
"(",
"self",
"*",
"SyslogHandler",
")",
"Emit",
"(",
"record",
"*",
"LogRecord",
")",
"error",
"{",
"message",
":=",
"self",
".",
"BaseHandler",
".",
"Format",
"(",
"record",
")",
"\n",
"var",
"err",
"error",
"\n",
"switch",
"record",
".",
"Lev... | // Emit a record.
// The record is formatted, and then sent to the syslog server
// in specified log level. | [
"Emit",
"a",
"record",
".",
"The",
"record",
"is",
"formatted",
"and",
"then",
"sent",
"to",
"the",
"syslog",
"server",
"in",
"specified",
"log",
"level",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_syslog.go#L65-L83 |
17,868 | hhkbp2/go-logging | handler_rotating_file.go | NewBaseRotatingHandler | func NewBaseRotatingHandler(
filepath string, mode, bufferSize int) (*BaseRotatingHandler, error) {
fileHandler, err := NewFileHandler(filepath, mode, bufferSize)
if err != nil {
return nil, err
}
object := &BaseRotatingHandler{
FileHandler: fileHandler,
}
Closer.RemoveHandler(object.FileHandler)
Closer.Ad... | go | func NewBaseRotatingHandler(
filepath string, mode, bufferSize int) (*BaseRotatingHandler, error) {
fileHandler, err := NewFileHandler(filepath, mode, bufferSize)
if err != nil {
return nil, err
}
object := &BaseRotatingHandler{
FileHandler: fileHandler,
}
Closer.RemoveHandler(object.FileHandler)
Closer.Ad... | [
"func",
"NewBaseRotatingHandler",
"(",
"filepath",
"string",
",",
"mode",
",",
"bufferSize",
"int",
")",
"(",
"*",
"BaseRotatingHandler",
",",
"error",
")",
"{",
"fileHandler",
",",
"err",
":=",
"NewFileHandler",
"(",
"filepath",
",",
"mode",
",",
"bufferSize"... | // Initialize base rotating handler with specified filename for stream logging. | [
"Initialize",
"base",
"rotating",
"handler",
"with",
"specified",
"filename",
"for",
"stream",
"logging",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_rotating_file.go#L37-L50 |
17,869 | hhkbp2/go-logging | handler_rotating_file.go | RolloverEmit | func (self *BaseRotatingHandler) RolloverEmit(
handler RotatingHandler, record *LogRecord) error {
// We don't use the implementation of StreamHandler.Emit2() but directly
// write to stream here in order to avoid calling self.Format() twice
// for performance optimization.
doRollover, message := handler.ShouldRo... | go | func (self *BaseRotatingHandler) RolloverEmit(
handler RotatingHandler, record *LogRecord) error {
// We don't use the implementation of StreamHandler.Emit2() but directly
// write to stream here in order to avoid calling self.Format() twice
// for performance optimization.
doRollover, message := handler.ShouldRo... | [
"func",
"(",
"self",
"*",
"BaseRotatingHandler",
")",
"RolloverEmit",
"(",
"handler",
"RotatingHandler",
",",
"record",
"*",
"LogRecord",
")",
"error",
"{",
"// We don't use the implementation of StreamHandler.Emit2() but directly",
"// write to stream here in order to avoid call... | // A helper function for subclass to emit record. | [
"A",
"helper",
"function",
"for",
"subclass",
"to",
"emit",
"record",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_rotating_file.go#L53-L74 |
17,870 | hhkbp2/go-logging | handler_rotating_file.go | ShouldRollover | func (self *RotatingFileHandler) ShouldRollover(
record *LogRecord) (bool, string) {
message := self.Format(record)
if self.maxBytes > 0 {
offset, err := self.GetStream().Tell()
if err != nil {
// don't trigger rollover action if we lose offset info
return false, message
}
if (uint64(offset) + uint64(... | go | func (self *RotatingFileHandler) ShouldRollover(
record *LogRecord) (bool, string) {
message := self.Format(record)
if self.maxBytes > 0 {
offset, err := self.GetStream().Tell()
if err != nil {
// don't trigger rollover action if we lose offset info
return false, message
}
if (uint64(offset) + uint64(... | [
"func",
"(",
"self",
"*",
"RotatingFileHandler",
")",
"ShouldRollover",
"(",
"record",
"*",
"LogRecord",
")",
"(",
"bool",
",",
"string",
")",
"{",
"message",
":=",
"self",
".",
"Format",
"(",
"record",
")",
"\n",
"if",
"self",
".",
"maxBytes",
">",
"0... | // Determine if rollover should occur.
// Basically, see if the supplied record would cause the file to exceed the
// size limit we have. | [
"Determine",
"if",
"rollover",
"should",
"occur",
".",
"Basically",
"see",
"if",
"the",
"supplied",
"record",
"would",
"cause",
"the",
"file",
"to",
"exceed",
"the",
"size",
"limit",
"we",
"have",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_rotating_file.go#L190-L205 |
17,871 | hhkbp2/go-logging | handler_rotating_file.go | RotateFile | func (self *RotatingFileHandler) RotateFile(sourceFile, destFile string) error {
if FileExists(sourceFile) {
if FileExists(destFile) {
if err := os.Remove(destFile); err != nil {
return err
}
}
if err := os.Rename(sourceFile, destFile); err != nil {
return err
}
}
return nil
} | go | func (self *RotatingFileHandler) RotateFile(sourceFile, destFile string) error {
if FileExists(sourceFile) {
if FileExists(destFile) {
if err := os.Remove(destFile); err != nil {
return err
}
}
if err := os.Rename(sourceFile, destFile); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"self",
"*",
"RotatingFileHandler",
")",
"RotateFile",
"(",
"sourceFile",
",",
"destFile",
"string",
")",
"error",
"{",
"if",
"FileExists",
"(",
"sourceFile",
")",
"{",
"if",
"FileExists",
"(",
"destFile",
")",
"{",
"if",
"err",
":=",
"os",
... | // Rotate source file to destination file if source file exists. | [
"Rotate",
"source",
"file",
"to",
"destination",
"file",
"if",
"source",
"file",
"exists",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_rotating_file.go#L208-L220 |
17,872 | hhkbp2/go-logging | handler_rotating_file.go | DoRollover | func (self *RotatingFileHandler) DoRollover() (err error) {
self.FileHandler.Close()
defer func() {
if e := self.FileHandler.Open(); e != nil {
if e == nil {
err = e
}
}
}()
if self.backupCount > 0 {
filepath := self.GetFilePath()
for i := self.backupCount - 1; i > 0; i-- {
sourceFile := fmt.Sp... | go | func (self *RotatingFileHandler) DoRollover() (err error) {
self.FileHandler.Close()
defer func() {
if e := self.FileHandler.Open(); e != nil {
if e == nil {
err = e
}
}
}()
if self.backupCount > 0 {
filepath := self.GetFilePath()
for i := self.backupCount - 1; i > 0; i-- {
sourceFile := fmt.Sp... | [
"func",
"(",
"self",
"*",
"RotatingFileHandler",
")",
"DoRollover",
"(",
")",
"(",
"err",
"error",
")",
"{",
"self",
".",
"FileHandler",
".",
"Close",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"e",
":=",
"self",
".",
"FileHandler",
".",
... | // Do a rollover, as described above. | [
"Do",
"a",
"rollover",
"as",
"described",
"above",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_rotating_file.go#L223-L247 |
17,873 | hhkbp2/go-logging | handler_socket.go | NewSocketHandler | func NewSocketHandler(host string, port uint16) *SocketHandler {
retry := NewErrorRetry().
Delay(SocketDefaultDelay).
Deadline(SocketDefaultMaxDeadline)
object := &SocketHandler{
BaseHandler: NewBaseHandler("", LevelNotset),
host: host,
port: port,
closeOnError: true,
retry: retr... | go | func NewSocketHandler(host string, port uint16) *SocketHandler {
retry := NewErrorRetry().
Delay(SocketDefaultDelay).
Deadline(SocketDefaultMaxDeadline)
object := &SocketHandler{
BaseHandler: NewBaseHandler("", LevelNotset),
host: host,
port: port,
closeOnError: true,
retry: retr... | [
"func",
"NewSocketHandler",
"(",
"host",
"string",
",",
"port",
"uint16",
")",
"*",
"SocketHandler",
"{",
"retry",
":=",
"NewErrorRetry",
"(",
")",
".",
"Delay",
"(",
"SocketDefaultDelay",
")",
".",
"Deadline",
"(",
"SocketDefaultMaxDeadline",
")",
"\n",
"obje... | // Initializes the handler with a specific host address and port.
// The attribute 'closeOnError' is set to true by default, which means that
// if a socket error occurs, the socket is silently closed and then reopen
// on the next loggging call. | [
"Initializes",
"the",
"handler",
"with",
"a",
"specific",
"host",
"address",
"and",
"port",
".",
"The",
"attribute",
"closeOnError",
"is",
"set",
"to",
"true",
"by",
"default",
"which",
"means",
"that",
"if",
"a",
"socket",
"error",
"occurs",
"the",
"socket"... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L52-L67 |
17,874 | hhkbp2/go-logging | handler_socket.go | Marshal | func (self *SocketHandler) Marshal(record *LogRecord) ([]byte, error) {
r := SocketLogRecord{
CreatedTime: record.CreatedTime,
AscTime: record.AscTime,
Name: record.Name,
Level: record.Level,
PathName: record.PathName,
FileName: record.FileName,
LineNo: record.LineNo,
FuncNa... | go | func (self *SocketHandler) Marshal(record *LogRecord) ([]byte, error) {
r := SocketLogRecord{
CreatedTime: record.CreatedTime,
AscTime: record.AscTime,
Name: record.Name,
Level: record.Level,
PathName: record.PathName,
FileName: record.FileName,
LineNo: record.LineNo,
FuncNa... | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"Marshal",
"(",
"record",
"*",
"LogRecord",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"r",
":=",
"SocketLogRecord",
"{",
"CreatedTime",
":",
"record",
".",
"CreatedTime",
",",
"AscTime",
":",
"r... | // Marshals the record in gob binary format and returns it ready for
// transmission across socket. | [
"Marshals",
"the",
"record",
"in",
"gob",
"binary",
"format",
"and",
"returns",
"it",
"ready",
"for",
"transmission",
"across",
"socket",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L71-L92 |
17,875 | hhkbp2/go-logging | handler_socket.go | makeSocket | func (self *SocketHandler) makeSocket(network string) error {
address := fmt.Sprintf("%s:%d", self.host, self.port)
conn, err := net.DialTimeout(network, address, SocketDefaultTimeout)
if err != nil {
return err
}
self.conn = conn
return nil
} | go | func (self *SocketHandler) makeSocket(network string) error {
address := fmt.Sprintf("%s:%d", self.host, self.port)
conn, err := net.DialTimeout(network, address, SocketDefaultTimeout)
if err != nil {
return err
}
self.conn = conn
return nil
} | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"makeSocket",
"(",
"network",
"string",
")",
"error",
"{",
"address",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
"\n",
"conn",
",",
"err",
"... | // A factory method which allows succlasses to define the precise type of
// socket they want. | [
"A",
"factory",
"method",
"which",
"allows",
"succlasses",
"to",
"define",
"the",
"precise",
"type",
"of",
"socket",
"they",
"want",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L96-L104 |
17,876 | hhkbp2/go-logging | handler_socket.go | sendTCP | func (self *SocketHandler) sendTCP(bin []byte) error {
if self.conn == nil {
err := self.createSocket()
if err != nil {
return err
}
}
sentSoFar, left := 0, len(bin)
for left > 0 {
sent, err := self.conn.Write(bin[sentSoFar:])
if err != nil {
return err
}
sentSoFar += sent
left -= sent
}
ret... | go | func (self *SocketHandler) sendTCP(bin []byte) error {
if self.conn == nil {
err := self.createSocket()
if err != nil {
return err
}
}
sentSoFar, left := 0, len(bin)
for left > 0 {
sent, err := self.conn.Write(bin[sentSoFar:])
if err != nil {
return err
}
sentSoFar += sent
left -= sent
}
ret... | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"sendTCP",
"(",
"bin",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"self",
".",
"conn",
"==",
"nil",
"{",
"err",
":=",
"self",
".",
"createSocket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // Send a marshaled binary to the tcp socket. | [
"Send",
"a",
"marshaled",
"binary",
"to",
"the",
"tcp",
"socket",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L120-L137 |
17,877 | hhkbp2/go-logging | handler_socket.go | sendUDP | func (self *SocketHandler) sendUDP(bin []byte) error {
if self.conn == nil {
err := self.createSocket()
if err != nil {
return err
}
}
_, err := self.conn.Write(bin)
return err
} | go | func (self *SocketHandler) sendUDP(bin []byte) error {
if self.conn == nil {
err := self.createSocket()
if err != nil {
return err
}
}
_, err := self.conn.Write(bin)
return err
} | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"sendUDP",
"(",
"bin",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"self",
".",
"conn",
"==",
"nil",
"{",
"err",
":=",
"self",
".",
"createSocket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // Send a marshaled binary to the udp socket. | [
"Send",
"a",
"marshaled",
"binary",
"to",
"the",
"udp",
"socket",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L140-L149 |
17,878 | hhkbp2/go-logging | handler_socket.go | Emit | func (self *SocketHandler) Emit(record *LogRecord) error {
self.Format(record)
bin, err := self.Marshal(record)
if err != nil {
return err
}
return self.sendFunc(bin)
} | go | func (self *SocketHandler) Emit(record *LogRecord) error {
self.Format(record)
bin, err := self.Marshal(record)
if err != nil {
return err
}
return self.sendFunc(bin)
} | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"Emit",
"(",
"record",
"*",
"LogRecord",
")",
"error",
"{",
"self",
".",
"Format",
"(",
"record",
")",
"\n",
"bin",
",",
"err",
":=",
"self",
".",
"Marshal",
"(",
"record",
")",
"\n",
"if",
"err",
"!=... | // Emit a record.
// Marshals the record and writes it to the socket in binary format.
// If there is an error with the socket, silently drop the packet.
// If there was a problem with the socket, re-establishes the socket. | [
"Emit",
"a",
"record",
".",
"Marshals",
"the",
"record",
"and",
"writes",
"it",
"to",
"the",
"socket",
"in",
"binary",
"format",
".",
"If",
"there",
"is",
"an",
"error",
"with",
"the",
"socket",
"silently",
"drop",
"the",
"packet",
".",
"If",
"there",
... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L155-L162 |
17,879 | hhkbp2/go-logging | handler_socket.go | HandleError | func (self *SocketHandler) HandleError(record *LogRecord, err error) {
if self.closeOnError && (self.conn != nil) {
self.conn.Close()
self.conn = nil
} else {
self.BaseHandler.HandleError(record, err)
}
} | go | func (self *SocketHandler) HandleError(record *LogRecord, err error) {
if self.closeOnError && (self.conn != nil) {
self.conn.Close()
self.conn = nil
} else {
self.BaseHandler.HandleError(record, err)
}
} | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"HandleError",
"(",
"record",
"*",
"LogRecord",
",",
"err",
"error",
")",
"{",
"if",
"self",
".",
"closeOnError",
"&&",
"(",
"self",
".",
"conn",
"!=",
"nil",
")",
"{",
"self",
".",
"conn",
".",
"Close"... | // Handles an error during logging.
// An error has occurred during logging. Most likely cause connection lost.
// Close the socket so that we can retry on the next event. | [
"Handles",
"an",
"error",
"during",
"logging",
".",
"An",
"error",
"has",
"occurred",
"during",
"logging",
".",
"Most",
"likely",
"cause",
"connection",
"lost",
".",
"Close",
"the",
"socket",
"so",
"that",
"we",
"can",
"retry",
"on",
"the",
"next",
"event"... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L171-L178 |
17,880 | hhkbp2/go-logging | handler_socket.go | Close | func (self *SocketHandler) Close() {
self.Lock()
defer self.Unlock()
if self.conn != nil {
self.conn.Close()
self.conn = nil
}
self.BaseHandler.Close()
} | go | func (self *SocketHandler) Close() {
self.Lock()
defer self.Unlock()
if self.conn != nil {
self.conn.Close()
self.conn = nil
}
self.BaseHandler.Close()
} | [
"func",
"(",
"self",
"*",
"SocketHandler",
")",
"Close",
"(",
")",
"{",
"self",
".",
"Lock",
"(",
")",
"\n",
"defer",
"self",
".",
"Unlock",
"(",
")",
"\n",
"if",
"self",
".",
"conn",
"!=",
"nil",
"{",
"self",
".",
"conn",
".",
"Close",
"(",
")... | // Close the socket. | [
"Close",
"the",
"socket",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_socket.go#L181-L189 |
17,881 | hhkbp2/go-logging | filter.go | Filter | func (self *NameFilter) Filter(record *LogRecord) bool {
length := len(self.name)
if length == 0 {
return true
} else if self.name == record.Name {
return true
} else if !strings.HasPrefix(record.Name, self.name) {
return false
}
return (record.Name[length] == '.')
} | go | func (self *NameFilter) Filter(record *LogRecord) bool {
length := len(self.name)
if length == 0 {
return true
} else if self.name == record.Name {
return true
} else if !strings.HasPrefix(record.Name, self.name) {
return false
}
return (record.Name[length] == '.')
} | [
"func",
"(",
"self",
"*",
"NameFilter",
")",
"Filter",
"(",
"record",
"*",
"LogRecord",
")",
"bool",
"{",
"length",
":=",
"len",
"(",
"self",
".",
"name",
")",
"\n",
"if",
"length",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"else",
"if",
"self",... | // Determine if the specified record is to be logged.
// Is the specified record to be logged? Returns false for no, true for yes.
// If deemed appropriate, the record may be modified in-place. | [
"Determine",
"if",
"the",
"specified",
"record",
"is",
"to",
"be",
"logged",
".",
"Is",
"the",
"specified",
"record",
"to",
"be",
"logged?",
"Returns",
"false",
"for",
"no",
"true",
"for",
"yes",
".",
"If",
"deemed",
"appropriate",
"the",
"record",
"may",
... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/filter.go#L35-L45 |
17,882 | hhkbp2/go-logging | filter.go | AddFilter | func (self *StandardFilterer) AddFilter(filter Filter) {
if !self.filters.SetContains(filter) {
self.filters.SetAdd(filter)
}
} | go | func (self *StandardFilterer) AddFilter(filter Filter) {
if !self.filters.SetContains(filter) {
self.filters.SetAdd(filter)
}
} | [
"func",
"(",
"self",
"*",
"StandardFilterer",
")",
"AddFilter",
"(",
"filter",
"Filter",
")",
"{",
"if",
"!",
"self",
".",
"filters",
".",
"SetContains",
"(",
"filter",
")",
"{",
"self",
".",
"filters",
".",
"SetAdd",
"(",
"filter",
")",
"\n",
"}",
"... | // Add the specified filter. | [
"Add",
"the",
"specified",
"filter",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/filter.go#L68-L72 |
17,883 | hhkbp2/go-logging | filter.go | RemoveFilter | func (self *StandardFilterer) RemoveFilter(filter Filter) {
if self.filters.SetContains(filter) {
self.filters.SetRemove(filter)
}
} | go | func (self *StandardFilterer) RemoveFilter(filter Filter) {
if self.filters.SetContains(filter) {
self.filters.SetRemove(filter)
}
} | [
"func",
"(",
"self",
"*",
"StandardFilterer",
")",
"RemoveFilter",
"(",
"filter",
"Filter",
")",
"{",
"if",
"self",
".",
"filters",
".",
"SetContains",
"(",
"filter",
")",
"{",
"self",
".",
"filters",
".",
"SetRemove",
"(",
"filter",
")",
"\n",
"}",
"\... | // Remove the specified filter. | [
"Remove",
"the",
"specified",
"filter",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/filter.go#L75-L79 |
17,884 | hhkbp2/go-logging | init.go | GetLogger | func GetLogger(name string) Logger {
if len(name) > 0 {
return manager.GetLogger(name)
} else {
return root
}
} | go | func GetLogger(name string) Logger {
if len(name) > 0 {
return manager.GetLogger(name)
} else {
return root
}
} | [
"func",
"GetLogger",
"(",
"name",
"string",
")",
"Logger",
"{",
"if",
"len",
"(",
"name",
")",
">",
"0",
"{",
"return",
"manager",
".",
"GetLogger",
"(",
"name",
")",
"\n",
"}",
"else",
"{",
"return",
"root",
"\n",
"}",
"\n",
"}"
] | // Return a logger with the specified name, creating it if necessary.
// If empty name is specified, return the root logger. | [
"Return",
"a",
"logger",
"with",
"the",
"specified",
"name",
"creating",
"it",
"if",
"necessary",
".",
"If",
"empty",
"name",
"is",
"specified",
"return",
"the",
"root",
"logger",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/init.go#L72-L78 |
17,885 | hhkbp2/go-logging | init.go | Logf | func Logf(level LogLevelType, format string, args ...interface{}) {
root.Logf(level, format, args...)
} | go | func Logf(level LogLevelType, format string, args ...interface{}) {
root.Logf(level, format, args...)
} | [
"func",
"Logf",
"(",
"level",
"LogLevelType",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"root",
".",
"Logf",
"(",
"level",
",",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] | // Log a message with specified severity level on the root logger. | [
"Log",
"a",
"message",
"with",
"specified",
"severity",
"level",
"on",
"the",
"root",
"logger",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/init.go#L111-L113 |
17,886 | hhkbp2/go-logging | handler_file.go | NewFileHandler | func NewFileHandler(filename string, mode int, bufferSize int) (*FileHandler, error) {
// keep the absolute path, otherwise derived classes which use this
// may come a cropper when the current directory changes.
filepath, err := filepath.Abs(filename)
if err != nil {
return nil, err
}
handler := NewStreamHandl... | go | func NewFileHandler(filename string, mode int, bufferSize int) (*FileHandler, error) {
// keep the absolute path, otherwise derived classes which use this
// may come a cropper when the current directory changes.
filepath, err := filepath.Abs(filename)
if err != nil {
return nil, err
}
handler := NewStreamHandl... | [
"func",
"NewFileHandler",
"(",
"filename",
"string",
",",
"mode",
"int",
",",
"bufferSize",
"int",
")",
"(",
"*",
"FileHandler",
",",
"error",
")",
"{",
"// keep the absolute path, otherwise derived classes which use this",
"// may come a cropper when the current directory ch... | // Open the specified file and use it as the stream for logging. | [
"Open",
"the",
"specified",
"file",
"and",
"use",
"it",
"as",
"the",
"stream",
"for",
"logging",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_file.go#L126-L146 |
17,887 | hhkbp2/go-logging | config.go | ApplyConfigFile | func ApplyConfigFile(file string) error {
ext := filepath.Ext(file)
switch ext {
case ".json":
return ApplyJsonConfigFile(file)
case ".yml":
fallthrough
case ".yaml":
return ApplyYAMLConfigFile(file)
default:
return errors.New(fmt.Sprintf(
"unknown format of the specified file: %s", file))
}
} | go | func ApplyConfigFile(file string) error {
ext := filepath.Ext(file)
switch ext {
case ".json":
return ApplyJsonConfigFile(file)
case ".yml":
fallthrough
case ".yaml":
return ApplyYAMLConfigFile(file)
default:
return errors.New(fmt.Sprintf(
"unknown format of the specified file: %s", file))
}
} | [
"func",
"ApplyConfigFile",
"(",
"file",
"string",
")",
"error",
"{",
"ext",
":=",
"filepath",
".",
"Ext",
"(",
"file",
")",
"\n",
"switch",
"ext",
"{",
"case",
"\"",
"\"",
":",
"return",
"ApplyJsonConfigFile",
"(",
"file",
")",
"\n",
"case",
"\"",
"\""... | // Apply all configuration in specified file. | [
"Apply",
"all",
"configuration",
"in",
"specified",
"file",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/config.go#L70-L83 |
17,888 | hhkbp2/go-logging | config.go | ApplyJsonConfigFile | func ApplyJsonConfigFile(file string) error {
bin, err := ioutil.ReadFile(file)
if err != nil {
return err
}
decoder := json.NewDecoder(bytes.NewBuffer(bin))
decoder.UseNumber()
var conf Conf
if err = decoder.Decode(&conf); err != nil {
return err
}
return DictConfig(&conf)
} | go | func ApplyJsonConfigFile(file string) error {
bin, err := ioutil.ReadFile(file)
if err != nil {
return err
}
decoder := json.NewDecoder(bytes.NewBuffer(bin))
decoder.UseNumber()
var conf Conf
if err = decoder.Decode(&conf); err != nil {
return err
}
return DictConfig(&conf)
} | [
"func",
"ApplyJsonConfigFile",
"(",
"file",
"string",
")",
"error",
"{",
"bin",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"decoder",
":=",
"json",
".",
"NewDe... | // Apply all configuration in specified json file. | [
"Apply",
"all",
"configuration",
"in",
"specified",
"json",
"file",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/config.go#L86-L98 |
17,889 | hhkbp2/go-logging | config.go | ApplyYAMLConfigFile | func ApplyYAMLConfigFile(file string) error {
bin, err := ioutil.ReadFile(file)
if err != nil {
return err
}
var conf Conf
if err = yaml.Unmarshal(bin, &conf); err != nil {
return err
}
return DictConfig(&conf)
} | go | func ApplyYAMLConfigFile(file string) error {
bin, err := ioutil.ReadFile(file)
if err != nil {
return err
}
var conf Conf
if err = yaml.Unmarshal(bin, &conf); err != nil {
return err
}
return DictConfig(&conf)
} | [
"func",
"ApplyYAMLConfigFile",
"(",
"file",
"string",
")",
"error",
"{",
"bin",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"conf",
"Conf",
"\n",
"if",
... | // Apply all configuration in specified yaml file. | [
"Apply",
"all",
"configuration",
"in",
"specified",
"yaml",
"file",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/config.go#L101-L111 |
17,890 | hhkbp2/go-logging | handler.go | NewBaseHandler | func NewBaseHandler(name string, level LogLevelType) *BaseHandler {
return &BaseHandler{
StandardFilterer: NewStandardFilterer(),
name: name,
level: level,
formatter: nil,
}
} | go | func NewBaseHandler(name string, level LogLevelType) *BaseHandler {
return &BaseHandler{
StandardFilterer: NewStandardFilterer(),
name: name,
level: level,
formatter: nil,
}
} | [
"func",
"NewBaseHandler",
"(",
"name",
"string",
",",
"level",
"LogLevelType",
")",
"*",
"BaseHandler",
"{",
"return",
"&",
"BaseHandler",
"{",
"StandardFilterer",
":",
"NewStandardFilterer",
"(",
")",
",",
"name",
":",
"name",
",",
"level",
":",
"level",
",... | // Initialize the instance - basically setting the formatter to nil and the
// filterer without filter. | [
"Initialize",
"the",
"instance",
"-",
"basically",
"setting",
"the",
"formatter",
"to",
"nil",
"and",
"the",
"filterer",
"without",
"filter",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler.go#L58-L65 |
17,891 | hhkbp2/go-logging | handler.go | Format | func (self *BaseHandler) Format(record *LogRecord) string {
self.formatterLock.RLock()
defer self.formatterLock.RUnlock()
var formatter Formatter
if self.formatter != nil {
formatter = self.formatter
} else {
formatter = defaultFormatter
}
return formatter.Format(record)
} | go | func (self *BaseHandler) Format(record *LogRecord) string {
self.formatterLock.RLock()
defer self.formatterLock.RUnlock()
var formatter Formatter
if self.formatter != nil {
formatter = self.formatter
} else {
formatter = defaultFormatter
}
return formatter.Format(record)
} | [
"func",
"(",
"self",
"*",
"BaseHandler",
")",
"Format",
"(",
"record",
"*",
"LogRecord",
")",
"string",
"{",
"self",
".",
"formatterLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"self",
".",
"formatterLock",
".",
"RUnlock",
"(",
")",
"\n",
"var",
"form... | // Format the specified record.
// If a formatter is set, use it. Otherwise, use the default formatter
// for the module. | [
"Format",
"the",
"specified",
"record",
".",
"If",
"a",
"formatter",
"is",
"set",
"use",
"it",
".",
"Otherwise",
"use",
"the",
"default",
"formatter",
"for",
"the",
"module",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler.go#L115-L125 |
17,892 | hhkbp2/go-logging | level.go | AddLevel | func AddLevel(level LogLevelType, levelName string) {
levelLock.Lock()
defer levelLock.Unlock()
levelToNames[level] = levelName
nameToLevels[levelName] = level
} | go | func AddLevel(level LogLevelType, levelName string) {
levelLock.Lock()
defer levelLock.Unlock()
levelToNames[level] = levelName
nameToLevels[levelName] = level
} | [
"func",
"AddLevel",
"(",
"level",
"LogLevelType",
",",
"levelName",
"string",
")",
"{",
"levelLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"levelLock",
".",
"Unlock",
"(",
")",
"\n",
"levelToNames",
"[",
"level",
"]",
"=",
"levelName",
"\n",
"nameToLevels"... | // Associate levelName with level.
// This is used when converting levels to test during message formatting. | [
"Associate",
"levelName",
"with",
"level",
".",
"This",
"is",
"used",
"when",
"converting",
"levels",
"to",
"test",
"during",
"message",
"formatting",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/level.go#L80-L85 |
17,893 | hhkbp2/go-logging | logger.go | NewPlaceHolder | func NewPlaceHolder(logger Logger) *PlaceHolder {
object := &PlaceHolder{
Loggers: NewListSet(),
}
object.Append(logger)
return object
} | go | func NewPlaceHolder(logger Logger) *PlaceHolder {
object := &PlaceHolder{
Loggers: NewListSet(),
}
object.Append(logger)
return object
} | [
"func",
"NewPlaceHolder",
"(",
"logger",
"Logger",
")",
"*",
"PlaceHolder",
"{",
"object",
":=",
"&",
"PlaceHolder",
"{",
"Loggers",
":",
"NewListSet",
"(",
")",
",",
"}",
"\n",
"object",
".",
"Append",
"(",
"logger",
")",
"\n",
"return",
"object",
"\n",... | // Initialize a PlaceHolder with the specified logger being a child of
// this PlaceHolder. | [
"Initialize",
"a",
"PlaceHolder",
"with",
"the",
"specified",
"logger",
"being",
"a",
"child",
"of",
"this",
"PlaceHolder",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L43-L49 |
17,894 | hhkbp2/go-logging | logger.go | Append | func (self *PlaceHolder) Append(logger Logger) {
if !self.Loggers.SetContains(logger) {
self.Loggers.SetAdd(logger)
}
} | go | func (self *PlaceHolder) Append(logger Logger) {
if !self.Loggers.SetContains(logger) {
self.Loggers.SetAdd(logger)
}
} | [
"func",
"(",
"self",
"*",
"PlaceHolder",
")",
"Append",
"(",
"logger",
"Logger",
")",
"{",
"if",
"!",
"self",
".",
"Loggers",
".",
"SetContains",
"(",
"logger",
")",
"{",
"self",
".",
"Loggers",
".",
"SetAdd",
"(",
"logger",
")",
"\n",
"}",
"\n",
"... | // Add the specified logger as a child of this PlaceHolder. | [
"Add",
"the",
"specified",
"logger",
"as",
"a",
"child",
"of",
"this",
"PlaceHolder",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L56-L60 |
17,895 | hhkbp2/go-logging | logger.go | findCaller | func findCaller() *CallerInfo {
for i := 3; ; i++ {
pc, filepath, line, ok := runtime.Caller(i)
if !ok {
return UnknownCallerInfo
}
parts := strings.Split(filepath, "/")
dir := parts[len(parts)-2]
file := parts[len(parts)-1]
if (dir != thisPackageName) || (file != thisFileName) {
funcName := runtim... | go | func findCaller() *CallerInfo {
for i := 3; ; i++ {
pc, filepath, line, ok := runtime.Caller(i)
if !ok {
return UnknownCallerInfo
}
parts := strings.Split(filepath, "/")
dir := parts[len(parts)-2]
file := parts[len(parts)-1]
if (dir != thisPackageName) || (file != thisFileName) {
funcName := runtim... | [
"func",
"findCaller",
"(",
")",
"*",
"CallerInfo",
"{",
"for",
"i",
":=",
"3",
";",
";",
"i",
"++",
"{",
"pc",
",",
"filepath",
",",
"line",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"i",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"Unknow... | // Find the stack frame of the caller so that we can note the source file name,
// line number and function name. | [
"Find",
"the",
"stack",
"frame",
"of",
"the",
"caller",
"so",
"that",
"we",
"can",
"note",
"the",
"source",
"file",
"name",
"line",
"number",
"and",
"function",
"name",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L165-L184 |
17,896 | hhkbp2/go-logging | logger.go | NewStandardLogger | func NewStandardLogger(name string, level LogLevelType) *StandardLogger {
object := &StandardLogger{
StandardFilterer: NewStandardFilterer(),
parent: nil,
name: name,
findCallerFunc: findCaller,
level: level,
propagate: true,
handlers: NewListSet(),
man... | go | func NewStandardLogger(name string, level LogLevelType) *StandardLogger {
object := &StandardLogger{
StandardFilterer: NewStandardFilterer(),
parent: nil,
name: name,
findCallerFunc: findCaller,
level: level,
propagate: true,
handlers: NewListSet(),
man... | [
"func",
"NewStandardLogger",
"(",
"name",
"string",
",",
"level",
"LogLevelType",
")",
"*",
"StandardLogger",
"{",
"object",
":=",
"&",
"StandardLogger",
"{",
"StandardFilterer",
":",
"NewStandardFilterer",
"(",
")",
",",
"parent",
":",
"nil",
",",
"name",
":"... | // Initialize a standard logger instance with name and logging level. | [
"Initialize",
"a",
"standard",
"logger",
"instance",
"with",
"name",
"and",
"logging",
"level",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L200-L212 |
17,897 | hhkbp2/go-logging | logger.go | GetEffectiveLevel | func (self *StandardLogger) GetEffectiveLevel() LogLevelType {
self.lock.RLock()
defer self.lock.RUnlock()
var logger Logger = self
for logger != nil {
level := logger.GetLevel()
if level != LevelNotset {
return level
}
logger = logger.GetParent()
}
return LevelNotset
} | go | func (self *StandardLogger) GetEffectiveLevel() LogLevelType {
self.lock.RLock()
defer self.lock.RUnlock()
var logger Logger = self
for logger != nil {
level := logger.GetLevel()
if level != LevelNotset {
return level
}
logger = logger.GetParent()
}
return LevelNotset
} | [
"func",
"(",
"self",
"*",
"StandardLogger",
")",
"GetEffectiveLevel",
"(",
")",
"LogLevelType",
"{",
"self",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"self",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"var",
"logger",
"Logger",
"=",
"self"... | // Get the effective level for this logger.
// Loop through this logger and its parents in the logger hierarchy,
// looking for a non-zero logging level. Return the first one found. | [
"Get",
"the",
"effective",
"level",
"for",
"this",
"logger",
".",
"Loop",
"through",
"this",
"logger",
"and",
"its",
"parents",
"in",
"the",
"logger",
"hierarchy",
"looking",
"for",
"a",
"non",
"-",
"zero",
"logging",
"level",
".",
"Return",
"the",
"first"... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L266-L278 |
17,898 | hhkbp2/go-logging | logger.go | traverseHandlers | func (self *StandardLogger) traverseHandlers(record *LogRecord) {
var call Logger = self
for call != nil {
call.CallHandlers(record)
if !call.GetPropagate() {
call = nil
} else {
call = call.GetParent()
}
}
} | go | func (self *StandardLogger) traverseHandlers(record *LogRecord) {
var call Logger = self
for call != nil {
call.CallHandlers(record)
if !call.GetPropagate() {
call = nil
} else {
call = call.GetParent()
}
}
} | [
"func",
"(",
"self",
"*",
"StandardLogger",
")",
"traverseHandlers",
"(",
"record",
"*",
"LogRecord",
")",
"{",
"var",
"call",
"Logger",
"=",
"self",
"\n",
"for",
"call",
"!=",
"nil",
"{",
"call",
".",
"CallHandlers",
"(",
"record",
")",
"\n",
"if",
"!... | // Pass a record to all relevant handlers.
// Loop through all handlers for this logger and its parents in the logger
// hierarchy. Stop searching up the hierarchy whenever a logger with the
// "propagate" attribute set to false is found - that will be the last
// logger whose handlers are called. | [
"Pass",
"a",
"record",
"to",
"all",
"relevant",
"handlers",
".",
"Loop",
"through",
"all",
"handlers",
"for",
"this",
"logger",
"and",
"its",
"parents",
"in",
"the",
"logger",
"hierarchy",
".",
"Stop",
"searching",
"up",
"the",
"hierarchy",
"whenever",
"a",
... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L430-L440 |
17,899 | hhkbp2/go-logging | logger.go | NewRootLogger | func NewRootLogger(level LogLevelType) *RootLogger {
logger := NewStandardLogger("root", level)
logger.SetPropagate(false)
return &RootLogger{
StandardLogger: logger,
}
} | go | func NewRootLogger(level LogLevelType) *RootLogger {
logger := NewStandardLogger("root", level)
logger.SetPropagate(false)
return &RootLogger{
StandardLogger: logger,
}
} | [
"func",
"NewRootLogger",
"(",
"level",
"LogLevelType",
")",
"*",
"RootLogger",
"{",
"logger",
":=",
"NewStandardLogger",
"(",
"\"",
"\"",
",",
"level",
")",
"\n",
"logger",
".",
"SetPropagate",
"(",
"false",
")",
"\n",
"return",
"&",
"RootLogger",
"{",
"St... | // Initialize the root logger with the name "root". | [
"Initialize",
"the",
"root",
"logger",
"with",
"the",
"name",
"root",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L526-L532 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.