id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
147,600 | logicmonitor/k8s-collectorset-controller | pkg/apis/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *CollectorSetStatus) DeepCopy() *CollectorSetStatus {
if in == nil {
return nil
}
out := new(CollectorSetStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *CollectorSetStatus) DeepCopy() *CollectorSetStatus {
if in == nil {
return nil
}
out := new(CollectorSetStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CollectorSetStatus",
")",
"DeepCopy",
"(",
")",
"*",
"CollectorSetStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CollectorSetStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectorSetStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CollectorSetStatus",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/apis/v1alpha1/zz_generated.deepcopy.go#L176-L183 |
147,601 | mohae/joefriday | disk/diskstats/diskstats_unix.go | Get | func Get() (stat *structs.DiskStats, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (stat *structs.DiskStats, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"stat",
"*",
"structs",
".",
"DiskStats",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",... | // Get returns the current IO statistics of the block devices using the
// package's global Profiler. | [
"Get",
"returns",
"the",
"current",
"IO",
"statistics",
"of",
"the",
"block",
"devices",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/disk/diskstats/diskstats_unix.go#L168-L178 |
147,602 | logicmonitor/k8s-collectorset-controller | pkg/client/client.go | NewForConfig | func NewForConfig(cfg *rest.Config) (*Client, *runtime.Scheme, error) {
s := runtime.NewScheme()
err := crv1alpha1.AddToScheme(s)
if err != nil {
return nil, nil, err
}
client, err := clientset.NewForConfig(cfg)
if err != nil {
return nil, nil, err
}
config := *cfg
config.GroupVersion = &crv1alpha1.Schem... | go | func NewForConfig(cfg *rest.Config) (*Client, *runtime.Scheme, error) {
s := runtime.NewScheme()
err := crv1alpha1.AddToScheme(s)
if err != nil {
return nil, nil, err
}
client, err := clientset.NewForConfig(cfg)
if err != nil {
return nil, nil, err
}
config := *cfg
config.GroupVersion = &crv1alpha1.Schem... | [
"func",
"NewForConfig",
"(",
"cfg",
"*",
"rest",
".",
"Config",
")",
"(",
"*",
"Client",
",",
"*",
"runtime",
".",
"Scheme",
",",
"error",
")",
"{",
"s",
":=",
"runtime",
".",
"NewScheme",
"(",
")",
"\n",
"err",
":=",
"crv1alpha1",
".",
"AddToScheme"... | // NewForConfig instantiates and returns the client and scheme. | [
"NewForConfig",
"instantiates",
"and",
"returns",
"the",
"client",
"and",
"scheme",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/client/client.go#L30-L65 |
147,603 | logicmonitor/k8s-collectorset-controller | pkg/client/client.go | CreateCustomResourceDefinition | func (c *Client) CreateCustomResourceDefinition() (*apiextensionsv1beta1.CustomResourceDefinition, error) {
crd := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: crv1alpha1.GroupName,
Vers... | go | func (c *Client) CreateCustomResourceDefinition() (*apiextensionsv1beta1.CustomResourceDefinition, error) {
crd := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: crv1alpha1.GroupName,
Vers... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateCustomResourceDefinition",
"(",
")",
"(",
"*",
"apiextensionsv1beta1",
".",
"CustomResourceDefinition",
",",
"error",
")",
"{",
"crd",
":=",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceDefinition",
"{",
"ObjectMeta",... | // CreateCustomResourceDefinition creates the CRD for collectors. | [
"CreateCustomResourceDefinition",
"creates",
"the",
"CRD",
"for",
"collectors",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/client/client.go#L68-L117 |
147,604 | mohae/joefriday | system/version/version_unix.go | SetArch | func (k *Kernel) SetArch() {
// get everything after the last -
for i := len(k.Version) - 1; i > 0; i-- {
if k.Version[i] == '-' {
k.Arch = string(k.Version[i+1:])
return
}
}
} | go | func (k *Kernel) SetArch() {
// get everything after the last -
for i := len(k.Version) - 1; i > 0; i-- {
if k.Version[i] == '-' {
k.Arch = string(k.Version[i+1:])
return
}
}
} | [
"func",
"(",
"k",
"*",
"Kernel",
")",
"SetArch",
"(",
")",
"{",
"// get everything after the last -",
"for",
"i",
":=",
"len",
"(",
"k",
".",
"Version",
")",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
"{",
"if",
"k",
".",
"Version",
"[",
"i",
... | // Set the Version's architecture information. This is the last segment of
// the Version. | [
"Set",
"the",
"Version",
"s",
"architecture",
"information",
".",
"This",
"is",
"the",
"last",
"segment",
"of",
"the",
"Version",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/version/version_unix.go#L161-L169 |
147,605 | logicmonitor/k8s-collectorset-controller | pkg/controller/collectorset.go | DeleteCollectorSet | func DeleteCollectorSet(collectorset *crv1alpha1.CollectorSet, client clientset.Interface) error {
data := []byte(`[{"op":"add","path":"/spec/replicas","value": 0}]`)
if _, err := client.AppsV1beta1().StatefulSets(collectorset.Namespace).Patch(collectorset.Name, types.JSONPatchType, data); err != nil {
return err
... | go | func DeleteCollectorSet(collectorset *crv1alpha1.CollectorSet, client clientset.Interface) error {
data := []byte(`[{"op":"add","path":"/spec/replicas","value": 0}]`)
if _, err := client.AppsV1beta1().StatefulSets(collectorset.Namespace).Patch(collectorset.Name, types.JSONPatchType, data); err != nil {
return err
... | [
"func",
"DeleteCollectorSet",
"(",
"collectorset",
"*",
"crv1alpha1",
".",
"CollectorSet",
",",
"client",
"clientset",
".",
"Interface",
")",
"error",
"{",
"data",
":=",
"[",
"]",
"byte",
"(",
"`[{\"op\":\"add\",\"path\":\"/spec/replicas\",\"value\": 0}]`",
")",
"\n",... | // DeleteCollectorSet deletes the collectorset. | [
"DeleteCollectorSet",
"deletes",
"the",
"collectorset",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/controller/collectorset.go#L195-L203 |
147,606 | mohae/joefriday | system/loadavg/flat/loadavg_unix.go | Serialize | func (prof *Profiler) Serialize(la l.LoadAvg) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
structs.LoadAvgStart(prof.Builder)
structs.LoadAvgAddTimestamp(prof.Builder, la.Timestamp)
structs.LoadAvgAddMinute(prof.Builder, la.Minute)
structs.LoadAvgAddFive(prof.Builder, la.Five)
struct... | go | func (prof *Profiler) Serialize(la l.LoadAvg) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
structs.LoadAvgStart(prof.Builder)
structs.LoadAvgAddTimestamp(prof.Builder, la.Timestamp)
structs.LoadAvgAddMinute(prof.Builder, la.Minute)
structs.LoadAvgAddFive(prof.Builder, la.Five)
struct... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"la",
"l",
".",
"LoadAvg",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"prof",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"structs",
".",
"LoadAvgStart",
"(",
"p... | // Serialize serializes loadavg information using Flatbuffers. | [
"Serialize",
"serializes",
"loadavg",
"information",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/loadavg/flat/loadavg_unix.go#L76-L93 |
147,607 | mohae/joefriday | system/loadavg/flat/loadavg_unix.go | Deserialize | func Deserialize(p []byte) l.LoadAvg {
flatLA := structs.GetRootAsLoadAvg(p, 0)
var la l.LoadAvg
la.Timestamp = flatLA.Timestamp()
la.Minute = flatLA.Minute()
la.Five = flatLA.Five()
la.Fifteen = flatLA.Fifteen()
la.Running = flatLA.Running()
la.Total = flatLA.Total()
la.PID = flatLA.PID()
return la
} | go | func Deserialize(p []byte) l.LoadAvg {
flatLA := structs.GetRootAsLoadAvg(p, 0)
var la l.LoadAvg
la.Timestamp = flatLA.Timestamp()
la.Minute = flatLA.Minute()
la.Five = flatLA.Five()
la.Fifteen = flatLA.Fifteen()
la.Running = flatLA.Running()
la.Total = flatLA.Total()
la.PID = flatLA.PID()
return la
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"l",
".",
"LoadAvg",
"{",
"flatLA",
":=",
"structs",
".",
"GetRootAsLoadAvg",
"(",
"p",
",",
"0",
")",
"\n",
"var",
"la",
"l",
".",
"LoadAvg",
"\n",
"la",
".",
"Timestamp",
"=",
"flatLA",
".",... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them as
// loadavg.LoadAvg. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"loadavg",
".",
"LoadAvg",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/loadavg/flat/loadavg_unix.go#L111-L122 |
147,608 | mohae/joefriday | cpu/cpustats/flat/cpustats_unix.go | Deserialize | func Deserialize(p []byte) *stats.CPUStats {
statsS := &stats.CPUStats{}
cpuF := &structs.CPU{}
statsF := structs.GetRootAsCPUStats(p, 0)
statsS.ClkTck = statsF.ClkTck()
statsS.Timestamp = statsF.Timestamp()
statsS.Ctxt = statsF.Ctxt()
statsS.BTime = statsF.BTime()
statsS.Processes = statsF.Processes()
len := ... | go | func Deserialize(p []byte) *stats.CPUStats {
statsS := &stats.CPUStats{}
cpuF := &structs.CPU{}
statsF := structs.GetRootAsCPUStats(p, 0)
statsS.ClkTck = statsF.ClkTck()
statsS.Timestamp = statsF.Timestamp()
statsS.Ctxt = statsF.Ctxt()
statsS.BTime = statsF.BTime()
statsS.Processes = statsF.Processes()
len := ... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"stats",
".",
"CPUStats",
"{",
"statsS",
":=",
"&",
"stats",
".",
"CPUStats",
"{",
"}",
"\n",
"cpuF",
":=",
"&",
"structs",
".",
"CPU",
"{",
"}",
"\n",
"statsF",
":=",
"structs",
".",
"... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them as
// cpustats.CPUStats. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"cpustats",
".",
"CPUStats",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpustats/flat/cpustats_unix.go#L141-L170 |
147,609 | mohae/joefriday | net/netusage/json/netusage_unix.go | Serialize | func (prof *Profiler) Serialize(u *structs.DevUsage) ([]byte, error) {
return json.Marshal(u)
} | go | func (prof *Profiler) Serialize(u *structs.DevUsage) ([]byte, error) {
return json.Marshal(u)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"u",
"*",
"structs",
".",
"DevUsage",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"u",
")",
"\n",
"}"
] | // Serialize network device usage using JSON. | [
"Serialize",
"network",
"device",
"usage",
"using",
"JSON",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/net/netusage/json/netusage_unix.go#L87-L89 |
147,610 | mohae/joefriday | net/netusage/json/netusage_unix.go | Deserialize | func Deserialize(p []byte) (*structs.DevUsage, error) {
u := &structs.DevUsage{}
err := json.Unmarshal(p, u)
if err != nil {
return nil, err
}
return u, nil
} | go | func Deserialize(p []byte) (*structs.DevUsage, error) {
u := &structs.DevUsage{}
err := json.Unmarshal(p, u)
if err != nil {
return nil, err
}
return u, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"structs",
".",
"DevUsage",
",",
"error",
")",
"{",
"u",
":=",
"&",
"structs",
".",
"DevUsage",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"u",
")",
"\... | // Deserialize deserializes JSON serialized bytes as structs.DevUsage. | [
"Deserialize",
"deserializes",
"JSON",
"serialized",
"bytes",
"as",
"structs",
".",
"DevUsage",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/net/netusage/json/netusage_unix.go#L111-L118 |
147,611 | logicmonitor/k8s-collectorset-controller | pkg/controller/controller.go | New | func New(collectorsetconfig *config.Config, storage storage.Storage) (*Controller, error) {
// Instantiate the Kubernetes in cluster config.
restconfig, err := rest.InClusterConfig()
if err != nil {
return nil, err
}
// Instantiate the CollectorSet client.
client, collectorsetscheme, err := collectorsetclient.... | go | func New(collectorsetconfig *config.Config, storage storage.Storage) (*Controller, error) {
// Instantiate the Kubernetes in cluster config.
restconfig, err := rest.InClusterConfig()
if err != nil {
return nil, err
}
// Instantiate the CollectorSet client.
client, collectorsetscheme, err := collectorsetclient.... | [
"func",
"New",
"(",
"collectorsetconfig",
"*",
"config",
".",
"Config",
",",
"storage",
"storage",
".",
"Storage",
")",
"(",
"*",
"Controller",
",",
"error",
")",
"{",
"// Instantiate the Kubernetes in cluster config.",
"restconfig",
",",
"err",
":=",
"rest",
".... | // New instantiates and returns a Controller and an error if any. | [
"New",
"instantiates",
"and",
"returns",
"a",
"Controller",
"and",
"an",
"error",
"if",
"any",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/controller/controller.go#L35-L60 |
147,612 | logicmonitor/k8s-collectorset-controller | pkg/controller/controller.go | Run | func (c *Controller) Run(ctx context.Context) error {
// Watch CollectorSet objects
err := c.watch(ctx)
if err != nil {
return err
}
<-ctx.Done()
return ctx.Err()
} | go | func (c *Controller) Run(ctx context.Context) error {
// Watch CollectorSet objects
err := c.watch(ctx)
if err != nil {
return err
}
<-ctx.Done()
return ctx.Err()
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Watch CollectorSet objects",
"err",
":=",
"c",
".",
"watch",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"... | // Run starts a CollectorSet resource controller. | [
"Run",
"starts",
"a",
"CollectorSet",
"resource",
"controller",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/controller/controller.go#L63-L73 |
147,613 | mohae/joefriday | cpu/cpuinfo/json/cpuinfo_unix.go | NewProfiler | func NewProfiler() (prof *Profiler, err error) {
p, err := info.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | go | func NewProfiler() (prof *Profiler, err error) {
p, err := info.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"prof",
"*",
"Profiler",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"info",
".",
"NewProfiler",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // Initializes and returns a cpuinfo profiler. | [
"Initializes",
"and",
"returns",
"a",
"cpuinfo",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuinfo/json/cpuinfo_unix.go#L36-L42 |
147,614 | mohae/joefriday | cpu/cpuinfo/json/cpuinfo_unix.go | Serialize | func (prof *Profiler) Serialize(inf *info.CPUInfo) ([]byte, error) {
return json.Marshal(inf)
} | go | func (prof *Profiler) Serialize(inf *info.CPUInfo) ([]byte, error) {
return json.Marshal(inf)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"inf",
"*",
"info",
".",
"CPUInfo",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"inf",
")",
"\n",
"}"
] | // Serialize cpuinfo as JSON. | [
"Serialize",
"cpuinfo",
"as",
"JSON",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuinfo/json/cpuinfo_unix.go#L71-L73 |
147,615 | mohae/joefriday | cpu/cpuinfo/json/cpuinfo_unix.go | Deserialize | func Deserialize(p []byte) (*info.CPUInfo, error) {
inf := &info.CPUInfo{}
err := json.Unmarshal(p, inf)
if err != nil {
return nil, err
}
return inf, nil
} | go | func Deserialize(p []byte) (*info.CPUInfo, error) {
inf := &info.CPUInfo{}
err := json.Unmarshal(p, inf)
if err != nil {
return nil, err
}
return inf, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"info",
".",
"CPUInfo",
",",
"error",
")",
"{",
"inf",
":=",
"&",
"info",
".",
"CPUInfo",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"inf",
")",
"\n",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// cpuinfo.CPUInfo. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"cpuinfo",
".",
"CPUInfo",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuinfo/json/cpuinfo_unix.go#L100-L107 |
147,616 | mohae/joefriday | mem/membasic/json/membasic_unix.go | Serialize | func Serialize(inf *basic.Info) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(inf)
} | go | func Serialize(inf *basic.Info) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(inf)
} | [
"func",
"Serialize",
"(",
"inf",
"*",
"basic",
".",
"Info",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
... | // Serialize the basic memory information using JSON with the package's global
// Profiler. | [
"Serialize",
"the",
"basic",
"memory",
"information",
"using",
"JSON",
"with",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/mem/membasic/json/membasic_unix.go#L81-L91 |
147,617 | mohae/joefriday | cpu/cpuinfo/flat/cpuinfo_unix.go | Serialize | func (p *Profiler) Serialize(inf *info.CPUInfo) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
uoffs := make([]fb.UOffsetT, len(inf.CPU))
for i, cpu := range inf.CPU {
uoffs[i] = p.SerializeCPU(&cpu)
}
structs.CPUInfoStartCPUVector(p.Builder, len(uoffs))
for i := len(uoffs) - 1; i >= 0;... | go | func (p *Profiler) Serialize(inf *info.CPUInfo) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
uoffs := make([]fb.UOffsetT, len(inf.CPU))
for i, cpu := range inf.CPU {
uoffs[i] = p.SerializeCPU(&cpu)
}
structs.CPUInfoStartCPUVector(p.Builder, len(uoffs))
for i := len(uoffs) - 1; i >= 0;... | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"Serialize",
"(",
"inf",
"*",
"info",
".",
"CPUInfo",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"p",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"uoffs",
":=",
"make",
"(",
"[",
... | // Serialize serializes cpuinfo using Flatbuffers. | [
"Serialize",
"serializes",
"cpuinfo",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuinfo/flat/cpuinfo_unix.go#L74-L96 |
147,618 | mohae/joefriday | cpu/cpuinfo/flat/cpuinfo_unix.go | Serialize | func Serialize(inf *info.CPUInfo) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(inf), nil
} | go | func Serialize(inf *info.CPUInfo) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(inf), nil
} | [
"func",
"Serialize",
"(",
"inf",
"*",
"info",
".",
"CPUInfo",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
... | // Serialize cpuinfo.CPUInfo using the package global profiler. | [
"Serialize",
"cpuinfo",
".",
"CPUInfo",
"using",
"the",
"package",
"global",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuinfo/flat/cpuinfo_unix.go#L184-L194 |
147,619 | logicmonitor/k8s-collectorset-controller | pkg/healthz/healthz.go | HandleFunc | func HandleFunc(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("ok"))
if err != nil {
log.Errorf("Failed to write healthz: %v", err)
}
} | go | func HandleFunc(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("ok"))
if err != nil {
log.Errorf("Failed to write healthz: %v", err)
}
} | [
"func",
"HandleFunc",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusOK",
")",
"\n",
"_",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"[",
"]",
"byte",
"... | // HandleFunc is an http handler function to expose health metrics. | [
"HandleFunc",
"is",
"an",
"http",
"handler",
"function",
"to",
"expose",
"health",
"metrics",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/healthz/healthz.go#L10-L16 |
147,620 | mohae/joefriday | system/uptime/flat/uptime_unix.go | Serialize | func (prof *Profiler) Serialize(up u.Uptime) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
structs.UptimeStart(prof.Builder)
structs.UptimeAddTimestamp(prof.Builder, up.Timestamp)
structs.UptimeAddTotal(prof.Builder, up.Total)
structs.UptimeAddIdle(prof.Builder, up.Idle)
prof.Builder.... | go | func (prof *Profiler) Serialize(up u.Uptime) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
structs.UptimeStart(prof.Builder)
structs.UptimeAddTimestamp(prof.Builder, up.Timestamp)
structs.UptimeAddTotal(prof.Builder, up.Total)
structs.UptimeAddIdle(prof.Builder, up.Idle)
prof.Builder.... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"up",
"u",
".",
"Uptime",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"prof",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"structs",
".",
"UptimeStart",
"(",
"pro... | // Serialize serializes uptime information as Flatbuffers. | [
"Serialize",
"serializes",
"uptime",
"information",
"as",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/uptime/flat/uptime_unix.go#L76-L89 |
147,621 | mohae/joefriday | system/uptime/flat/uptime_unix.go | Serialize | func Serialize(up u.Uptime) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(up), nil
} | go | func Serialize(up u.Uptime) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(up), nil
} | [
"func",
"Serialize",
"(",
"up",
"u",
".",
"Uptime",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
"... | // Serialize serializes uptime information as Flatbuffers using the
// package's global Profiler. | [
"Serialize",
"serializes",
"uptime",
"information",
"as",
"Flatbuffers",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/uptime/flat/uptime_unix.go#L93-L103 |
147,622 | mohae/joefriday | sysinfo/mem/json/mem_unix.go | Get | func Get() (p []byte, err error) {
var inf m.MemInfo
err = inf.Get()
if err != nil {
return nil, err
}
return json.Marshal(&inf)
} | go | func Get() (p []byte, err error) {
var inf m.MemInfo
err = inf.Get()
if err != nil {
return nil, err
}
return json.Marshal(&inf)
} | [
"func",
"Get",
"(",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"inf",
"m",
".",
"MemInfo",
"\n",
"err",
"=",
"inf",
".",
"Get",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // Get returns the system's memory information as JSON serialized bytes. | [
"Get",
"returns",
"the",
"system",
"s",
"memory",
"information",
"as",
"JSON",
"serialized",
"bytes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/mem/json/mem_unix.go#L31-L38 |
147,623 | mohae/joefriday | sysinfo/mem/json/mem_unix.go | Deserialize | func Deserialize(p []byte) (*m.MemInfo, error) {
var inf m.MemInfo
err := json.Unmarshal(p, &inf)
if err != nil {
return nil, err
}
return &inf, nil
} | go | func Deserialize(p []byte) (*m.MemInfo, error) {
var inf m.MemInfo
err := json.Unmarshal(p, &inf)
if err != nil {
return nil, err
}
return &inf, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"m",
".",
"MemInfo",
",",
"error",
")",
"{",
"var",
"inf",
"m",
".",
"MemInfo",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"&",
"inf",
")",
"\n",
"if",
"err",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// mem.MemInfo. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"mem",
".",
"MemInfo",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/mem/json/mem_unix.go#L42-L49 |
147,624 | mohae/joefriday | net/netusage/flat/netusage_unix.go | Deserialize | func Deserialize(p []byte) *structs.DevUsage {
uFlat := flat.GetRootAsDevUsage(p, 0)
// get the # of interfaces
iLen := uFlat.DeviceLength()
u := &structs.DevUsage{
Timestamp: uFlat.Timestamp(),
TimeDelta: uFlat.TimeDelta(),
Device: make([]structs.Device, iLen),
}
fDev := &flat.Device{}
sDev := structs.D... | go | func Deserialize(p []byte) *structs.DevUsage {
uFlat := flat.GetRootAsDevUsage(p, 0)
// get the # of interfaces
iLen := uFlat.DeviceLength()
u := &structs.DevUsage{
Timestamp: uFlat.Timestamp(),
TimeDelta: uFlat.TimeDelta(),
Device: make([]structs.Device, iLen),
}
fDev := &flat.Device{}
sDev := structs.D... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"structs",
".",
"DevUsage",
"{",
"uFlat",
":=",
"flat",
".",
"GetRootAsDevUsage",
"(",
"p",
",",
"0",
")",
"\n",
"// get the # of interfaces",
"iLen",
":=",
"uFlat",
".",
"DeviceLength",
"(",
"... | // Deserialize deserializes Flatbuffer serialized bytes as structs.DevUsage. | [
"Deserialize",
"deserializes",
"Flatbuffer",
"serialized",
"bytes",
"as",
"structs",
".",
"DevUsage",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/net/netusage/flat/netusage_unix.go#L150-L184 |
147,625 | mohae/joefriday | disk/diskusage/diskusage_unix.go | Get | func Get() (u *structs.DiskUsage, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (u *structs.DiskUsage, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"u",
"*",
"structs",
".",
"DiskUsage",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
... | // Get returns the current IO usage of the block devices using the package's
// global Profiler. The Profiler is instantiated lazily. If the profiler
// doesn't already exist, the first usage information will not be useful due
// to minimal time elapsing between the initial and second snapshots used for
// usage calcul... | [
"Get",
"returns",
"the",
"current",
"IO",
"usage",
"of",
"the",
"block",
"devices",
"using",
"the",
"package",
"s",
"global",
"Profiler",
".",
"The",
"Profiler",
"is",
"instantiated",
"lazily",
".",
"If",
"the",
"profiler",
"doesn",
"t",
"already",
"exist",
... | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/disk/diskusage/diskusage_unix.go#L77-L87 |
147,626 | logicmonitor/k8s-collectorset-controller | pkg/utilities/utilities.go | CheckAllErrors | func CheckAllErrors(restResponse interface{}, apiResponse *logicmonitor.APIResponse, err error) error {
if err != nil {
return fmt.Errorf("[ERROR] %v", err)
}
if apiResponse.Response != nil && apiResponse.StatusCode != http.StatusOK {
metrics.APIError()
return fmt.Errorf("[API] [%d] %s", apiResponse.StatusCod... | go | func CheckAllErrors(restResponse interface{}, apiResponse *logicmonitor.APIResponse, err error) error {
if err != nil {
return fmt.Errorf("[ERROR] %v", err)
}
if apiResponse.Response != nil && apiResponse.StatusCode != http.StatusOK {
metrics.APIError()
return fmt.Errorf("[API] [%d] %s", apiResponse.StatusCod... | [
"func",
"CheckAllErrors",
"(",
"restResponse",
"interface",
"{",
"}",
",",
"apiResponse",
"*",
"logicmonitor",
".",
"APIResponse",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
","... | // CheckAllErrors is a helper function to deal with the number of possible places that an API call can fail. | [
"CheckAllErrors",
"is",
"a",
"helper",
"function",
"to",
"deal",
"with",
"the",
"number",
"of",
"possible",
"places",
"that",
"an",
"API",
"call",
"can",
"fail",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/utilities/utilities.go#L13-L52 |
147,627 | logicmonitor/k8s-collectorset-controller | pkg/distributor/roundrobin/roundrobin.go | ID | func (d *Distributor) ID(req *api.CollectorIDRequest) (*api.CollectorIDReply, error) {
d.Lock()
defer d.Unlock()
if len(d.ids) == 0 {
return nil, fmt.Errorf("No available collectors")
}
i, j := d.ids[0], d.ids[1:]
d.ids = append(j, i)
reply := &api.CollectorIDReply{Id: i}
return reply, nil
} | go | func (d *Distributor) ID(req *api.CollectorIDRequest) (*api.CollectorIDReply, error) {
d.Lock()
defer d.Unlock()
if len(d.ids) == 0 {
return nil, fmt.Errorf("No available collectors")
}
i, j := d.ids[0], d.ids[1:]
d.ids = append(j, i)
reply := &api.CollectorIDReply{Id: i}
return reply, nil
} | [
"func",
"(",
"d",
"*",
"Distributor",
")",
"ID",
"(",
"req",
"*",
"api",
".",
"CollectorIDRequest",
")",
"(",
"*",
"api",
".",
"CollectorIDReply",
",",
"error",
")",
"{",
"d",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"Unlock",
"(",
")",
"\... | // ID implements distributor.DistributionStratgey | [
"ID",
"implements",
"distributor",
".",
"DistributionStratgey"
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/distributor/roundrobin/roundrobin.go#L18-L31 |
147,628 | logicmonitor/k8s-collectorset-controller | pkg/distributor/roundrobin/roundrobin.go | SetIDs | func (d *Distributor) SetIDs(ids []int32) error {
d.ids = ids
return nil
} | go | func (d *Distributor) SetIDs(ids []int32) error {
d.ids = ids
return nil
} | [
"func",
"(",
"d",
"*",
"Distributor",
")",
"SetIDs",
"(",
"ids",
"[",
"]",
"int32",
")",
"error",
"{",
"d",
".",
"ids",
"=",
"ids",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetIDs implements distributor.DistributionStratgey | [
"SetIDs",
"implements",
"distributor",
".",
"DistributionStratgey"
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/distributor/roundrobin/roundrobin.go#L34-L37 |
147,629 | mohae/joefriday | mem/meminfo/json/meminfo_unix.go | NewProfiler | func NewProfiler() (prof *Profiler, err error) {
p, err := mem.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | go | func NewProfiler() (prof *Profiler, err error) {
p, err := mem.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"prof",
"*",
"Profiler",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"mem",
".",
"NewProfiler",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",... | // Returns an Initialized profiler that uses JSON; ready to use. | [
"Returns",
"an",
"Initialized",
"profiler",
"that",
"uses",
"JSON",
";",
"ready",
"to",
"use",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/mem/meminfo/json/meminfo_unix.go#L38-L44 |
147,630 | mohae/joefriday | mem/meminfo/json/meminfo_unix.go | Deserialize | func Deserialize(p []byte) (*mem.Info, error) {
info := &mem.Info{}
err := json.Unmarshal(p, info)
if err != nil {
return nil, err
}
return info, nil
} | go | func Deserialize(p []byte) (*mem.Info, error) {
info := &mem.Info{}
err := json.Unmarshal(p, info)
if err != nil {
return nil, err
}
return info, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"mem",
".",
"Info",
",",
"error",
")",
"{",
"info",
":=",
"&",
"mem",
".",
"Info",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"info",
")",
"\n",
"if"... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// meminfo.Info. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"meminfo",
".",
"Info",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/mem/meminfo/json/meminfo_unix.go#L102-L109 |
147,631 | mohae/joefriday | system/os/os_unix.go | Get | func Get() (os *OS, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (os *OS, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"os",
"*",
"OS",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
"NewProfiler",
"(",
")... | // Get gets the OS release information using the package's global Profiler. | [
"Get",
"gets",
"the",
"OS",
"release",
"information",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/os/os_unix.go#L133-L143 |
147,632 | logicmonitor/k8s-collectorset-controller | pkg/storage/inmem/inmem.go | GetPolicy | func (m *InMem) GetPolicy(name storage.CollectorSetName) (*policy.Policy, bool) {
m.Lock()
defer m.Unlock()
p, ok := m.policies[name]
return p, ok
} | go | func (m *InMem) GetPolicy(name storage.CollectorSetName) (*policy.Policy, bool) {
m.Lock()
defer m.Unlock()
p, ok := m.policies[name]
return p, ok
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"GetPolicy",
"(",
"name",
"storage",
".",
"CollectorSetName",
")",
"(",
"*",
"policy",
".",
"Policy",
",",
"bool",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"p"... | // GetPolicy provides thread-safe reads from a PolicyMap. | [
"GetPolicy",
"provides",
"thread",
"-",
"safe",
"reads",
"from",
"a",
"PolicyMap",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/storage/inmem/inmem.go#L31-L38 |
147,633 | logicmonitor/k8s-collectorset-controller | pkg/storage/inmem/inmem.go | SetPolicy | func (m *InMem) SetPolicy(name storage.CollectorSetName, policy *policy.Policy) error {
m.Lock()
defer m.Unlock()
m.policies[name] = policy
m.countChan <- len(m.policies)
return nil
} | go | func (m *InMem) SetPolicy(name storage.CollectorSetName, policy *policy.Policy) error {
m.Lock()
defer m.Unlock()
m.policies[name] = policy
m.countChan <- len(m.policies)
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"SetPolicy",
"(",
"name",
"storage",
".",
"CollectorSetName",
",",
"policy",
"*",
"policy",
".",
"Policy",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"m",... | // SetPolicy provides thread-safe writes to a PolicyMap. | [
"SetPolicy",
"provides",
"thread",
"-",
"safe",
"writes",
"to",
"a",
"PolicyMap",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/storage/inmem/inmem.go#L41-L49 |
147,634 | logicmonitor/k8s-collectorset-controller | pkg/storage/inmem/inmem.go | DeletePolicy | func (m *InMem) DeletePolicy(name storage.CollectorSetName) error {
m.Lock()
defer m.Unlock()
delete(m.policies, name)
m.countChan <- len(m.policies)
return nil
} | go | func (m *InMem) DeletePolicy(name storage.CollectorSetName) error {
m.Lock()
defer m.Unlock()
delete(m.policies, name)
m.countChan <- len(m.policies)
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"DeletePolicy",
"(",
"name",
"storage",
".",
"CollectorSetName",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"m",
".",
"policies",
",",
"nam... | // DeletePolicy provides thread-safe writes to a PolicyMap. | [
"DeletePolicy",
"provides",
"thread",
"-",
"safe",
"writes",
"to",
"a",
"PolicyMap",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/storage/inmem/inmem.go#L52-L60 |
147,635 | logicmonitor/k8s-collectorset-controller | pkg/storage/inmem/inmem.go | IterPolicies | func (m *InMem) IterPolicies() <-chan *policy.Policy {
c := make(chan *policy.Policy)
f := func() {
m.Lock()
defer m.Unlock()
for _, v := range m.policies {
c <- v
}
close(c)
}
go f()
return c
} | go | func (m *InMem) IterPolicies() <-chan *policy.Policy {
c := make(chan *policy.Policy)
f := func() {
m.Lock()
defer m.Unlock()
for _, v := range m.policies {
c <- v
}
close(c)
}
go f()
return c
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"IterPolicies",
"(",
")",
"<-",
"chan",
"*",
"policy",
".",
"Policy",
"{",
"c",
":=",
"make",
"(",
"chan",
"*",
"policy",
".",
"Policy",
")",
"\n\n",
"f",
":=",
"func",
"(",
")",
"{",
"m",
".",
"Lock",
"(",
... | // IterPolicies provides thread-safe iteration of a PolicyMap. | [
"IterPolicies",
"provides",
"thread",
"-",
"safe",
"iteration",
"of",
"a",
"PolicyMap",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/storage/inmem/inmem.go#L63-L78 |
147,636 | mohae/joefriday | node/flat/node_unix.go | NewProfiler | func NewProfiler() (p *Profiler) {
prof := numa.NewProfiler()
return &Profiler{Profiler: prof, Builder: fb.NewBuilder(0)}
} | go | func NewProfiler() (p *Profiler) {
prof := numa.NewProfiler()
return &Profiler{Profiler: prof, Builder: fb.NewBuilder(0)}
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"p",
"*",
"Profiler",
")",
"{",
"prof",
":=",
"numa",
".",
"NewProfiler",
"(",
")",
"\n",
"return",
"&",
"Profiler",
"{",
"Profiler",
":",
"prof",
",",
"Builder",
":",
"fb",
".",
"NewBuilder",
"(",
"0",
")",
"}... | // Initializes and returns a node profiler. | [
"Initializes",
"and",
"returns",
"a",
"node",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/flat/node_unix.go#L41-L44 |
147,637 | mohae/joefriday | node/flat/node_unix.go | Serialize | func (p *Profiler) Serialize(nodes *numa.Nodes) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
uoffs := make([]fb.UOffsetT, len(nodes.Node))
for i, node := range nodes.Node {
uoffs[i] = p.SerializeNode(&node)
}
structs.NodesStartNodeVector(p.Builder, len(uoffs))
for i := len(uoffs) - 1;... | go | func (p *Profiler) Serialize(nodes *numa.Nodes) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
uoffs := make([]fb.UOffsetT, len(nodes.Node))
for i, node := range nodes.Node {
uoffs[i] = p.SerializeNode(&node)
}
structs.NodesStartNodeVector(p.Builder, len(uoffs))
for i := len(uoffs) - 1;... | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"Serialize",
"(",
"nodes",
"*",
"numa",
".",
"Nodes",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"p",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"uoffs",
":=",
"make",
"(",
"[",
... | // Serialize serializes node.Nodes using Flatbuffers. | [
"Serialize",
"serializes",
"node",
".",
"Nodes",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/flat/node_unix.go#L70-L90 |
147,638 | mohae/joefriday | node/flat/node_unix.go | SerializeNode | func (p *Profiler) SerializeNode(node *numa.Node) fb.UOffsetT {
cpuList := p.Builder.CreateString(node.CPUList)
structs.NodeStart(p.Builder)
structs.NodeAddID(p.Builder, node.ID)
structs.NodeAddCPUList(p.Builder, cpuList)
return structs.NodeEnd(p.Builder)
} | go | func (p *Profiler) SerializeNode(node *numa.Node) fb.UOffsetT {
cpuList := p.Builder.CreateString(node.CPUList)
structs.NodeStart(p.Builder)
structs.NodeAddID(p.Builder, node.ID)
structs.NodeAddCPUList(p.Builder, cpuList)
return structs.NodeEnd(p.Builder)
} | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"SerializeNode",
"(",
"node",
"*",
"numa",
".",
"Node",
")",
"fb",
".",
"UOffsetT",
"{",
"cpuList",
":=",
"p",
".",
"Builder",
".",
"CreateString",
"(",
"node",
".",
"CPUList",
")",
"\n",
"structs",
".",
"NodeS... | // SerializeNode serializes a Node using flatbuffers and returns the resulting
// UOffsetT. | [
"SerializeNode",
"serializes",
"a",
"Node",
"using",
"flatbuffers",
"and",
"returns",
"the",
"resulting",
"UOffsetT",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/flat/node_unix.go#L94-L100 |
147,639 | mohae/joefriday | node/flat/node_unix.go | Serialize | func Serialize(nodes *numa.Nodes) (p []byte) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(nodes)
} | go | func Serialize(nodes *numa.Nodes) (p []byte) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(nodes)
} | [
"func",
"Serialize",
"(",
"nodes",
"*",
"numa",
".",
"Nodes",
")",
"(",
"p",
"[",
"]",
"byte",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
"=",
"NewProfi... | // Serialize node.Nodes using the package global profiler. | [
"Serialize",
"node",
".",
"Nodes",
"using",
"the",
"package",
"global",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/flat/node_unix.go#L103-L110 |
147,640 | mohae/joefriday | node/flat/node_unix.go | Deserialize | func Deserialize(p []byte) *numa.Nodes {
fnodes := structs.GetRootAsNodes(p, 0)
l := fnodes.NodeLength()
nodes := &numa.Nodes{}
fNode := &structs.Node{}
node := numa.Node{}
nodes.Node = make([]numa.Node, 0, l)
for i := 0; i < l; i++ {
if !fnodes.Node(fNode, i) {
continue
}
node.ID = fNode.ID()
node.CP... | go | func Deserialize(p []byte) *numa.Nodes {
fnodes := structs.GetRootAsNodes(p, 0)
l := fnodes.NodeLength()
nodes := &numa.Nodes{}
fNode := &structs.Node{}
node := numa.Node{}
nodes.Node = make([]numa.Node, 0, l)
for i := 0; i < l; i++ {
if !fnodes.Node(fNode, i) {
continue
}
node.ID = fNode.ID()
node.CP... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"numa",
".",
"Nodes",
"{",
"fnodes",
":=",
"structs",
".",
"GetRootAsNodes",
"(",
"p",
",",
"0",
")",
"\n",
"l",
":=",
"fnodes",
".",
"NodeLength",
"(",
")",
"\n",
"nodes",
":=",
"&",
"... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them
// as node.Nodes. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"node",
".",
"Nodes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/flat/node_unix.go#L114-L130 |
147,641 | 4ydx/gltext | misc.go | Pow2 | func Pow2(x uint32) uint32 {
x--
x |= x >> 1
x |= x >> 2
x |= x >> 4
x |= x >> 8
x |= x >> 16
return x + 1
} | go | func Pow2(x uint32) uint32 {
x--
x |= x >> 1
x |= x >> 2
x |= x >> 4
x |= x >> 8
x |= x >> 16
return x + 1
} | [
"func",
"Pow2",
"(",
"x",
"uint32",
")",
"uint32",
"{",
"x",
"--",
"\n",
"x",
"|=",
"x",
">>",
"1",
"\n",
"x",
"|=",
"x",
">>",
"2",
"\n",
"x",
"|=",
"x",
">>",
"4",
"\n",
"x",
"|=",
"x",
">>",
"8",
"\n",
"x",
"|=",
"x",
">>",
"16",
"\n... | // Pow2 returns the first power-of-two value >= to n.
// This can be used to create suitable texture dimensions. | [
"Pow2",
"returns",
"the",
"first",
"power",
"-",
"of",
"-",
"two",
"value",
">",
"=",
"to",
"n",
".",
"This",
"can",
"be",
"used",
"to",
"create",
"suitable",
"texture",
"dimensions",
"."
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/misc.go#L17-L25 |
147,642 | 4ydx/gltext | misc.go | Pow2Image | func Pow2Image(src image.Image) image.Image {
sb := src.Bounds()
w, h := uint32(sb.Dx()), uint32(sb.Dy())
if IsPow2(w) && IsPow2(h) {
return src // Nothing to do.
}
rect := image.Rect(0, 0, int(Pow2(w)), int(Pow2(h)))
switch src := src.(type) {
case *image.Alpha:
return copyImg(src, image.NewAlpha(rect))
... | go | func Pow2Image(src image.Image) image.Image {
sb := src.Bounds()
w, h := uint32(sb.Dx()), uint32(sb.Dy())
if IsPow2(w) && IsPow2(h) {
return src // Nothing to do.
}
rect := image.Rect(0, 0, int(Pow2(w)), int(Pow2(h)))
switch src := src.(type) {
case *image.Alpha:
return copyImg(src, image.NewAlpha(rect))
... | [
"func",
"Pow2Image",
"(",
"src",
"image",
".",
"Image",
")",
"image",
".",
"Image",
"{",
"sb",
":=",
"src",
".",
"Bounds",
"(",
")",
"\n",
"w",
",",
"h",
":=",
"uint32",
"(",
"sb",
".",
"Dx",
"(",
")",
")",
",",
"uint32",
"(",
"sb",
".",
"Dy"... | // Pow2Image returns the given image, scaled to the smallest power-of-two
// dimensions larger or equal to the input dimensions.
// It preserves the image format and contents.
//
// This is useful if an image is to be used as an OpenGL texture.
// These often require image data to have power-of-two dimensions. | [
"Pow2Image",
"returns",
"the",
"given",
"image",
"scaled",
"to",
"the",
"smallest",
"power",
"-",
"of",
"-",
"two",
"dimensions",
"larger",
"or",
"equal",
"to",
"the",
"input",
"dimensions",
".",
"It",
"preserves",
"the",
"image",
"format",
"and",
"contents"... | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/misc.go#L36-L76 |
147,643 | mohae/joefriday | cpu/cpuutil/flat/cpuutil_unix.go | NewProfiler | func NewProfiler() (prof *Profiler, err error) {
p, err := util.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p, Builder: fb.NewBuilder(0)}, nil
} | go | func NewProfiler() (prof *Profiler, err error) {
p, err := util.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p, Builder: fb.NewBuilder(0)}, nil
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"prof",
"*",
"Profiler",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"util",
".",
"NewProfiler",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // Initializes and returns a cpu utilization profiler that uses FlatBuffers. | [
"Initializes",
"and",
"returns",
"a",
"cpu",
"utilization",
"profiler",
"that",
"uses",
"FlatBuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/flat/cpuutil_unix.go#L45-L51 |
147,644 | mohae/joefriday | cpu/cpuutil/flat/cpuutil_unix.go | Serialize | func (prof *Profiler) Serialize(u *util.CPUUtil) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
utils := make([]fb.UOffsetT, len(u.CPU))
ids := make([]fb.UOffsetT, len(u.CPU))
for i := 0; i < len(ids); i++ {
ids[i] = prof.Builder.CreateString(u.CPU[i].ID)
}
for i := 0; i < len(utils)... | go | func (prof *Profiler) Serialize(u *util.CPUUtil) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
utils := make([]fb.UOffsetT, len(u.CPU))
ids := make([]fb.UOffsetT, len(u.CPU))
for i := 0; i < len(ids); i++ {
ids[i] = prof.Builder.CreateString(u.CPU[i].ID)
}
for i := 0; i < len(utils)... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"u",
"*",
"util",
".",
"CPUUtil",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"prof",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"utils",
":=",
"make",
"(",
"[... | // Serialize cpu utilization using Flatbuffers. | [
"Serialize",
"cpu",
"utilization",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/flat/cpuutil_unix.go#L87-L124 |
147,645 | mohae/joefriday | cpu/cpuutil/flat/cpuutil_unix.go | Serialize | func Serialize(u *util.CPUUtil) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(u), nil
} | go | func Serialize(u *util.CPUUtil) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(u), nil
} | [
"func",
"Serialize",
"(",
"u",
"*",
"util",
".",
"CPUUtil",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
... | // Serialize the CPU Utilization using the package global Profiler. | [
"Serialize",
"the",
"CPU",
"Utilization",
"using",
"the",
"package",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/flat/cpuutil_unix.go#L127-L137 |
147,646 | mohae/joefriday | cpu/cpuutil/flat/cpuutil_unix.go | Deserialize | func Deserialize(p []byte) *util.CPUUtil {
cpuU := &util.CPUUtil{}
uF := &structs.Utilization{}
flatCPUUtil := structs.GetRootAsCPUUtil(p, 0)
cpuU.Timestamp = flatCPUUtil.Timestamp()
cpuU.TimeDelta = flatCPUUtil.TimeDelta()
cpuU.CtxtDelta = flatCPUUtil.CtxtDelta()
cpuU.BTimeDelta = flatCPUUtil.BTimeDelta()
cpuU... | go | func Deserialize(p []byte) *util.CPUUtil {
cpuU := &util.CPUUtil{}
uF := &structs.Utilization{}
flatCPUUtil := structs.GetRootAsCPUUtil(p, 0)
cpuU.Timestamp = flatCPUUtil.Timestamp()
cpuU.TimeDelta = flatCPUUtil.TimeDelta()
cpuU.CtxtDelta = flatCPUUtil.CtxtDelta()
cpuU.BTimeDelta = flatCPUUtil.BTimeDelta()
cpuU... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"util",
".",
"CPUUtil",
"{",
"cpuU",
":=",
"&",
"util",
".",
"CPUUtil",
"{",
"}",
"\n",
"uF",
":=",
"&",
"structs",
".",
"Utilization",
"{",
"}",
"\n",
"flatCPUUtil",
":=",
"structs",
"."... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them as
// cpuutil.CPUUtil. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"cpuutil",
".",
"CPUUtil",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/flat/cpuutil_unix.go#L141-L166 |
147,647 | mohae/joefriday | processors/json/processors_unix.go | Deserialize | func Deserialize(p []byte) (*procs.Processors, error) {
proc := &procs.Processors{}
err := json.Unmarshal(p, proc)
if err != nil {
return nil, err
}
return proc, nil
} | go | func Deserialize(p []byte) (*procs.Processors, error) {
proc := &procs.Processors{}
err := json.Unmarshal(p, proc)
if err != nil {
return nil, err
}
return proc, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"procs",
".",
"Processors",
",",
"error",
")",
"{",
"proc",
":=",
"&",
"procs",
".",
"Processors",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"proc",
")"... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// processors.Processors | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"processors",
".",
"Processors"
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/processors/json/processors_unix.go#L112-L119 |
147,648 | mohae/joefriday | system/loadavg/json/loadavg_unix.go | Serialize | func Serialize(la l.LoadAvg) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(la)
} | go | func Serialize(la l.LoadAvg) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(la)
} | [
"func",
"Serialize",
"(",
"la",
"l",
".",
"LoadAvg",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
... | // Serialize loadavg.LoadAvg using JSON with the package's global Profiler. | [
"Serialize",
"loadavg",
".",
"LoadAvg",
"using",
"JSON",
"with",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/loadavg/json/loadavg_unix.go#L79-L89 |
147,649 | mohae/joefriday | system/loadavg/json/loadavg_unix.go | Deserialize | func Deserialize(p []byte) (la l.LoadAvg, err error) {
err = json.Unmarshal(p, &la)
if err != nil {
return la, err
}
return la, nil
} | go | func Deserialize(p []byte) (la l.LoadAvg, err error) {
err = json.Unmarshal(p, &la)
if err != nil {
return la, err
}
return la, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"la",
"l",
".",
"LoadAvg",
",",
"err",
"error",
")",
"{",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"&",
"la",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"la",
"... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// loadavg.LoadAvg. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"loadavg",
".",
"LoadAvg",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/loadavg/json/loadavg_unix.go#L103-L109 |
147,650 | mohae/joefriday | cpu/cpuutil/json/cpuutil_unix.go | NewProfiler | func NewProfiler() (prof *Profiler, err error) {
p, err := util.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | go | func NewProfiler() (prof *Profiler, err error) {
p, err := util.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"prof",
"*",
"Profiler",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"util",
".",
"NewProfiler",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // Initializes and returns a cpu utlization profiler. | [
"Initializes",
"and",
"returns",
"a",
"cpu",
"utlization",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/json/cpuutil_unix.go#L42-L48 |
147,651 | mohae/joefriday | cpu/cpuutil/json/cpuutil_unix.go | Marshal | func (prof *Profiler) Marshal(ut *util.CPUUtil) ([]byte, error) {
return prof.Serialize(ut)
} | go | func (prof *Profiler) Marshal(ut *util.CPUUtil) ([]byte, error) {
return prof.Serialize(ut)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Marshal",
"(",
"ut",
"*",
"util",
".",
"CPUUtil",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"prof",
".",
"Serialize",
"(",
"ut",
")",
"\n",
"}"
] | // Marshal is an alias for Serialize | [
"Marshal",
"is",
"an",
"alias",
"for",
"Serialize"
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/json/cpuutil_unix.go#L105-L107 |
147,652 | mohae/joefriday | cpu/cpuutil/json/cpuutil_unix.go | Deserialize | func Deserialize(p []byte) (*util.CPUUtil, error) {
ut := &util.CPUUtil{}
err := json.Unmarshal(p, ut)
if err != nil {
return nil, err
}
return ut, nil
} | go | func Deserialize(p []byte) (*util.CPUUtil, error) {
ut := &util.CPUUtil{}
err := json.Unmarshal(p, ut)
if err != nil {
return nil, err
}
return ut, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"util",
".",
"CPUUtil",
",",
"error",
")",
"{",
"ut",
":=",
"&",
"util",
".",
"CPUUtil",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"ut",
")",
"\n",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// cpuutil.CPUUtil. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"cpuutil",
".",
"CPUUtil",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpuutil/json/cpuutil_unix.go#L116-L123 |
147,653 | mohae/joefriday | processors/flat/processors_unix.go | SerializeCache | func (p *Profiler) SerializeCache(id, inf string) fb.UOffsetT {
cID := p.Builder.CreateString(id)
cInf := p.Builder.CreateString(inf)
structs.CacheInfStart(p.Builder)
structs.CacheInfAddID(p.Builder, cID)
structs.CacheInfAddSize(p.Builder, cInf)
return structs.CacheInfEnd(p.Builder)
} | go | func (p *Profiler) SerializeCache(id, inf string) fb.UOffsetT {
cID := p.Builder.CreateString(id)
cInf := p.Builder.CreateString(inf)
structs.CacheInfStart(p.Builder)
structs.CacheInfAddID(p.Builder, cID)
structs.CacheInfAddSize(p.Builder, cInf)
return structs.CacheInfEnd(p.Builder)
} | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"SerializeCache",
"(",
"id",
",",
"inf",
"string",
")",
"fb",
".",
"UOffsetT",
"{",
"cID",
":=",
"p",
".",
"Builder",
".",
"CreateString",
"(",
"id",
")",
"\n",
"cInf",
":=",
"p",
".",
"Builder",
".",
"Create... | // SerializeCache serializes a cache entry using flatbuffers and returns the
// resulting UOffsetT. | [
"SerializeCache",
"serializes",
"a",
"cache",
"entry",
"using",
"flatbuffers",
"and",
"returns",
"the",
"resulting",
"UOffsetT",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/processors/flat/processors_unix.go#L194-L201 |
147,654 | mohae/joefriday | sysinfo/uptime/flat/uptime_unix.go | Get | func Get() (p []byte, err error) {
var u up.Uptime
err = u.Get()
if err != nil {
return nil, err
}
return Serialize(&u), nil
} | go | func Get() (p []byte, err error) {
var u up.Uptime
err = u.Get()
if err != nil {
return nil, err
}
return Serialize(&u), nil
} | [
"func",
"Get",
"(",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"u",
"up",
".",
"Uptime",
"\n",
"err",
"=",
"u",
".",
"Get",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
... | // Get returns the current uptime as Flatbuffer serialized bytes. | [
"Get",
"returns",
"the",
"current",
"uptime",
"as",
"Flatbuffer",
"serialized",
"bytes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/uptime/flat/uptime_unix.go#L37-L44 |
147,655 | mohae/joefriday | sysinfo/uptime/flat/uptime_unix.go | Serialize | func Serialize(u *up.Uptime) []byte {
mu.Lock()
defer mu.Unlock()
// ensure the Builder is in a usable state.
builder.Reset()
structs.UptimeStart(builder)
structs.UptimeAddTimestamp(builder, u.Timestamp)
structs.UptimeAddUptime(builder, u.Uptime)
builder.Finish(structs.UptimeEnd(builder))
p := builder.Bytes[bu... | go | func Serialize(u *up.Uptime) []byte {
mu.Lock()
defer mu.Unlock()
// ensure the Builder is in a usable state.
builder.Reset()
structs.UptimeStart(builder)
structs.UptimeAddTimestamp(builder, u.Timestamp)
structs.UptimeAddUptime(builder, u.Uptime)
builder.Finish(structs.UptimeEnd(builder))
p := builder.Bytes[bu... | [
"func",
"Serialize",
"(",
"u",
"*",
"up",
".",
"Uptime",
")",
"[",
"]",
"byte",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"// ensure the Builder is in a usable state.",
"builder",
".",
"Reset",
"(",
")",
"\n"... | // Serialize uptime.Uptime using Flatbuffers. | [
"Serialize",
"uptime",
".",
"Uptime",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/uptime/flat/uptime_unix.go#L47-L61 |
147,656 | mohae/joefriday | cpu/cpux/flat/cpux_unix.go | NewProfiler | func NewProfiler() *Profiler {
prof := cpux.NewProfiler()
return &Profiler{Profiler: prof, Builder: fb.NewBuilder(0)}
} | go | func NewProfiler() *Profiler {
prof := cpux.NewProfiler()
return &Profiler{Profiler: prof, Builder: fb.NewBuilder(0)}
} | [
"func",
"NewProfiler",
"(",
")",
"*",
"Profiler",
"{",
"prof",
":=",
"cpux",
".",
"NewProfiler",
"(",
")",
"\n",
"return",
"&",
"Profiler",
"{",
"Profiler",
":",
"prof",
",",
"Builder",
":",
"fb",
".",
"NewBuilder",
"(",
"0",
")",
"}",
"\n",
"}"
] | // Initializes and returns a cpux profiler. | [
"Initializes",
"and",
"returns",
"a",
"cpux",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/flat/cpux_unix.go#L43-L46 |
147,657 | mohae/joefriday | cpu/cpux/flat/cpux_unix.go | Serialize | func (p *Profiler) Serialize(cpus *cpux.CPUs) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
possible := p.Builder.CreateString(cpus.Possible)
online := p.Builder.CreateString(cpus.Online)
offline := p.Builder.CreateString(cpus.Offline)
present := p.Builder.CreateString(cpus.Present)
uoff... | go | func (p *Profiler) Serialize(cpus *cpux.CPUs) []byte {
// ensure the Builder is in a usable state.
p.Builder.Reset()
possible := p.Builder.CreateString(cpus.Possible)
online := p.Builder.CreateString(cpus.Online)
offline := p.Builder.CreateString(cpus.Offline)
present := p.Builder.CreateString(cpus.Present)
uoff... | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"Serialize",
"(",
"cpus",
"*",
"cpux",
".",
"CPUs",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"p",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"possible",
":=",
"p",
".",
"Builder... | // Serialize serializes cpux.CPUs using Flatbuffers. | [
"Serialize",
"serializes",
"cpux",
".",
"CPUs",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/flat/cpux_unix.go#L72-L101 |
147,658 | mohae/joefriday | cpu/cpux/flat/cpux_unix.go | SerializeCPU | func (p *Profiler) SerializeCPU(cpu *cpux.CPU) fb.UOffsetT {
uoffs := make([]fb.UOffsetT, len(cpu.CacheIDs))
// serialize cache info in order; the flatbuffer table will have the info
// in order so a separate cache ID list isn't necessary for flatbuffers.
for i, id := range cpu.CacheIDs {
// If the ID doesn't exi... | go | func (p *Profiler) SerializeCPU(cpu *cpux.CPU) fb.UOffsetT {
uoffs := make([]fb.UOffsetT, len(cpu.CacheIDs))
// serialize cache info in order; the flatbuffer table will have the info
// in order so a separate cache ID list isn't necessary for flatbuffers.
for i, id := range cpu.CacheIDs {
// If the ID doesn't exi... | [
"func",
"(",
"p",
"*",
"Profiler",
")",
"SerializeCPU",
"(",
"cpu",
"*",
"cpux",
".",
"CPU",
")",
"fb",
".",
"UOffsetT",
"{",
"uoffs",
":=",
"make",
"(",
"[",
"]",
"fb",
".",
"UOffsetT",
",",
"len",
"(",
"cpu",
".",
"CacheIDs",
")",
")",
"\n",
... | // SerializeCPU serializes a CPU using flatbuffers and returns the resulting
// UOffsetT. | [
"SerializeCPU",
"serializes",
"a",
"CPU",
"using",
"flatbuffers",
"and",
"returns",
"the",
"resulting",
"UOffsetT",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/flat/cpux_unix.go#L105-L127 |
147,659 | mohae/joefriday | cpu/cpux/flat/cpux_unix.go | Serialize | func Serialize(cpus *cpux.CPUs) (p []byte) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(cpus)
} | go | func Serialize(cpus *cpux.CPUs) (p []byte) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(cpus)
} | [
"func",
"Serialize",
"(",
"cpus",
"*",
"cpux",
".",
"CPUs",
")",
"(",
"p",
"[",
"]",
"byte",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
"=",
"NewProfile... | // Serialize cpux.CPUs using the package global profiler. | [
"Serialize",
"cpux",
".",
"CPUs",
"using",
"the",
"package",
"global",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/flat/cpux_unix.go#L141-L148 |
147,660 | mohae/joefriday | cpu/cpux/flat/cpux_unix.go | Deserialize | func Deserialize(p []byte) *cpux.CPUs {
fcpus := structs.GetRootAsCPUs(p, 0)
l := fcpus.CPULength()
cpus := &cpux.CPUs{}
fCPU := &structs.CPU{}
fCache := &structs.CacheInf{}
cpu := cpux.CPU{}
cpus.Sockets = fcpus.Sockets()
cpus.Possible = string(fcpus.Possible())
cpus.Online = string(fcpus.Online())
cpus.Pres... | go | func Deserialize(p []byte) *cpux.CPUs {
fcpus := structs.GetRootAsCPUs(p, 0)
l := fcpus.CPULength()
cpus := &cpux.CPUs{}
fCPU := &structs.CPU{}
fCache := &structs.CacheInf{}
cpu := cpux.CPU{}
cpus.Sockets = fcpus.Sockets()
cpus.Possible = string(fcpus.Possible())
cpus.Online = string(fcpus.Online())
cpus.Pres... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"cpux",
".",
"CPUs",
"{",
"fcpus",
":=",
"structs",
".",
"GetRootAsCPUs",
"(",
"p",
",",
"0",
")",
"\n",
"l",
":=",
"fcpus",
".",
"CPULength",
"(",
")",
"\n",
"cpus",
":=",
"&",
"cpux",... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them
// as cpux.CPUs. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"cpux",
".",
"CPUs",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/flat/cpux_unix.go#L152-L184 |
147,661 | logicmonitor/k8s-collectorset-controller | pkg/server/server.go | New | func New(storage storage.Storage, count <-chan int) *Server {
srv := &Server{
Server: health.NewServer(),
Storage: storage,
countChan: count,
}
srv.SetServingStatus(constants.HealthServerServiceName, healthpb.HealthCheckResponse_NOT_SERVING)
return srv
} | go | func New(storage storage.Storage, count <-chan int) *Server {
srv := &Server{
Server: health.NewServer(),
Storage: storage,
countChan: count,
}
srv.SetServingStatus(constants.HealthServerServiceName, healthpb.HealthCheckResponse_NOT_SERVING)
return srv
} | [
"func",
"New",
"(",
"storage",
"storage",
".",
"Storage",
",",
"count",
"<-",
"chan",
"int",
")",
"*",
"Server",
"{",
"srv",
":=",
"&",
"Server",
"{",
"Server",
":",
"health",
".",
"NewServer",
"(",
")",
",",
"Storage",
":",
"storage",
",",
"countCha... | // New instantiates and returns a Server. | [
"New",
"instantiates",
"and",
"returns",
"a",
"Server",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/server/server.go#L27-L37 |
147,662 | logicmonitor/k8s-collectorset-controller | pkg/server/server.go | Run | func (srv *Server) Run() {
s := grpc.NewServer()
go srv.listenForPolicyCountChanges()
healthpb.RegisterHealthServer(s, srv)
api.RegisterCollectorSetControllerServer(s, srv)
reflection.Register(s)
// Start the gRPC server.
lis, err := net.Listen("tcp", fmt.Sprintf(":%s", "50000"))
if err != nil {
log.Fatalf("... | go | func (srv *Server) Run() {
s := grpc.NewServer()
go srv.listenForPolicyCountChanges()
healthpb.RegisterHealthServer(s, srv)
api.RegisterCollectorSetControllerServer(s, srv)
reflection.Register(s)
// Start the gRPC server.
lis, err := net.Listen("tcp", fmt.Sprintf(":%s", "50000"))
if err != nil {
log.Fatalf("... | [
"func",
"(",
"srv",
"*",
"Server",
")",
"Run",
"(",
")",
"{",
"s",
":=",
"grpc",
".",
"NewServer",
"(",
")",
"\n",
"go",
"srv",
".",
"listenForPolicyCountChanges",
"(",
")",
"\n",
"healthpb",
".",
"RegisterHealthServer",
"(",
"s",
",",
"srv",
")",
"\... | // Run starts the gRPC server. | [
"Run",
"starts",
"the",
"gRPC",
"server",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/server/server.go#L40-L53 |
147,663 | logicmonitor/k8s-collectorset-controller | pkg/server/server.go | CollectorID | func (srv Server) CollectorID(ctx context.Context, req *api.CollectorIDRequest) (*api.CollectorIDReply, error) {
return srv.enforcePolicy(req)
} | go | func (srv Server) CollectorID(ctx context.Context, req *api.CollectorIDRequest) (*api.CollectorIDReply, error) {
return srv.enforcePolicy(req)
} | [
"func",
"(",
"srv",
"Server",
")",
"CollectorID",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"api",
".",
"CollectorIDRequest",
")",
"(",
"*",
"api",
".",
"CollectorIDReply",
",",
"error",
")",
"{",
"return",
"srv",
".",
"enforcePolicy",
"(",... | // CollectorID implements api.CollectorSetControllerServer. It returns the
// next collector ID to use. | [
"CollectorID",
"implements",
"api",
".",
"CollectorSetControllerServer",
".",
"It",
"returns",
"the",
"next",
"collector",
"ID",
"to",
"use",
"."
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/server/server.go#L57-L59 |
147,664 | rsc/x86 | x86asm/plan9x.go | plan9Syntax | func plan9Syntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
if symname == nil {
symname = func(uint64) (string, uint64) { return "", 0 }
}
var args []string
for i := len(inst.Args) - 1; i >= 0; i-- {
a := inst.Args[i]
if a == nil {
continue
}
args = append(args, plan9Arg(&ins... | go | func plan9Syntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
if symname == nil {
symname = func(uint64) (string, uint64) { return "", 0 }
}
var args []string
for i := len(inst.Args) - 1; i >= 0; i-- {
a := inst.Args[i]
if a == nil {
continue
}
args = append(args, plan9Arg(&ins... | [
"func",
"plan9Syntax",
"(",
"inst",
"Inst",
",",
"pc",
"uint64",
",",
"symname",
"func",
"(",
"uint64",
")",
"(",
"string",
",",
"uint64",
")",
")",
"string",
"{",
"if",
"symname",
"==",
"nil",
"{",
"symname",
"=",
"func",
"(",
"uint64",
")",
"(",
... | // plan9Syntax returns the Go assembler syntax for the instruction.
// The syntax was originally defined by Plan 9.
// The pc is the program counter of the instruction, used for expanding
// PC-relative addresses into absolute ones.
// The symname function queries the symbol table for the program
// being disassembled.... | [
"plan9Syntax",
"returns",
"the",
"Go",
"assembler",
"syntax",
"for",
"the",
"instruction",
".",
"The",
"syntax",
"was",
"originally",
"defined",
"by",
"Plan",
"9",
".",
"The",
"pc",
"is",
"the",
"program",
"counter",
"of",
"the",
"instruction",
"used",
"for"... | 01d8f0379593fd888e08a4c4057d69f5765ab2e4 | https://github.com/rsc/x86/blob/01d8f0379593fd888e08a4c4057d69f5765ab2e4/x86asm/plan9x.go#L19-L69 |
147,665 | mohae/joefriday | cpu/cpufreq/cpufreq_unix.go | newFrequency | func (prof *Profiler) newFrequency() *Frequency {
f := &Frequency{Timestamp: time.Now().UTC().UnixNano(), Sockets: prof.Frequency.Sockets, CPU: make([]CPU, len(prof.Frequency.CPU))}
copy(f.CPU, prof.Frequency.CPU)
return f
} | go | func (prof *Profiler) newFrequency() *Frequency {
f := &Frequency{Timestamp: time.Now().UTC().UnixNano(), Sockets: prof.Frequency.Sockets, CPU: make([]CPU, len(prof.Frequency.CPU))}
copy(f.CPU, prof.Frequency.CPU)
return f
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"newFrequency",
"(",
")",
"*",
"Frequency",
"{",
"f",
":=",
"&",
"Frequency",
"{",
"Timestamp",
":",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
".",
"UnixNano",
"(",
")",
",",
"Sockets",
":",
"p... | // returns a copy of the profiler's frequency. | [
"returns",
"a",
"copy",
"of",
"the",
"profiler",
"s",
"frequency",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/cpufreq_unix.go#L184-L188 |
147,666 | mohae/joefriday | cpu/cpufreq/cpufreq_unix.go | Get | func (prof *Profiler) Get() (f *Frequency, err error) {
f = prof.newFrequency()
err = prof.Reset()
if err != nil {
return nil, err
}
var (
i, pos, nameLen int
v byte
x float64
)
processor := -1 // start at -1 because it'll be incremented before use as it's the first line enco... | go | func (prof *Profiler) Get() (f *Frequency, err error) {
f = prof.newFrequency()
err = prof.Reset()
if err != nil {
return nil, err
}
var (
i, pos, nameLen int
v byte
x float64
)
processor := -1 // start at -1 because it'll be incremented before use as it's the first line enco... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Get",
"(",
")",
"(",
"f",
"*",
"Frequency",
",",
"err",
"error",
")",
"{",
"f",
"=",
"prof",
".",
"newFrequency",
"(",
")",
"\n",
"err",
"=",
"prof",
".",
"Reset",
"(",
")",
"\n",
"if",
"err",
"!=",
... | // Get returns Frequency information. | [
"Get",
"returns",
"Frequency",
"information",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/cpufreq_unix.go#L191-L251 |
147,667 | mohae/joefriday | cpu/cpufreq/cpufreq_unix.go | Get | func Get() (f *Frequency, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (f *Frequency, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"f",
"*",
"Frequency",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
"NewProfiler",
"("... | // Get returns Frequency using the package's global Profiler. | [
"Get",
"returns",
"Frequency",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/cpufreq_unix.go#L257-L267 |
147,668 | mohae/joefriday | joefriday.go | IsReadError | func IsReadError(e error) bool {
if _, ok := e.(*ReadError); ok {
return true
}
return false
} | go | func IsReadError(e error) bool {
if _, ok := e.(*ReadError); ok {
return true
}
return false
} | [
"func",
"IsReadError",
"(",
"e",
"error",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"ReadError",
")",
";",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsReadError returns a boolean indicating whether the error is a result of
// a read problem. | [
"IsReadError",
"returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"error",
"is",
"a",
"result",
"of",
"a",
"read",
"problem",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L87-L92 |
147,669 | mohae/joefriday | joefriday.go | IsResetError | func IsResetError(e error) bool {
if _, ok := e.(*ResetError); ok {
return true
}
return false
} | go | func IsResetError(e error) bool {
if _, ok := e.(*ResetError); ok {
return true
}
return false
} | [
"func",
"IsResetError",
"(",
"e",
"error",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"ResetError",
")",
";",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsResetError returns a boolean indicating whether the error is a result of
// a problem resetting the file buffer. | [
"IsResetError",
"returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"error",
"is",
"a",
"result",
"of",
"a",
"problem",
"resetting",
"the",
"file",
"buffer",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L96-L101 |
147,670 | mohae/joefriday | joefriday.go | IsParseError | func IsParseError(e error) bool {
if _, ok := e.(*ParseError); ok {
return true
}
return false
} | go | func IsParseError(e error) bool {
if _, ok := e.(*ParseError); ok {
return true
}
return false
} | [
"func",
"IsParseError",
"(",
"e",
"error",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"ParseError",
")",
";",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsParseError r eturns a boolean indicating whether the error is a result of
// encountering a problem while trying to parse the file data. | [
"IsParseError",
"r",
"eturns",
"a",
"boolean",
"indicating",
"whether",
"the",
"error",
"is",
"a",
"result",
"of",
"encountering",
"a",
"problem",
"while",
"trying",
"to",
"parse",
"the",
"file",
"data",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L105-L110 |
147,671 | mohae/joefriday | joefriday.go | NewProc | func NewProc(fname string) (*Proc, error) {
f, err := os.Open(fname)
if err != nil {
return nil, err
}
return &Proc{File: f, Buf: bufio.NewReader(f)}, nil
} | go | func NewProc(fname string) (*Proc, error) {
f, err := os.Open(fname)
if err != nil {
return nil, err
}
return &Proc{File: f, Buf: bufio.NewReader(f)}, nil
} | [
"func",
"NewProc",
"(",
"fname",
"string",
")",
"(",
"*",
"Proc",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
... | // NewProc Creates a Proc using the file handle. | [
"NewProc",
"Creates",
"a",
"Proc",
"using",
"the",
"file",
"handle",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L125-L131 |
147,672 | mohae/joefriday | joefriday.go | Close | func (t *Ticker) Close() {
t.Ticker.Stop()
close(t.Done)
close(t.Errs)
} | go | func (t *Ticker) Close() {
t.Ticker.Stop()
close(t.Done)
close(t.Errs)
} | [
"func",
"(",
"t",
"*",
"Ticker",
")",
"Close",
"(",
")",
"{",
"t",
".",
"Ticker",
".",
"Stop",
"(",
")",
"\n",
"close",
"(",
"t",
".",
"Done",
")",
"\n",
"close",
"(",
"t",
".",
"Errs",
")",
"\n",
"}"
] | // Close stops the ticker and closes the ticker resources. | [
"Close",
"stops",
"the",
"ticker",
"and",
"closes",
"the",
"ticker",
"resources",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L171-L175 |
147,673 | mohae/joefriday | joefriday.go | Int64Column | func Int64Column(w int, v int64) string {
s := strconv.FormatInt(v, 10)
return Column(w, s)
} | go | func Int64Column(w int, v int64) string {
s := strconv.FormatInt(v, 10)
return Column(w, s)
} | [
"func",
"Int64Column",
"(",
"w",
"int",
",",
"v",
"int64",
")",
"string",
"{",
"s",
":=",
"strconv",
".",
"FormatInt",
"(",
"v",
",",
"10",
")",
"\n",
"return",
"Column",
"(",
"w",
",",
"s",
")",
"\n",
"}"
] | // Int64Column takes an int64 and returns a right justified string of width w. | [
"Int64Column",
"takes",
"an",
"int64",
"and",
"returns",
"a",
"right",
"justified",
"string",
"of",
"width",
"w",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L189-L192 |
147,674 | mohae/joefriday | joefriday.go | TrimTrailingSpaces | func TrimTrailingSpaces(p []byte) []byte {
for i := len(p) - 1; i >= 0; i-- {
if p[i] != 0x20 && p[i] != '\n' && p[i] != '\t' {
return p[:i+1]
}
}
// it was all spaces
return p[:0]
} | go | func TrimTrailingSpaces(p []byte) []byte {
for i := len(p) - 1; i >= 0; i-- {
if p[i] != 0x20 && p[i] != '\n' && p[i] != '\t' {
return p[:i+1]
}
}
// it was all spaces
return p[:0]
} | [
"func",
"TrimTrailingSpaces",
"(",
"p",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"for",
"i",
":=",
"len",
"(",
"p",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
"p",
"[",
"i",
"]",
"!=",
"0x20",
"&&",
"p",
"[",
"i",... | // TrimTrailingSpaces removes the trailing spaces from a slice and returns
// it. Only 0x20, tabs, NL are considered space characters. | [
"TrimTrailingSpaces",
"removes",
"the",
"trailing",
"spaces",
"from",
"a",
"slice",
"and",
"returns",
"it",
".",
"Only",
"0x20",
"tabs",
"NL",
"are",
"considered",
"space",
"characters",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L196-L204 |
147,675 | mohae/joefriday | joefriday.go | TrimLeadingSpaces | func TrimLeadingSpaces(p []byte) []byte {
for i := 0; i < len(p); i++ {
if p[i] != 0x20 && p[i] != '\t' {
return p[i:]
}
}
// it was all spaces
return p[:0]
} | go | func TrimLeadingSpaces(p []byte) []byte {
for i := 0; i < len(p); i++ {
if p[i] != 0x20 && p[i] != '\t' {
return p[i:]
}
}
// it was all spaces
return p[:0]
} | [
"func",
"TrimLeadingSpaces",
"(",
"p",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"p",
")",
";",
"i",
"++",
"{",
"if",
"p",
"[",
"i",
"]",
"!=",
"0x20",
"&&",
"p",
"[",
"i",
"]",
"!=",
... | // TrimLeadingpaces removes the leading spaces from a slice and returns it.
// Only 0x20 and tabs are considered space characters. | [
"TrimLeadingpaces",
"removes",
"the",
"leading",
"spaces",
"from",
"a",
"slice",
"and",
"returns",
"it",
".",
"Only",
"0x20",
"and",
"tabs",
"are",
"considered",
"space",
"characters",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L208-L216 |
147,676 | mohae/joefriday | joefriday.go | NewTempFileProc | func NewTempFileProc(prefix, name string, data []byte) (proc *TempFileProc, err error) {
var t TempFileProc
if prefix == "" {
t.Dir = os.TempDir()
} else {
t.Dir, err = ioutil.TempDir("", prefix)
if err != nil {
return nil, err
}
}
if name == "" {
name = string(randchars.AlphaNum(12))
}
t.Name = nam... | go | func NewTempFileProc(prefix, name string, data []byte) (proc *TempFileProc, err error) {
var t TempFileProc
if prefix == "" {
t.Dir = os.TempDir()
} else {
t.Dir, err = ioutil.TempDir("", prefix)
if err != nil {
return nil, err
}
}
if name == "" {
name = string(randchars.AlphaNum(12))
}
t.Name = nam... | [
"func",
"NewTempFileProc",
"(",
"prefix",
",",
"name",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"proc",
"*",
"TempFileProc",
",",
"err",
"error",
")",
"{",
"var",
"t",
"TempFileProc",
"\n",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"t",
".",
... | // NewTempFileProc creates a temporary file with data as its contents and
// returns a TempFileProc that uses the temporary file. The file will be saved
// in a randomly generated tempdir that starts with prefix. If prefix is empty
// the os.TempDir will be used as the save directory. Name is the name of the
// tempora... | [
"NewTempFileProc",
"creates",
"a",
"temporary",
"file",
"with",
"data",
"as",
"its",
"contents",
"and",
"returns",
"a",
"TempFileProc",
"that",
"uses",
"the",
"temporary",
"file",
".",
"The",
"file",
"will",
"be",
"saved",
"in",
"a",
"randomly",
"generated",
... | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L236-L262 |
147,677 | mohae/joefriday | joefriday.go | FullPath | func (p *TempFileProc) FullPath() string {
return filepath.Join(p.Dir, p.Name)
} | go | func (p *TempFileProc) FullPath() string {
return filepath.Join(p.Dir, p.Name)
} | [
"func",
"(",
"p",
"*",
"TempFileProc",
")",
"FullPath",
"(",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"p",
".",
"Dir",
",",
"p",
".",
"Name",
")",
"\n",
"}"
] | // Returns the full path of the temp file for this TempFileProc. | [
"Returns",
"the",
"full",
"path",
"of",
"the",
"temp",
"file",
"for",
"this",
"TempFileProc",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L265-L267 |
147,678 | mohae/joefriday | joefriday.go | ReadSlice | func (p *TempFileProc) ReadSlice(delim byte) (line []byte, err error) {
return p.Buf.ReadSlice(delim)
} | go | func (p *TempFileProc) ReadSlice(delim byte) (line []byte, err error) {
return p.Buf.ReadSlice(delim)
} | [
"func",
"(",
"p",
"*",
"TempFileProc",
")",
"ReadSlice",
"(",
"delim",
"byte",
")",
"(",
"line",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"p",
".",
"Buf",
".",
"ReadSlice",
"(",
"delim",
")",
"\n",
"}"
] | // ReadSlice is a wrapper for bufio.Reader.ReadSlice. | [
"ReadSlice",
"is",
"a",
"wrapper",
"for",
"bufio",
".",
"Reader",
".",
"ReadSlice",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L270-L272 |
147,679 | mohae/joefriday | joefriday.go | Reset | func (p *TempFileProc) Reset() error {
_, err := p.File.Seek(0, os.SEEK_SET)
if err != nil {
return &ResetError{err}
}
p.Buf.Reset(p.File)
return nil
} | go | func (p *TempFileProc) Reset() error {
_, err := p.File.Seek(0, os.SEEK_SET)
if err != nil {
return &ResetError{err}
}
p.Buf.Reset(p.File)
return nil
} | [
"func",
"(",
"p",
"*",
"TempFileProc",
")",
"Reset",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"p",
".",
"File",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"ResetError",
"{",... | // Reset reset's the profiler's resources. | [
"Reset",
"reset",
"s",
"the",
"profiler",
"s",
"resources",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L275-L282 |
147,680 | mohae/joefriday | joefriday.go | Remove | func (p *TempFileProc) Remove() error {
// only remove the directory if it is a subdir of the default temp dir.
if p.Dir != os.TempDir() {
os.RemoveAll(p.Dir)
}
// otherwise just remove the file
return os.RemoveAll(p.FullPath())
} | go | func (p *TempFileProc) Remove() error {
// only remove the directory if it is a subdir of the default temp dir.
if p.Dir != os.TempDir() {
os.RemoveAll(p.Dir)
}
// otherwise just remove the file
return os.RemoveAll(p.FullPath())
} | [
"func",
"(",
"p",
"*",
"TempFileProc",
")",
"Remove",
"(",
")",
"error",
"{",
"// only remove the directory if it is a subdir of the default temp dir.",
"if",
"p",
".",
"Dir",
"!=",
"os",
".",
"TempDir",
"(",
")",
"{",
"os",
".",
"RemoveAll",
"(",
"p",
".",
... | // Remove removes the temp dir and temp file. | [
"Remove",
"removes",
"the",
"temp",
"dir",
"and",
"temp",
"file",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L285-L292 |
147,681 | mohae/joefriday | joefriday.go | Reset | func (b *Buffer) Reset() {
b.Line = b.Line[:0]
b.Val = b.Val[:0]
} | go | func (b *Buffer) Reset() {
b.Line = b.Line[:0]
b.Val = b.Val[:0]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Reset",
"(",
")",
"{",
"b",
".",
"Line",
"=",
"b",
".",
"Line",
"[",
":",
"0",
"]",
"\n",
"b",
".",
"Val",
"=",
"b",
".",
"Val",
"[",
":",
"0",
"]",
"\n",
"}"
] | // Reset resets the Buffer's slices len to 0 so that they can be re-used. | [
"Reset",
"resets",
"the",
"Buffer",
"s",
"slices",
"len",
"to",
"0",
"so",
"that",
"they",
"can",
"be",
"re",
"-",
"used",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/joefriday.go#L306-L309 |
147,682 | mohae/joefriday | node/json/node_unix.go | Marshal | func (prof *Profiler) Marshal(nodes *numa.Nodes) ([]byte, error) {
return prof.Serialize(nodes)
} | go | func (prof *Profiler) Marshal(nodes *numa.Nodes) ([]byte, error) {
return prof.Serialize(nodes)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Marshal",
"(",
"nodes",
"*",
"numa",
".",
"Nodes",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"prof",
".",
"Serialize",
"(",
"nodes",
")",
"\n",
"}"
] | // Marshal is an alias for serialize. | [
"Marshal",
"is",
"an",
"alias",
"for",
"serialize",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/json/node_unix.go#L82-L84 |
147,683 | mohae/joefriday | node/json/node_unix.go | Deserialize | func Deserialize(p []byte) (*numa.Nodes, error) {
nodes := &numa.Nodes{}
err := json.Unmarshal(p, nodes)
if err != nil {
return nil, err
}
return nodes, nil
} | go | func Deserialize(p []byte) (*numa.Nodes, error) {
nodes := &numa.Nodes{}
err := json.Unmarshal(p, nodes)
if err != nil {
return nil, err
}
return nodes, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"numa",
".",
"Nodes",
",",
"error",
")",
"{",
"nodes",
":=",
"&",
"numa",
".",
"Nodes",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"nodes",
")",
"\n",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// node.Nodes. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"node",
".",
"Nodes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/node/json/node_unix.go#L93-L100 |
147,684 | mohae/joefriday | system/version/json/version_unix.go | Serialize | func Serialize(k *v.Kernel) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(k)
} | go | func Serialize(k *v.Kernel) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Serialize(k)
} | [
"func",
"Serialize",
"(",
"k",
"*",
"v",
".",
"Kernel",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std... | // Serialize version.Kernel as JSON using the package's global Profiler. | [
"Serialize",
"version",
".",
"Kernel",
"as",
"JSON",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/version/json/version_unix.go#L78-L88 |
147,685 | mohae/joefriday | system/version/json/version_unix.go | Deserialize | func Deserialize(p []byte) (*v.Kernel, error) {
k := &v.Kernel{}
err := json.Unmarshal(p, k)
if err != nil {
return nil, err
}
return k, nil
} | go | func Deserialize(p []byte) (*v.Kernel, error) {
k := &v.Kernel{}
err := json.Unmarshal(p, k)
if err != nil {
return nil, err
}
return k, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"v",
".",
"Kernel",
",",
"error",
")",
"{",
"k",
":=",
"&",
"v",
".",
"Kernel",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"k",
")",
"\n",
"if",
"e... | // Deserialize takes some JSON serialized bytes and deserializes them as
// version.Kernel. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"version",
".",
"Kernel",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/version/json/version_unix.go#L102-L109 |
147,686 | mohae/joefriday | cpu/cpustats/cpustats_unix.go | ClkTck | func ClkTck() error {
tckMu.Lock()
defer tckMu.Unlock()
var out bytes.Buffer
cmd := exec.Command("getconf", "CLK_TCK")
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return fmt.Errorf("get CLK_TCK: %s", err)
}
b, err := out.ReadBytes('\n')
if err != nil {
return fmt.Errorf("err CLK_TCK: %s", err)
}
... | go | func ClkTck() error {
tckMu.Lock()
defer tckMu.Unlock()
var out bytes.Buffer
cmd := exec.Command("getconf", "CLK_TCK")
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return fmt.Errorf("get CLK_TCK: %s", err)
}
b, err := out.ReadBytes('\n')
if err != nil {
return fmt.Errorf("err CLK_TCK: %s", err)
}
... | [
"func",
"ClkTck",
"(",
")",
"error",
"{",
"tckMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tckMu",
".",
"Unlock",
"(",
")",
"\n",
"var",
"out",
"bytes",
".",
"Buffer",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
... | // Set CLK_TCK. | [
"Set",
"CLK_TCK",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpustats/cpustats_unix.go#L39-L59 |
147,687 | mohae/joefriday | cpu/cpustats/cpustats_unix.go | Get | func Get() (stat *CPUStats, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (stat *CPUStats, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"stat",
"*",
"CPUStats",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
"NewProfiler",
"... | // Get returns the current kernel activity information using the package's
// global Profiler. | [
"Get",
"returns",
"the",
"current",
"kernel",
"activity",
"information",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpustats/cpustats_unix.go#L257-L267 |
147,688 | mohae/joefriday | system/loadavg/loadavg_unix.go | Get | func Get() (la LoadAvg, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return la, err
}
}
return std.Get()
} | go | func Get() (la LoadAvg, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return la, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"la",
"LoadAvg",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
"NewProfiler",
"(",
")",... | // Get gets the loadavg information using the package's global Profiler. | [
"Get",
"gets",
"the",
"loadavg",
"information",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/loadavg/loadavg_unix.go#L143-L153 |
147,689 | mohae/joefriday | cpu/cpux/json/cpux_unix.go | Serialize | func (prof *Profiler) Serialize(cpus *x.CPUs) ([]byte, error) {
return json.Marshal(cpus)
} | go | func (prof *Profiler) Serialize(cpus *x.CPUs) ([]byte, error) {
return json.Marshal(cpus)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"cpus",
"*",
"x",
".",
"CPUs",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"cpus",
")",
"\n",
"}"
] | // Serialize cpux.CPUs as JSON. | [
"Serialize",
"cpux",
".",
"CPUs",
"as",
"JSON",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/json/cpux_unix.go#L69-L71 |
147,690 | mohae/joefriday | cpu/cpux/json/cpux_unix.go | Serialize | func Serialize(cpus *x.CPUs) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(cpus)
} | go | func Serialize(cpus *x.CPUs) (p []byte, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std = NewProfiler()
}
return std.Serialize(cpus)
} | [
"func",
"Serialize",
"(",
"cpus",
"*",
"x",
".",
"CPUs",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"st... | // Serialize cpux.CPUs as JSON using package globals. | [
"Serialize",
"cpux",
".",
"CPUs",
"as",
"JSON",
"using",
"package",
"globals",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/json/cpux_unix.go#L74-L81 |
147,691 | mohae/joefriday | cpu/cpux/json/cpux_unix.go | Deserialize | func Deserialize(p []byte) (*x.CPUs, error) {
cpus := &x.CPUs{}
err := json.Unmarshal(p, cpus)
if err != nil {
return nil, err
}
return cpus, nil
} | go | func Deserialize(p []byte) (*x.CPUs, error) {
cpus := &x.CPUs{}
err := json.Unmarshal(p, cpus)
if err != nil {
return nil, err
}
return cpus, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"x",
".",
"CPUs",
",",
"error",
")",
"{",
"cpus",
":=",
"&",
"x",
".",
"CPUs",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"cpus",
")",
"\n",
"if",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// cpux.CPUs. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"cpux",
".",
"CPUs",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpux/json/cpux_unix.go#L95-L102 |
147,692 | mohae/joefriday | system/version/flat/version_unix.go | Serialize | func (prof *Profiler) Serialize(k *v.Kernel) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
os := prof.Builder.CreateString(k.OS)
version := prof.Builder.CreateString(k.Version)
compileUser := prof.Builder.CreateString(k.CompileUser)
gcc := prof.Builder.CreateString(k.GCC)
osgcc := pro... | go | func (prof *Profiler) Serialize(k *v.Kernel) []byte {
// ensure the Builder is in a usable state.
prof.Builder.Reset()
os := prof.Builder.CreateString(k.OS)
version := prof.Builder.CreateString(k.Version)
compileUser := prof.Builder.CreateString(k.CompileUser)
gcc := prof.Builder.CreateString(k.GCC)
osgcc := pro... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"k",
"*",
"v",
".",
"Kernel",
")",
"[",
"]",
"byte",
"{",
"// ensure the Builder is in a usable state.",
"prof",
".",
"Builder",
".",
"Reset",
"(",
")",
"\n",
"os",
":=",
"prof",
".",
"Builder"... | // Serialize version.Kernel as Flatbuffers. | [
"Serialize",
"version",
".",
"Kernel",
"as",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/version/flat/version_unix.go#L75-L101 |
147,693 | mohae/joefriday | system/version/flat/version_unix.go | Deserialize | func Deserialize(p []byte) *v.Kernel {
flatK := structs.GetRootAsKernel(p, 0)
var k v.Kernel
k.OS = string(flatK.OS())
k.Version = string(flatK.Version())
k.CompileUser = string(flatK.CompileUser())
k.GCC = string(flatK.GCC())
k.OSGCC = string(flatK.OSGCC())
k.Type = string(flatK.Type())
k.CompileDate = string... | go | func Deserialize(p []byte) *v.Kernel {
flatK := structs.GetRootAsKernel(p, 0)
var k v.Kernel
k.OS = string(flatK.OS())
k.Version = string(flatK.Version())
k.CompileUser = string(flatK.CompileUser())
k.GCC = string(flatK.GCC())
k.OSGCC = string(flatK.OSGCC())
k.Type = string(flatK.Type())
k.CompileDate = string... | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"v",
".",
"Kernel",
"{",
"flatK",
":=",
"structs",
".",
"GetRootAsKernel",
"(",
"p",
",",
"0",
")",
"\n",
"var",
"k",
"v",
".",
"Kernel",
"\n",
"k",
".",
"OS",
"=",
"string",
"(",
"fl... | // Deserialize takes some Flatbuffer serialized bytes and deserializes them as
// version.Kernel. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserializes",
"them",
"as",
"version",
".",
"Kernel",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/system/version/flat/version_unix.go#L118-L130 |
147,694 | MEDIGO/go-healthz | healthz.go | NewChecker | func NewChecker(config *Config) *Checker {
if config == nil {
config = &Config{}
}
if config.RuntimeTTL == 0 {
config.RuntimeTTL = DefaultRuntimeTTL
}
return &Checker{
since: time.Now(),
metadata: make(map[string]interface{}),
checks: make(map[string]*check),
runtimeTTL: config.RuntimeTTL,... | go | func NewChecker(config *Config) *Checker {
if config == nil {
config = &Config{}
}
if config.RuntimeTTL == 0 {
config.RuntimeTTL = DefaultRuntimeTTL
}
return &Checker{
since: time.Now(),
metadata: make(map[string]interface{}),
checks: make(map[string]*check),
runtimeTTL: config.RuntimeTTL,... | [
"func",
"NewChecker",
"(",
"config",
"*",
"Config",
")",
"*",
"Checker",
"{",
"if",
"config",
"==",
"nil",
"{",
"config",
"=",
"&",
"Config",
"{",
"}",
"\n",
"}",
"\n\n",
"if",
"config",
".",
"RuntimeTTL",
"==",
"0",
"{",
"config",
".",
"RuntimeTTL",... | // NewChecker creates a new Checker. | [
"NewChecker",
"creates",
"a",
"new",
"Checker",
"."
] | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L103-L118 |
147,695 | MEDIGO/go-healthz | healthz.go | Set | func (c *Checker) Set(name string, value interface{}) {
c.metadata[name] = value
} | go | func (c *Checker) Set(name string, value interface{}) {
c.metadata[name] = value
} | [
"func",
"(",
"c",
"*",
"Checker",
")",
"Set",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"metadata",
"[",
"name",
"]",
"=",
"value",
"\n",
"}"
] | // Set sets a name value pair as a metadata entry to be returned with earch response.
// This can be used to store useful debug informaton like version numbers
// or git commit shas. | [
"Set",
"sets",
"a",
"name",
"value",
"pair",
"as",
"a",
"metadata",
"entry",
"to",
"be",
"returned",
"with",
"earch",
"response",
".",
"This",
"can",
"be",
"used",
"to",
"store",
"useful",
"debug",
"informaton",
"like",
"version",
"numbers",
"or",
"git",
... | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L123-L125 |
147,696 | MEDIGO/go-healthz | healthz.go | Register | func (c *Checker) Register(name string, period time.Duration, fn CheckFunc) {
c.mutex.Lock()
defer c.mutex.Unlock()
if check := c.checks[name]; check != nil {
check.Close()
}
check := &check{
period: period,
fn: fn,
err: errors.New("pending"),
stopch: make(chan bool, 1),
}
go check.Do()
c.c... | go | func (c *Checker) Register(name string, period time.Duration, fn CheckFunc) {
c.mutex.Lock()
defer c.mutex.Unlock()
if check := c.checks[name]; check != nil {
check.Close()
}
check := &check{
period: period,
fn: fn,
err: errors.New("pending"),
stopch: make(chan bool, 1),
}
go check.Do()
c.c... | [
"func",
"(",
"c",
"*",
"Checker",
")",
"Register",
"(",
"name",
"string",
",",
"period",
"time",
".",
"Duration",
",",
"fn",
"CheckFunc",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")... | // Register registers a check to be evaluated each given period. | [
"Register",
"registers",
"a",
"check",
"to",
"be",
"evaluated",
"each",
"given",
"period",
"."
] | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L133-L151 |
147,697 | MEDIGO/go-healthz | healthz.go | Deregister | func (c *Checker) Deregister(name string) {
c.mutex.Lock()
defer c.mutex.Unlock()
check := c.checks[name]
if check == nil {
return
}
check.Close()
delete(c.checks, name)
} | go | func (c *Checker) Deregister(name string) {
c.mutex.Lock()
defer c.mutex.Unlock()
check := c.checks[name]
if check == nil {
return
}
check.Close()
delete(c.checks, name)
} | [
"func",
"(",
"c",
"*",
"Checker",
")",
"Deregister",
"(",
"name",
"string",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"check",
":=",
"c",
".",
"checks",
"[",
"name",
"... | // Deregister deregisters a check. | [
"Deregister",
"deregisters",
"a",
"check",
"."
] | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L154-L166 |
147,698 | MEDIGO/go-healthz | healthz.go | Status | func (c *Checker) Status() Status {
c.mutex.Lock()
defer c.mutex.Unlock()
now := time.Now()
if c.runtime.CollectedAt.Add(c.runtimeTTL).Before(now) {
c.runtime = collect()
}
failures := make(map[string]string)
for name, check := range c.checks {
if err := check.Status(); err != nil {
failures[name] = er... | go | func (c *Checker) Status() Status {
c.mutex.Lock()
defer c.mutex.Unlock()
now := time.Now()
if c.runtime.CollectedAt.Add(c.runtimeTTL).Before(now) {
c.runtime = collect()
}
failures := make(map[string]string)
for name, check := range c.checks {
if err := check.Status(); err != nil {
failures[name] = er... | [
"func",
"(",
"c",
"*",
"Checker",
")",
"Status",
"(",
")",
"Status",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"if",
"c... | // Status returns the current service status. | [
"Status",
"returns",
"the",
"current",
"service",
"status",
"."
] | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L178-L208 |
147,699 | MEDIGO/go-healthz | healthz.go | Register | func Register(name string, period time.Duration, fn CheckFunc) {
DefaultChecker.Register(name, period, fn)
} | go | func Register(name string, period time.Duration, fn CheckFunc) {
DefaultChecker.Register(name, period, fn)
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"period",
"time",
".",
"Duration",
",",
"fn",
"CheckFunc",
")",
"{",
"DefaultChecker",
".",
"Register",
"(",
"name",
",",
"period",
",",
"fn",
")",
"\n",
"}"
] | // Register is a shortcut for DefaultChecker.Register. See there for more information. | [
"Register",
"is",
"a",
"shortcut",
"for",
"DefaultChecker",
".",
"Register",
".",
"See",
"there",
"for",
"more",
"information",
"."
] | 9b0725fef6573efc0aacf442d5461ab25590985e | https://github.com/MEDIGO/go-healthz/blob/9b0725fef6573efc0aacf442d5461ab25590985e/healthz.go#L237-L239 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.