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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,500 | hashicorp/nomad | client/stats/cpu.go | TicksConsumed | func (c *CpuStats) TicksConsumed(percent float64) float64 {
return (percent / 100) * shelpers.TotalTicksAvailable() / float64(c.totalCpus)
} | go | func (c *CpuStats) TicksConsumed(percent float64) float64 {
return (percent / 100) * shelpers.TotalTicksAvailable() / float64(c.totalCpus)
} | [
"func",
"(",
"c",
"*",
"CpuStats",
")",
"TicksConsumed",
"(",
"percent",
"float64",
")",
"float64",
"{",
"return",
"(",
"percent",
"/",
"100",
")",
"*",
"shelpers",
".",
"TotalTicksAvailable",
"(",
")",
"/",
"float64",
"(",
"c",
".",
"totalCpus",
")",
... | // TicksConsumed calculates the total ticks consumes by the process across all
// cpu cores | [
"TicksConsumed",
"calculates",
"the",
"total",
"ticks",
"consumes",
"by",
"the",
"process",
"across",
"all",
"cpu",
"cores"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/stats/cpu.go#L49-L51 |
133,501 | hashicorp/nomad | client/fingerprint/env_aws.go | NewEnvAWSFingerprint | func NewEnvAWSFingerprint(logger log.Logger) Fingerprint {
f := &EnvAWSFingerprint{
logger: logger.Named("env_aws"),
timeout: AwsMetadataTimeout,
}
return f
} | go | func NewEnvAWSFingerprint(logger log.Logger) Fingerprint {
f := &EnvAWSFingerprint{
logger: logger.Named("env_aws"),
timeout: AwsMetadataTimeout,
}
return f
} | [
"func",
"NewEnvAWSFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"f",
":=",
"&",
"EnvAWSFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"timeout",
":",
"AwsMetadataTimeout",
",",
"}",
"\n",
... | // NewEnvAWSFingerprint is used to create a fingerprint from AWS metadata | [
"NewEnvAWSFingerprint",
"is",
"used",
"to",
"create",
"a",
"fingerprint",
"from",
"AWS",
"metadata"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/env_aws.go#L58-L64 |
133,502 | hashicorp/nomad | client/fingerprint/env_aws.go | linkSpeed | func (f *EnvAWSFingerprint) linkSpeed() int {
// Query the API for the instance type, and use the table above to approximate
// the network speed
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = DEFAULT_AWS_URL
}
client := &http.Client{
Timeout: f.timeout,
Transport: cleanhtt... | go | func (f *EnvAWSFingerprint) linkSpeed() int {
// Query the API for the instance type, and use the table above to approximate
// the network speed
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = DEFAULT_AWS_URL
}
client := &http.Client{
Timeout: f.timeout,
Transport: cleanhtt... | [
"func",
"(",
"f",
"*",
"EnvAWSFingerprint",
")",
"linkSpeed",
"(",
")",
"int",
"{",
"// Query the API for the instance type, and use the table above to approximate",
"// the network speed",
"metadataURL",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"m... | // EnvAWSFingerprint uses lookup table to approximate network speeds | [
"EnvAWSFingerprint",
"uses",
"lookup",
"table",
"to",
"approximate",
"network",
"speeds"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/env_aws.go#L221-L258 |
133,503 | hashicorp/nomad | scheduler/reconcile_util.go | newAllocMatrix | func newAllocMatrix(job *structs.Job, allocs []*structs.Allocation) allocMatrix {
m := allocMatrix(make(map[string]allocSet))
for _, a := range allocs {
s, ok := m[a.TaskGroup]
if !ok {
s = make(map[string]*structs.Allocation)
m[a.TaskGroup] = s
}
s[a.ID] = a
}
if job != nil {
for _, tg := range jo... | go | func newAllocMatrix(job *structs.Job, allocs []*structs.Allocation) allocMatrix {
m := allocMatrix(make(map[string]allocSet))
for _, a := range allocs {
s, ok := m[a.TaskGroup]
if !ok {
s = make(map[string]*structs.Allocation)
m[a.TaskGroup] = s
}
s[a.ID] = a
}
if job != nil {
for _, tg := range jo... | [
"func",
"newAllocMatrix",
"(",
"job",
"*",
"structs",
".",
"Job",
",",
"allocs",
"[",
"]",
"*",
"structs",
".",
"Allocation",
")",
"allocMatrix",
"{",
"m",
":=",
"allocMatrix",
"(",
"make",
"(",
"map",
"[",
"string",
"]",
"allocSet",
")",
")",
"\n",
... | // newAllocMatrix takes a job and the existing allocations for the job and
// creates an allocMatrix | [
"newAllocMatrix",
"takes",
"a",
"job",
"and",
"the",
"existing",
"allocations",
"for",
"the",
"job",
"and",
"creates",
"an",
"allocMatrix"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L87-L106 |
133,504 | hashicorp/nomad | scheduler/reconcile_util.go | GoString | func (a allocSet) GoString() string {
if len(a) == 0 {
return "[]"
}
start := fmt.Sprintf("len(%d) [\n", len(a))
var s []string
for k, v := range a {
s = append(s, fmt.Sprintf("%q: %v", k, v.Name))
}
return start + strings.Join(s, "\n") + "]"
} | go | func (a allocSet) GoString() string {
if len(a) == 0 {
return "[]"
}
start := fmt.Sprintf("len(%d) [\n", len(a))
var s []string
for k, v := range a {
s = append(s, fmt.Sprintf("%q: %v", k, v.Name))
}
return start + strings.Join(s, "\n") + "]"
} | [
"func",
"(",
"a",
"allocSet",
")",
"GoString",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"a",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"start",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"len",
"(",
"a",
"... | // GoString provides a human readable view of the set | [
"GoString",
"provides",
"a",
"human",
"readable",
"view",
"of",
"the",
"set"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L113-L124 |
133,505 | hashicorp/nomad | scheduler/reconcile_util.go | nameSet | func (a allocSet) nameSet() map[string]struct{} {
names := make(map[string]struct{}, len(a))
for _, alloc := range a {
names[alloc.Name] = struct{}{}
}
return names
} | go | func (a allocSet) nameSet() map[string]struct{} {
names := make(map[string]struct{}, len(a))
for _, alloc := range a {
names[alloc.Name] = struct{}{}
}
return names
} | [
"func",
"(",
"a",
"allocSet",
")",
"nameSet",
"(",
")",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"names",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"_",
",",
"all... | // nameSet returns the set of allocation names | [
"nameSet",
"returns",
"the",
"set",
"of",
"allocation",
"names"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L127-L133 |
133,506 | hashicorp/nomad | scheduler/reconcile_util.go | nameOrder | func (a allocSet) nameOrder() []*structs.Allocation {
allocs := make([]*structs.Allocation, 0, len(a))
for _, alloc := range a {
allocs = append(allocs, alloc)
}
sort.Slice(allocs, func(i, j int) bool {
return allocs[i].Index() < allocs[j].Index()
})
return allocs
} | go | func (a allocSet) nameOrder() []*structs.Allocation {
allocs := make([]*structs.Allocation, 0, len(a))
for _, alloc := range a {
allocs = append(allocs, alloc)
}
sort.Slice(allocs, func(i, j int) bool {
return allocs[i].Index() < allocs[j].Index()
})
return allocs
} | [
"func",
"(",
"a",
"allocSet",
")",
"nameOrder",
"(",
")",
"[",
"]",
"*",
"structs",
".",
"Allocation",
"{",
"allocs",
":=",
"make",
"(",
"[",
"]",
"*",
"structs",
".",
"Allocation",
",",
"0",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"_",
",... | // nameOrder returns the set of allocation names in sorted order | [
"nameOrder",
"returns",
"the",
"set",
"of",
"allocation",
"names",
"in",
"sorted",
"order"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L136-L145 |
133,507 | hashicorp/nomad | scheduler/reconcile_util.go | difference | func (a allocSet) difference(others ...allocSet) allocSet {
diff := make(map[string]*structs.Allocation)
OUTER:
for k, v := range a {
for _, other := range others {
if _, ok := other[k]; ok {
continue OUTER
}
}
diff[k] = v
}
return diff
} | go | func (a allocSet) difference(others ...allocSet) allocSet {
diff := make(map[string]*structs.Allocation)
OUTER:
for k, v := range a {
for _, other := range others {
if _, ok := other[k]; ok {
continue OUTER
}
}
diff[k] = v
}
return diff
} | [
"func",
"(",
"a",
"allocSet",
")",
"difference",
"(",
"others",
"...",
"allocSet",
")",
"allocSet",
"{",
"diff",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Allocation",
")",
"\n",
"OUTER",
":",
"for",
"k",
",",
"v",
":=",
"... | // difference returns a new allocSet that has all the existing item except those
// contained within the other allocation sets | [
"difference",
"returns",
"a",
"new",
"allocSet",
"that",
"has",
"all",
"the",
"existing",
"item",
"except",
"those",
"contained",
"within",
"the",
"other",
"allocation",
"sets"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L149-L161 |
133,508 | hashicorp/nomad | scheduler/reconcile_util.go | union | func (a allocSet) union(others ...allocSet) allocSet {
union := make(map[string]*structs.Allocation, len(a))
order := []allocSet{a}
order = append(order, others...)
for _, set := range order {
for k, v := range set {
union[k] = v
}
}
return union
} | go | func (a allocSet) union(others ...allocSet) allocSet {
union := make(map[string]*structs.Allocation, len(a))
order := []allocSet{a}
order = append(order, others...)
for _, set := range order {
for k, v := range set {
union[k] = v
}
}
return union
} | [
"func",
"(",
"a",
"allocSet",
")",
"union",
"(",
"others",
"...",
"allocSet",
")",
"allocSet",
"{",
"union",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Allocation",
",",
"len",
"(",
"a",
")",
")",
"\n",
"order",
":=",
"[",
... | // union returns a new allocSet that has the union of the two allocSets.
// Conflicts prefer the last passed allocSet containing the value | [
"union",
"returns",
"a",
"new",
"allocSet",
"that",
"has",
"the",
"union",
"of",
"the",
"two",
"allocSets",
".",
"Conflicts",
"prefer",
"the",
"last",
"passed",
"allocSet",
"containing",
"the",
"value"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L165-L177 |
133,509 | hashicorp/nomad | scheduler/reconcile_util.go | fromKeys | func (a allocSet) fromKeys(keys ...[]string) allocSet {
from := make(map[string]*structs.Allocation)
for _, set := range keys {
for _, k := range set {
if alloc, ok := a[k]; ok {
from[k] = alloc
}
}
}
return from
} | go | func (a allocSet) fromKeys(keys ...[]string) allocSet {
from := make(map[string]*structs.Allocation)
for _, set := range keys {
for _, k := range set {
if alloc, ok := a[k]; ok {
from[k] = alloc
}
}
}
return from
} | [
"func",
"(",
"a",
"allocSet",
")",
"fromKeys",
"(",
"keys",
"...",
"[",
"]",
"string",
")",
"allocSet",
"{",
"from",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Allocation",
")",
"\n",
"for",
"_",
",",
"set",
":=",
"range",
... | // fromKeys returns an alloc set matching the passed keys | [
"fromKeys",
"returns",
"an",
"alloc",
"set",
"matching",
"the",
"passed",
"keys"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L180-L190 |
133,510 | hashicorp/nomad | scheduler/reconcile_util.go | filterByRescheduleable | func (a allocSet) filterByRescheduleable(isBatch bool, now time.Time, evalID string, deployment *structs.Deployment) (untainted, rescheduleNow allocSet, rescheduleLater []*delayedRescheduleInfo) {
untainted = make(map[string]*structs.Allocation)
rescheduleNow = make(map[string]*structs.Allocation)
for _, alloc := r... | go | func (a allocSet) filterByRescheduleable(isBatch bool, now time.Time, evalID string, deployment *structs.Deployment) (untainted, rescheduleNow allocSet, rescheduleLater []*delayedRescheduleInfo) {
untainted = make(map[string]*structs.Allocation)
rescheduleNow = make(map[string]*structs.Allocation)
for _, alloc := r... | [
"func",
"(",
"a",
"allocSet",
")",
"filterByRescheduleable",
"(",
"isBatch",
"bool",
",",
"now",
"time",
".",
"Time",
",",
"evalID",
"string",
",",
"deployment",
"*",
"structs",
".",
"Deployment",
")",
"(",
"untainted",
",",
"rescheduleNow",
"allocSet",
",",... | // filterByRescheduleable filters the allocation set to return the set of allocations that are either
// untainted or a set of allocations that must be rescheduled now. Allocations that can be rescheduled
// at a future time are also returned so that we can create follow up evaluations for them. Allocs are
// skipped o... | [
"filterByRescheduleable",
"filters",
"the",
"allocation",
"set",
"to",
"return",
"the",
"set",
"of",
"allocations",
"that",
"are",
"either",
"untainted",
"or",
"a",
"set",
"of",
"allocations",
"that",
"must",
"be",
"rescheduled",
"now",
".",
"Allocations",
"that... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L237-L271 |
133,511 | hashicorp/nomad | scheduler/reconcile_util.go | updateByReschedulable | func updateByReschedulable(alloc *structs.Allocation, now time.Time, evalID string, d *structs.Deployment) (rescheduleNow, rescheduleLater bool, rescheduleTime time.Time) {
// If the allocation is part of an ongoing active deployment, we only allow it to reschedule
// if it has been marked eligible
if d != nil && al... | go | func updateByReschedulable(alloc *structs.Allocation, now time.Time, evalID string, d *structs.Deployment) (rescheduleNow, rescheduleLater bool, rescheduleTime time.Time) {
// If the allocation is part of an ongoing active deployment, we only allow it to reschedule
// if it has been marked eligible
if d != nil && al... | [
"func",
"updateByReschedulable",
"(",
"alloc",
"*",
"structs",
".",
"Allocation",
",",
"now",
"time",
".",
"Time",
",",
"evalID",
"string",
",",
"d",
"*",
"structs",
".",
"Deployment",
")",
"(",
"rescheduleNow",
",",
"rescheduleLater",
"bool",
",",
"reschedu... | // updateByReschedulable is a helper method that encapsulates logic for whether a failed allocation
// should be rescheduled now, later or left in the untainted set | [
"updateByReschedulable",
"is",
"a",
"helper",
"method",
"that",
"encapsulates",
"logic",
"for",
"whether",
"a",
"failed",
"allocation",
"should",
"be",
"rescheduled",
"now",
"later",
"or",
"left",
"in",
"the",
"untainted",
"set"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L323-L345 |
133,512 | hashicorp/nomad | scheduler/reconcile_util.go | filterByTerminal | func filterByTerminal(untainted allocSet) (nonTerminal allocSet) {
nonTerminal = make(map[string]*structs.Allocation)
for id, alloc := range untainted {
if !alloc.TerminalStatus() {
nonTerminal[id] = alloc
}
}
return
} | go | func filterByTerminal(untainted allocSet) (nonTerminal allocSet) {
nonTerminal = make(map[string]*structs.Allocation)
for id, alloc := range untainted {
if !alloc.TerminalStatus() {
nonTerminal[id] = alloc
}
}
return
} | [
"func",
"filterByTerminal",
"(",
"untainted",
"allocSet",
")",
"(",
"nonTerminal",
"allocSet",
")",
"{",
"nonTerminal",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Allocation",
")",
"\n",
"for",
"id",
",",
"alloc",
":=",
"range",
"... | // filterByTerminal filters out terminal allocs | [
"filterByTerminal",
"filters",
"out",
"terminal",
"allocs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L348-L356 |
133,513 | hashicorp/nomad | scheduler/reconcile_util.go | filterByDeployment | func (a allocSet) filterByDeployment(id string) (match, nonmatch allocSet) {
match = make(map[string]*structs.Allocation)
nonmatch = make(map[string]*structs.Allocation)
for _, alloc := range a {
if alloc.DeploymentID == id {
match[alloc.ID] = alloc
} else {
nonmatch[alloc.ID] = alloc
}
}
return
} | go | func (a allocSet) filterByDeployment(id string) (match, nonmatch allocSet) {
match = make(map[string]*structs.Allocation)
nonmatch = make(map[string]*structs.Allocation)
for _, alloc := range a {
if alloc.DeploymentID == id {
match[alloc.ID] = alloc
} else {
nonmatch[alloc.ID] = alloc
}
}
return
} | [
"func",
"(",
"a",
"allocSet",
")",
"filterByDeployment",
"(",
"id",
"string",
")",
"(",
"match",
",",
"nonmatch",
"allocSet",
")",
"{",
"match",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Allocation",
")",
"\n",
"nonmatch",
"=",... | // filterByDeployment filters allocations into two sets, those that match the
// given deployment ID and those that don't | [
"filterByDeployment",
"filters",
"allocations",
"into",
"two",
"sets",
"those",
"that",
"match",
"the",
"given",
"deployment",
"ID",
"and",
"those",
"that",
"don",
"t"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L360-L371 |
133,514 | hashicorp/nomad | scheduler/reconcile_util.go | newAllocNameIndex | func newAllocNameIndex(job, taskGroup string, count int, in allocSet) *allocNameIndex {
return &allocNameIndex{
count: count,
b: bitmapFrom(in, uint(count)),
job: job,
taskGroup: taskGroup,
}
} | go | func newAllocNameIndex(job, taskGroup string, count int, in allocSet) *allocNameIndex {
return &allocNameIndex{
count: count,
b: bitmapFrom(in, uint(count)),
job: job,
taskGroup: taskGroup,
}
} | [
"func",
"newAllocNameIndex",
"(",
"job",
",",
"taskGroup",
"string",
",",
"count",
"int",
",",
"in",
"allocSet",
")",
"*",
"allocNameIndex",
"{",
"return",
"&",
"allocNameIndex",
"{",
"count",
":",
"count",
",",
"b",
":",
"bitmapFrom",
"(",
"in",
",",
"u... | // newAllocNameIndex returns an allocNameIndex for use in selecting names of
// allocations to create or stop. It takes the job and task group name, desired
// count and any existing allocations as input. | [
"newAllocNameIndex",
"returns",
"an",
"allocNameIndex",
"for",
"use",
"in",
"selecting",
"names",
"of",
"allocations",
"to",
"create",
"or",
"stop",
".",
"It",
"takes",
"the",
"job",
"and",
"task",
"group",
"name",
"desired",
"count",
"and",
"any",
"existing",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L384-L391 |
133,515 | hashicorp/nomad | scheduler/reconcile_util.go | Highest | func (a *allocNameIndex) Highest(n uint) map[string]struct{} {
h := make(map[string]struct{}, n)
for i := a.b.Size(); i > uint(0) && uint(len(h)) < n; i-- {
// Use this to avoid wrapping around b/c of the unsigned int
idx := i - 1
if a.b.Check(idx) {
a.b.Unset(idx)
h[structs.AllocName(a.job, a.taskGroup, ... | go | func (a *allocNameIndex) Highest(n uint) map[string]struct{} {
h := make(map[string]struct{}, n)
for i := a.b.Size(); i > uint(0) && uint(len(h)) < n; i-- {
// Use this to avoid wrapping around b/c of the unsigned int
idx := i - 1
if a.b.Check(idx) {
a.b.Unset(idx)
h[structs.AllocName(a.job, a.taskGroup, ... | [
"func",
"(",
"a",
"*",
"allocNameIndex",
")",
"Highest",
"(",
"n",
"uint",
")",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"h",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"n",
")",
"\n",
"for",
"i",
":=",
... | // RemoveHighest removes and returns the highest n used names. The returned set
// can be less than n if there aren't n names set in the index | [
"RemoveHighest",
"removes",
"and",
"returns",
"the",
"highest",
"n",
"used",
"names",
".",
"The",
"returned",
"set",
"can",
"be",
"less",
"than",
"n",
"if",
"there",
"aren",
"t",
"n",
"names",
"set",
"in",
"the",
"index"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L440-L452 |
133,516 | hashicorp/nomad | scheduler/reconcile_util.go | Set | func (a *allocNameIndex) Set(set allocSet) {
for _, alloc := range set {
a.b.Set(alloc.Index())
}
} | go | func (a *allocNameIndex) Set(set allocSet) {
for _, alloc := range set {
a.b.Set(alloc.Index())
}
} | [
"func",
"(",
"a",
"*",
"allocNameIndex",
")",
"Set",
"(",
"set",
"allocSet",
")",
"{",
"for",
"_",
",",
"alloc",
":=",
"range",
"set",
"{",
"a",
".",
"b",
".",
"Set",
"(",
"alloc",
".",
"Index",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Set sets the indexes from the passed alloc set as used | [
"Set",
"sets",
"the",
"indexes",
"from",
"the",
"passed",
"alloc",
"set",
"as",
"used"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L455-L459 |
133,517 | hashicorp/nomad | scheduler/reconcile_util.go | Unset | func (a *allocNameIndex) Unset(as allocSet) {
for _, alloc := range as {
a.b.Unset(alloc.Index())
}
} | go | func (a *allocNameIndex) Unset(as allocSet) {
for _, alloc := range as {
a.b.Unset(alloc.Index())
}
} | [
"func",
"(",
"a",
"*",
"allocNameIndex",
")",
"Unset",
"(",
"as",
"allocSet",
")",
"{",
"for",
"_",
",",
"alloc",
":=",
"range",
"as",
"{",
"a",
".",
"b",
".",
"Unset",
"(",
"alloc",
".",
"Index",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Unset unsets all indexes of the passed alloc set as being used | [
"Unset",
"unsets",
"all",
"indexes",
"of",
"the",
"passed",
"alloc",
"set",
"as",
"being",
"used"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L462-L466 |
133,518 | hashicorp/nomad | scheduler/reconcile_util.go | NextCanaries | func (a *allocNameIndex) NextCanaries(n uint, existing, destructive allocSet) []string {
next := make([]string, 0, n)
// Create a name index
existingNames := existing.nameSet()
// First select indexes from the allocations that are undergoing destructive
// updates. This way we avoid duplicate names as they will ... | go | func (a *allocNameIndex) NextCanaries(n uint, existing, destructive allocSet) []string {
next := make([]string, 0, n)
// Create a name index
existingNames := existing.nameSet()
// First select indexes from the allocations that are undergoing destructive
// updates. This way we avoid duplicate names as they will ... | [
"func",
"(",
"a",
"*",
"allocNameIndex",
")",
"NextCanaries",
"(",
"n",
"uint",
",",
"existing",
",",
"destructive",
"allocSet",
")",
"[",
"]",
"string",
"{",
"next",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"n",
")",
"\n\n",
"// Create ... | // NextCanaries returns the next n names for use as canaries and sets them as
// used. The existing canaries and destructive updates are also passed in. | [
"NextCanaries",
"returns",
"the",
"next",
"n",
"names",
"for",
"use",
"as",
"canaries",
"and",
"sets",
"them",
"as",
"used",
".",
"The",
"existing",
"canaries",
"and",
"destructive",
"updates",
"are",
"also",
"passed",
"in",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L475-L526 |
133,519 | hashicorp/nomad | scheduler/reconcile_util.go | Next | func (a *allocNameIndex) Next(n uint) []string {
next := make([]string, 0, n)
// Get the set of unset names that can be used
remainder := n
for _, idx := range a.b.IndexesInRange(false, uint(0), uint(a.count)-1) {
next = append(next, structs.AllocName(a.job, a.taskGroup, uint(idx)))
a.b.Set(uint(idx))
// If... | go | func (a *allocNameIndex) Next(n uint) []string {
next := make([]string, 0, n)
// Get the set of unset names that can be used
remainder := n
for _, idx := range a.b.IndexesInRange(false, uint(0), uint(a.count)-1) {
next = append(next, structs.AllocName(a.job, a.taskGroup, uint(idx)))
a.b.Set(uint(idx))
// If... | [
"func",
"(",
"a",
"*",
"allocNameIndex",
")",
"Next",
"(",
"n",
"uint",
")",
"[",
"]",
"string",
"{",
"next",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"n",
")",
"\n\n",
"// Get the set of unset names that can be used",
"remainder",
":=",
"n"... | // Next returns the next n names for use as new placements and sets them as
// used. | [
"Next",
"returns",
"the",
"next",
"n",
"names",
"for",
"use",
"as",
"new",
"placements",
"and",
"sets",
"them",
"as",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/reconcile_util.go#L530-L554 |
133,520 | hashicorp/nomad | drivers/docker/docklog/plugin.go | LaunchDockerLogger | func LaunchDockerLogger(logger hclog.Logger) (DockerLogger, *plugin.Client, error) {
logger = logger.Named(PluginName)
bin, err := discover.NomadExecutable()
if err != nil {
return nil, nil, err
}
client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Pl... | go | func LaunchDockerLogger(logger hclog.Logger) (DockerLogger, *plugin.Client, error) {
logger = logger.Named(PluginName)
bin, err := discover.NomadExecutable()
if err != nil {
return nil, nil, err
}
client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Pl... | [
"func",
"LaunchDockerLogger",
"(",
"logger",
"hclog",
".",
"Logger",
")",
"(",
"DockerLogger",
",",
"*",
"plugin",
".",
"Client",
",",
"error",
")",
"{",
"logger",
"=",
"logger",
".",
"Named",
"(",
"PluginName",
")",
"\n",
"bin",
",",
"err",
":=",
"dis... | // LaunchDockerLogger launches an instance of DockerLogger | [
"LaunchDockerLogger",
"launches",
"an",
"instance",
"of",
"DockerLogger"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/plugin.go#L18-L50 |
133,521 | hashicorp/nomad | drivers/docker/docklog/plugin.go | GRPCServer | func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
proto.RegisterDockerLoggerServer(s, &dockerLoggerServer{
impl: p.impl,
broker: broker,
})
return nil
} | go | func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
proto.RegisterDockerLoggerServer(s, &dockerLoggerServer{
impl: p.impl,
broker: broker,
})
return nil
} | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"GRPCServer",
"(",
"broker",
"*",
"plugin",
".",
"GRPCBroker",
",",
"s",
"*",
"grpc",
".",
"Server",
")",
"error",
"{",
"proto",
".",
"RegisterDockerLoggerServer",
"(",
"s",
",",
"&",
"dockerLoggerServer",
"{",
"impl... | // GRPCServer registered the server side implementation with the grpc server | [
"GRPCServer",
"registered",
"the",
"server",
"side",
"implementation",
"with",
"the",
"grpc",
"server"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/plugin.go#L89-L95 |
133,522 | hashicorp/nomad | drivers/docker/docklog/plugin.go | GRPCClient | func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
return &dockerLoggerClient{client: proto.NewDockerLoggerClient(c)}, nil
} | go | func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
return &dockerLoggerClient{client: proto.NewDockerLoggerClient(c)}, nil
} | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"GRPCClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"broker",
"*",
"plugin",
".",
"GRPCBroker",
",",
"c",
"*",
"grpc",
".",
"ClientConn",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
... | // GRPCClient returns a client side implementation of the plugin | [
"GRPCClient",
"returns",
"a",
"client",
"side",
"implementation",
"of",
"the",
"plugin"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/plugin.go#L98-L100 |
133,523 | hashicorp/nomad | command/agent/consul/version_checker.go | checkConsulTLSSkipVerify | func checkConsulTLSSkipVerify(ctx context.Context, logger log.Logger, client AgentAPI, done chan struct{}) {
const (
baseline = time.Second
limit = 20 * time.Second
)
defer close(done)
i := uint64(0)
for {
self, err := client.Self()
if err == nil {
if supportsTLSSkipVerify(self) {
logger.Trace(... | go | func checkConsulTLSSkipVerify(ctx context.Context, logger log.Logger, client AgentAPI, done chan struct{}) {
const (
baseline = time.Second
limit = 20 * time.Second
)
defer close(done)
i := uint64(0)
for {
self, err := client.Self()
if err == nil {
if supportsTLSSkipVerify(self) {
logger.Trace(... | [
"func",
"checkConsulTLSSkipVerify",
"(",
"ctx",
"context",
".",
"Context",
",",
"logger",
"log",
".",
"Logger",
",",
"client",
"AgentAPI",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"{",
"const",
"(",
"baseline",
"=",
"time",
".",
"Second",
"\n",
"lim... | // checkConsulTLSSkipVerify logs if Consul does not support TLSSkipVerify on
// checks and is intended to be run in a goroutine. | [
"checkConsulTLSSkipVerify",
"logs",
"if",
"Consul",
"does",
"not",
"support",
"TLSSkipVerify",
"on",
"checks",
"and",
"is",
"intended",
"to",
"be",
"run",
"in",
"a",
"goroutine",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/version_checker.go#L14-L48 |
133,524 | hashicorp/nomad | command/agent/consul/version_checker.go | supportsTLSSkipVerify | func supportsTLSSkipVerify(self map[string]map[string]interface{}) bool {
member, ok := self["Member"]
if !ok {
return false
}
tagsI, ok := member["Tags"]
if !ok {
return false
}
tags, ok := tagsI.(map[string]interface{})
if !ok {
return false
}
buildI, ok := tags["build"]
if !ok {
return false
}
b... | go | func supportsTLSSkipVerify(self map[string]map[string]interface{}) bool {
member, ok := self["Member"]
if !ok {
return false
}
tagsI, ok := member["Tags"]
if !ok {
return false
}
tags, ok := tagsI.(map[string]interface{})
if !ok {
return false
}
buildI, ok := tags["build"]
if !ok {
return false
}
b... | [
"func",
"supportsTLSSkipVerify",
"(",
"self",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"bool",
"{",
"member",
",",
"ok",
":=",
"self",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n... | // supportsTLSSkipVerify returns true if Consul supports TLSSkipVerify. | [
"supportsTLSSkipVerify",
"returns",
"true",
"if",
"Consul",
"supports",
"TLSSkipVerify",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/version_checker.go#L53-L86 |
133,525 | hashicorp/nomad | command/agent/fs_endpoint.go | fsStreamImpl | func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
req *http.Request, method string, args interface{}, allocID string) (interface{}, error) {
// Get the correct handler
localClient, remoteClient, localServer := s.rpcHandlerForAlloc(allocID)
var handler structs.StreamingRpcHandler
var handlerErr error
if... | go | func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
req *http.Request, method string, args interface{}, allocID string) (interface{}, error) {
// Get the correct handler
localClient, remoteClient, localServer := s.rpcHandlerForAlloc(allocID)
var handler structs.StreamingRpcHandler
var handlerErr error
if... | [
"func",
"(",
"s",
"*",
"HTTPServer",
")",
"fsStreamImpl",
"(",
"resp",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"method",
"string",
",",
"args",
"interface",
"{",
"}",
",",
"allocID",
"string",
")",
"(",
"interface",
... | // fsStreamImpl is used to make a streaming filesystem call that serializes the
// args and then expects a stream of StreamErrWrapper results where the payload
// is copied to the response body. | [
"fsStreamImpl",
"is",
"used",
"to",
"make",
"a",
"streaming",
"filesystem",
"call",
"that",
"serializes",
"the",
"args",
"and",
"then",
"expects",
"a",
"stream",
"of",
"StreamErrWrapper",
"results",
"where",
"the",
"payload",
"is",
"copied",
"to",
"the",
"resp... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/fs_endpoint.go#L322-L408 |
133,526 | hashicorp/nomad | helper/pluginutils/hclutils/util.go | ParseHclInterface | func ParseHclInterface(val interface{}, spec hcldec.Spec, vars map[string]cty.Value) (cty.Value, hcl.Diagnostics) {
evalCtx := &hcl.EvalContext{
Variables: vars,
Functions: GetStdlibFuncs(),
}
// Encode to json
var buf bytes.Buffer
enc := codec.NewEncoder(&buf, structs.JsonHandle)
err := enc.Encode(val)
if ... | go | func ParseHclInterface(val interface{}, spec hcldec.Spec, vars map[string]cty.Value) (cty.Value, hcl.Diagnostics) {
evalCtx := &hcl.EvalContext{
Variables: vars,
Functions: GetStdlibFuncs(),
}
// Encode to json
var buf bytes.Buffer
enc := codec.NewEncoder(&buf, structs.JsonHandle)
err := enc.Encode(val)
if ... | [
"func",
"ParseHclInterface",
"(",
"val",
"interface",
"{",
"}",
",",
"spec",
"hcldec",
".",
"Spec",
",",
"vars",
"map",
"[",
"string",
"]",
"cty",
".",
"Value",
")",
"(",
"cty",
".",
"Value",
",",
"hcl",
".",
"Diagnostics",
")",
"{",
"evalCtx",
":=",... | // ParseHclInterface is used to convert an interface value representing a hcl2
// body and return the interpolated value. Vars may be nil if there are no
// variables to interpolate. | [
"ParseHclInterface",
"is",
"used",
"to",
"convert",
"an",
"interface",
"value",
"representing",
"a",
"hcl2",
"body",
"and",
"return",
"the",
"interpolated",
"value",
".",
"Vars",
"may",
"be",
"nil",
"if",
"there",
"are",
"no",
"variables",
"to",
"interpolate",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/hclutils/util.go#L20-L53 |
133,527 | hashicorp/nomad | helper/pluginutils/hclutils/util.go | GetStdlibFuncs | func GetStdlibFuncs() map[string]function.Function {
return map[string]function.Function{
"abs": stdlib.AbsoluteFunc,
"coalesce": stdlib.CoalesceFunc,
"concat": stdlib.ConcatFunc,
"hasindex": stdlib.HasIndexFunc,
"int": stdlib.IntFunc,
"jsondecode": stdlib.JSONDecodeFunc,
"jsonencod... | go | func GetStdlibFuncs() map[string]function.Function {
return map[string]function.Function{
"abs": stdlib.AbsoluteFunc,
"coalesce": stdlib.CoalesceFunc,
"concat": stdlib.ConcatFunc,
"hasindex": stdlib.HasIndexFunc,
"int": stdlib.IntFunc,
"jsondecode": stdlib.JSONDecodeFunc,
"jsonencod... | [
"func",
"GetStdlibFuncs",
"(",
")",
"map",
"[",
"string",
"]",
"function",
".",
"Function",
"{",
"return",
"map",
"[",
"string",
"]",
"function",
".",
"Function",
"{",
"\"",
"\"",
":",
"stdlib",
".",
"AbsoluteFunc",
",",
"\"",
"\"",
":",
"stdlib",
".",... | // GetStdlibFuncs returns the set of stdlib functions. | [
"GetStdlibFuncs",
"returns",
"the",
"set",
"of",
"stdlib",
"functions",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/hclutils/util.go#L56-L74 |
133,528 | hashicorp/nomad | helper/pluginutils/catalog/catalog.go | Register | func Register(id loader.PluginID, config *loader.InternalPluginConfig) {
mu.Lock()
defer mu.Unlock()
catalog[id] = &Registration{
Config: config,
}
} | go | func Register(id loader.PluginID, config *loader.InternalPluginConfig) {
mu.Lock()
defer mu.Unlock()
catalog[id] = &Registration{
Config: config,
}
} | [
"func",
"Register",
"(",
"id",
"loader",
".",
"PluginID",
",",
"config",
"*",
"loader",
".",
"InternalPluginConfig",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"catalog",
"[",
"id",
"]",
"=",
"&",
"Re... | // Register is used to register an internal plugin. | [
"Register",
"is",
"used",
"to",
"register",
"an",
"internal",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/catalog/catalog.go#L29-L35 |
133,529 | hashicorp/nomad | helper/pluginutils/catalog/catalog.go | RegisterDeferredConfig | func RegisterDeferredConfig(id loader.PluginID, config *loader.InternalPluginConfig, configLoader ConfigFromOptions) {
mu.Lock()
defer mu.Unlock()
catalog[id] = &Registration{
Config: config,
ConfigLoader: configLoader,
}
} | go | func RegisterDeferredConfig(id loader.PluginID, config *loader.InternalPluginConfig, configLoader ConfigFromOptions) {
mu.Lock()
defer mu.Unlock()
catalog[id] = &Registration{
Config: config,
ConfigLoader: configLoader,
}
} | [
"func",
"RegisterDeferredConfig",
"(",
"id",
"loader",
".",
"PluginID",
",",
"config",
"*",
"loader",
".",
"InternalPluginConfig",
",",
"configLoader",
"ConfigFromOptions",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
... | // RegisterDeferredConfig is used to register an internal plugin that sets its
// config using the client's option map. | [
"RegisterDeferredConfig",
"is",
"used",
"to",
"register",
"an",
"internal",
"plugin",
"that",
"sets",
"its",
"config",
"using",
"the",
"client",
"s",
"option",
"map",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/catalog/catalog.go#L39-L46 |
133,530 | hashicorp/nomad | command/helper_devices.go | getDeviceResourcesForNode | func getDeviceResourcesForNode(deviceGroupStats []*api.DeviceGroupStats, node *api.Node) []string {
statsSummaryMap := buildDeviceStatsSummaryMap(deviceGroupStats)
devices := []string{}
for _, dg := range node.NodeResources.Devices {
for _, inst := range dg.Instances {
id := deviceQualifiedID(dg.Vendor, dg.Typ... | go | func getDeviceResourcesForNode(deviceGroupStats []*api.DeviceGroupStats, node *api.Node) []string {
statsSummaryMap := buildDeviceStatsSummaryMap(deviceGroupStats)
devices := []string{}
for _, dg := range node.NodeResources.Devices {
for _, inst := range dg.Instances {
id := deviceQualifiedID(dg.Vendor, dg.Typ... | [
"func",
"getDeviceResourcesForNode",
"(",
"deviceGroupStats",
"[",
"]",
"*",
"api",
".",
"DeviceGroupStats",
",",
"node",
"*",
"api",
".",
"Node",
")",
"[",
"]",
"string",
"{",
"statsSummaryMap",
":=",
"buildDeviceStatsSummaryMap",
"(",
"deviceGroupStats",
")",
... | // getDeviceResourcesForNode returns a list of devices and their statistics summary
// and tracks devices without statistics | [
"getDeviceResourcesForNode",
"returns",
"a",
"list",
"of",
"devices",
"and",
"their",
"statistics",
"summary",
"and",
"tracks",
"devices",
"without",
"statistics"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helper_devices.go#L61-L80 |
133,531 | hashicorp/nomad | command/helper_devices.go | getDeviceResources | func getDeviceResources(deviceGroupStats []*api.DeviceGroupStats) []string {
statsSummaryMap := buildDeviceStatsSummaryMap(deviceGroupStats)
result := make([]string, 0, len(statsSummaryMap))
for id, stats := range statsSummaryMap {
result = append(result, id+"|"+stats.String())
}
sort.Strings(result)
return ... | go | func getDeviceResources(deviceGroupStats []*api.DeviceGroupStats) []string {
statsSummaryMap := buildDeviceStatsSummaryMap(deviceGroupStats)
result := make([]string, 0, len(statsSummaryMap))
for id, stats := range statsSummaryMap {
result = append(result, id+"|"+stats.String())
}
sort.Strings(result)
return ... | [
"func",
"getDeviceResources",
"(",
"deviceGroupStats",
"[",
"]",
"*",
"api",
".",
"DeviceGroupStats",
")",
"[",
"]",
"string",
"{",
"statsSummaryMap",
":=",
"buildDeviceStatsSummaryMap",
"(",
"deviceGroupStats",
")",
"\n\n",
"result",
":=",
"make",
"(",
"[",
"]"... | // getDeviceResources returns alist of devices and their statistics summary | [
"getDeviceResources",
"returns",
"alist",
"of",
"devices",
"and",
"their",
"statistics",
"summary"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helper_devices.go#L83-L94 |
133,532 | hashicorp/nomad | nomad/structs/streaming_rpc.go | Register | func (s *StreamingRpcRegistry) Register(method string, handler StreamingRpcHandler) {
s.registry[method] = handler
} | go | func (s *StreamingRpcRegistry) Register(method string, handler StreamingRpcHandler) {
s.registry[method] = handler
} | [
"func",
"(",
"s",
"*",
"StreamingRpcRegistry",
")",
"Register",
"(",
"method",
"string",
",",
"handler",
"StreamingRpcHandler",
")",
"{",
"s",
".",
"registry",
"[",
"method",
"]",
"=",
"handler",
"\n",
"}"
] | // Register registers a new handler for the given method name | [
"Register",
"registers",
"a",
"new",
"handler",
"for",
"the",
"given",
"method",
"name"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/streaming_rpc.go#L41-L43 |
133,533 | hashicorp/nomad | nomad/structs/streaming_rpc.go | GetHandler | func (s *StreamingRpcRegistry) GetHandler(method string) (StreamingRpcHandler, error) {
h, ok := s.registry[method]
if !ok {
return nil, fmt.Errorf("%s: %q", ErrUnknownMethod, method)
}
return h, nil
} | go | func (s *StreamingRpcRegistry) GetHandler(method string) (StreamingRpcHandler, error) {
h, ok := s.registry[method]
if !ok {
return nil, fmt.Errorf("%s: %q", ErrUnknownMethod, method)
}
return h, nil
} | [
"func",
"(",
"s",
"*",
"StreamingRpcRegistry",
")",
"GetHandler",
"(",
"method",
"string",
")",
"(",
"StreamingRpcHandler",
",",
"error",
")",
"{",
"h",
",",
"ok",
":=",
"s",
".",
"registry",
"[",
"method",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // GetHandler returns a handler for the given method or an error if it doesn't exist. | [
"GetHandler",
"returns",
"a",
"handler",
"for",
"the",
"given",
"method",
"or",
"an",
"error",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/streaming_rpc.go#L46-L53 |
133,534 | hashicorp/nomad | nomad/structs/streaming_rpc.go | Bridge | func Bridge(a, b io.ReadWriteCloser) {
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
io.Copy(a, b)
a.Close()
b.Close()
}()
go func() {
defer wg.Done()
io.Copy(b, a)
a.Close()
b.Close()
}()
wg.Wait()
} | go | func Bridge(a, b io.ReadWriteCloser) {
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
io.Copy(a, b)
a.Close()
b.Close()
}()
go func() {
defer wg.Done()
io.Copy(b, a)
a.Close()
b.Close()
}()
wg.Wait()
} | [
"func",
"Bridge",
"(",
"a",
",",
"b",
"io",
".",
"ReadWriteCloser",
")",
"{",
"wg",
":=",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"wg",
".",
"Add",
"(",
"2",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n"... | // Bridge is used to just link two connections together and copy traffic | [
"Bridge",
"is",
"used",
"to",
"just",
"link",
"two",
"connections",
"together",
"and",
"copy",
"traffic"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/streaming_rpc.go#L56-L72 |
133,535 | hashicorp/nomad | helper/pluginutils/hclspecutils/dec.go | Convert | func Convert(spec *hclspec.Spec) (hcldec.Spec, hcl.Diagnostics) {
if spec == nil {
return nil, hcl.Diagnostics([]*hcl.Diagnostic{nilSpecDiagnostic})
}
return decodeSpecBlock(spec, "")
} | go | func Convert(spec *hclspec.Spec) (hcldec.Spec, hcl.Diagnostics) {
if spec == nil {
return nil, hcl.Diagnostics([]*hcl.Diagnostic{nilSpecDiagnostic})
}
return decodeSpecBlock(spec, "")
} | [
"func",
"Convert",
"(",
"spec",
"*",
"hclspec",
".",
"Spec",
")",
"(",
"hcldec",
".",
"Spec",
",",
"hcl",
".",
"Diagnostics",
")",
"{",
"if",
"spec",
"==",
"nil",
"{",
"return",
"nil",
",",
"hcl",
".",
"Diagnostics",
"(",
"[",
"]",
"*",
"hcl",
".... | // Convert converts a Spec to an hcl specification. | [
"Convert",
"converts",
"a",
"Spec",
"to",
"an",
"hcl",
"specification",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/hclspecutils/dec.go#L35-L41 |
133,536 | hashicorp/nomad | helper/pluginutils/hclspecutils/dec.go | decodeSpecBlock | func decodeSpecBlock(spec *hclspec.Spec, impliedName string) (hcldec.Spec, hcl.Diagnostics) {
switch spec.Block.(type) {
case *hclspec.Spec_Object:
return decodeObjectSpec(spec.GetObject())
case *hclspec.Spec_Array:
return decodeArraySpec(spec.GetArray())
case *hclspec.Spec_Attr:
return decodeAttrSpec(spec... | go | func decodeSpecBlock(spec *hclspec.Spec, impliedName string) (hcldec.Spec, hcl.Diagnostics) {
switch spec.Block.(type) {
case *hclspec.Spec_Object:
return decodeObjectSpec(spec.GetObject())
case *hclspec.Spec_Array:
return decodeArraySpec(spec.GetArray())
case *hclspec.Spec_Attr:
return decodeAttrSpec(spec... | [
"func",
"decodeSpecBlock",
"(",
"spec",
"*",
"hclspec",
".",
"Spec",
",",
"impliedName",
"string",
")",
"(",
"hcldec",
".",
"Spec",
",",
"hcl",
".",
"Diagnostics",
")",
"{",
"switch",
"spec",
".",
"Block",
".",
"(",
"type",
")",
"{",
"case",
"*",
"hc... | // decodeSpecBlock is the recursive entry point that converts between the two
// spec types. | [
"decodeSpecBlock",
"is",
"the",
"recursive",
"entry",
"point",
"that",
"converts",
"between",
"the",
"two",
"spec",
"types",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/hclspecutils/dec.go#L45-L89 |
133,537 | hashicorp/nomad | drivers/docker/docklog/client.go | Start | func (c *dockerLoggerClient) Start(opts *StartOpts) error {
req := &proto.StartRequest{
Endpoint: opts.Endpoint,
ContainerId: opts.ContainerID,
StdoutFifo: opts.Stdout,
StderrFifo: opts.Stderr,
Tty: opts.TTY,
TlsCert: opts.TLSCert,
TlsKey: opts.TLSKey,
TlsCa: opts.TLSCA,
}
_, err := ... | go | func (c *dockerLoggerClient) Start(opts *StartOpts) error {
req := &proto.StartRequest{
Endpoint: opts.Endpoint,
ContainerId: opts.ContainerID,
StdoutFifo: opts.Stdout,
StderrFifo: opts.Stderr,
Tty: opts.TTY,
TlsCert: opts.TLSCert,
TlsKey: opts.TLSKey,
TlsCa: opts.TLSCA,
}
_, err := ... | [
"func",
"(",
"c",
"*",
"dockerLoggerClient",
")",
"Start",
"(",
"opts",
"*",
"StartOpts",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"StartRequest",
"{",
"Endpoint",
":",
"opts",
".",
"Endpoint",
",",
"ContainerId",
":",
"opts",
".",
"ContainerID... | // Start proxies the Start client side func to the protobuf interface | [
"Start",
"proxies",
"the",
"Start",
"client",
"side",
"func",
"to",
"the",
"protobuf",
"interface"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/client.go#L15-L29 |
133,538 | hashicorp/nomad | drivers/docker/docklog/client.go | Stop | func (c *dockerLoggerClient) Stop() error {
req := &proto.StopRequest{}
_, err := c.client.Stop(context.Background(), req)
return err
} | go | func (c *dockerLoggerClient) Stop() error {
req := &proto.StopRequest{}
_, err := c.client.Stop(context.Background(), req)
return err
} | [
"func",
"(",
"c",
"*",
"dockerLoggerClient",
")",
"Stop",
"(",
")",
"error",
"{",
"req",
":=",
"&",
"proto",
".",
"StopRequest",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"Stop",
"(",
"context",
".",
"Background",
"(",
")",
... | // Stop proxies the Stop client side func to the protobuf interface | [
"Stop",
"proxies",
"the",
"Stop",
"client",
"side",
"func",
"to",
"the",
"protobuf",
"interface"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/client.go#L32-L36 |
133,539 | hashicorp/nomad | helper/boltdd/boltdd.go | IsErrNotFound | func IsErrNotFound(e error) bool {
if e == nil {
return false
}
_, ok := e.(*ErrNotFound)
return ok
} | go | func IsErrNotFound(e error) bool {
if e == nil {
return false
}
_, ok := e.(*ErrNotFound)
return ok
} | [
"func",
"IsErrNotFound",
"(",
"e",
"error",
")",
"bool",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"_",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"ErrNotFound",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsErrNotFound returns true if the error is an ErrNotFound error. | [
"IsErrNotFound",
"returns",
"true",
"if",
"the",
"error",
"is",
"an",
"ErrNotFound",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L32-L38 |
133,540 | hashicorp/nomad | helper/boltdd/boltdd.go | Open | func Open(path string, mode os.FileMode, options *bolt.Options) (*DB, error) {
bdb, err := bolt.Open(path, mode, options)
if err != nil {
return nil, err
}
return New(bdb), nil
} | go | func Open(path string, mode os.FileMode, options *bolt.Options) (*DB, error) {
bdb, err := bolt.Open(path, mode, options)
if err != nil {
return nil, err
}
return New(bdb), nil
} | [
"func",
"Open",
"(",
"path",
"string",
",",
"mode",
"os",
".",
"FileMode",
",",
"options",
"*",
"bolt",
".",
"Options",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"bdb",
",",
"err",
":=",
"bolt",
".",
"Open",
"(",
"path",
",",
"mode",
",",
"o... | // Open a bolt.DB and wrap it in a write-deduplicating msgpack-encoding
// implementation. | [
"Open",
"a",
"bolt",
".",
"DB",
"and",
"wrap",
"it",
"in",
"a",
"write",
"-",
"deduplicating",
"msgpack",
"-",
"encoding",
"implementation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L51-L58 |
133,541 | hashicorp/nomad | helper/boltdd/boltdd.go | New | func New(bdb *bolt.DB) *DB {
return &DB{
rootBuckets: make(map[string]*bucketMeta),
bdb: bdb,
}
} | go | func New(bdb *bolt.DB) *DB {
return &DB{
rootBuckets: make(map[string]*bucketMeta),
bdb: bdb,
}
} | [
"func",
"New",
"(",
"bdb",
"*",
"bolt",
".",
"DB",
")",
"*",
"DB",
"{",
"return",
"&",
"DB",
"{",
"rootBuckets",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"bucketMeta",
")",
",",
"bdb",
":",
"bdb",
",",
"}",
"\n",
"}"
] | // New deduplicating wrapper for the given boltdb. | [
"New",
"deduplicating",
"wrapper",
"for",
"the",
"given",
"boltdb",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L61-L66 |
133,542 | hashicorp/nomad | helper/boltdd/boltdd.go | Close | func (db *DB) Close() error {
db.rootBucketsLock.Lock()
db.rootBuckets = nil
db.rootBucketsLock.Unlock()
return db.bdb.Close()
} | go | func (db *DB) Close() error {
db.rootBucketsLock.Lock()
db.rootBuckets = nil
db.rootBucketsLock.Unlock()
return db.bdb.Close()
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Close",
"(",
")",
"error",
"{",
"db",
".",
"rootBucketsLock",
".",
"Lock",
"(",
")",
"\n",
"db",
".",
"rootBuckets",
"=",
"nil",
"\n",
"db",
".",
"rootBucketsLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"db",
... | // Close closes the underlying bolt.DB and clears all bucket hashes. DB is
// unusable after closing. | [
"Close",
"closes",
"the",
"underlying",
"bolt",
".",
"DB",
"and",
"clears",
"all",
"bucket",
"hashes",
".",
"DB",
"is",
"unusable",
"after",
"closing",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L159-L164 |
133,543 | hashicorp/nomad | helper/boltdd/boltdd.go | Bucket | func (tx *Tx) Bucket(name []byte) *Bucket {
return tx.db.bucket(tx.btx, name)
} | go | func (tx *Tx) Bucket(name []byte) *Bucket {
return tx.db.bucket(tx.btx, name)
} | [
"func",
"(",
"tx",
"*",
"Tx",
")",
"Bucket",
"(",
"name",
"[",
"]",
"byte",
")",
"*",
"Bucket",
"{",
"return",
"tx",
".",
"db",
".",
"bucket",
"(",
"tx",
".",
"btx",
",",
"name",
")",
"\n",
"}"
] | // Bucket returns a root bucket or nil if it doesn't exist. | [
"Bucket",
"returns",
"a",
"root",
"bucket",
"or",
"nil",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L184-L186 |
133,544 | hashicorp/nomad | helper/boltdd/boltdd.go | CreateBucketIfNotExists | func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) {
return tx.db.createBucketIfNotExists(tx.btx, name)
} | go | func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) {
return tx.db.createBucketIfNotExists(tx.btx, name)
} | [
"func",
"(",
"tx",
"*",
"Tx",
")",
"CreateBucketIfNotExists",
"(",
"name",
"[",
"]",
"byte",
")",
"(",
"*",
"Bucket",
",",
"error",
")",
"{",
"return",
"tx",
".",
"db",
".",
"createBucketIfNotExists",
"(",
"tx",
".",
"btx",
",",
"name",
")",
"\n",
... | // CreateBucketIfNotExists returns a root bucket or creates a new one if it
// doesn't already exist. | [
"CreateBucketIfNotExists",
"returns",
"a",
"root",
"bucket",
"or",
"creates",
"a",
"new",
"one",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L194-L196 |
133,545 | hashicorp/nomad | helper/boltdd/boltdd.go | getHash | func (bm *bucketMeta) getHash(hashKey string) []byte {
bm.hashesLock.Lock()
lastHash := bm.hashes[hashKey]
bm.hashesLock.Unlock()
return lastHash
} | go | func (bm *bucketMeta) getHash(hashKey string) []byte {
bm.hashesLock.Lock()
lastHash := bm.hashes[hashKey]
bm.hashesLock.Unlock()
return lastHash
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"getHash",
"(",
"hashKey",
"string",
")",
"[",
"]",
"byte",
"{",
"bm",
".",
"hashesLock",
".",
"Lock",
"(",
")",
"\n",
"lastHash",
":=",
"bm",
".",
"hashes",
"[",
"hashKey",
"]",
"\n",
"bm",
".",
"hashesLo... | // getHash of last value written to a key or nil if no hash exists. | [
"getHash",
"of",
"last",
"value",
"written",
"to",
"a",
"key",
"or",
"nil",
"if",
"no",
"hash",
"exists",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L228-L233 |
133,546 | hashicorp/nomad | helper/boltdd/boltdd.go | setHash | func (bm *bucketMeta) setHash(hashKey string, hashVal []byte) {
bm.hashesLock.Lock()
bm.hashes[hashKey] = hashVal
bm.hashesLock.Unlock()
} | go | func (bm *bucketMeta) setHash(hashKey string, hashVal []byte) {
bm.hashesLock.Lock()
bm.hashes[hashKey] = hashVal
bm.hashesLock.Unlock()
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"setHash",
"(",
"hashKey",
"string",
",",
"hashVal",
"[",
"]",
"byte",
")",
"{",
"bm",
".",
"hashesLock",
".",
"Lock",
"(",
")",
"\n",
"bm",
".",
"hashes",
"[",
"hashKey",
"]",
"=",
"hashVal",
"\n",
"bm",
... | // setHash of last value written to key. | [
"setHash",
"of",
"last",
"value",
"written",
"to",
"key",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L236-L240 |
133,547 | hashicorp/nomad | helper/boltdd/boltdd.go | delHash | func (bm *bucketMeta) delHash(hashKey string) {
bm.hashesLock.Lock()
delete(bm.hashes, hashKey)
bm.hashesLock.Unlock()
} | go | func (bm *bucketMeta) delHash(hashKey string) {
bm.hashesLock.Lock()
delete(bm.hashes, hashKey)
bm.hashesLock.Unlock()
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"delHash",
"(",
"hashKey",
"string",
")",
"{",
"bm",
".",
"hashesLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"bm",
".",
"hashes",
",",
"hashKey",
")",
"\n",
"bm",
".",
"hashesLock",
".",
"Unlock",
"... | // delHash deletes a hash value or does nothing if the hash key does not exist. | [
"delHash",
"deletes",
"a",
"hash",
"value",
"or",
"does",
"nothing",
"if",
"the",
"hash",
"key",
"does",
"not",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L243-L247 |
133,548 | hashicorp/nomad | helper/boltdd/boltdd.go | createBucket | func (bm *bucketMeta) createBucket(name []byte) *bucketMeta {
bm.bucketsLock.Lock()
defer bm.bucketsLock.Unlock()
// Always create a new Bucket since CreateBucket above fails if the
// bucket already exists.
b := newBucketMeta()
bm.buckets[string(name)] = b
return b
} | go | func (bm *bucketMeta) createBucket(name []byte) *bucketMeta {
bm.bucketsLock.Lock()
defer bm.bucketsLock.Unlock()
// Always create a new Bucket since CreateBucket above fails if the
// bucket already exists.
b := newBucketMeta()
bm.buckets[string(name)] = b
return b
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"createBucket",
"(",
"name",
"[",
"]",
"byte",
")",
"*",
"bucketMeta",
"{",
"bm",
".",
"bucketsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"bm",
".",
"bucketsLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// Alwa... | // createBucket metadata entry for the given nested bucket. Overwrites any
// existing entry so caller should ensure bucket does not already exist. | [
"createBucket",
"metadata",
"entry",
"for",
"the",
"given",
"nested",
"bucket",
".",
"Overwrites",
"any",
"existing",
"entry",
"so",
"caller",
"should",
"ensure",
"bucket",
"does",
"not",
"already",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L251-L260 |
133,549 | hashicorp/nomad | helper/boltdd/boltdd.go | deleteBucket | func (bm *bucketMeta) deleteBucket(name []byte) {
bm.bucketsLock.Lock()
delete(bm.buckets, string(name))
bm.bucketsLock.Unlock()
} | go | func (bm *bucketMeta) deleteBucket(name []byte) {
bm.bucketsLock.Lock()
delete(bm.buckets, string(name))
bm.bucketsLock.Unlock()
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"deleteBucket",
"(",
"name",
"[",
"]",
"byte",
")",
"{",
"bm",
".",
"bucketsLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"bm",
".",
"buckets",
",",
"string",
"(",
"name",
")",
")",
"\n",
"bm",
".",... | // deleteBucket metadata entry for the given nested bucket. Does nothing if
// nested bucket metadata does not exist. | [
"deleteBucket",
"metadata",
"entry",
"for",
"the",
"given",
"nested",
"bucket",
".",
"Does",
"nothing",
"if",
"nested",
"bucket",
"metadata",
"does",
"not",
"exist",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L264-L269 |
133,550 | hashicorp/nomad | helper/boltdd/boltdd.go | getOrCreateBucket | func (bm *bucketMeta) getOrCreateBucket(name []byte) *bucketMeta {
bm.bucketsLock.Lock()
defer bm.bucketsLock.Unlock()
b, ok := bm.buckets[string(name)]
if !ok {
b = newBucketMeta()
bm.buckets[string(name)] = b
}
return b
} | go | func (bm *bucketMeta) getOrCreateBucket(name []byte) *bucketMeta {
bm.bucketsLock.Lock()
defer bm.bucketsLock.Unlock()
b, ok := bm.buckets[string(name)]
if !ok {
b = newBucketMeta()
bm.buckets[string(name)] = b
}
return b
} | [
"func",
"(",
"bm",
"*",
"bucketMeta",
")",
"getOrCreateBucket",
"(",
"name",
"[",
"]",
"byte",
")",
"*",
"bucketMeta",
"{",
"bm",
".",
"bucketsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"bm",
".",
"bucketsLock",
".",
"Unlock",
"(",
")",
"\n\n",
"b"... | // getOrCreateBucket metadata entry for the given nested bucket. | [
"getOrCreateBucket",
"metadata",
"entry",
"for",
"the",
"given",
"nested",
"bucket",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L272-L282 |
133,551 | hashicorp/nomad | helper/boltdd/boltdd.go | newBucket | func newBucket(b *bucketMeta, bb *bolt.Bucket) *Bucket {
return &Bucket{
bm: b,
boltBucket: bb,
}
} | go | func newBucket(b *bucketMeta, bb *bolt.Bucket) *Bucket {
return &Bucket{
bm: b,
boltBucket: bb,
}
} | [
"func",
"newBucket",
"(",
"b",
"*",
"bucketMeta",
",",
"bb",
"*",
"bolt",
".",
"Bucket",
")",
"*",
"Bucket",
"{",
"return",
"&",
"Bucket",
"{",
"bm",
":",
"b",
",",
"boltBucket",
":",
"bb",
",",
"}",
"\n",
"}"
] | // newBucket creates a new view into a bucket backed by a boltdb
// transaction. | [
"newBucket",
"creates",
"a",
"new",
"view",
"into",
"a",
"bucket",
"backed",
"by",
"a",
"boltdb",
"transaction",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L291-L296 |
133,552 | hashicorp/nomad | helper/boltdd/boltdd.go | Put | func (b *Bucket) Put(key []byte, val interface{}) error {
// buffer for writing serialized state to
var buf bytes.Buffer
// Serialize the object
if err := codec.NewEncoder(&buf, structs.MsgpackHandle).Encode(val); err != nil {
return fmt.Errorf("failed to encode passed object: %v", err)
}
// Hash for skipping... | go | func (b *Bucket) Put(key []byte, val interface{}) error {
// buffer for writing serialized state to
var buf bytes.Buffer
// Serialize the object
if err := codec.NewEncoder(&buf, structs.MsgpackHandle).Encode(val); err != nil {
return fmt.Errorf("failed to encode passed object: %v", err)
}
// Hash for skipping... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Put",
"(",
"key",
"[",
"]",
"byte",
",",
"val",
"interface",
"{",
"}",
")",
"error",
"{",
"// buffer for writing serialized state to",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n\n",
"// Serialize the object",
"if",
"err"... | // Put into boltdb iff it has changed since the last write. | [
"Put",
"into",
"boltdb",
"iff",
"it",
"has",
"changed",
"since",
"the",
"last",
"write",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L299-L330 |
133,553 | hashicorp/nomad | helper/boltdd/boltdd.go | Get | func (b *Bucket) Get(key []byte, obj interface{}) error {
// Get the raw data from the underlying boltdb
data := b.boltBucket.Get(key)
if data == nil {
return NotFound(string(key))
}
// Deserialize the object
if err := codec.NewDecoderBytes(data, structs.MsgpackHandle).Decode(obj); err != nil {
return fmt.Er... | go | func (b *Bucket) Get(key []byte, obj interface{}) error {
// Get the raw data from the underlying boltdb
data := b.boltBucket.Get(key)
if data == nil {
return NotFound(string(key))
}
// Deserialize the object
if err := codec.NewDecoderBytes(data, structs.MsgpackHandle).Decode(obj); err != nil {
return fmt.Er... | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"// Get the raw data from the underlying boltdb",
"data",
":=",
"b",
".",
"boltBucket",
".",
"Get",
"(",
"key",
")",
"\n",
... | // Get value by key from boltdb or return an ErrNotFound error if key not
// found. | [
"Get",
"value",
"by",
"key",
"from",
"boltdb",
"or",
"return",
"an",
"ErrNotFound",
"error",
"if",
"key",
"not",
"found",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L334-L347 |
133,554 | hashicorp/nomad | helper/boltdd/boltdd.go | Bucket | func (b *Bucket) Bucket(name []byte) *Bucket {
bb := b.boltBucket.Bucket(name)
if bb == nil {
return nil
}
bmeta := b.bm.getOrCreateBucket(name)
return newBucket(bmeta, bb)
} | go | func (b *Bucket) Bucket(name []byte) *Bucket {
bb := b.boltBucket.Bucket(name)
if bb == nil {
return nil
}
bmeta := b.bm.getOrCreateBucket(name)
return newBucket(bmeta, bb)
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Bucket",
"(",
"name",
"[",
"]",
"byte",
")",
"*",
"Bucket",
"{",
"bb",
":=",
"b",
".",
"boltBucket",
".",
"Bucket",
"(",
"name",
")",
"\n",
"if",
"bb",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",... | // Bucket represents a boltdb Bucket and its associated metadata necessary for
// write deduplication. Like bolt.Buckets it is only valid for the duration of
// the transaction that created it. | [
"Bucket",
"represents",
"a",
"boltdb",
"Bucket",
"and",
"its",
"associated",
"metadata",
"necessary",
"for",
"write",
"deduplication",
".",
"Like",
"bolt",
".",
"Buckets",
"it",
"is",
"only",
"valid",
"for",
"the",
"duration",
"of",
"the",
"transaction",
"that... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L361-L369 |
133,555 | hashicorp/nomad | helper/boltdd/boltdd.go | CreateBucketIfNotExists | func (b *Bucket) CreateBucketIfNotExists(name []byte) (*Bucket, error) {
bb, err := b.boltBucket.CreateBucketIfNotExists(name)
if err != nil {
return nil, err
}
bmeta := b.bm.getOrCreateBucket(name)
return newBucket(bmeta, bb), nil
} | go | func (b *Bucket) CreateBucketIfNotExists(name []byte) (*Bucket, error) {
bb, err := b.boltBucket.CreateBucketIfNotExists(name)
if err != nil {
return nil, err
}
bmeta := b.bm.getOrCreateBucket(name)
return newBucket(bmeta, bb), nil
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"CreateBucketIfNotExists",
"(",
"name",
"[",
"]",
"byte",
")",
"(",
"*",
"Bucket",
",",
"error",
")",
"{",
"bb",
",",
"err",
":=",
"b",
".",
"boltBucket",
".",
"CreateBucketIfNotExists",
"(",
"name",
")",
"\n",
"... | // CreateBucketIfNotExists creates a new bucket if it doesn't already exist and
// returns a reference to it. The bucket instance is only valid for the
// lifetime of the transaction. | [
"CreateBucketIfNotExists",
"creates",
"a",
"new",
"bucket",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"and",
"returns",
"a",
"reference",
"to",
"it",
".",
"The",
"bucket",
"instance",
"is",
"only",
"valid",
"for",
"the",
"lifetime",
"of",
"the",
"transac... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L388-L396 |
133,556 | hashicorp/nomad | helper/boltdd/boltdd.go | DeleteBucket | func (b *Bucket) DeleteBucket(name []byte) error {
// Delete the bucket from the underlying boltdb
err := b.boltBucket.DeleteBucket(name)
if err == bolt.ErrBucketNotFound {
err = nil
}
// Remove reference to child bucket
b.bm.deleteBucket(name)
return err
} | go | func (b *Bucket) DeleteBucket(name []byte) error {
// Delete the bucket from the underlying boltdb
err := b.boltBucket.DeleteBucket(name)
if err == bolt.ErrBucketNotFound {
err = nil
}
// Remove reference to child bucket
b.bm.deleteBucket(name)
return err
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"DeleteBucket",
"(",
"name",
"[",
"]",
"byte",
")",
"error",
"{",
"// Delete the bucket from the underlying boltdb",
"err",
":=",
"b",
".",
"boltBucket",
".",
"DeleteBucket",
"(",
"name",
")",
"\n",
"if",
"err",
"==",
... | // DeleteBucket deletes a child bucket. Returns an error if the bucket
// corresponds to a non-bucket key or another error is encountered. No error is
// returned if the bucket does not exist. | [
"DeleteBucket",
"deletes",
"a",
"child",
"bucket",
".",
"Returns",
"an",
"error",
"if",
"the",
"bucket",
"corresponds",
"to",
"a",
"non",
"-",
"bucket",
"key",
"or",
"another",
"error",
"is",
"encountered",
".",
"No",
"error",
"is",
"returned",
"if",
"the"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/boltdd/boltdd.go#L401-L411 |
133,557 | hashicorp/nomad | api/jobs.go | EnforceRegister | func (j *Jobs) EnforceRegister(job *Job, modifyIndex uint64, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error) {
opts := RegisterOptions{EnforceIndex: true, ModifyIndex: modifyIndex}
return j.RegisterOpts(job, &opts, q)
} | go | func (j *Jobs) EnforceRegister(job *Job, modifyIndex uint64, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error) {
opts := RegisterOptions{EnforceIndex: true, ModifyIndex: modifyIndex}
return j.RegisterOpts(job, &opts, q)
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"EnforceRegister",
"(",
"job",
"*",
"Job",
",",
"modifyIndex",
"uint64",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"JobRegisterResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"opts",
":=",
"RegisterOption... | // EnforceRegister is used to register a job enforcing its job modify index. | [
"EnforceRegister",
"is",
"used",
"to",
"register",
"a",
"job",
"enforcing",
"its",
"job",
"modify",
"index",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L92-L95 |
133,558 | hashicorp/nomad | api/jobs.go | List | func (j *Jobs) List(q *QueryOptions) ([]*JobListStub, *QueryMeta, error) {
var resp []*JobListStub
qm, err := j.client.query("/v1/jobs", &resp, q)
if err != nil {
return nil, qm, err
}
sort.Sort(JobIDSort(resp))
return resp, qm, nil
} | go | func (j *Jobs) List(q *QueryOptions) ([]*JobListStub, *QueryMeta, error) {
var resp []*JobListStub
qm, err := j.client.query("/v1/jobs", &resp, q)
if err != nil {
return nil, qm, err
}
sort.Sort(JobIDSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"JobListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"JobListStub",
"\n",
"qm",
",",
"err",
":=",
"j",
".... | // List is used to list all of the existing jobs. | [
"List",
"is",
"used",
"to",
"list",
"all",
"of",
"the",
"existing",
"jobs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L123-L131 |
133,559 | hashicorp/nomad | api/jobs.go | PrefixList | func (j *Jobs) PrefixList(prefix string) ([]*JobListStub, *QueryMeta, error) {
return j.List(&QueryOptions{Prefix: prefix})
} | go | func (j *Jobs) PrefixList(prefix string) ([]*JobListStub, *QueryMeta, error) {
return j.List(&QueryOptions{Prefix: prefix})
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"PrefixList",
"(",
"prefix",
"string",
")",
"(",
"[",
"]",
"*",
"JobListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"return",
"j",
".",
"List",
"(",
"&",
"QueryOptions",
"{",
"Prefix",
":",
"prefix",
"}... | // PrefixList is used to list all existing jobs that match the prefix. | [
"PrefixList",
"is",
"used",
"to",
"list",
"all",
"existing",
"jobs",
"that",
"match",
"the",
"prefix",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L134-L136 |
133,560 | hashicorp/nomad | api/jobs.go | Info | func (j *Jobs) Info(jobID string, q *QueryOptions) (*Job, *QueryMeta, error) {
var resp Job
qm, err := j.client.query("/v1/job/"+jobID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (j *Jobs) Info(jobID string, q *QueryOptions) (*Job, *QueryMeta, error) {
var resp Job
qm, err := j.client.query("/v1/job/"+jobID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Info",
"(",
"jobID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Job",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Job",
"\n",
"qm",
",",
"err",
":=",
"j",
".",
"client",
".",... | // Info is used to retrieve information about a particular
// job given its unique ID. | [
"Info",
"is",
"used",
"to",
"retrieve",
"information",
"about",
"a",
"particular",
"job",
"given",
"its",
"unique",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L140-L147 |
133,561 | hashicorp/nomad | api/jobs.go | Versions | func (j *Jobs) Versions(jobID string, diffs bool, q *QueryOptions) ([]*Job, []*JobDiff, *QueryMeta, error) {
var resp JobVersionsResponse
qm, err := j.client.query(fmt.Sprintf("/v1/job/%s/versions?diffs=%v", jobID, diffs), &resp, q)
if err != nil {
return nil, nil, nil, err
}
return resp.Versions, resp.Diffs, qm... | go | func (j *Jobs) Versions(jobID string, diffs bool, q *QueryOptions) ([]*Job, []*JobDiff, *QueryMeta, error) {
var resp JobVersionsResponse
qm, err := j.client.query(fmt.Sprintf("/v1/job/%s/versions?diffs=%v", jobID, diffs), &resp, q)
if err != nil {
return nil, nil, nil, err
}
return resp.Versions, resp.Diffs, qm... | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Versions",
"(",
"jobID",
"string",
",",
"diffs",
"bool",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Job",
",",
"[",
"]",
"*",
"JobDiff",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"r... | // Versions is used to retrieve all versions of a particular job given its
// unique ID. | [
"Versions",
"is",
"used",
"to",
"retrieve",
"all",
"versions",
"of",
"a",
"particular",
"job",
"given",
"its",
"unique",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L151-L158 |
133,562 | hashicorp/nomad | api/jobs.go | Allocations | func (j *Jobs) Allocations(jobID string, allAllocs bool, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
u, err := url.Parse("/v1/job/" + jobID + "/allocations")
if err != nil {
return nil, nil, err
}
v := u.Query()
v.Add("all", strconv.FormatBool(allAllocs))
u.Raw... | go | func (j *Jobs) Allocations(jobID string, allAllocs bool, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
u, err := url.Parse("/v1/job/" + jobID + "/allocations")
if err != nil {
return nil, nil, err
}
v := u.Query()
v.Add("all", strconv.FormatBool(allAllocs))
u.Raw... | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Allocations",
"(",
"jobID",
"string",
",",
"allAllocs",
"bool",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"AllocationListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",... | // Allocations is used to return the allocs for a given job ID. | [
"Allocations",
"is",
"used",
"to",
"return",
"the",
"allocs",
"for",
"a",
"given",
"job",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L161-L178 |
133,563 | hashicorp/nomad | api/jobs.go | Deployments | func (j *Jobs) Deployments(jobID string, q *QueryOptions) ([]*Deployment, *QueryMeta, error) {
var resp []*Deployment
qm, err := j.client.query("/v1/job/"+jobID+"/deployments", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(DeploymentIndexSort(resp))
return resp, qm, nil
} | go | func (j *Jobs) Deployments(jobID string, q *QueryOptions) ([]*Deployment, *QueryMeta, error) {
var resp []*Deployment
qm, err := j.client.query("/v1/job/"+jobID+"/deployments", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(DeploymentIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Deployments",
"(",
"jobID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Deployment",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Deployment",
"\n",
"qm",
... | // Deployments is used to query the deployments associated with the given job
// ID. | [
"Deployments",
"is",
"used",
"to",
"query",
"the",
"deployments",
"associated",
"with",
"the",
"given",
"job",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L182-L190 |
133,564 | hashicorp/nomad | api/jobs.go | Evaluations | func (j *Jobs) Evaluations(jobID string, q *QueryOptions) ([]*Evaluation, *QueryMeta, error) {
var resp []*Evaluation
qm, err := j.client.query("/v1/job/"+jobID+"/evaluations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(EvalIndexSort(resp))
return resp, qm, nil
} | go | func (j *Jobs) Evaluations(jobID string, q *QueryOptions) ([]*Evaluation, *QueryMeta, error) {
var resp []*Evaluation
qm, err := j.client.query("/v1/job/"+jobID+"/evaluations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(EvalIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Evaluations",
"(",
"jobID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Evaluation",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Evaluation",
"\n",
"qm",
... | // Evaluations is used to query the evaluations associated with the given job
// ID. | [
"Evaluations",
"is",
"used",
"to",
"query",
"the",
"evaluations",
"associated",
"with",
"the",
"given",
"job",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L205-L213 |
133,565 | hashicorp/nomad | api/jobs.go | Deregister | func (j *Jobs) Deregister(jobID string, purge bool, q *WriteOptions) (string, *WriteMeta, error) {
var resp JobDeregisterResponse
wm, err := j.client.delete(fmt.Sprintf("/v1/job/%v?purge=%t", jobID, purge), &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | go | func (j *Jobs) Deregister(jobID string, purge bool, q *WriteOptions) (string, *WriteMeta, error) {
var resp JobDeregisterResponse
wm, err := j.client.delete(fmt.Sprintf("/v1/job/%v?purge=%t", jobID, purge), &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Deregister",
"(",
"jobID",
"string",
",",
"purge",
"bool",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"string",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"JobDeregisterResponse",
"\n",
"wm",
",",
... | // Deregister is used to remove an existing job. If purge is set to true, the job
// is deregistered and purged from the system versus still being queryable and
// eventually GC'ed from the system. Most callers should not specify purge. | [
"Deregister",
"is",
"used",
"to",
"remove",
"an",
"existing",
"job",
".",
"If",
"purge",
"is",
"set",
"to",
"true",
"the",
"job",
"is",
"deregistered",
"and",
"purged",
"from",
"the",
"system",
"versus",
"still",
"being",
"queryable",
"and",
"eventually",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L218-L225 |
133,566 | hashicorp/nomad | api/jobs.go | ForceEvaluate | func (j *Jobs) ForceEvaluate(jobID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp JobRegisterResponse
wm, err := j.client.write("/v1/job/"+jobID+"/evaluate", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | go | func (j *Jobs) ForceEvaluate(jobID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp JobRegisterResponse
wm, err := j.client.write("/v1/job/"+jobID+"/evaluate", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"ForceEvaluate",
"(",
"jobID",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"string",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"JobRegisterResponse",
"\n",
"wm",
",",
"err",
":=",
"j",
".... | // ForceEvaluate is used to force-evaluate an existing job. | [
"ForceEvaluate",
"is",
"used",
"to",
"force",
"-",
"evaluate",
"an",
"existing",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L228-L235 |
133,567 | hashicorp/nomad | api/jobs.go | EvaluateWithOpts | func (j *Jobs) EvaluateWithOpts(jobID string, opts EvalOptions, q *WriteOptions) (string, *WriteMeta, error) {
req := &JobEvaluateRequest{
JobID: jobID,
EvalOptions: opts,
}
var resp JobRegisterResponse
wm, err := j.client.write("/v1/job/"+jobID+"/evaluate", req, &resp, q)
if err != nil {
return "", n... | go | func (j *Jobs) EvaluateWithOpts(jobID string, opts EvalOptions, q *WriteOptions) (string, *WriteMeta, error) {
req := &JobEvaluateRequest{
JobID: jobID,
EvalOptions: opts,
}
var resp JobRegisterResponse
wm, err := j.client.write("/v1/job/"+jobID+"/evaluate", req, &resp, q)
if err != nil {
return "", n... | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"EvaluateWithOpts",
"(",
"jobID",
"string",
",",
"opts",
"EvalOptions",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"string",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"req",
":=",
"&",
"JobEvaluateRequest",
"{",
"... | // EvaluateWithOpts is used to force-evaluate an existing job and takes additional options
// for whether to force reschedule failed allocations | [
"EvaluateWithOpts",
"is",
"used",
"to",
"force",
"-",
"evaluate",
"an",
"existing",
"job",
"and",
"takes",
"additional",
"options",
"for",
"whether",
"to",
"force",
"reschedule",
"failed",
"allocations"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L239-L251 |
133,568 | hashicorp/nomad | api/jobs.go | PeriodicForce | func (j *Jobs) PeriodicForce(jobID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp periodicForceResponse
wm, err := j.client.write("/v1/job/"+jobID+"/periodic/force", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | go | func (j *Jobs) PeriodicForce(jobID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp periodicForceResponse
wm, err := j.client.write("/v1/job/"+jobID+"/periodic/force", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"PeriodicForce",
"(",
"jobID",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"string",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"periodicForceResponse",
"\n",
"wm",
",",
"err",
":=",
"j",
... | // PeriodicForce spawns a new instance of the periodic job and returns the eval ID | [
"PeriodicForce",
"spawns",
"a",
"new",
"instance",
"of",
"the",
"periodic",
"job",
"and",
"returns",
"the",
"eval",
"ID"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L254-L261 |
133,569 | hashicorp/nomad | api/jobs.go | Revert | func (j *Jobs) Revert(jobID string, version uint64, enforcePriorVersion *uint64,
q *WriteOptions, vaultToken string) (*JobRegisterResponse, *WriteMeta, error) {
var resp JobRegisterResponse
req := &JobRevertRequest{
JobID: jobID,
JobVersion: version,
EnforcePriorVersion: enforcePriorVer... | go | func (j *Jobs) Revert(jobID string, version uint64, enforcePriorVersion *uint64,
q *WriteOptions, vaultToken string) (*JobRegisterResponse, *WriteMeta, error) {
var resp JobRegisterResponse
req := &JobRevertRequest{
JobID: jobID,
JobVersion: version,
EnforcePriorVersion: enforcePriorVer... | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Revert",
"(",
"jobID",
"string",
",",
"version",
"uint64",
",",
"enforcePriorVersion",
"*",
"uint64",
",",
"q",
"*",
"WriteOptions",
",",
"vaultToken",
"string",
")",
"(",
"*",
"JobRegisterResponse",
",",
"*",
"WriteMet... | // Revert is used to revert the given job to the passed version. If
// enforceVersion is set, the job is only reverted if the current version is at
// the passed version. | [
"Revert",
"is",
"used",
"to",
"revert",
"the",
"given",
"job",
"to",
"the",
"passed",
"version",
".",
"If",
"enforceVersion",
"is",
"set",
"the",
"job",
"is",
"only",
"reverted",
"if",
"the",
"current",
"version",
"is",
"at",
"the",
"passed",
"version",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L323-L338 |
133,570 | hashicorp/nomad | api/jobs.go | Stable | func (j *Jobs) Stable(jobID string, version uint64, stable bool,
q *WriteOptions) (*JobStabilityResponse, *WriteMeta, error) {
var resp JobStabilityResponse
req := &JobStabilityRequest{
JobID: jobID,
JobVersion: version,
Stable: stable,
}
wm, err := j.client.write("/v1/job/"+jobID+"/stable", req, &... | go | func (j *Jobs) Stable(jobID string, version uint64, stable bool,
q *WriteOptions) (*JobStabilityResponse, *WriteMeta, error) {
var resp JobStabilityResponse
req := &JobStabilityRequest{
JobID: jobID,
JobVersion: version,
Stable: stable,
}
wm, err := j.client.write("/v1/job/"+jobID+"/stable", req, &... | [
"func",
"(",
"j",
"*",
"Jobs",
")",
"Stable",
"(",
"jobID",
"string",
",",
"version",
"uint64",
",",
"stable",
"bool",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"JobStabilityResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
... | // Stable is used to mark a job version's stability. | [
"Stable",
"is",
"used",
"to",
"mark",
"a",
"job",
"version",
"s",
"stability",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L341-L355 |
133,571 | hashicorp/nomad | api/jobs.go | DefaultUpdateStrategy | func DefaultUpdateStrategy() *UpdateStrategy {
return &UpdateStrategy{
Stagger: timeToPtr(30 * time.Second),
MaxParallel: intToPtr(1),
HealthCheck: stringToPtr("checks"),
MinHealthyTime: timeToPtr(10 * time.Second),
HealthyDeadline: timeToPtr(5 * time.Minute),
ProgressDeadline: timeTo... | go | func DefaultUpdateStrategy() *UpdateStrategy {
return &UpdateStrategy{
Stagger: timeToPtr(30 * time.Second),
MaxParallel: intToPtr(1),
HealthCheck: stringToPtr("checks"),
MinHealthyTime: timeToPtr(10 * time.Second),
HealthyDeadline: timeToPtr(5 * time.Minute),
ProgressDeadline: timeTo... | [
"func",
"DefaultUpdateStrategy",
"(",
")",
"*",
"UpdateStrategy",
"{",
"return",
"&",
"UpdateStrategy",
"{",
"Stagger",
":",
"timeToPtr",
"(",
"30",
"*",
"time",
".",
"Second",
")",
",",
"MaxParallel",
":",
"intToPtr",
"(",
"1",
")",
",",
"HealthCheck",
":... | // DefaultUpdateStrategy provides a baseline that can be used to upgrade
// jobs with the old policy or for populating field defaults. | [
"DefaultUpdateStrategy",
"provides",
"a",
"baseline",
"that",
"can",
"be",
"used",
"to",
"upgrade",
"jobs",
"with",
"the",
"old",
"policy",
"or",
"for",
"populating",
"field",
"defaults",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L376-L387 |
133,572 | hashicorp/nomad | api/jobs.go | Empty | func (u *UpdateStrategy) Empty() bool {
if u == nil {
return true
}
if u.Stagger != nil && *u.Stagger != 0 {
return false
}
if u.MaxParallel != nil && *u.MaxParallel != 0 {
return false
}
if u.HealthCheck != nil && *u.HealthCheck != "" {
return false
}
if u.MinHealthyTime != nil && *u.MinHealthyTim... | go | func (u *UpdateStrategy) Empty() bool {
if u == nil {
return true
}
if u.Stagger != nil && *u.Stagger != 0 {
return false
}
if u.MaxParallel != nil && *u.MaxParallel != 0 {
return false
}
if u.HealthCheck != nil && *u.HealthCheck != "" {
return false
}
if u.MinHealthyTime != nil && *u.MinHealthyTim... | [
"func",
"(",
"u",
"*",
"UpdateStrategy",
")",
"Empty",
"(",
")",
"bool",
"{",
"if",
"u",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"if",
"u",
".",
"Stagger",
"!=",
"nil",
"&&",
"*",
"u",
".",
"Stagger",
"!=",
"0",
"{",
"return",
"f... | // Empty returns whether the UpdateStrategy is empty or has user defined values. | [
"Empty",
"returns",
"whether",
"the",
"UpdateStrategy",
"is",
"empty",
"or",
"has",
"user",
"defined",
"values",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L506-L544 |
133,573 | hashicorp/nomad | api/jobs.go | NewServiceJob | func NewServiceJob(id, name, region string, pri int) *Job {
return newJob(id, name, region, JobTypeService, pri)
} | go | func NewServiceJob(id, name, region string, pri int) *Job {
return newJob(id, name, region, JobTypeService, pri)
} | [
"func",
"NewServiceJob",
"(",
"id",
",",
"name",
",",
"region",
"string",
",",
"pri",
"int",
")",
"*",
"Job",
"{",
"return",
"newJob",
"(",
"id",
",",
"name",
",",
"region",
",",
"JobTypeService",
",",
"pri",
")",
"\n",
"}"
] | // NewServiceJob creates and returns a new service-style job
// for long-lived processes using the provided name, ID, and
// relative job priority. | [
"NewServiceJob",
"creates",
"and",
"returns",
"a",
"new",
"service",
"-",
"style",
"job",
"for",
"long",
"-",
"lived",
"processes",
"using",
"the",
"provided",
"name",
"ID",
"and",
"relative",
"job",
"priority",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L822-L824 |
133,574 | hashicorp/nomad | api/jobs.go | NewBatchJob | func NewBatchJob(id, name, region string, pri int) *Job {
return newJob(id, name, region, JobTypeBatch, pri)
} | go | func NewBatchJob(id, name, region string, pri int) *Job {
return newJob(id, name, region, JobTypeBatch, pri)
} | [
"func",
"NewBatchJob",
"(",
"id",
",",
"name",
",",
"region",
"string",
",",
"pri",
"int",
")",
"*",
"Job",
"{",
"return",
"newJob",
"(",
"id",
",",
"name",
",",
"region",
",",
"JobTypeBatch",
",",
"pri",
")",
"\n",
"}"
] | // NewBatchJob creates and returns a new batch-style job for
// short-lived processes using the provided name and ID along
// with the relative job priority. | [
"NewBatchJob",
"creates",
"and",
"returns",
"a",
"new",
"batch",
"-",
"style",
"job",
"for",
"short",
"-",
"lived",
"processes",
"using",
"the",
"provided",
"name",
"and",
"ID",
"along",
"with",
"the",
"relative",
"job",
"priority",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L829-L831 |
133,575 | hashicorp/nomad | api/jobs.go | newJob | func newJob(id, name, region, typ string, pri int) *Job {
return &Job{
Region: ®ion,
ID: &id,
Name: &name,
Type: &typ,
Priority: &pri,
}
} | go | func newJob(id, name, region, typ string, pri int) *Job {
return &Job{
Region: ®ion,
ID: &id,
Name: &name,
Type: &typ,
Priority: &pri,
}
} | [
"func",
"newJob",
"(",
"id",
",",
"name",
",",
"region",
",",
"typ",
"string",
",",
"pri",
"int",
")",
"*",
"Job",
"{",
"return",
"&",
"Job",
"{",
"Region",
":",
"&",
"region",
",",
"ID",
":",
"&",
"id",
",",
"Name",
":",
"&",
"name",
",",
"T... | // newJob is used to create a new Job struct. | [
"newJob",
"is",
"used",
"to",
"create",
"a",
"new",
"Job",
"struct",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L834-L842 |
133,576 | hashicorp/nomad | api/jobs.go | AddDatacenter | func (j *Job) AddDatacenter(dc string) *Job {
j.Datacenters = append(j.Datacenters, dc)
return j
} | go | func (j *Job) AddDatacenter(dc string) *Job {
j.Datacenters = append(j.Datacenters, dc)
return j
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"AddDatacenter",
"(",
"dc",
"string",
")",
"*",
"Job",
"{",
"j",
".",
"Datacenters",
"=",
"append",
"(",
"j",
".",
"Datacenters",
",",
"dc",
")",
"\n",
"return",
"j",
"\n",
"}"
] | // AddDatacenter is used to add a datacenter to a job. | [
"AddDatacenter",
"is",
"used",
"to",
"add",
"a",
"datacenter",
"to",
"a",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L854-L857 |
133,577 | hashicorp/nomad | api/jobs.go | Constrain | func (j *Job) Constrain(c *Constraint) *Job {
j.Constraints = append(j.Constraints, c)
return j
} | go | func (j *Job) Constrain(c *Constraint) *Job {
j.Constraints = append(j.Constraints, c)
return j
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Constrain",
"(",
"c",
"*",
"Constraint",
")",
"*",
"Job",
"{",
"j",
".",
"Constraints",
"=",
"append",
"(",
"j",
".",
"Constraints",
",",
"c",
")",
"\n",
"return",
"j",
"\n",
"}"
] | // Constrain is used to add a constraint to a job. | [
"Constrain",
"is",
"used",
"to",
"add",
"a",
"constraint",
"to",
"a",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L860-L863 |
133,578 | hashicorp/nomad | api/jobs.go | AddAffinity | func (j *Job) AddAffinity(a *Affinity) *Job {
j.Affinities = append(j.Affinities, a)
return j
} | go | func (j *Job) AddAffinity(a *Affinity) *Job {
j.Affinities = append(j.Affinities, a)
return j
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"AddAffinity",
"(",
"a",
"*",
"Affinity",
")",
"*",
"Job",
"{",
"j",
".",
"Affinities",
"=",
"append",
"(",
"j",
".",
"Affinities",
",",
"a",
")",
"\n",
"return",
"j",
"\n",
"}"
] | // AddAffinity is used to add an affinity to a job. | [
"AddAffinity",
"is",
"used",
"to",
"add",
"an",
"affinity",
"to",
"a",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L866-L869 |
133,579 | hashicorp/nomad | api/jobs.go | AddTaskGroup | func (j *Job) AddTaskGroup(grp *TaskGroup) *Job {
j.TaskGroups = append(j.TaskGroups, grp)
return j
} | go | func (j *Job) AddTaskGroup(grp *TaskGroup) *Job {
j.TaskGroups = append(j.TaskGroups, grp)
return j
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"AddTaskGroup",
"(",
"grp",
"*",
"TaskGroup",
")",
"*",
"Job",
"{",
"j",
".",
"TaskGroups",
"=",
"append",
"(",
"j",
".",
"TaskGroups",
",",
"grp",
")",
"\n",
"return",
"j",
"\n",
"}"
] | // AddTaskGroup adds a task group to an existing job. | [
"AddTaskGroup",
"adds",
"a",
"task",
"group",
"to",
"an",
"existing",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L872-L875 |
133,580 | hashicorp/nomad | api/jobs.go | AddPeriodicConfig | func (j *Job) AddPeriodicConfig(cfg *PeriodicConfig) *Job {
j.Periodic = cfg
return j
} | go | func (j *Job) AddPeriodicConfig(cfg *PeriodicConfig) *Job {
j.Periodic = cfg
return j
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"AddPeriodicConfig",
"(",
"cfg",
"*",
"PeriodicConfig",
")",
"*",
"Job",
"{",
"j",
".",
"Periodic",
"=",
"cfg",
"\n",
"return",
"j",
"\n",
"}"
] | // AddPeriodicConfig adds a periodic config to an existing job. | [
"AddPeriodicConfig",
"adds",
"a",
"periodic",
"config",
"to",
"an",
"existing",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/jobs.go#L878-L881 |
133,581 | hashicorp/nomad | api/quota.go | List | func (q *Quotas) List(qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error) {
var resp []*QuotaSpec
qm, err := q.client.query("/v1/quotas", &resp, qo)
if err != nil {
return nil, nil, err
}
sort.Sort(QuotaSpecIndexSort(resp))
return resp, qm, nil
} | go | func (q *Quotas) List(qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error) {
var resp []*QuotaSpec
qm, err := q.client.query("/v1/quotas", &resp, qo)
if err != nil {
return nil, nil, err
}
sort.Sort(QuotaSpecIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"List",
"(",
"qo",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"QuotaSpec",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"QuotaSpec",
"\n",
"qm",
",",
"err",
":=",
"q",
"."... | // List is used to dump all of the quota specs | [
"List",
"is",
"used",
"to",
"dump",
"all",
"of",
"the",
"quota",
"specs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L19-L27 |
133,582 | hashicorp/nomad | api/quota.go | PrefixList | func (q *Quotas) PrefixList(prefix string, qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error) {
if qo == nil {
qo = &QueryOptions{Prefix: prefix}
} else {
qo.Prefix = prefix
}
return q.List(qo)
} | go | func (q *Quotas) PrefixList(prefix string, qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error) {
if qo == nil {
qo = &QueryOptions{Prefix: prefix}
} else {
qo.Prefix = prefix
}
return q.List(qo)
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"PrefixList",
"(",
"prefix",
"string",
",",
"qo",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"QuotaSpec",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"if",
"qo",
"==",
"nil",
"{",
"qo",
"=",
"&",
"Query... | // PrefixList is used to do a PrefixList search over quota specs | [
"PrefixList",
"is",
"used",
"to",
"do",
"a",
"PrefixList",
"search",
"over",
"quota",
"specs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L30-L38 |
133,583 | hashicorp/nomad | api/quota.go | ListUsage | func (q *Quotas) ListUsage(qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
var resp []*QuotaUsage
qm, err := q.client.query("/v1/quota-usages", &resp, qo)
if err != nil {
return nil, nil, err
}
sort.Sort(QuotaUsageIndexSort(resp))
return resp, qm, nil
} | go | func (q *Quotas) ListUsage(qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
var resp []*QuotaUsage
qm, err := q.client.query("/v1/quota-usages", &resp, qo)
if err != nil {
return nil, nil, err
}
sort.Sort(QuotaUsageIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"ListUsage",
"(",
"qo",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"QuotaUsage",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"QuotaUsage",
"\n",
"qm",
",",
"err",
":=",
"q"... | // ListUsage is used to dump all of the quota usages | [
"ListUsage",
"is",
"used",
"to",
"dump",
"all",
"of",
"the",
"quota",
"usages"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L41-L49 |
133,584 | hashicorp/nomad | api/quota.go | PrefixListUsage | func (q *Quotas) PrefixListUsage(prefix string, qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
if qo == nil {
qo = &QueryOptions{Prefix: prefix}
} else {
qo.Prefix = prefix
}
return q.ListUsage(qo)
} | go | func (q *Quotas) PrefixListUsage(prefix string, qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
if qo == nil {
qo = &QueryOptions{Prefix: prefix}
} else {
qo.Prefix = prefix
}
return q.ListUsage(qo)
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"PrefixListUsage",
"(",
"prefix",
"string",
",",
"qo",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"QuotaUsage",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"if",
"qo",
"==",
"nil",
"{",
"qo",
"=",
"&",
... | // PrefixList is used to do a PrefixList search over quota usages | [
"PrefixList",
"is",
"used",
"to",
"do",
"a",
"PrefixList",
"search",
"over",
"quota",
"usages"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L52-L60 |
133,585 | hashicorp/nomad | api/quota.go | Info | func (q *Quotas) Info(name string, qo *QueryOptions) (*QuotaSpec, *QueryMeta, error) {
var resp QuotaSpec
qm, err := q.client.query("/v1/quota/"+name, &resp, qo)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (q *Quotas) Info(name string, qo *QueryOptions) (*QuotaSpec, *QueryMeta, error) {
var resp QuotaSpec
qm, err := q.client.query("/v1/quota/"+name, &resp, qo)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"Info",
"(",
"name",
"string",
",",
"qo",
"*",
"QueryOptions",
")",
"(",
"*",
"QuotaSpec",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"QuotaSpec",
"\n",
"qm",
",",
"err",
":=",
"q",
".",
"c... | // Info is used to query a single quota spec by its name. | [
"Info",
"is",
"used",
"to",
"query",
"a",
"single",
"quota",
"spec",
"by",
"its",
"name",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L63-L70 |
133,586 | hashicorp/nomad | api/quota.go | Usage | func (q *Quotas) Usage(name string, qo *QueryOptions) (*QuotaUsage, *QueryMeta, error) {
var resp QuotaUsage
qm, err := q.client.query("/v1/quota/usage/"+name, &resp, qo)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (q *Quotas) Usage(name string, qo *QueryOptions) (*QuotaUsage, *QueryMeta, error) {
var resp QuotaUsage
qm, err := q.client.query("/v1/quota/usage/"+name, &resp, qo)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"Usage",
"(",
"name",
"string",
",",
"qo",
"*",
"QueryOptions",
")",
"(",
"*",
"QuotaUsage",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"QuotaUsage",
"\n",
"qm",
",",
"err",
":=",
"q",
".",
... | // Usage is used to query a single quota usage by its name. | [
"Usage",
"is",
"used",
"to",
"query",
"a",
"single",
"quota",
"usage",
"by",
"its",
"name",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L73-L80 |
133,587 | hashicorp/nomad | api/quota.go | Register | func (q *Quotas) Register(spec *QuotaSpec, qo *WriteOptions) (*WriteMeta, error) {
wm, err := q.client.write("/v1/quota", spec, nil, qo)
if err != nil {
return nil, err
}
return wm, nil
} | go | func (q *Quotas) Register(spec *QuotaSpec, qo *WriteOptions) (*WriteMeta, error) {
wm, err := q.client.write("/v1/quota", spec, nil, qo)
if err != nil {
return nil, err
}
return wm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"Register",
"(",
"spec",
"*",
"QuotaSpec",
",",
"qo",
"*",
"WriteOptions",
")",
"(",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"wm",
",",
"err",
":=",
"q",
".",
"client",
".",
"write",
"(",
"\"",
"\"",
",",
... | // Register is used to register a quota spec. | [
"Register",
"is",
"used",
"to",
"register",
"a",
"quota",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L83-L89 |
133,588 | hashicorp/nomad | api/quota.go | Delete | func (q *Quotas) Delete(quota string, qo *WriteOptions) (*WriteMeta, error) {
wm, err := q.client.delete(fmt.Sprintf("/v1/quota/%s", quota), nil, qo)
if err != nil {
return nil, err
}
return wm, nil
} | go | func (q *Quotas) Delete(quota string, qo *WriteOptions) (*WriteMeta, error) {
wm, err := q.client.delete(fmt.Sprintf("/v1/quota/%s", quota), nil, qo)
if err != nil {
return nil, err
}
return wm, nil
} | [
"func",
"(",
"q",
"*",
"Quotas",
")",
"Delete",
"(",
"quota",
"string",
",",
"qo",
"*",
"WriteOptions",
")",
"(",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"wm",
",",
"err",
":=",
"q",
".",
"client",
".",
"delete",
"(",
"fmt",
".",
"Sprintf",
"("... | // Delete is used to delete a quota spec | [
"Delete",
"is",
"used",
"to",
"delete",
"a",
"quota",
"spec"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/quota.go#L92-L98 |
133,589 | hashicorp/nomad | command/agent/command.go | setupAgent | func (c *Command) setupAgent(config *Config, logger hclog.Logger, logOutput io.Writer, inmem *metrics.InmemSink) error {
c.Ui.Output("Starting Nomad agent...")
agent, err := NewAgent(config, logger, logOutput, inmem)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error starting agent: %s", err))
return err
}
c.agent ... | go | func (c *Command) setupAgent(config *Config, logger hclog.Logger, logOutput io.Writer, inmem *metrics.InmemSink) error {
c.Ui.Output("Starting Nomad agent...")
agent, err := NewAgent(config, logger, logOutput, inmem)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error starting agent: %s", err))
return err
}
c.agent ... | [
"func",
"(",
"c",
"*",
"Command",
")",
"setupAgent",
"(",
"config",
"*",
"Config",
",",
"logger",
"hclog",
".",
"Logger",
",",
"logOutput",
"io",
".",
"Writer",
",",
"inmem",
"*",
"metrics",
".",
"InmemSink",
")",
"error",
"{",
"c",
".",
"Ui",
".",
... | // setupAgent is used to start the agent and various interfaces | [
"setupAgent",
"is",
"used",
"to",
"start",
"the",
"agent",
"and",
"various",
"interfaces"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/command.go#L411-L455 |
133,590 | hashicorp/nomad | command/agent/command.go | handleRetryJoin | func (c *Command) handleRetryJoin(config *Config) error {
c.retryJoinErrCh = make(chan struct{})
if config.Server.Enabled && len(config.Server.RetryJoin) != 0 {
joiner := retryJoiner{
discover: &discover.Discover{},
errCh: c.retryJoinErrCh,
logger: c.agent.logger.Named("joiner"),
se... | go | func (c *Command) handleRetryJoin(config *Config) error {
c.retryJoinErrCh = make(chan struct{})
if config.Server.Enabled && len(config.Server.RetryJoin) != 0 {
joiner := retryJoiner{
discover: &discover.Discover{},
errCh: c.retryJoinErrCh,
logger: c.agent.logger.Named("joiner"),
se... | [
"func",
"(",
"c",
"*",
"Command",
")",
"handleRetryJoin",
"(",
"config",
"*",
"Config",
")",
"error",
"{",
"c",
".",
"retryJoinErrCh",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"if",
"config",
".",
"Server",
".",
"Enabled",
"&&",
"le... | // handleRetryJoin is used to start retry joining if it is configured. | [
"handleRetryJoin",
"is",
"used",
"to",
"start",
"retry",
"joining",
"if",
"it",
"is",
"configured",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/command.go#L657-L728 |
133,591 | hashicorp/nomad | command/agent/command.go | handleSignals | func (c *Command) handleSignals() int {
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGPIPE)
// Wait for a signal
WAIT:
var sig os.Signal
select {
case s := <-signalCh:
sig = s
case <-c.ShutdownCh:
sig = os.Interrupt
case <-c.retryJoinE... | go | func (c *Command) handleSignals() int {
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGPIPE)
// Wait for a signal
WAIT:
var sig os.Signal
select {
case s := <-signalCh:
sig = s
case <-c.ShutdownCh:
sig = os.Interrupt
case <-c.retryJoinE... | [
"func",
"(",
"c",
"*",
"Command",
")",
"handleSignals",
"(",
")",
"int",
"{",
"signalCh",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"4",
")",
"\n",
"signal",
".",
"Notify",
"(",
"signalCh",
",",
"os",
".",
"Interrupt",
",",
"syscall",
".... | // handleSignals blocks until we get an exit-causing signal | [
"handleSignals",
"blocks",
"until",
"we",
"get",
"an",
"exit",
"-",
"causing",
"signal"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/command.go#L731-L793 |
133,592 | hashicorp/nomad | command/agent/command.go | reloadHTTPServer | func (c *Command) reloadHTTPServer() error {
c.agent.logger.Info("reloading HTTP server with new TLS configuration")
c.httpServer.Shutdown()
http, err := NewHTTPServer(c.agent, c.agent.config)
if err != nil {
return err
}
c.httpServer = http
return nil
} | go | func (c *Command) reloadHTTPServer() error {
c.agent.logger.Info("reloading HTTP server with new TLS configuration")
c.httpServer.Shutdown()
http, err := NewHTTPServer(c.agent, c.agent.config)
if err != nil {
return err
}
c.httpServer = http
return nil
} | [
"func",
"(",
"c",
"*",
"Command",
")",
"reloadHTTPServer",
"(",
")",
"error",
"{",
"c",
".",
"agent",
".",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"c",
".",
"httpServer",
".",
"Shutdown",
"(",
")",
"\n\n",
"http",
",",
"err",
":=",
"... | // reloadHTTPServer shuts down the existing HTTP server and restarts it. This
// is helpful when reloading the agent configuration. | [
"reloadHTTPServer",
"shuts",
"down",
"the",
"existing",
"HTTP",
"server",
"and",
"restarts",
"it",
".",
"This",
"is",
"helpful",
"when",
"reloading",
"the",
"agent",
"configuration",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/command.go#L797-L809 |
133,593 | hashicorp/nomad | command/agent/command.go | getBindAddrSynopsis | func (c *Command) getBindAddrSynopsis() string {
if c == nil || c.agent == nil || c.agent.config == nil || c.agent.config.normalizedAddrs == nil {
return ""
}
b := new(strings.Builder)
fmt.Fprintf(b, "HTTP: %s", c.agent.config.normalizedAddrs.HTTP)
if c.agent.server != nil {
if c.agent.config.normalizedAddrs... | go | func (c *Command) getBindAddrSynopsis() string {
if c == nil || c.agent == nil || c.agent.config == nil || c.agent.config.normalizedAddrs == nil {
return ""
}
b := new(strings.Builder)
fmt.Fprintf(b, "HTTP: %s", c.agent.config.normalizedAddrs.HTTP)
if c.agent.server != nil {
if c.agent.config.normalizedAddrs... | [
"func",
"(",
"c",
"*",
"Command",
")",
"getBindAddrSynopsis",
"(",
")",
"string",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"agent",
"==",
"nil",
"||",
"c",
".",
"agent",
".",
"config",
"==",
"nil",
"||",
"c",
".",
"agent",
".",
"config",
".",... | // getBindAddrSynopsis returns a string that describes the addresses the agent
// is bound to. | [
"getBindAddrSynopsis",
"returns",
"a",
"string",
"that",
"describes",
"the",
"addresses",
"the",
"agent",
"is",
"bound",
"to",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/command.go#L1060-L1078 |
133,594 | hashicorp/nomad | command/server_members.go | regionLeaders | func regionLeaders(client *api.Client, mem []*api.AgentMember) (map[string]string, error) {
// Determine the unique regions.
leaders := make(map[string]string)
regions := make(map[string]struct{})
for _, m := range mem {
// Ignore left members
// This prevents querying for leader status on regions where all mem... | go | func regionLeaders(client *api.Client, mem []*api.AgentMember) (map[string]string, error) {
// Determine the unique regions.
leaders := make(map[string]string)
regions := make(map[string]struct{})
for _, m := range mem {
// Ignore left members
// This prevents querying for leader status on regions where all mem... | [
"func",
"regionLeaders",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"mem",
"[",
"]",
"*",
"api",
".",
"AgentMember",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"// Determine the unique regions.",
"leaders",
":=",
"make",
"... | // regionLeaders returns a map of regions to the IP of the member that is the
// leader. | [
"regionLeaders",
"returns",
"a",
"map",
"of",
"regions",
"to",
"the",
"IP",
"of",
"the",
"member",
"that",
"is",
"the",
"leader",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/server_members.go#L174-L205 |
133,595 | hashicorp/nomad | plugins/device/device.go | Validate | func (d *DeviceGroup) Validate() error {
var mErr multierror.Error
if d.Vendor == "" {
multierror.Append(&mErr, fmt.Errorf("device vendor must be specified"))
}
if d.Type == "" {
multierror.Append(&mErr, fmt.Errorf("device type must be specified"))
}
if d.Name == "" {
multierror.Append(&mErr, fmt.Errorf("d... | go | func (d *DeviceGroup) Validate() error {
var mErr multierror.Error
if d.Vendor == "" {
multierror.Append(&mErr, fmt.Errorf("device vendor must be specified"))
}
if d.Type == "" {
multierror.Append(&mErr, fmt.Errorf("device type must be specified"))
}
if d.Name == "" {
multierror.Append(&mErr, fmt.Errorf("d... | [
"func",
"(",
"d",
"*",
"DeviceGroup",
")",
"Validate",
"(",
")",
"error",
"{",
"var",
"mErr",
"multierror",
".",
"Error",
"\n\n",
"if",
"d",
".",
"Vendor",
"==",
"\"",
"\"",
"{",
"multierror",
".",
"Append",
"(",
"&",
"mErr",
",",
"fmt",
".",
"Erro... | // Validate validates that the device group is valid | [
"Validate",
"validates",
"that",
"the",
"device",
"group",
"is",
"valid"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/device.go#L80-L112 |
133,596 | hashicorp/nomad | scheduler/spread.go | computeSpreadInfo | func (iter *SpreadIterator) computeSpreadInfo(tg *structs.TaskGroup) {
spreadInfos := make(spreadAttributeMap, len(tg.Spreads))
totalCount := tg.Count
// Always combine any spread stanzas defined at the job level here
combinedSpreads := make([]*structs.Spread, 0, len(tg.Spreads)+len(iter.jobSpreads))
combinedSpre... | go | func (iter *SpreadIterator) computeSpreadInfo(tg *structs.TaskGroup) {
spreadInfos := make(spreadAttributeMap, len(tg.Spreads))
totalCount := tg.Count
// Always combine any spread stanzas defined at the job level here
combinedSpreads := make([]*structs.Spread, 0, len(tg.Spreads)+len(iter.jobSpreads))
combinedSpre... | [
"func",
"(",
"iter",
"*",
"SpreadIterator",
")",
"computeSpreadInfo",
"(",
"tg",
"*",
"structs",
".",
"TaskGroup",
")",
"{",
"spreadInfos",
":=",
"make",
"(",
"spreadAttributeMap",
",",
"len",
"(",
"tg",
".",
"Spreads",
")",
")",
"\n",
"totalCount",
":=",
... | // computeSpreadInfo computes and stores percentages and total values
// from all spreads that apply to a specific task group | [
"computeSpreadInfo",
"computes",
"and",
"stores",
"percentages",
"and",
"total",
"values",
"from",
"all",
"spreads",
"that",
"apply",
"to",
"a",
"specific",
"task",
"group"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/spread.go#L227-L252 |
133,597 | hashicorp/nomad | lib/circbufwriter/writer.go | New | func New(w io.Writer, bufferSize int64) io.WriteCloser {
buf, _ := circbuf.NewBuffer(bufferSize)
c := &circbufWriter{
buf: buf,
wr: w,
flushCh: make(chan struct{}, 1),
}
go c.flushLoop()
return c
} | go | func New(w io.Writer, bufferSize int64) io.WriteCloser {
buf, _ := circbuf.NewBuffer(bufferSize)
c := &circbufWriter{
buf: buf,
wr: w,
flushCh: make(chan struct{}, 1),
}
go c.flushLoop()
return c
} | [
"func",
"New",
"(",
"w",
"io",
".",
"Writer",
",",
"bufferSize",
"int64",
")",
"io",
".",
"WriteCloser",
"{",
"buf",
",",
"_",
":=",
"circbuf",
".",
"NewBuffer",
"(",
"bufferSize",
")",
"\n",
"c",
":=",
"&",
"circbufWriter",
"{",
"buf",
":",
"buf",
... | // New created a circle buffered writer that wraps the given writer. The
// bufferSize is the amount of data that will be stored in memory before
// overwriting. | [
"New",
"created",
"a",
"circle",
"buffered",
"writer",
"that",
"wraps",
"the",
"given",
"writer",
".",
"The",
"bufferSize",
"is",
"the",
"amount",
"of",
"data",
"that",
"will",
"be",
"stored",
"in",
"memory",
"before",
"overwriting",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/lib/circbufwriter/writer.go#L31-L40 |
133,598 | hashicorp/nomad | lib/circbufwriter/writer.go | Write | func (c *circbufWriter) Write(p []byte) (nn int, err error) {
// If the last write returned an error, return it here. Note there is a
// small chance of missing an error if multiple writes occure at the same
// time where the last write nils out the error before it can be returned
// here.
c.bufLock.Lock()
defer ... | go | func (c *circbufWriter) Write(p []byte) (nn int, err error) {
// If the last write returned an error, return it here. Note there is a
// small chance of missing an error if multiple writes occure at the same
// time where the last write nils out the error before it can be returned
// here.
c.bufLock.Lock()
defer ... | [
"func",
"(",
"c",
"*",
"circbufWriter",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"nn",
"int",
",",
"err",
"error",
")",
"{",
"// If the last write returned an error, return it here. Note there is a",
"// small chance of missing an error if multiple writes occur... | // Write will write the data to the buffer and attempt to flush the buffer to
// the wrapped writer. If the wrapped writer blocks on write, subsequent write
// will be written to the circle buffer. | [
"Write",
"will",
"write",
"the",
"data",
"to",
"the",
"buffer",
"and",
"attempt",
"to",
"flush",
"the",
"buffer",
"to",
"the",
"wrapped",
"writer",
".",
"If",
"the",
"wrapped",
"writer",
"blocks",
"on",
"write",
"subsequent",
"write",
"will",
"be",
"writte... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/lib/circbufwriter/writer.go#L45-L66 |
133,599 | hashicorp/nomad | api/resources.go | Canonicalize | func (r *Resources) Canonicalize() {
defaultResources := DefaultResources()
if r.CPU == nil {
r.CPU = defaultResources.CPU
}
if r.MemoryMB == nil {
r.MemoryMB = defaultResources.MemoryMB
}
for _, n := range r.Networks {
n.Canonicalize()
}
for _, d := range r.Devices {
d.Canonicalize()
}
} | go | func (r *Resources) Canonicalize() {
defaultResources := DefaultResources()
if r.CPU == nil {
r.CPU = defaultResources.CPU
}
if r.MemoryMB == nil {
r.MemoryMB = defaultResources.MemoryMB
}
for _, n := range r.Networks {
n.Canonicalize()
}
for _, d := range r.Devices {
d.Canonicalize()
}
} | [
"func",
"(",
"r",
"*",
"Resources",
")",
"Canonicalize",
"(",
")",
"{",
"defaultResources",
":=",
"DefaultResources",
"(",
")",
"\n",
"if",
"r",
".",
"CPU",
"==",
"nil",
"{",
"r",
".",
"CPU",
"=",
"defaultResources",
".",
"CPU",
"\n",
"}",
"\n",
"if"... | // Canonicalize will supply missing values in the cases
// where they are not provided. | [
"Canonicalize",
"will",
"supply",
"missing",
"values",
"in",
"the",
"cases",
"where",
"they",
"are",
"not",
"provided",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/resources.go#L25-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.