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,200 | hashicorp/nomad | nomad/structs/config/consul.go | Merge | func (a *ConsulConfig) Merge(b *ConsulConfig) *ConsulConfig {
result := a.Copy()
if b.ServerServiceName != "" {
result.ServerServiceName = b.ServerServiceName
}
if b.ServerHTTPCheckName != "" {
result.ServerHTTPCheckName = b.ServerHTTPCheckName
}
if b.ServerSerfCheckName != "" {
result.ServerSerfCheckName ... | go | func (a *ConsulConfig) Merge(b *ConsulConfig) *ConsulConfig {
result := a.Copy()
if b.ServerServiceName != "" {
result.ServerServiceName = b.ServerServiceName
}
if b.ServerHTTPCheckName != "" {
result.ServerHTTPCheckName = b.ServerHTTPCheckName
}
if b.ServerSerfCheckName != "" {
result.ServerSerfCheckName ... | [
"func",
"(",
"a",
"*",
"ConsulConfig",
")",
"Merge",
"(",
"b",
"*",
"ConsulConfig",
")",
"*",
"ConsulConfig",
"{",
"result",
":=",
"a",
".",
"Copy",
"(",
")",
"\n\n",
"if",
"b",
".",
"ServerServiceName",
"!=",
"\"",
"\"",
"{",
"result",
".",
"ServerS... | // Merge merges two Consul Configurations together. | [
"Merge",
"merges",
"two",
"Consul",
"Configurations",
"together",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/consul.go#L114-L175 |
133,201 | hashicorp/nomad | nomad/structs/config/consul.go | Copy | func (c *ConsulConfig) Copy() *ConsulConfig {
if c == nil {
return nil
}
nc := new(ConsulConfig)
*nc = *c
// Copy the bools
if nc.AutoAdvertise != nil {
nc.AutoAdvertise = helper.BoolToPtr(*nc.AutoAdvertise)
}
if nc.ChecksUseAdvertise != nil {
nc.ChecksUseAdvertise = helper.BoolToPtr(*nc.ChecksUseAdvert... | go | func (c *ConsulConfig) Copy() *ConsulConfig {
if c == nil {
return nil
}
nc := new(ConsulConfig)
*nc = *c
// Copy the bools
if nc.AutoAdvertise != nil {
nc.AutoAdvertise = helper.BoolToPtr(*nc.AutoAdvertise)
}
if nc.ChecksUseAdvertise != nil {
nc.ChecksUseAdvertise = helper.BoolToPtr(*nc.ChecksUseAdvert... | [
"func",
"(",
"c",
"*",
"ConsulConfig",
")",
"Copy",
"(",
")",
"*",
"ConsulConfig",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"nc",
":=",
"new",
"(",
"ConsulConfig",
")",
"\n",
"*",
"nc",
"=",
"*",
"c",
"\n\n",
"// Copy... | // Copy returns a copy of this Consul config. | [
"Copy",
"returns",
"a",
"copy",
"of",
"this",
"Consul",
"config",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/consul.go#L234-L263 |
133,202 | hashicorp/nomad | client/allocwatcher/group_alloc_watcher.go | Wait | func (g *groupPrevAllocWatcher) Wait(ctx context.Context) error {
g.waitingLock.Lock()
g.waiting = true
g.waitingLock.Unlock()
defer func() {
g.waitingLock.Lock()
g.waiting = false
g.waitingLock.Unlock()
}()
var merr multierror.Error
var errmu sync.Mutex
g.wg.Add(len(g.prevAllocs))
for _, alloc := ran... | go | func (g *groupPrevAllocWatcher) Wait(ctx context.Context) error {
g.waitingLock.Lock()
g.waiting = true
g.waitingLock.Unlock()
defer func() {
g.waitingLock.Lock()
g.waiting = false
g.waitingLock.Unlock()
}()
var merr multierror.Error
var errmu sync.Mutex
g.wg.Add(len(g.prevAllocs))
for _, alloc := ran... | [
"func",
"(",
"g",
"*",
"groupPrevAllocWatcher",
")",
"Wait",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"g",
".",
"waitingLock",
".",
"Lock",
"(",
")",
"\n",
"g",
".",
"waiting",
"=",
"true",
"\n",
"g",
".",
"waitingLock",
".",
"Unlock... | // Wait on the previous allocs to become terminal, exit, or, return due to
// context termination. Usage of the groupPrevAllocWatcher requires that all
// sub-watchers correctly handle context cancellation.
// We may need to adjust this to use channels rather than a wait group, if we
// wish to more strictly enforce ti... | [
"Wait",
"on",
"the",
"previous",
"allocs",
"to",
"become",
"terminal",
"exit",
"or",
"return",
"due",
"to",
"context",
"termination",
".",
"Usage",
"of",
"the",
"groupPrevAllocWatcher",
"requires",
"that",
"all",
"sub",
"-",
"watchers",
"correctly",
"handle",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/group_alloc_watcher.go#L32-L68 |
133,203 | hashicorp/nomad | client/fingerprint/nomad.go | NewNomadFingerprint | func NewNomadFingerprint(logger log.Logger) Fingerprint {
f := &NomadFingerprint{logger: logger.Named("nomad")}
return f
} | go | func NewNomadFingerprint(logger log.Logger) Fingerprint {
f := &NomadFingerprint{logger: logger.Named("nomad")}
return f
} | [
"func",
"NewNomadFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"f",
":=",
"&",
"NomadFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // NewNomadFingerprint is used to create a Nomad fingerprint | [
"NewNomadFingerprint",
"is",
"used",
"to",
"create",
"a",
"Nomad",
"fingerprint"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/nomad.go#L14-L17 |
133,204 | hashicorp/nomad | nomad/state/autopilot.go | autopilotConfigTableSchema | func autopilotConfigTableSchema() *memdb.TableSchema {
return &memdb.TableSchema{
Name: "autopilot-config",
Indexes: map[string]*memdb.IndexSchema{
"id": {
Name: "id",
AllowMissing: true,
Unique: true,
Indexer: &memdb.ConditionalIndex{
Conditional: func(obj interface{}) (bool,... | go | func autopilotConfigTableSchema() *memdb.TableSchema {
return &memdb.TableSchema{
Name: "autopilot-config",
Indexes: map[string]*memdb.IndexSchema{
"id": {
Name: "id",
AllowMissing: true,
Unique: true,
Indexer: &memdb.ConditionalIndex{
Conditional: func(obj interface{}) (bool,... | [
"func",
"autopilotConfigTableSchema",
"(",
")",
"*",
"memdb",
".",
"TableSchema",
"{",
"return",
"&",
"memdb",
".",
"TableSchema",
"{",
"Name",
":",
"\"",
"\"",
",",
"Indexes",
":",
"map",
"[",
"string",
"]",
"*",
"memdb",
".",
"IndexSchema",
"{",
"\"",
... | // autopilotConfigTableSchema returns a new table schema used for storing
// the autopilot configuration | [
"autopilotConfigTableSchema",
"returns",
"a",
"new",
"table",
"schema",
"used",
"for",
"storing",
"the",
"autopilot",
"configuration"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/autopilot.go#L12-L26 |
133,205 | hashicorp/nomad | client/lib/streamframer/framer.go | NewStreamFramer | func NewStreamFramer(out chan<- *StreamFrame,
heartbeatRate, batchWindow time.Duration, frameSize int) *StreamFramer {
// Create the heartbeat and flush ticker
heartbeat := time.NewTicker(heartbeatRate)
flusher := time.NewTicker(batchWindow)
return &StreamFramer{
out: out,
frameSize: frameSize,
hea... | go | func NewStreamFramer(out chan<- *StreamFrame,
heartbeatRate, batchWindow time.Duration, frameSize int) *StreamFramer {
// Create the heartbeat and flush ticker
heartbeat := time.NewTicker(heartbeatRate)
flusher := time.NewTicker(batchWindow)
return &StreamFramer{
out: out,
frameSize: frameSize,
hea... | [
"func",
"NewStreamFramer",
"(",
"out",
"chan",
"<-",
"*",
"StreamFrame",
",",
"heartbeatRate",
",",
"batchWindow",
"time",
".",
"Duration",
",",
"frameSize",
"int",
")",
"*",
"StreamFramer",
"{",
"// Create the heartbeat and flush ticker",
"heartbeat",
":=",
"time",... | // NewStreamFramer creates a new stream framer that will output StreamFrames to
// the passed output channel. | [
"NewStreamFramer",
"creates",
"a",
"new",
"stream",
"framer",
"that",
"will",
"output",
"StreamFrames",
"to",
"the",
"passed",
"output",
"channel",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L101-L118 |
133,206 | hashicorp/nomad | client/lib/streamframer/framer.go | Destroy | func (s *StreamFramer) Destroy() {
s.l.Lock()
wasShutdown := s.shutdown
s.shutdown = true
if !wasShutdown {
close(s.shutdownCh)
}
s.heartbeat.Stop()
s.flusher.Stop()
running := s.running
s.l.Unlock()
// Ensure things were flushed
if running {
<-s.exitCh
}
// Close out chan only after exitCh has ex... | go | func (s *StreamFramer) Destroy() {
s.l.Lock()
wasShutdown := s.shutdown
s.shutdown = true
if !wasShutdown {
close(s.shutdownCh)
}
s.heartbeat.Stop()
s.flusher.Stop()
running := s.running
s.l.Unlock()
// Ensure things were flushed
if running {
<-s.exitCh
}
// Close out chan only after exitCh has ex... | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"Destroy",
"(",
")",
"{",
"s",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",
"wasShutdown",
":=",
"s",
".",
"shutdown",
"\n",
"s",
".",
"shutdown",
"=",
"true",
"\n\n",
"if",
"!",
"wasShutdown",
"{",
"close",
... | // Destroy is used to cleanup the StreamFramer and flush any pending frames | [
"Destroy",
"is",
"used",
"to",
"cleanup",
"the",
"StreamFramer",
"and",
"flush",
"any",
"pending",
"frames"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L121-L145 |
133,207 | hashicorp/nomad | client/lib/streamframer/framer.go | Run | func (s *StreamFramer) Run() {
s.l.Lock()
defer s.l.Unlock()
if s.running {
return
}
s.running = true
go s.run()
} | go | func (s *StreamFramer) Run() {
s.l.Lock()
defer s.l.Unlock()
if s.running {
return
}
s.running = true
go s.run()
} | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"Run",
"(",
")",
"{",
"s",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"if",
"s",
".",
"running",
"{",
"return",
"\n",
"}",
"\n\n",
"s",
".",
"run... | // Run starts a long lived goroutine that handles sending data as well as
// heartbeating | [
"Run",
"starts",
"a",
"long",
"lived",
"goroutine",
"that",
"handles",
"sending",
"data",
"as",
"well",
"as",
"heartbeating"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L149-L158 |
133,208 | hashicorp/nomad | client/lib/streamframer/framer.go | run | func (s *StreamFramer) run() {
defer func() {
s.l.Lock()
s.running = false
s.l.Unlock()
close(s.exitCh)
}()
OUTER:
for {
select {
case <-s.shutdownCh:
break OUTER
case <-s.flusher.C:
// Skip if there is nothing to flush
s.l.Lock()
if s.f.IsCleared() {
s.l.Unlock()
continue
}
... | go | func (s *StreamFramer) run() {
defer func() {
s.l.Lock()
s.running = false
s.l.Unlock()
close(s.exitCh)
}()
OUTER:
for {
select {
case <-s.shutdownCh:
break OUTER
case <-s.flusher.C:
// Skip if there is nothing to flush
s.l.Lock()
if s.f.IsCleared() {
s.l.Unlock()
continue
}
... | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"run",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"s",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"running",
"=",
"false",
"\n",
"s",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"close",
"(... | // run is the internal run method. It exits if Destroy is called or an error
// occurs, in which case the exit channel is closed. | [
"run",
"is",
"the",
"internal",
"run",
"method",
".",
"It",
"exits",
"if",
"Destroy",
"is",
"called",
"or",
"an",
"error",
"occurs",
"in",
"which",
"case",
"the",
"exit",
"channel",
"is",
"closed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L167-L213 |
133,209 | hashicorp/nomad | client/lib/streamframer/framer.go | send | func (s *StreamFramer) send() {
// Ensure s.out has not already been closd by Destroy
select {
case <-s.exitCh:
return
default:
}
s.f.Data = s.readData()
select {
case s.out <- s.f.Copy():
s.f.Clear()
case <-s.exitCh:
}
} | go | func (s *StreamFramer) send() {
// Ensure s.out has not already been closd by Destroy
select {
case <-s.exitCh:
return
default:
}
s.f.Data = s.readData()
select {
case s.out <- s.f.Copy():
s.f.Clear()
case <-s.exitCh:
}
} | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"send",
"(",
")",
"{",
"// Ensure s.out has not already been closd by Destroy",
"select",
"{",
"case",
"<-",
"s",
".",
"exitCh",
":",
"return",
"\n",
"default",
":",
"}",
"\n\n",
"s",
".",
"f",
".",
"Data",
"=",
... | // send takes a StreamFrame, encodes and sends it | [
"send",
"takes",
"a",
"StreamFrame",
"encodes",
"and",
"sends",
"it"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L216-L230 |
133,210 | hashicorp/nomad | client/lib/streamframer/framer.go | readData | func (s *StreamFramer) readData() []byte {
// Compute the amount to read from the buffer
size := s.data.Len()
if size > s.frameSize {
size = s.frameSize
}
if size == 0 {
return nil
}
d := s.data.Next(size)
return d
} | go | func (s *StreamFramer) readData() []byte {
// Compute the amount to read from the buffer
size := s.data.Len()
if size > s.frameSize {
size = s.frameSize
}
if size == 0 {
return nil
}
d := s.data.Next(size)
return d
} | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"readData",
"(",
")",
"[",
"]",
"byte",
"{",
"// Compute the amount to read from the buffer",
"size",
":=",
"s",
".",
"data",
".",
"Len",
"(",
")",
"\n",
"if",
"size",
">",
"s",
".",
"frameSize",
"{",
"size",
... | // readData is a helper which reads the buffered data returning up to the frame
// size of data. Must be called with the lock held. The returned value is
// invalid on the next read or write into the StreamFramer buffer | [
"readData",
"is",
"a",
"helper",
"which",
"reads",
"the",
"buffered",
"data",
"returning",
"up",
"to",
"the",
"frame",
"size",
"of",
"data",
".",
"Must",
"be",
"called",
"with",
"the",
"lock",
"held",
".",
"The",
"returned",
"value",
"is",
"invalid",
"on... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L235-L246 |
133,211 | hashicorp/nomad | client/lib/streamframer/framer.go | Send | func (s *StreamFramer) Send(file, fileEvent string, data []byte, offset int64) error {
s.l.Lock()
defer s.l.Unlock()
// If we are not running, return the error that caused us to not run or
// indicated that it was never started.
if !s.running {
return fmt.Errorf("StreamFramer not running")
}
// Check if not m... | go | func (s *StreamFramer) Send(file, fileEvent string, data []byte, offset int64) error {
s.l.Lock()
defer s.l.Unlock()
// If we are not running, return the error that caused us to not run or
// indicated that it was never started.
if !s.running {
return fmt.Errorf("StreamFramer not running")
}
// Check if not m... | [
"func",
"(",
"s",
"*",
"StreamFramer",
")",
"Send",
"(",
"file",
",",
"fileEvent",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"offset",
"int64",
")",
"error",
"{",
"s",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"l",
".",
"Unl... | // Send creates and sends a StreamFrame based on the passed parameters. An error
// is returned if the run routine hasn't run or encountered an error. Send is
// asynchronous and does not block for the data to be transferred. | [
"Send",
"creates",
"and",
"sends",
"a",
"StreamFrame",
"based",
"on",
"the",
"passed",
"parameters",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"run",
"routine",
"hasn",
"t",
"run",
"or",
"encountered",
"an",
"error",
".",
"Send",
"is",
"asynchrono... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/streamframer/framer.go#L251-L308 |
133,212 | hashicorp/nomad | nomad/util.go | isNomadServer | func isNomadServer(m serf.Member) (bool, *serverParts) {
if m.Tags["role"] != "nomad" {
return false, nil
}
id := "unknown"
if v, ok := m.Tags["id"]; ok {
id = v
}
region := m.Tags["region"]
datacenter := m.Tags["dc"]
_, bootstrap := m.Tags["bootstrap"]
expect := 0
expectStr, ok := m.Tags["expect"]
var... | go | func isNomadServer(m serf.Member) (bool, *serverParts) {
if m.Tags["role"] != "nomad" {
return false, nil
}
id := "unknown"
if v, ok := m.Tags["id"]; ok {
id = v
}
region := m.Tags["region"]
datacenter := m.Tags["dc"]
_, bootstrap := m.Tags["bootstrap"]
expect := 0
expectStr, ok := m.Tags["expect"]
var... | [
"func",
"isNomadServer",
"(",
"m",
"serf",
".",
"Member",
")",
"(",
"bool",
",",
"*",
"serverParts",
")",
"{",
"if",
"m",
".",
"Tags",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"id",
":=",
"\... | // Returns if a member is a Nomad server. Returns a boolean,
// and a struct with the various important components | [
"Returns",
"if",
"a",
"member",
"is",
"a",
"Nomad",
"server",
".",
"Returns",
"a",
"boolean",
"and",
"a",
"struct",
"with",
"the",
"various",
"important",
"components"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L62-L149 |
133,213 | hashicorp/nomad | nomad/util.go | ServersMeetMinimumVersion | func ServersMeetMinimumVersion(members []serf.Member, minVersion *version.Version, checkFailedServers bool) bool {
for _, member := range members {
if valid, parts := isNomadServer(member); valid && (parts.Status == serf.StatusAlive || (checkFailedServers && parts.Status == serf.StatusFailed)) {
// Check if the v... | go | func ServersMeetMinimumVersion(members []serf.Member, minVersion *version.Version, checkFailedServers bool) bool {
for _, member := range members {
if valid, parts := isNomadServer(member); valid && (parts.Status == serf.StatusAlive || (checkFailedServers && parts.Status == serf.StatusFailed)) {
// Check if the v... | [
"func",
"ServersMeetMinimumVersion",
"(",
"members",
"[",
"]",
"serf",
".",
"Member",
",",
"minVersion",
"*",
"version",
".",
"Version",
",",
"checkFailedServers",
"bool",
")",
"bool",
"{",
"for",
"_",
",",
"member",
":=",
"range",
"members",
"{",
"if",
"v... | // ServersMeetMinimumVersion returns whether the Nomad servers are at least on the
// given Nomad version. The checkFailedServers parameter specifies whether version
// for the failed servers should be verified. | [
"ServersMeetMinimumVersion",
"returns",
"whether",
"the",
"Nomad",
"servers",
"are",
"at",
"least",
"on",
"the",
"given",
"Nomad",
"version",
".",
"The",
"checkFailedServers",
"parameter",
"specifies",
"whether",
"version",
"for",
"the",
"failed",
"servers",
"should... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L154-L167 |
133,214 | hashicorp/nomad | nomad/util.go | shuffleStrings | func shuffleStrings(list []string) {
for i := range list {
j := rand.Intn(i + 1)
list[i], list[j] = list[j], list[i]
}
} | go | func shuffleStrings(list []string) {
for i := range list {
j := rand.Intn(i + 1)
list[i], list[j] = list[j], list[i]
}
} | [
"func",
"shuffleStrings",
"(",
"list",
"[",
"]",
"string",
")",
"{",
"for",
"i",
":=",
"range",
"list",
"{",
"j",
":=",
"rand",
".",
"Intn",
"(",
"i",
"+",
"1",
")",
"\n",
"list",
"[",
"i",
"]",
",",
"list",
"[",
"j",
"]",
"=",
"list",
"[",
... | // shuffleStrings randomly shuffles the list of strings | [
"shuffleStrings",
"randomly",
"shuffles",
"the",
"list",
"of",
"strings"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L192-L197 |
133,215 | hashicorp/nomad | nomad/util.go | maxUint64 | func maxUint64(inputs ...uint64) uint64 {
l := len(inputs)
if l == 0 {
return 0
} else if l == 1 {
return inputs[0]
}
max := inputs[0]
for i := 1; i < l; i++ {
cur := inputs[i]
if cur > max {
max = cur
}
}
return max
} | go | func maxUint64(inputs ...uint64) uint64 {
l := len(inputs)
if l == 0 {
return 0
} else if l == 1 {
return inputs[0]
}
max := inputs[0]
for i := 1; i < l; i++ {
cur := inputs[i]
if cur > max {
max = cur
}
}
return max
} | [
"func",
"maxUint64",
"(",
"inputs",
"...",
"uint64",
")",
"uint64",
"{",
"l",
":=",
"len",
"(",
"inputs",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"else",
"if",
"l",
"==",
"1",
"{",
"return",
"inputs",
"[",
"0",
"]",
"\n"... | // maxUint64 returns the maximum value | [
"maxUint64",
"returns",
"the",
"maximum",
"value"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L200-L216 |
133,216 | hashicorp/nomad | nomad/util.go | getNodeForRpc | func getNodeForRpc(snap *state.StateSnapshot, nodeID string) (*structs.Node, error) {
node, err := snap.NodeByID(nil, nodeID)
if err != nil {
return nil, err
}
if node == nil {
return nil, fmt.Errorf("Unknown node %q", nodeID)
}
if err := nodeSupportsRpc(node); err != nil {
return nil, err
}
return nod... | go | func getNodeForRpc(snap *state.StateSnapshot, nodeID string) (*structs.Node, error) {
node, err := snap.NodeByID(nil, nodeID)
if err != nil {
return nil, err
}
if node == nil {
return nil, fmt.Errorf("Unknown node %q", nodeID)
}
if err := nodeSupportsRpc(node); err != nil {
return nil, err
}
return nod... | [
"func",
"getNodeForRpc",
"(",
"snap",
"*",
"state",
".",
"StateSnapshot",
",",
"nodeID",
"string",
")",
"(",
"*",
"structs",
".",
"Node",
",",
"error",
")",
"{",
"node",
",",
"err",
":=",
"snap",
".",
"NodeByID",
"(",
"nil",
",",
"nodeID",
")",
"\n",... | // getNodeForRpc returns a Node struct if the Node supports Node RPC. Otherwise
// an error is returned. | [
"getNodeForRpc",
"returns",
"a",
"Node",
"struct",
"if",
"the",
"Node",
"supports",
"Node",
"RPC",
".",
"Otherwise",
"an",
"error",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L220-L235 |
133,217 | hashicorp/nomad | nomad/util.go | nodeSupportsRpc | func nodeSupportsRpc(node *structs.Node) error {
rawNodeVer, ok := node.Attributes["nomad.version"]
if !ok {
return structs.ErrUnknownNomadVersion
}
nodeVer, err := version.NewVersion(rawNodeVer)
if err != nil {
return structs.ErrUnknownNomadVersion
}
if nodeVer.LessThan(minNodeVersionSupportingRPC) {
re... | go | func nodeSupportsRpc(node *structs.Node) error {
rawNodeVer, ok := node.Attributes["nomad.version"]
if !ok {
return structs.ErrUnknownNomadVersion
}
nodeVer, err := version.NewVersion(rawNodeVer)
if err != nil {
return structs.ErrUnknownNomadVersion
}
if nodeVer.LessThan(minNodeVersionSupportingRPC) {
re... | [
"func",
"nodeSupportsRpc",
"(",
"node",
"*",
"structs",
".",
"Node",
")",
"error",
"{",
"rawNodeVer",
",",
"ok",
":=",
"node",
".",
"Attributes",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"structs",
".",
"ErrUnknownNomadVersion",
"\n",
... | // nodeSupportsRpc returns a non-nil error if a Node does not support RPC. | [
"nodeSupportsRpc",
"returns",
"a",
"non",
"-",
"nil",
"error",
"if",
"a",
"Node",
"does",
"not",
"support",
"RPC",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/util.go#L240-L256 |
133,218 | hashicorp/nomad | client/state/08types.go | UnmarshalPre09HandleID | func UnmarshalPre09HandleID(raw []byte) (*TaskRunnerHandle08, error) {
var handle TaskRunnerHandle08
if err := json.Unmarshal(raw, &handle); err != nil {
return nil, fmt.Errorf("failed to decode 0.8 driver state: %v", err)
}
return &handle, nil
} | go | func UnmarshalPre09HandleID(raw []byte) (*TaskRunnerHandle08, error) {
var handle TaskRunnerHandle08
if err := json.Unmarshal(raw, &handle); err != nil {
return nil, fmt.Errorf("failed to decode 0.8 driver state: %v", err)
}
return &handle, nil
} | [
"func",
"UnmarshalPre09HandleID",
"(",
"raw",
"[",
"]",
"byte",
")",
"(",
"*",
"TaskRunnerHandle08",
",",
"error",
")",
"{",
"var",
"handle",
"TaskRunnerHandle08",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"raw",
",",
"&",
"handle",
")",
";... | // UnmarshalPre09HandleID decodes the pre09 json encoded handle ID | [
"UnmarshalPre09HandleID",
"decodes",
"the",
"pre09",
"json",
"encoded",
"handle",
"ID"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/08types.go#L128-L135 |
133,219 | hashicorp/nomad | client/devicemanager/instance.go | newInstanceManager | func newInstanceManager(c *instanceManagerConfig) *instanceManager {
ctx, cancel := context.WithCancel(c.Ctx)
i := &instanceManager{
logger: c.Logger.With("plugin", c.Id.Name),
ctx: ctx,
cancel: cancel,
loader: c.Loader,
storeReattach: c.StoreReattach... | go | func newInstanceManager(c *instanceManagerConfig) *instanceManager {
ctx, cancel := context.WithCancel(c.Ctx)
i := &instanceManager{
logger: c.Logger.With("plugin", c.Id.Name),
ctx: ctx,
cancel: cancel,
loader: c.Loader,
storeReattach: c.StoreReattach... | [
"func",
"newInstanceManager",
"(",
"c",
"*",
"instanceManagerConfig",
")",
"*",
"instanceManager",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"c",
".",
"Ctx",
")",
"\n",
"i",
":=",
"&",
"instanceManager",
"{",
"logger",
":",
"c",
... | // newInstanceManager returns a new device instance manager. It is expected that
// the context passed in the configuration is cancelled in order to shutdown
// launched goroutines. | [
"newInstanceManager",
"returns",
"a",
"new",
"device",
"instance",
"manager",
".",
"It",
"is",
"expected",
"that",
"the",
"context",
"passed",
"in",
"the",
"configuration",
"is",
"cancelled",
"in",
"order",
"to",
"shutdown",
"launched",
"goroutines",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L114-L132 |
133,220 | hashicorp/nomad | client/devicemanager/instance.go | HasDevices | func (i *instanceManager) HasDevices(d *structs.AllocatedDeviceResource) bool {
i.deviceLock.RLock()
defer i.deviceLock.RUnlock()
OUTER:
for _, dev := range i.devices {
if dev.Name != d.Name || dev.Type != d.Type || dev.Vendor != d.Vendor {
continue
}
// Check that we have all the requested devices
ids ... | go | func (i *instanceManager) HasDevices(d *structs.AllocatedDeviceResource) bool {
i.deviceLock.RLock()
defer i.deviceLock.RUnlock()
OUTER:
for _, dev := range i.devices {
if dev.Name != d.Name || dev.Type != d.Type || dev.Vendor != d.Vendor {
continue
}
// Check that we have all the requested devices
ids ... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"HasDevices",
"(",
"d",
"*",
"structs",
".",
"AllocatedDeviceResource",
")",
"bool",
"{",
"i",
".",
"deviceLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"deviceLock",
".",
"RUnlock",
"(",
")",
"\... | // HasDevices returns if the instance is managing the passed devices | [
"HasDevices",
"returns",
"if",
"the",
"instance",
"is",
"managing",
"the",
"passed",
"devices"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L135-L161 |
133,221 | hashicorp/nomad | client/devicemanager/instance.go | AllStats | func (i *instanceManager) AllStats() []*device.DeviceGroupStats {
i.deviceStatsLock.RLock()
defer i.deviceStatsLock.RUnlock()
return i.deviceStats
} | go | func (i *instanceManager) AllStats() []*device.DeviceGroupStats {
i.deviceStatsLock.RLock()
defer i.deviceStatsLock.RUnlock()
return i.deviceStats
} | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"AllStats",
"(",
")",
"[",
"]",
"*",
"device",
".",
"DeviceGroupStats",
"{",
"i",
".",
"deviceStatsLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"deviceStatsLock",
".",
"RUnlock",
"(",
")",
"\n",... | // AllStats returns all the device statistics returned by the device plugin. | [
"AllStats",
"returns",
"all",
"the",
"device",
"statistics",
"returned",
"by",
"the",
"device",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L164-L168 |
133,222 | hashicorp/nomad | client/devicemanager/instance.go | DeviceStats | func (i *instanceManager) DeviceStats(d *structs.AllocatedDeviceResource) *device.DeviceGroupStats {
i.deviceStatsLock.RLock()
defer i.deviceStatsLock.RUnlock()
// Find the device in question and then gather the instance statistics we
// are interested in
for _, group := range i.deviceStats {
if group.Vendor !=... | go | func (i *instanceManager) DeviceStats(d *structs.AllocatedDeviceResource) *device.DeviceGroupStats {
i.deviceStatsLock.RLock()
defer i.deviceStatsLock.RUnlock()
// Find the device in question and then gather the instance statistics we
// are interested in
for _, group := range i.deviceStats {
if group.Vendor !=... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"DeviceStats",
"(",
"d",
"*",
"structs",
".",
"AllocatedDeviceResource",
")",
"*",
"device",
".",
"DeviceGroupStats",
"{",
"i",
".",
"deviceStatsLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"deviceS... | // DeviceStats returns the device statistics for the request devices. | [
"DeviceStats",
"returns",
"the",
"device",
"statistics",
"for",
"the",
"request",
"devices",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L171-L198 |
133,223 | hashicorp/nomad | client/devicemanager/instance.go | Reserve | func (i *instanceManager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error) {
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
return nil, err
}
// Send the reserve request
return devicePlugin.Res... | go | func (i *instanceManager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error) {
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
return nil, err
}
// Send the reserve request
return devicePlugin.Res... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"Reserve",
"(",
"d",
"*",
"structs",
".",
"AllocatedDeviceResource",
")",
"(",
"*",
"device",
".",
"ContainerReservation",
",",
"error",
")",
"{",
"// Get a device plugin",
"devicePlugin",
",",
"err",
":=",
"i",
... | // Reserve reserves the given devices | [
"Reserve",
"reserves",
"the",
"given",
"devices"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L201-L211 |
133,224 | hashicorp/nomad | client/devicemanager/instance.go | Devices | func (i *instanceManager) Devices() []*device.DeviceGroup {
i.deviceLock.RLock()
defer i.deviceLock.RUnlock()
return i.devices
} | go | func (i *instanceManager) Devices() []*device.DeviceGroup {
i.deviceLock.RLock()
defer i.deviceLock.RUnlock()
return i.devices
} | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"Devices",
"(",
")",
"[",
"]",
"*",
"device",
".",
"DeviceGroup",
"{",
"i",
".",
"deviceLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"deviceLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"... | // Devices returns the detected devices. | [
"Devices",
"returns",
"the",
"detected",
"devices",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L214-L218 |
133,225 | hashicorp/nomad | client/devicemanager/instance.go | fingerprint | func (i *instanceManager) fingerprint() {
START:
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
i.cancel()
return
}
// Start fingerprinting
fingerprintCh, err := devicePlugin.Fingerprint(i.ctx)
if err != nil {
i.logger.Er... | go | func (i *instanceManager) fingerprint() {
START:
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
i.cancel()
return
}
// Start fingerprinting
fingerprintCh, err := devicePlugin.Fingerprint(i.ctx)
if err != nil {
i.logger.Er... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"fingerprint",
"(",
")",
"{",
"START",
":",
"// Get a device plugin",
"devicePlugin",
",",
"err",
":=",
"i",
".",
"dispense",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"i",
".",
"logger",
".",
"Error"... | // fingerprint is a long lived routine used to fingerprint the device | [
"fingerprint",
"is",
"a",
"long",
"lived",
"routine",
"used",
"to",
"fingerprint",
"the",
"device"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L327-L383 |
133,226 | hashicorp/nomad | client/devicemanager/instance.go | handleFingerprintError | func (i *instanceManager) handleFingerprintError() {
// Clear out the devices and trigger a node update
i.deviceLock.Lock()
defer i.deviceLock.Unlock()
// If we have fingerprinted before clear it out
if i.hasFingerprinted {
// Store the new devices
i.devices = nil
// Trigger that the we have new devices
... | go | func (i *instanceManager) handleFingerprintError() {
// Clear out the devices and trigger a node update
i.deviceLock.Lock()
defer i.deviceLock.Unlock()
// If we have fingerprinted before clear it out
if i.hasFingerprinted {
// Store the new devices
i.devices = nil
// Trigger that the we have new devices
... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"handleFingerprintError",
"(",
")",
"{",
"// Clear out the devices and trigger a node update",
"i",
".",
"deviceLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"i",
".",
"deviceLock",
".",
"Unlock",
"(",
")",
"\n\n",
... | // handleFingerprintError exits the manager and shutsdown the plugin. | [
"handleFingerprintError",
"exits",
"the",
"manager",
"and",
"shutsdown",
"the",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L386-L407 |
133,227 | hashicorp/nomad | client/devicemanager/instance.go | handleFingerprint | func (i *instanceManager) handleFingerprint(f *device.FingerprintResponse) error {
// If no devices are returned then there is nothing to do.
if f.Devices == nil {
return nil
}
// Validate the received devices
var validationErr multierror.Error
for i, d := range f.Devices {
if err := d.Validate(); err != nil... | go | func (i *instanceManager) handleFingerprint(f *device.FingerprintResponse) error {
// If no devices are returned then there is nothing to do.
if f.Devices == nil {
return nil
}
// Validate the received devices
var validationErr multierror.Error
for i, d := range f.Devices {
if err := d.Validate(); err != nil... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"handleFingerprint",
"(",
"f",
"*",
"device",
".",
"FingerprintResponse",
")",
"error",
"{",
"// If no devices are returned then there is nothing to do.",
"if",
"f",
".",
"Devices",
"==",
"nil",
"{",
"return",
"nil",
... | // handleFingerprint stores the new devices and triggers the fingerprint output
// channel. An error is returned if the passed devices don't pass validation. | [
"handleFingerprint",
"stores",
"the",
"new",
"devices",
"and",
"triggers",
"the",
"fingerprint",
"output",
"channel",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"passed",
"devices",
"don",
"t",
"pass",
"validation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L411-L448 |
133,228 | hashicorp/nomad | client/devicemanager/instance.go | collectStats | func (i *instanceManager) collectStats() {
attempt := 0
START:
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
i.cancel()
return
}
// Start stats collection
statsCh, err := devicePlugin.Stats(i.ctx, i.statsInterval)
if err... | go | func (i *instanceManager) collectStats() {
attempt := 0
START:
// Get a device plugin
devicePlugin, err := i.dispense()
if err != nil {
i.logger.Error("dispensing plugin failed", "error", err)
i.cancel()
return
}
// Start stats collection
statsCh, err := devicePlugin.Stats(i.ctx, i.statsInterval)
if err... | [
"func",
"(",
"i",
"*",
"instanceManager",
")",
"collectStats",
"(",
")",
"{",
"attempt",
":=",
"0",
"\n\n",
"START",
":",
"// Get a device plugin",
"devicePlugin",
",",
"err",
":=",
"i",
".",
"dispense",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // collectStats is a long lived goroutine for collecting device statistics. It
// handles errors by backing off exponentially and retrying. | [
"collectStats",
"is",
"a",
"long",
"lived",
"goroutine",
"for",
"collecting",
"device",
"statistics",
".",
"It",
"handles",
"errors",
"by",
"backing",
"off",
"exponentially",
"and",
"retrying",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/instance.go#L452-L524 |
133,229 | hashicorp/nomad | devices/gpu/nvidia/stats.go | filterStatsByID | func filterStatsByID(stats []*nvml.StatsData, IDs map[string]struct{}) []*nvml.StatsData {
var filteredStats []*nvml.StatsData
for _, statsItem := range stats {
if _, ok := IDs[statsItem.UUID]; ok {
filteredStats = append(filteredStats, statsItem)
}
}
return filteredStats
} | go | func filterStatsByID(stats []*nvml.StatsData, IDs map[string]struct{}) []*nvml.StatsData {
var filteredStats []*nvml.StatsData
for _, statsItem := range stats {
if _, ok := IDs[statsItem.UUID]; ok {
filteredStats = append(filteredStats, statsItem)
}
}
return filteredStats
} | [
"func",
"filterStatsByID",
"(",
"stats",
"[",
"]",
"*",
"nvml",
".",
"StatsData",
",",
"IDs",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"[",
"]",
"*",
"nvml",
".",
"StatsData",
"{",
"var",
"filteredStats",
"[",
"]",
"*",
"nvml",
".",
"Sta... | // filterStatsByID accepts list of StatsData and set of IDs
// this function would return entries from StatsData with IDs found in the set | [
"filterStatsByID",
"accepts",
"list",
"of",
"StatsData",
"and",
"set",
"of",
"IDs",
"this",
"function",
"would",
"return",
"entries",
"from",
"StatsData",
"with",
"IDs",
"found",
"in",
"the",
"set"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/stats.go#L84-L92 |
133,230 | hashicorp/nomad | devices/gpu/nvidia/stats.go | writeStatsToChannel | func (d *NvidiaDevice) writeStatsToChannel(stats chan<- *device.StatsResponse, timestamp time.Time) {
statsData, err := d.nvmlClient.GetStatsData()
if err != nil {
d.logger.Error("failed to get nvidia stats", "error", err)
stats <- &device.StatsResponse{
Error: err,
}
return
}
// filter only stats from ... | go | func (d *NvidiaDevice) writeStatsToChannel(stats chan<- *device.StatsResponse, timestamp time.Time) {
statsData, err := d.nvmlClient.GetStatsData()
if err != nil {
d.logger.Error("failed to get nvidia stats", "error", err)
stats <- &device.StatsResponse{
Error: err,
}
return
}
// filter only stats from ... | [
"func",
"(",
"d",
"*",
"NvidiaDevice",
")",
"writeStatsToChannel",
"(",
"stats",
"chan",
"<-",
"*",
"device",
".",
"StatsResponse",
",",
"timestamp",
"time",
".",
"Time",
")",
"{",
"statsData",
",",
"err",
":=",
"d",
".",
"nvmlClient",
".",
"GetStatsData",... | // writeStatsToChannel collects StatsData from NVML backend, groups StatsData
// by DeviceName attribute, populates DeviceGroupStats structure for every group
// and sends data over provided channel | [
"writeStatsToChannel",
"collects",
"StatsData",
"from",
"NVML",
"backend",
"groups",
"StatsData",
"by",
"DeviceName",
"attribute",
"populates",
"DeviceGroupStats",
"structure",
"for",
"every",
"group",
"and",
"sends",
"data",
"over",
"provided",
"channel"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/stats.go#L97-L135 |
133,231 | hashicorp/nomad | devices/gpu/nvidia/stats.go | statsForGroup | func statsForGroup(groupName string, groupStats []*nvml.StatsData, timestamp time.Time) *device.DeviceGroupStats {
instanceStats := make(map[string]*device.DeviceStats)
for _, statsItem := range groupStats {
instanceStats[statsItem.UUID] = statsForItem(statsItem, timestamp)
}
return &device.DeviceGroupStats{
V... | go | func statsForGroup(groupName string, groupStats []*nvml.StatsData, timestamp time.Time) *device.DeviceGroupStats {
instanceStats := make(map[string]*device.DeviceStats)
for _, statsItem := range groupStats {
instanceStats[statsItem.UUID] = statsForItem(statsItem, timestamp)
}
return &device.DeviceGroupStats{
V... | [
"func",
"statsForGroup",
"(",
"groupName",
"string",
",",
"groupStats",
"[",
"]",
"*",
"nvml",
".",
"StatsData",
",",
"timestamp",
"time",
".",
"Time",
")",
"*",
"device",
".",
"DeviceGroupStats",
"{",
"instanceStats",
":=",
"make",
"(",
"map",
"[",
"strin... | // statsForGroup is a helper function that populates device.DeviceGroupStats
// for given groupName with groupStats list | [
"statsForGroup",
"is",
"a",
"helper",
"function",
"that",
"populates",
"device",
".",
"DeviceGroupStats",
"for",
"given",
"groupName",
"with",
"groupStats",
"list"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/stats.go#L143-L155 |
133,232 | hashicorp/nomad | command/namespace.go | NamespacePredictor | func NamespacePredictor(factory ApiClientFactory, filter map[string]struct{}) complete.Predictor {
return complete.PredictFunc(func(a complete.Args) []string {
client, err := factory()
if err != nil {
return nil
}
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Namespaces, nil)
if err != ni... | go | func NamespacePredictor(factory ApiClientFactory, filter map[string]struct{}) complete.Predictor {
return complete.PredictFunc(func(a complete.Args) []string {
client, err := factory()
if err != nil {
return nil
}
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Namespaces, nil)
if err != ni... | [
"func",
"NamespacePredictor",
"(",
"factory",
"ApiClientFactory",
",",
"filter",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"complete",
".",
"Predictor",
"{",
"return",
"complete",
".",
"PredictFunc",
"(",
"func",
"(",
"a",
"complete",
".",
"Args",
... | // NamespacePredictor returns a namespace predictor that can optionally filter
// specific namespaces | [
"NamespacePredictor",
"returns",
"a",
"namespace",
"predictor",
"that",
"can",
"optionally",
"filter",
"specific",
"namespaces"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/namespace.go#L54-L79 |
133,233 | hashicorp/nomad | command/agent/consul/check_watcher.go | newCheckWatcher | func newCheckWatcher(logger log.Logger, consul ChecksAPI) *checkWatcher {
return &checkWatcher{
consul: consul,
pollFreq: defaultPollFreq,
checkUpdateCh: make(chan checkWatchUpdate, 8),
done: make(chan struct{}),
logger: logger.ResetNamed("consul.health"),
}
} | go | func newCheckWatcher(logger log.Logger, consul ChecksAPI) *checkWatcher {
return &checkWatcher{
consul: consul,
pollFreq: defaultPollFreq,
checkUpdateCh: make(chan checkWatchUpdate, 8),
done: make(chan struct{}),
logger: logger.ResetNamed("consul.health"),
}
} | [
"func",
"newCheckWatcher",
"(",
"logger",
"log",
".",
"Logger",
",",
"consul",
"ChecksAPI",
")",
"*",
"checkWatcher",
"{",
"return",
"&",
"checkWatcher",
"{",
"consul",
":",
"consul",
",",
"pollFreq",
":",
"defaultPollFreq",
",",
"checkUpdateCh",
":",
"make",
... | // newCheckWatcher creates a new checkWatcher but does not call its Run method. | [
"newCheckWatcher",
"creates",
"a",
"new",
"checkWatcher",
"but",
"does",
"not",
"call",
"its",
"Run",
"method",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/check_watcher.go#L151-L159 |
133,234 | hashicorp/nomad | command/agent/consul/check_watcher.go | Run | func (w *checkWatcher) Run(ctx context.Context) {
defer close(w.done)
// map of check IDs to their metadata
checks := map[string]*checkRestart{}
// timer for check polling
checkTimer := time.NewTimer(0)
defer checkTimer.Stop() // ensure timer is never leaked
stopTimer := func() {
checkTimer.Stop()
select ... | go | func (w *checkWatcher) Run(ctx context.Context) {
defer close(w.done)
// map of check IDs to their metadata
checks := map[string]*checkRestart{}
// timer for check polling
checkTimer := time.NewTimer(0)
defer checkTimer.Stop() // ensure timer is never leaked
stopTimer := func() {
checkTimer.Stop()
select ... | [
"func",
"(",
"w",
"*",
"checkWatcher",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"defer",
"close",
"(",
"w",
".",
"done",
")",
"\n\n",
"// map of check IDs to their metadata",
"checks",
":=",
"map",
"[",
"string",
"]",
"*",
"checkRestart... | // Run the main Consul checks watching loop to restart tasks when their checks
// fail. Blocks until context is canceled. | [
"Run",
"the",
"main",
"Consul",
"checks",
"watching",
"loop",
"to",
"restart",
"tasks",
"when",
"their",
"checks",
"fail",
".",
"Blocks",
"until",
"context",
"is",
"canceled",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/check_watcher.go#L163-L278 |
133,235 | hashicorp/nomad | command/agent/consul/check_watcher.go | Watch | func (w *checkWatcher) Watch(allocID, taskName, checkID string, check *structs.ServiceCheck, restarter TaskRestarter) {
if !check.TriggersRestarts() {
// Not watched, noop
return
}
c := &checkRestart{
allocID: allocID,
taskName: taskName,
checkID: checkID,
checkName: check.Name,... | go | func (w *checkWatcher) Watch(allocID, taskName, checkID string, check *structs.ServiceCheck, restarter TaskRestarter) {
if !check.TriggersRestarts() {
// Not watched, noop
return
}
c := &checkRestart{
allocID: allocID,
taskName: taskName,
checkID: checkID,
checkName: check.Name,... | [
"func",
"(",
"w",
"*",
"checkWatcher",
")",
"Watch",
"(",
"allocID",
",",
"taskName",
",",
"checkID",
"string",
",",
"check",
"*",
"structs",
".",
"ServiceCheck",
",",
"restarter",
"TaskRestarter",
")",
"{",
"if",
"!",
"check",
".",
"TriggersRestarts",
"("... | // Watch a check and restart its task if unhealthy. | [
"Watch",
"a",
"check",
"and",
"restart",
"its",
"task",
"if",
"unhealthy",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/check_watcher.go#L281-L313 |
133,236 | hashicorp/nomad | command/agent/consul/check_watcher.go | Unwatch | func (w *checkWatcher) Unwatch(cid string) {
c := checkWatchUpdate{
checkID: cid,
remove: true,
}
select {
case w.checkUpdateCh <- c:
// sent remove watch
case <-w.done:
// exited; nothing to do
}
} | go | func (w *checkWatcher) Unwatch(cid string) {
c := checkWatchUpdate{
checkID: cid,
remove: true,
}
select {
case w.checkUpdateCh <- c:
// sent remove watch
case <-w.done:
// exited; nothing to do
}
} | [
"func",
"(",
"w",
"*",
"checkWatcher",
")",
"Unwatch",
"(",
"cid",
"string",
")",
"{",
"c",
":=",
"checkWatchUpdate",
"{",
"checkID",
":",
"cid",
",",
"remove",
":",
"true",
",",
"}",
"\n",
"select",
"{",
"case",
"w",
".",
"checkUpdateCh",
"<-",
"c",... | // Unwatch a check. | [
"Unwatch",
"a",
"check",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/check_watcher.go#L316-L327 |
133,237 | hashicorp/nomad | drivers/shared/eventer/eventer.go | NewEventer | func NewEventer(ctx context.Context, logger hclog.Logger) *Eventer {
e := &Eventer{
events: make(chan *drivers.TaskEvent),
ctx: ctx,
logger: logger,
}
go e.eventLoop()
return e
} | go | func NewEventer(ctx context.Context, logger hclog.Logger) *Eventer {
e := &Eventer{
events: make(chan *drivers.TaskEvent),
ctx: ctx,
logger: logger,
}
go e.eventLoop()
return e
} | [
"func",
"NewEventer",
"(",
"ctx",
"context",
".",
"Context",
",",
"logger",
"hclog",
".",
"Logger",
")",
"*",
"Eventer",
"{",
"e",
":=",
"&",
"Eventer",
"{",
"events",
":",
"make",
"(",
"chan",
"*",
"drivers",
".",
"TaskEvent",
")",
",",
"ctx",
":",
... | // NewEventer returns an Eventer with a running event loop that can be stopped
// by closing the given stop channel | [
"NewEventer",
"returns",
"an",
"Eventer",
"with",
"a",
"running",
"event",
"loop",
"that",
"can",
"be",
"stopped",
"by",
"closing",
"the",
"given",
"stop",
"channel"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/eventer/eventer.go#L52-L60 |
133,238 | hashicorp/nomad | drivers/shared/eventer/eventer.go | eventLoop | func (e *Eventer) eventLoop() {
for {
select {
case <-e.ctx.Done():
e.logger.Trace("task event loop shutdown")
return
case event := <-e.events:
e.iterateConsumers(event)
case <-time.After(ConsumerGCInterval):
e.gcConsumers()
}
}
} | go | func (e *Eventer) eventLoop() {
for {
select {
case <-e.ctx.Done():
e.logger.Trace("task event loop shutdown")
return
case event := <-e.events:
e.iterateConsumers(event)
case <-time.After(ConsumerGCInterval):
e.gcConsumers()
}
}
} | [
"func",
"(",
"e",
"*",
"Eventer",
")",
"eventLoop",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"e",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"e",
".",
"logger",
".",
"Trace",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"case",
"ev... | // eventLoop is the main logic which pulls events from the channel and broadcasts
// them to all consumers | [
"eventLoop",
"is",
"the",
"main",
"logic",
"which",
"pulls",
"events",
"from",
"the",
"channel",
"and",
"broadcasts",
"them",
"to",
"all",
"consumers"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/eventer/eventer.go#L64-L76 |
133,239 | hashicorp/nomad | drivers/shared/eventer/eventer.go | iterateConsumers | func (e *Eventer) iterateConsumers(event *drivers.TaskEvent) {
e.consumersLock.Lock()
filtered := e.consumers[:0]
for _, consumer := range e.consumers {
// prioritize checking if context is cancelled prior
// to attempting to forwarding events
// golang select evaluations aren't predictable
if consumer.ctx.... | go | func (e *Eventer) iterateConsumers(event *drivers.TaskEvent) {
e.consumersLock.Lock()
filtered := e.consumers[:0]
for _, consumer := range e.consumers {
// prioritize checking if context is cancelled prior
// to attempting to forwarding events
// golang select evaluations aren't predictable
if consumer.ctx.... | [
"func",
"(",
"e",
"*",
"Eventer",
")",
"iterateConsumers",
"(",
"event",
"*",
"drivers",
".",
"TaskEvent",
")",
"{",
"e",
".",
"consumersLock",
".",
"Lock",
"(",
")",
"\n",
"filtered",
":=",
"e",
".",
"consumers",
"[",
":",
"0",
"]",
"\n",
"for",
"... | // iterateConsumers will iterate through all consumers and broadcast the event,
// cleaning up any consumers that have closed their context | [
"iterateConsumers",
"will",
"iterate",
"through",
"all",
"consumers",
"and",
"broadcast",
"the",
"event",
"cleaning",
"up",
"any",
"consumers",
"that",
"have",
"closed",
"their",
"context"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/eventer/eventer.go#L80-L106 |
133,240 | hashicorp/nomad | drivers/shared/eventer/eventer.go | TaskEvents | func (e *Eventer) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error) {
consumer := e.newConsumer(ctx)
return consumer.ch, nil
} | go | func (e *Eventer) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error) {
consumer := e.newConsumer(ctx)
return consumer.ch, nil
} | [
"func",
"(",
"e",
"*",
"Eventer",
")",
"TaskEvents",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"*",
"drivers",
".",
"TaskEvent",
",",
"error",
")",
"{",
"consumer",
":=",
"e",
".",
"newConsumer",
"(",
"ctx",
")",
"\n",
"return",
... | // TaskEvents is an implementation of the DriverPlugin.TaskEvents function | [
"TaskEvents",
"is",
"an",
"implementation",
"of",
"the",
"DriverPlugin",
".",
"TaskEvents",
"function"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/eventer/eventer.go#L139-L142 |
133,241 | hashicorp/nomad | drivers/shared/eventer/eventer.go | EmitEvent | func (e *Eventer) EmitEvent(event *drivers.TaskEvent) error {
select {
case <-e.ctx.Done():
return e.ctx.Err()
case e.events <- event:
if e.logger.IsTrace() {
e.logger.Trace("emitting event", "event", event)
}
}
return nil
} | go | func (e *Eventer) EmitEvent(event *drivers.TaskEvent) error {
select {
case <-e.ctx.Done():
return e.ctx.Err()
case e.events <- event:
if e.logger.IsTrace() {
e.logger.Trace("emitting event", "event", event)
}
}
return nil
} | [
"func",
"(",
"e",
"*",
"Eventer",
")",
"EmitEvent",
"(",
"event",
"*",
"drivers",
".",
"TaskEvent",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"e",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"e",
".",
"ctx",
".",
"Err",
"(",
")",
"\... | // EmitEvent can be used to broadcast a new event | [
"EmitEvent",
"can",
"be",
"used",
"to",
"broadcast",
"a",
"new",
"event"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/eventer/eventer.go#L145-L156 |
133,242 | hashicorp/nomad | client/allocrunner/taskrunner/getter/getter.go | getClient | func getClient(src string, mode gg.ClientMode, dst string) *gg.Client {
lock.Lock()
defer lock.Unlock()
// Return the pre-initialized client
if getters == nil {
getters = make(map[string]gg.Getter, len(supported))
for _, getter := range supported {
if impl, ok := gg.Getters[getter]; ok {
getters[getter]... | go | func getClient(src string, mode gg.ClientMode, dst string) *gg.Client {
lock.Lock()
defer lock.Unlock()
// Return the pre-initialized client
if getters == nil {
getters = make(map[string]gg.Getter, len(supported))
for _, getter := range supported {
if impl, ok := gg.Getters[getter]; ok {
getters[getter]... | [
"func",
"getClient",
"(",
"src",
"string",
",",
"mode",
"gg",
".",
"ClientMode",
",",
"dst",
"string",
")",
"*",
"gg",
".",
"Client",
"{",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"// Return the pre-initial... | // getClient returns a client that is suitable for Nomad downloading artifacts. | [
"getClient",
"returns",
"a",
"client",
"that",
"is",
"suitable",
"for",
"Nomad",
"downloading",
"artifacts",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/getter/getter.go#L36-L56 |
133,243 | hashicorp/nomad | client/allocrunner/taskrunner/getter/getter.go | getGetterUrl | func getGetterUrl(taskEnv EnvReplacer, artifact *structs.TaskArtifact) (string, error) {
source := taskEnv.ReplaceEnv(artifact.GetterSource)
// Handle an invalid URL when given a go-getter url such as
// git@github.com:hashicorp/nomad.git
gitSSH := false
if strings.HasPrefix(source, gitSSHPrefix) {
gitSSH = tru... | go | func getGetterUrl(taskEnv EnvReplacer, artifact *structs.TaskArtifact) (string, error) {
source := taskEnv.ReplaceEnv(artifact.GetterSource)
// Handle an invalid URL when given a go-getter url such as
// git@github.com:hashicorp/nomad.git
gitSSH := false
if strings.HasPrefix(source, gitSSHPrefix) {
gitSSH = tru... | [
"func",
"getGetterUrl",
"(",
"taskEnv",
"EnvReplacer",
",",
"artifact",
"*",
"structs",
".",
"TaskArtifact",
")",
"(",
"string",
",",
"error",
")",
"{",
"source",
":=",
"taskEnv",
".",
"ReplaceEnv",
"(",
"artifact",
".",
"GetterSource",
")",
"\n\n",
"// Hand... | // getGetterUrl returns the go-getter URL to download the artifact. | [
"getGetterUrl",
"returns",
"the",
"go",
"-",
"getter",
"URL",
"to",
"download",
"the",
"artifact",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/getter/getter.go#L59-L89 |
133,244 | hashicorp/nomad | client/allocrunner/taskrunner/getter/getter.go | GetArtifact | func GetArtifact(taskEnv EnvReplacer, artifact *structs.TaskArtifact, taskDir string) error {
url, err := getGetterUrl(taskEnv, artifact)
if err != nil {
return newGetError(artifact.GetterSource, err, false)
}
// Download the artifact
dest := filepath.Join(taskDir, artifact.RelativeDest)
// Convert from strin... | go | func GetArtifact(taskEnv EnvReplacer, artifact *structs.TaskArtifact, taskDir string) error {
url, err := getGetterUrl(taskEnv, artifact)
if err != nil {
return newGetError(artifact.GetterSource, err, false)
}
// Download the artifact
dest := filepath.Join(taskDir, artifact.RelativeDest)
// Convert from strin... | [
"func",
"GetArtifact",
"(",
"taskEnv",
"EnvReplacer",
",",
"artifact",
"*",
"structs",
".",
"TaskArtifact",
",",
"taskDir",
"string",
")",
"error",
"{",
"url",
",",
"err",
":=",
"getGetterUrl",
"(",
"taskEnv",
",",
"artifact",
")",
"\n",
"if",
"err",
"!=",... | // GetArtifact downloads an artifact into the specified task directory. | [
"GetArtifact",
"downloads",
"an",
"artifact",
"into",
"the",
"specified",
"task",
"directory",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/getter/getter.go#L92-L115 |
133,245 | hashicorp/nomad | client/fingerprint/cgroup.go | NewCGroupFingerprint | func NewCGroupFingerprint(logger log.Logger) Fingerprint {
f := &CGroupFingerprint{
logger: logger.Named("cgroup"),
lastState: cgroupUnavailable,
mountPointDetector: &DefaultMountPointDetector{},
}
return f
} | go | func NewCGroupFingerprint(logger log.Logger) Fingerprint {
f := &CGroupFingerprint{
logger: logger.Named("cgroup"),
lastState: cgroupUnavailable,
mountPointDetector: &DefaultMountPointDetector{},
}
return f
} | [
"func",
"NewCGroupFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"f",
":=",
"&",
"CGroupFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"lastState",
":",
"cgroupUnavailable",
",",
"mountPointD... | // NewCGroupFingerprint returns a new cgroup fingerprinter | [
"NewCGroupFingerprint",
"returns",
"a",
"new",
"cgroup",
"fingerprinter"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/cgroup.go#L37-L44 |
133,246 | hashicorp/nomad | client/fingerprint/cgroup.go | Periodic | func (f *CGroupFingerprint) Periodic() (bool, time.Duration) {
return true, interval * time.Second
} | go | func (f *CGroupFingerprint) Periodic() (bool, time.Duration) {
return true, interval * time.Second
} | [
"func",
"(",
"f",
"*",
"CGroupFingerprint",
")",
"Periodic",
"(",
")",
"(",
"bool",
",",
"time",
".",
"Duration",
")",
"{",
"return",
"true",
",",
"interval",
"*",
"time",
".",
"Second",
"\n",
"}"
] | // Periodic determines the interval at which the periodic fingerprinter will run. | [
"Periodic",
"determines",
"the",
"interval",
"at",
"which",
"the",
"periodic",
"fingerprinter",
"will",
"run",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/cgroup.go#L53-L55 |
133,247 | hashicorp/nomad | command/agent/config.go | PrefixFilters | func (t *Telemetry) PrefixFilters() (allowed, blocked []string, err error) {
for _, rule := range t.PrefixFilter {
if rule == "" {
continue
}
switch rule[0] {
case '+':
allowed = append(allowed, rule[1:])
case '-':
blocked = append(blocked, rule[1:])
default:
return nil, nil, fmt.Errorf("Filter... | go | func (t *Telemetry) PrefixFilters() (allowed, blocked []string, err error) {
for _, rule := range t.PrefixFilter {
if rule == "" {
continue
}
switch rule[0] {
case '+':
allowed = append(allowed, rule[1:])
case '-':
blocked = append(blocked, rule[1:])
default:
return nil, nil, fmt.Errorf("Filter... | [
"func",
"(",
"t",
"*",
"Telemetry",
")",
"PrefixFilters",
"(",
")",
"(",
"allowed",
",",
"blocked",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"rule",
":=",
"range",
"t",
".",
"PrefixFilter",
"{",
"if",
"rule",
"==",
"\"",
... | // PrefixFilters parses the PrefixFilter field and returns a list of allowed and blocked filters | [
"PrefixFilters",
"parses",
"the",
"PrefixFilter",
"field",
"and",
"returns",
"a",
"list",
"of",
"allowed",
"and",
"blocked",
"filters"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L532-L547 |
133,248 | hashicorp/nomad | command/agent/config.go | CanParseReserved | func (r *Resources) CanParseReserved() error {
_, err := structs.ParsePortRanges(r.ReservedPorts)
return err
} | go | func (r *Resources) CanParseReserved() error {
_, err := structs.ParsePortRanges(r.ReservedPorts)
return err
} | [
"func",
"(",
"r",
"*",
"Resources",
")",
"CanParseReserved",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"structs",
".",
"ParsePortRanges",
"(",
"r",
".",
"ReservedPorts",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // CanParseReserved returns if the reserved ports specification is parsable.
// The supported syntax is comma separated integers or ranges separated by
// hyphens. For example, "80,120-150,160" | [
"CanParseReserved",
"returns",
"if",
"the",
"reserved",
"ports",
"specification",
"is",
"parsable",
".",
"The",
"supported",
"syntax",
"is",
"comma",
"separated",
"integers",
"or",
"ranges",
"separated",
"by",
"hyphens",
".",
"For",
"example",
"80",
"120",
"-",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L584-L587 |
133,249 | hashicorp/nomad | command/agent/config.go | DevConfig | func DevConfig() *Config {
conf := DefaultConfig()
conf.BindAddr = "127.0.0.1"
conf.LogLevel = "DEBUG"
conf.Client.Enabled = true
conf.Server.Enabled = true
conf.DevMode = true
conf.EnableDebug = true
conf.DisableAnonymousSignature = true
conf.Consul.AutoAdvertise = helper.BoolToPtr(true)
if runtime.GOOS == "... | go | func DevConfig() *Config {
conf := DefaultConfig()
conf.BindAddr = "127.0.0.1"
conf.LogLevel = "DEBUG"
conf.Client.Enabled = true
conf.Server.Enabled = true
conf.DevMode = true
conf.EnableDebug = true
conf.DisableAnonymousSignature = true
conf.Consul.AutoAdvertise = helper.BoolToPtr(true)
if runtime.GOOS == "... | [
"func",
"DevConfig",
"(",
")",
"*",
"Config",
"{",
"conf",
":=",
"DefaultConfig",
"(",
")",
"\n",
"conf",
".",
"BindAddr",
"=",
"\"",
"\"",
"\n",
"conf",
".",
"LogLevel",
"=",
"\"",
"\"",
"\n",
"conf",
".",
"Client",
".",
"Enabled",
"=",
"true",
"\... | // DevConfig is a Config that is used for dev mode of Nomad. | [
"DevConfig",
"is",
"a",
"Config",
"that",
"is",
"used",
"for",
"dev",
"mode",
"of",
"Nomad",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L590-L618 |
133,250 | hashicorp/nomad | command/agent/config.go | DefaultConfig | func DefaultConfig() *Config {
return &Config{
LogLevel: "INFO",
Region: "global",
Datacenter: "dc1",
BindAddr: "0.0.0.0",
Ports: &Ports{
HTTP: 4646,
RPC: 4647,
Serf: 4648,
},
Addresses: &Addresses{},
AdvertiseAddrs: &AdvertiseAddrs{},
Consul: config.DefaultConsulConfig... | go | func DefaultConfig() *Config {
return &Config{
LogLevel: "INFO",
Region: "global",
Datacenter: "dc1",
BindAddr: "0.0.0.0",
Ports: &Ports{
HTTP: 4646,
RPC: 4647,
Serf: 4648,
},
Addresses: &Addresses{},
AdvertiseAddrs: &AdvertiseAddrs{},
Consul: config.DefaultConsulConfig... | [
"func",
"DefaultConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"LogLevel",
":",
"\"",
"\"",
",",
"Region",
":",
"\"",
"\"",
",",
"Datacenter",
":",
"\"",
"\"",
",",
"BindAddr",
":",
"\"",
"\"",
",",
"Ports",
":",
"&",
"Ports",... | // DefaultConfig is a the baseline configuration for Nomad | [
"DefaultConfig",
"is",
"a",
"the",
"baseline",
"configuration",
"for",
"Nomad"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L621-L679 |
133,251 | hashicorp/nomad | command/agent/config.go | Listener | func (c *Config) Listener(proto, addr string, port int) (net.Listener, error) {
if addr == "" {
addr = c.BindAddr
}
// Do our own range check to avoid bugs in package net.
//
// golang.org/issue/11715
// golang.org/issue/13447
//
// Both of the above bugs were fixed by golang.org/cl/12447 which will be
... | go | func (c *Config) Listener(proto, addr string, port int) (net.Listener, error) {
if addr == "" {
addr = c.BindAddr
}
// Do our own range check to avoid bugs in package net.
//
// golang.org/issue/11715
// golang.org/issue/13447
//
// Both of the above bugs were fixed by golang.org/cl/12447 which will be
... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Listener",
"(",
"proto",
",",
"addr",
"string",
",",
"port",
"int",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"addr",
"==",
"\"",
"\"",
"{",
"addr",
"=",
"c",
".",
"BindAddr",
"\n",
"... | // Listener can be used to get a new listener using a custom bind address.
// If the bind provided address is empty, the BindAddr is used instead. | [
"Listener",
"can",
"be",
"used",
"to",
"get",
"a",
"new",
"listener",
"using",
"a",
"custom",
"bind",
"address",
".",
"If",
"the",
"bind",
"provided",
"address",
"is",
"empty",
"the",
"BindAddr",
"is",
"used",
"instead",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L683-L704 |
133,252 | hashicorp/nomad | command/agent/config.go | normalizeAddrs | func (c *Config) normalizeAddrs() error {
if c.BindAddr != "" {
ipStr, err := parseSingleIPTemplate(c.BindAddr)
if err != nil {
return fmt.Errorf("Bind address resolution failed: %v", err)
}
c.BindAddr = ipStr
}
addr, err := normalizeBind(c.Addresses.HTTP, c.BindAddr)
if err != nil {
return fmt.Errorf... | go | func (c *Config) normalizeAddrs() error {
if c.BindAddr != "" {
ipStr, err := parseSingleIPTemplate(c.BindAddr)
if err != nil {
return fmt.Errorf("Bind address resolution failed: %v", err)
}
c.BindAddr = ipStr
}
addr, err := normalizeBind(c.Addresses.HTTP, c.BindAddr)
if err != nil {
return fmt.Errorf... | [
"func",
"(",
"c",
"*",
"Config",
")",
"normalizeAddrs",
"(",
")",
"error",
"{",
"if",
"c",
".",
"BindAddr",
"!=",
"\"",
"\"",
"{",
"ipStr",
",",
"err",
":=",
"parseSingleIPTemplate",
"(",
"c",
".",
"BindAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // normalizeAddrs normalizes Addresses and AdvertiseAddrs to always be
// initialized and have sane defaults. | [
"normalizeAddrs",
"normalizes",
"Addresses",
"and",
"AdvertiseAddrs",
"to",
"always",
"be",
"initialized",
"and",
"have",
"sane",
"defaults",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L875-L930 |
133,253 | hashicorp/nomad | command/agent/config.go | parseSingleIPTemplate | func parseSingleIPTemplate(ipTmpl string) (string, error) {
out, err := template.Parse(ipTmpl)
if err != nil {
return "", fmt.Errorf("Unable to parse address template %q: %v", ipTmpl, err)
}
ips := strings.Split(out, " ")
switch len(ips) {
case 0:
return "", errors.New("No addresses found, please configure o... | go | func parseSingleIPTemplate(ipTmpl string) (string, error) {
out, err := template.Parse(ipTmpl)
if err != nil {
return "", fmt.Errorf("Unable to parse address template %q: %v", ipTmpl, err)
}
ips := strings.Split(out, " ")
switch len(ips) {
case 0:
return "", errors.New("No addresses found, please configure o... | [
"func",
"parseSingleIPTemplate",
"(",
"ipTmpl",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"template",
".",
"Parse",
"(",
"ipTmpl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
... | // parseSingleIPTemplate is used as a helper function to parse out a single IP
// address from a config parameter. | [
"parseSingleIPTemplate",
"is",
"used",
"as",
"a",
"helper",
"function",
"to",
"parse",
"out",
"a",
"single",
"IP",
"address",
"from",
"a",
"config",
"parameter",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L934-L949 |
133,254 | hashicorp/nomad | command/agent/config.go | normalizeBind | func normalizeBind(addr, bind string) (string, error) {
if addr == "" {
return bind, nil
}
return parseSingleIPTemplate(addr)
} | go | func normalizeBind(addr, bind string) (string, error) {
if addr == "" {
return bind, nil
}
return parseSingleIPTemplate(addr)
} | [
"func",
"normalizeBind",
"(",
"addr",
",",
"bind",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"addr",
"==",
"\"",
"\"",
"{",
"return",
"bind",
",",
"nil",
"\n",
"}",
"\n",
"return",
"parseSingleIPTemplate",
"(",
"addr",
")",
"\n",
"}... | // normalizeBind returns a normalized bind address.
//
// If addr is set it is used, if not the default bind address is used. | [
"normalizeBind",
"returns",
"a",
"normalized",
"bind",
"address",
".",
"If",
"addr",
"is",
"set",
"it",
"is",
"used",
"if",
"not",
"the",
"default",
"bind",
"address",
"is",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L954-L959 |
133,255 | hashicorp/nomad | command/agent/config.go | normalizeAdvertise | func normalizeAdvertise(addr string, bind string, defport int, dev bool) (string, error) {
addr, err := parseSingleIPTemplate(addr)
if err != nil {
return "", fmt.Errorf("Error parsing advertise address template: %v", err)
}
if addr != "" {
// Default to using manually configured address
_, _, err = net.Spli... | go | func normalizeAdvertise(addr string, bind string, defport int, dev bool) (string, error) {
addr, err := parseSingleIPTemplate(addr)
if err != nil {
return "", fmt.Errorf("Error parsing advertise address template: %v", err)
}
if addr != "" {
// Default to using manually configured address
_, _, err = net.Spli... | [
"func",
"normalizeAdvertise",
"(",
"addr",
"string",
",",
"bind",
"string",
",",
"defport",
"int",
",",
"dev",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"addr",
",",
"err",
":=",
"parseSingleIPTemplate",
"(",
"addr",
")",
"\n",
"if",
"err",
"... | // normalizeAdvertise returns a normalized advertise address.
//
// If addr is set, it is used and the default port is appended if no port is
// set.
//
// If addr is not set and bind is a valid address, the returned string is the
// bind+port.
//
// If addr is not set and bind is not a valid advertise address, the hos... | [
"normalizeAdvertise",
"returns",
"a",
"normalized",
"advertise",
"address",
".",
"If",
"addr",
"is",
"set",
"it",
"is",
"used",
"and",
"the",
"default",
"port",
"is",
"appended",
"if",
"no",
"port",
"is",
"set",
".",
"If",
"addr",
"is",
"not",
"set",
"an... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L973-L1020 |
133,256 | hashicorp/nomad | command/agent/config.go | isMissingPort | func isMissingPort(err error) bool {
// matches error const in net/ipsock.go
const missingPort = "missing port in address"
return err != nil && strings.Contains(err.Error(), missingPort)
} | go | func isMissingPort(err error) bool {
// matches error const in net/ipsock.go
const missingPort = "missing port in address"
return err != nil && strings.Contains(err.Error(), missingPort)
} | [
"func",
"isMissingPort",
"(",
"err",
"error",
")",
"bool",
"{",
"// matches error const in net/ipsock.go",
"const",
"missingPort",
"=",
"\"",
"\"",
"\n",
"return",
"err",
"!=",
"nil",
"&&",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",
"(",
")",
",",... | // isMissingPort returns true if an error is a "missing port" error from
// net.SplitHostPort. | [
"isMissingPort",
"returns",
"true",
"if",
"an",
"error",
"is",
"a",
"missing",
"port",
"error",
"from",
"net",
".",
"SplitHostPort",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1024-L1028 |
133,257 | hashicorp/nomad | command/agent/config.go | isTooManyColons | func isTooManyColons(err error) bool {
// matches error const in net/ipsock.go
const tooManyColons = "too many colons in address"
return err != nil && strings.Contains(err.Error(), tooManyColons)
} | go | func isTooManyColons(err error) bool {
// matches error const in net/ipsock.go
const tooManyColons = "too many colons in address"
return err != nil && strings.Contains(err.Error(), tooManyColons)
} | [
"func",
"isTooManyColons",
"(",
"err",
"error",
")",
"bool",
"{",
"// matches error const in net/ipsock.go",
"const",
"tooManyColons",
"=",
"\"",
"\"",
"\n",
"return",
"err",
"!=",
"nil",
"&&",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",
"(",
")",
... | // isTooManyColons returns true if an error is a "too many colons" error from
// net.SplitHostPort. | [
"isTooManyColons",
"returns",
"true",
"if",
"an",
"error",
"is",
"a",
"too",
"many",
"colons",
"error",
"from",
"net",
".",
"SplitHostPort",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1032-L1036 |
133,258 | hashicorp/nomad | command/agent/config.go | Merge | func (a *ACLConfig) Merge(b *ACLConfig) *ACLConfig {
result := *a
if b.Enabled {
result.Enabled = true
}
if b.TokenTTL != 0 {
result.TokenTTL = b.TokenTTL
}
if b.PolicyTTL != 0 {
result.PolicyTTL = b.PolicyTTL
}
if b.ReplicationToken != "" {
result.ReplicationToken = b.ReplicationToken
}
return &resu... | go | func (a *ACLConfig) Merge(b *ACLConfig) *ACLConfig {
result := *a
if b.Enabled {
result.Enabled = true
}
if b.TokenTTL != 0 {
result.TokenTTL = b.TokenTTL
}
if b.PolicyTTL != 0 {
result.PolicyTTL = b.PolicyTTL
}
if b.ReplicationToken != "" {
result.ReplicationToken = b.ReplicationToken
}
return &resu... | [
"func",
"(",
"a",
"*",
"ACLConfig",
")",
"Merge",
"(",
"b",
"*",
"ACLConfig",
")",
"*",
"ACLConfig",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"Enabled",
"{",
"result",
".",
"Enabled",
"=",
"true",
"\n",
"}",
"\n",
"if",
"b",
".",
... | // Merge is used to merge two ACL configs together. The settings from the input always take precedence. | [
"Merge",
"is",
"used",
"to",
"merge",
"two",
"ACL",
"configs",
"together",
".",
"The",
"settings",
"from",
"the",
"input",
"always",
"take",
"precedence",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1039-L1055 |
133,259 | hashicorp/nomad | command/agent/config.go | Merge | func (a *Telemetry) Merge(b *Telemetry) *Telemetry {
result := *a
if b.StatsiteAddr != "" {
result.StatsiteAddr = b.StatsiteAddr
}
if b.StatsdAddr != "" {
result.StatsdAddr = b.StatsdAddr
}
if b.DataDogAddr != "" {
result.DataDogAddr = b.DataDogAddr
}
if b.DataDogTags != nil {
result.DataDogTags = b.Da... | go | func (a *Telemetry) Merge(b *Telemetry) *Telemetry {
result := *a
if b.StatsiteAddr != "" {
result.StatsiteAddr = b.StatsiteAddr
}
if b.StatsdAddr != "" {
result.StatsdAddr = b.StatsdAddr
}
if b.DataDogAddr != "" {
result.DataDogAddr = b.DataDogAddr
}
if b.DataDogTags != nil {
result.DataDogTags = b.Da... | [
"func",
"(",
"a",
"*",
"Telemetry",
")",
"Merge",
"(",
"b",
"*",
"Telemetry",
")",
"*",
"Telemetry",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"StatsiteAddr",
"!=",
"\"",
"\"",
"{",
"result",
".",
"StatsiteAddr",
"=",
"b",
".",
"Statsi... | // Merge is used to merge two telemetry configs together | [
"Merge",
"is",
"used",
"to",
"merge",
"two",
"telemetry",
"configs",
"together"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1242-L1340 |
133,260 | hashicorp/nomad | command/agent/config.go | Merge | func (a *Ports) Merge(b *Ports) *Ports {
result := *a
if b.HTTP != 0 {
result.HTTP = b.HTTP
}
if b.RPC != 0 {
result.RPC = b.RPC
}
if b.Serf != 0 {
result.Serf = b.Serf
}
return &result
} | go | func (a *Ports) Merge(b *Ports) *Ports {
result := *a
if b.HTTP != 0 {
result.HTTP = b.HTTP
}
if b.RPC != 0 {
result.RPC = b.RPC
}
if b.Serf != 0 {
result.Serf = b.Serf
}
return &result
} | [
"func",
"(",
"a",
"*",
"Ports",
")",
"Merge",
"(",
"b",
"*",
"Ports",
")",
"*",
"Ports",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"HTTP",
"!=",
"0",
"{",
"result",
".",
"HTTP",
"=",
"b",
".",
"HTTP",
"\n",
"}",
"\n",
"if",
"b"... | // Merge is used to merge two port configurations. | [
"Merge",
"is",
"used",
"to",
"merge",
"two",
"port",
"configurations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1343-L1356 |
133,261 | hashicorp/nomad | command/agent/config.go | Merge | func (a *Addresses) Merge(b *Addresses) *Addresses {
result := *a
if b.HTTP != "" {
result.HTTP = b.HTTP
}
if b.RPC != "" {
result.RPC = b.RPC
}
if b.Serf != "" {
result.Serf = b.Serf
}
return &result
} | go | func (a *Addresses) Merge(b *Addresses) *Addresses {
result := *a
if b.HTTP != "" {
result.HTTP = b.HTTP
}
if b.RPC != "" {
result.RPC = b.RPC
}
if b.Serf != "" {
result.Serf = b.Serf
}
return &result
} | [
"func",
"(",
"a",
"*",
"Addresses",
")",
"Merge",
"(",
"b",
"*",
"Addresses",
")",
"*",
"Addresses",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"HTTP",
"!=",
"\"",
"\"",
"{",
"result",
".",
"HTTP",
"=",
"b",
".",
"HTTP",
"\n",
"}",
... | // Merge is used to merge two address configs together. | [
"Merge",
"is",
"used",
"to",
"merge",
"two",
"address",
"configs",
"together",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1359-L1372 |
133,262 | hashicorp/nomad | command/agent/config.go | Merge | func (a *AdvertiseAddrs) Merge(b *AdvertiseAddrs) *AdvertiseAddrs {
result := *a
if b.RPC != "" {
result.RPC = b.RPC
}
if b.Serf != "" {
result.Serf = b.Serf
}
if b.HTTP != "" {
result.HTTP = b.HTTP
}
return &result
} | go | func (a *AdvertiseAddrs) Merge(b *AdvertiseAddrs) *AdvertiseAddrs {
result := *a
if b.RPC != "" {
result.RPC = b.RPC
}
if b.Serf != "" {
result.Serf = b.Serf
}
if b.HTTP != "" {
result.HTTP = b.HTTP
}
return &result
} | [
"func",
"(",
"a",
"*",
"AdvertiseAddrs",
")",
"Merge",
"(",
"b",
"*",
"AdvertiseAddrs",
")",
"*",
"AdvertiseAddrs",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"RPC",
"!=",
"\"",
"\"",
"{",
"result",
".",
"RPC",
"=",
"b",
".",
"RPC",
"... | // Merge merges two advertise addrs configs together. | [
"Merge",
"merges",
"two",
"advertise",
"addrs",
"configs",
"together",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/config.go#L1375-L1388 |
133,263 | hashicorp/nomad | scheduler/scheduler.go | NewScheduler | func NewScheduler(name string, logger log.Logger, state State, planner Planner) (Scheduler, error) {
// Lookup the factory function
factory, ok := BuiltinSchedulers[name]
if !ok {
return nil, fmt.Errorf("unknown scheduler '%s'", name)
}
// Instantiate the scheduler
sched := factory(logger, state, planner)
ret... | go | func NewScheduler(name string, logger log.Logger, state State, planner Planner) (Scheduler, error) {
// Lookup the factory function
factory, ok := BuiltinSchedulers[name]
if !ok {
return nil, fmt.Errorf("unknown scheduler '%s'", name)
}
// Instantiate the scheduler
sched := factory(logger, state, planner)
ret... | [
"func",
"NewScheduler",
"(",
"name",
"string",
",",
"logger",
"log",
".",
"Logger",
",",
"state",
"State",
",",
"planner",
"Planner",
")",
"(",
"Scheduler",
",",
"error",
")",
"{",
"// Lookup the factory function",
"factory",
",",
"ok",
":=",
"BuiltinScheduler... | // NewScheduler is used to instantiate and return a new scheduler
// given the scheduler name, initial state, and planner. | [
"NewScheduler",
"is",
"used",
"to",
"instantiate",
"and",
"return",
"a",
"new",
"scheduler",
"given",
"the",
"scheduler",
"name",
"initial",
"state",
"and",
"planner",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/scheduler.go#L31-L41 |
133,264 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewAttr | func NewAttr(name, attrType string, required bool) *Spec {
return AttrSpec(&Attr{
Name: name,
Type: attrType,
Required: required,
})
} | go | func NewAttr(name, attrType string, required bool) *Spec {
return AttrSpec(&Attr{
Name: name,
Type: attrType,
Required: required,
})
} | [
"func",
"NewAttr",
"(",
"name",
",",
"attrType",
"string",
",",
"required",
"bool",
")",
"*",
"Spec",
"{",
"return",
"AttrSpec",
"(",
"&",
"Attr",
"{",
"Name",
":",
"name",
",",
"Type",
":",
"attrType",
",",
"Required",
":",
"required",
",",
"}",
")"... | // NewAttr returns a new attribute spec. | [
"NewAttr",
"returns",
"a",
"new",
"attribute",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L101-L107 |
133,265 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewBlock | func NewBlock(name string, required bool, nested *Spec) *Spec {
return BlockSpec(&Block{
Name: name,
Required: required,
Nested: nested,
})
} | go | func NewBlock(name string, required bool, nested *Spec) *Spec {
return BlockSpec(&Block{
Name: name,
Required: required,
Nested: nested,
})
} | [
"func",
"NewBlock",
"(",
"name",
"string",
",",
"required",
"bool",
",",
"nested",
"*",
"Spec",
")",
"*",
"Spec",
"{",
"return",
"BlockSpec",
"(",
"&",
"Block",
"{",
"Name",
":",
"name",
",",
"Required",
":",
"required",
",",
"Nested",
":",
"nested",
... | // NewBlock returns a new block spec. | [
"NewBlock",
"returns",
"a",
"new",
"block",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L110-L116 |
133,266 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewBlockAttrs | func NewBlockAttrs(name, elementType string, required bool) *Spec {
return BlockAttrsSpec(&BlockAttrs{
Name: name,
Required: required,
Type: elementType,
})
} | go | func NewBlockAttrs(name, elementType string, required bool) *Spec {
return BlockAttrsSpec(&BlockAttrs{
Name: name,
Required: required,
Type: elementType,
})
} | [
"func",
"NewBlockAttrs",
"(",
"name",
",",
"elementType",
"string",
",",
"required",
"bool",
")",
"*",
"Spec",
"{",
"return",
"BlockAttrsSpec",
"(",
"&",
"BlockAttrs",
"{",
"Name",
":",
"name",
",",
"Required",
":",
"required",
",",
"Type",
":",
"elementTy... | // NewBlockAttrs returns a new block attrs spec | [
"NewBlockAttrs",
"returns",
"a",
"new",
"block",
"attrs",
"spec"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L119-L125 |
133,267 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewBlockListLimited | func NewBlockListLimited(name string, min, max uint64, nested *Spec) *Spec {
return BlockListSpec(&BlockList{
Name: name,
MinItems: min,
MaxItems: max,
Nested: nested,
})
} | go | func NewBlockListLimited(name string, min, max uint64, nested *Spec) *Spec {
return BlockListSpec(&BlockList{
Name: name,
MinItems: min,
MaxItems: max,
Nested: nested,
})
} | [
"func",
"NewBlockListLimited",
"(",
"name",
"string",
",",
"min",
",",
"max",
"uint64",
",",
"nested",
"*",
"Spec",
")",
"*",
"Spec",
"{",
"return",
"BlockListSpec",
"(",
"&",
"BlockList",
"{",
"Name",
":",
"name",
",",
"MinItems",
":",
"min",
",",
"Ma... | // NewBlockListLimited returns a new block list spec that limits the number of
// blocks. | [
"NewBlockListLimited",
"returns",
"a",
"new",
"block",
"list",
"spec",
"that",
"limits",
"the",
"number",
"of",
"blocks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L134-L141 |
133,268 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewBlockSetLimited | func NewBlockSetLimited(name string, min, max uint64, nested *Spec) *Spec {
return BlockSetSpec(&BlockSet{
Name: name,
MinItems: min,
MaxItems: max,
Nested: nested,
})
} | go | func NewBlockSetLimited(name string, min, max uint64, nested *Spec) *Spec {
return BlockSetSpec(&BlockSet{
Name: name,
MinItems: min,
MaxItems: max,
Nested: nested,
})
} | [
"func",
"NewBlockSetLimited",
"(",
"name",
"string",
",",
"min",
",",
"max",
"uint64",
",",
"nested",
"*",
"Spec",
")",
"*",
"Spec",
"{",
"return",
"BlockSetSpec",
"(",
"&",
"BlockSet",
"{",
"Name",
":",
"name",
",",
"MinItems",
":",
"min",
",",
"MaxIt... | // NewBlockSetLimited returns a new block set spec that limits the number of
// blocks. | [
"NewBlockSetLimited",
"returns",
"a",
"new",
"block",
"set",
"spec",
"that",
"limits",
"the",
"number",
"of",
"blocks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L150-L157 |
133,269 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewBlockMap | func NewBlockMap(name string, labels []string, nested *Spec) *Spec {
return BlockMapSpec(&BlockMap{
Name: name,
Labels: labels,
Nested: nested,
})
} | go | func NewBlockMap(name string, labels []string, nested *Spec) *Spec {
return BlockMapSpec(&BlockMap{
Name: name,
Labels: labels,
Nested: nested,
})
} | [
"func",
"NewBlockMap",
"(",
"name",
"string",
",",
"labels",
"[",
"]",
"string",
",",
"nested",
"*",
"Spec",
")",
"*",
"Spec",
"{",
"return",
"BlockMapSpec",
"(",
"&",
"BlockMap",
"{",
"Name",
":",
"name",
",",
"Labels",
":",
"labels",
",",
"Nested",
... | // NewBlockMap returns a new block map spec. | [
"NewBlockMap",
"returns",
"a",
"new",
"block",
"map",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L160-L166 |
133,270 | hashicorp/nomad | plugins/shared/hclspec/spec.go | NewDefault | func NewDefault(primary, defaultValue *Spec) *Spec {
return DefaultSpec(&Default{
Primary: primary,
Default: defaultValue,
})
} | go | func NewDefault(primary, defaultValue *Spec) *Spec {
return DefaultSpec(&Default{
Primary: primary,
Default: defaultValue,
})
} | [
"func",
"NewDefault",
"(",
"primary",
",",
"defaultValue",
"*",
"Spec",
")",
"*",
"Spec",
"{",
"return",
"DefaultSpec",
"(",
"&",
"Default",
"{",
"Primary",
":",
"primary",
",",
"Default",
":",
"defaultValue",
",",
"}",
")",
"\n",
"}"
] | // NewDefault returns a new default spec. | [
"NewDefault",
"returns",
"a",
"new",
"default",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/hclspec/spec.go#L176-L181 |
133,271 | hashicorp/nomad | drivers/docker/utils.go | loadDockerConfig | func loadDockerConfig(file string) (*configfile.ConfigFile, error) {
f, err := os.Open(file)
if err != nil {
return nil, fmt.Errorf("Failed to open auth config file: %v, error: %v", file, err)
}
defer f.Close()
cfile := new(configfile.ConfigFile)
if err = cfile.LoadFromReader(f); err != nil {
return nil, fmt... | go | func loadDockerConfig(file string) (*configfile.ConfigFile, error) {
f, err := os.Open(file)
if err != nil {
return nil, fmt.Errorf("Failed to open auth config file: %v, error: %v", file, err)
}
defer f.Close()
cfile := new(configfile.ConfigFile)
if err = cfile.LoadFromReader(f); err != nil {
return nil, fmt... | [
"func",
"loadDockerConfig",
"(",
"file",
"string",
")",
"(",
"*",
"configfile",
".",
"ConfigFile",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",... | // loadDockerConfig loads the docker config at the specified path, returning an
// error if it couldn't be read. | [
"loadDockerConfig",
"loads",
"the",
"docker",
"config",
"at",
"the",
"specified",
"path",
"returning",
"an",
"error",
"if",
"it",
"couldn",
"t",
"be",
"read",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L43-L55 |
133,272 | hashicorp/nomad | drivers/docker/utils.go | parseRepositoryInfo | func parseRepositoryInfo(repo string) (*registry.RepositoryInfo, error) {
name, err := reference.ParseNormalizedNamed(repo)
if err != nil {
return nil, fmt.Errorf("Failed to parse named repo %q: %v", repo, err)
}
repoInfo, err := registry.ParseRepositoryInfo(name)
if err != nil {
return nil, fmt.Errorf("Faile... | go | func parseRepositoryInfo(repo string) (*registry.RepositoryInfo, error) {
name, err := reference.ParseNormalizedNamed(repo)
if err != nil {
return nil, fmt.Errorf("Failed to parse named repo %q: %v", repo, err)
}
repoInfo, err := registry.ParseRepositoryInfo(name)
if err != nil {
return nil, fmt.Errorf("Faile... | [
"func",
"parseRepositoryInfo",
"(",
"repo",
"string",
")",
"(",
"*",
"registry",
".",
"RepositoryInfo",
",",
"error",
")",
"{",
"name",
",",
"err",
":=",
"reference",
".",
"ParseNormalizedNamed",
"(",
"repo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // parseRepositoryInfo takes a repo and returns the Docker RepositoryInfo. This
// is useful for interacting with a Docker config object. | [
"parseRepositoryInfo",
"takes",
"a",
"repo",
"and",
"returns",
"the",
"Docker",
"RepositoryInfo",
".",
"This",
"is",
"useful",
"for",
"interacting",
"with",
"a",
"Docker",
"config",
"object",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L59-L71 |
133,273 | hashicorp/nomad | drivers/docker/utils.go | firstValidAuth | func firstValidAuth(repo string, backends []authBackend) (*docker.AuthConfiguration, error) {
for _, backend := range backends {
auth, err := backend(repo)
if auth != nil || err != nil {
return auth, err
}
}
return nil, nil
} | go | func firstValidAuth(repo string, backends []authBackend) (*docker.AuthConfiguration, error) {
for _, backend := range backends {
auth, err := backend(repo)
if auth != nil || err != nil {
return auth, err
}
}
return nil, nil
} | [
"func",
"firstValidAuth",
"(",
"repo",
"string",
",",
"backends",
"[",
"]",
"authBackend",
")",
"(",
"*",
"docker",
".",
"AuthConfiguration",
",",
"error",
")",
"{",
"for",
"_",
",",
"backend",
":=",
"range",
"backends",
"{",
"auth",
",",
"err",
":=",
... | // firstValidAuth tries a list of auth backends, returning first error or AuthConfiguration | [
"firstValidAuth",
"tries",
"a",
"list",
"of",
"auth",
"backends",
"returning",
"first",
"error",
"or",
"AuthConfiguration"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L74-L82 |
133,274 | hashicorp/nomad | drivers/docker/utils.go | authFromTaskConfig | func authFromTaskConfig(driverConfig *TaskConfig) authBackend {
return func(string) (*docker.AuthConfiguration, error) {
// If all auth fields are empty, return
if len(driverConfig.Auth.Username) == 0 && len(driverConfig.Auth.Password) == 0 && len(driverConfig.Auth.Email) == 0 && len(driverConfig.Auth.ServerAddr) ... | go | func authFromTaskConfig(driverConfig *TaskConfig) authBackend {
return func(string) (*docker.AuthConfiguration, error) {
// If all auth fields are empty, return
if len(driverConfig.Auth.Username) == 0 && len(driverConfig.Auth.Password) == 0 && len(driverConfig.Auth.Email) == 0 && len(driverConfig.Auth.ServerAddr) ... | [
"func",
"authFromTaskConfig",
"(",
"driverConfig",
"*",
"TaskConfig",
")",
"authBackend",
"{",
"return",
"func",
"(",
"string",
")",
"(",
"*",
"docker",
".",
"AuthConfiguration",
",",
"error",
")",
"{",
"// If all auth fields are empty, return",
"if",
"len",
"(",
... | // authFromTaskConfig generates an authBackend for any auth given in the task-configuration | [
"authFromTaskConfig",
"generates",
"an",
"authBackend",
"for",
"any",
"auth",
"given",
"in",
"the",
"task",
"-",
"configuration"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L85-L98 |
133,275 | hashicorp/nomad | drivers/docker/utils.go | authFromDockerConfig | func authFromDockerConfig(file string) authBackend {
return func(repo string) (*docker.AuthConfiguration, error) {
if file == "" {
return nil, nil
}
repoInfo, err := parseRepositoryInfo(repo)
if err != nil {
return nil, err
}
cfile, err := loadDockerConfig(file)
if err != nil {
return nil, err
... | go | func authFromDockerConfig(file string) authBackend {
return func(repo string) (*docker.AuthConfiguration, error) {
if file == "" {
return nil, nil
}
repoInfo, err := parseRepositoryInfo(repo)
if err != nil {
return nil, err
}
cfile, err := loadDockerConfig(file)
if err != nil {
return nil, err
... | [
"func",
"authFromDockerConfig",
"(",
"file",
"string",
")",
"authBackend",
"{",
"return",
"func",
"(",
"repo",
"string",
")",
"(",
"*",
"docker",
".",
"AuthConfiguration",
",",
"error",
")",
"{",
"if",
"file",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",... | // authFromDockerConfig generate an authBackend for a dockercfg-compatible file.
// The authBacken can either be from explicit auth definitions or via credential
// helpers | [
"authFromDockerConfig",
"generate",
"an",
"authBackend",
"for",
"a",
"dockercfg",
"-",
"compatible",
"file",
".",
"The",
"authBacken",
"can",
"either",
"be",
"from",
"explicit",
"auth",
"definitions",
"or",
"via",
"credential",
"helpers"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L103-L136 |
133,276 | hashicorp/nomad | drivers/docker/utils.go | authFromHelper | func authFromHelper(helperName string) authBackend {
return func(repo string) (*docker.AuthConfiguration, error) {
if helperName == "" {
return nil, nil
}
helper := dockerAuthHelperPrefix + helperName
cmd := exec.Command(helper, "get")
repoInfo, err := parseRepositoryInfo(repo)
if err != nil {
retur... | go | func authFromHelper(helperName string) authBackend {
return func(repo string) (*docker.AuthConfiguration, error) {
if helperName == "" {
return nil, nil
}
helper := dockerAuthHelperPrefix + helperName
cmd := exec.Command(helper, "get")
repoInfo, err := parseRepositoryInfo(repo)
if err != nil {
retur... | [
"func",
"authFromHelper",
"(",
"helperName",
"string",
")",
"authBackend",
"{",
"return",
"func",
"(",
"repo",
"string",
")",
"(",
"*",
"docker",
".",
"AuthConfiguration",
",",
"error",
")",
"{",
"if",
"helperName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
... | // authFromHelper generates an authBackend for a docker-credentials-helper;
// A script taking the requested domain on input, outputting JSON with
// "Username" and "Secret" | [
"authFromHelper",
"generates",
"an",
"authBackend",
"for",
"a",
"docker",
"-",
"credentials",
"-",
"helper",
";",
"A",
"script",
"taking",
"the",
"requested",
"domain",
"on",
"input",
"outputting",
"JSON",
"with",
"Username",
"and",
"Secret"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L141-L183 |
133,277 | hashicorp/nomad | drivers/docker/utils.go | authIsEmpty | func authIsEmpty(auth *docker.AuthConfiguration) bool {
if auth == nil {
return false
}
return auth.Username == "" &&
auth.Password == "" &&
auth.Email == "" &&
auth.ServerAddress == ""
} | go | func authIsEmpty(auth *docker.AuthConfiguration) bool {
if auth == nil {
return false
}
return auth.Username == "" &&
auth.Password == "" &&
auth.Email == "" &&
auth.ServerAddress == ""
} | [
"func",
"authIsEmpty",
"(",
"auth",
"*",
"docker",
".",
"AuthConfiguration",
")",
"bool",
"{",
"if",
"auth",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"auth",
".",
"Username",
"==",
"\"",
"\"",
"&&",
"auth",
".",
"Password",
"==",... | // authIsEmpty returns if auth is nil or an empty structure | [
"authIsEmpty",
"returns",
"if",
"auth",
"is",
"nil",
"or",
"an",
"empty",
"structure"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L186-L194 |
133,278 | hashicorp/nomad | drivers/docker/utils.go | expandPath | func expandPath(base, dir string) string {
if filepath.IsAbs(dir) {
return filepath.Clean(dir)
}
return filepath.Clean(filepath.Join(base, dir))
} | go | func expandPath(base, dir string) string {
if filepath.IsAbs(dir) {
return filepath.Clean(dir)
}
return filepath.Clean(filepath.Join(base, dir))
} | [
"func",
"expandPath",
"(",
"base",
",",
"dir",
"string",
")",
"string",
"{",
"if",
"filepath",
".",
"IsAbs",
"(",
"dir",
")",
"{",
"return",
"filepath",
".",
"Clean",
"(",
"dir",
")",
"\n",
"}",
"\n\n",
"return",
"filepath",
".",
"Clean",
"(",
"filep... | // expandPath returns the absolute path of dir, relative to base if dir is relative path.
// base is expected to be an absolute path | [
"expandPath",
"returns",
"the",
"absolute",
"path",
"of",
"dir",
"relative",
"to",
"base",
"if",
"dir",
"is",
"relative",
"path",
".",
"base",
"is",
"expected",
"to",
"be",
"an",
"absolute",
"path"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L210-L216 |
133,279 | hashicorp/nomad | drivers/docker/utils.go | isParentPath | func isParentPath(parent, path string) bool {
rel, err := filepath.Rel(parent, path)
return err == nil && !strings.HasPrefix(rel, "..")
} | go | func isParentPath(parent, path string) bool {
rel, err := filepath.Rel(parent, path)
return err == nil && !strings.HasPrefix(rel, "..")
} | [
"func",
"isParentPath",
"(",
"parent",
",",
"path",
"string",
")",
"bool",
"{",
"rel",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"parent",
",",
"path",
")",
"\n",
"return",
"err",
"==",
"nil",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"rel",
... | // isParentPath returns true if path is a child or a descendant of parent path.
// Both inputs need to be absolute paths. | [
"isParentPath",
"returns",
"true",
"if",
"path",
"is",
"a",
"child",
"or",
"a",
"descendant",
"of",
"parent",
"path",
".",
"Both",
"inputs",
"need",
"to",
"be",
"absolute",
"paths",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/utils.go#L220-L223 |
133,280 | hashicorp/nomad | nomad/periodic.go | DispatchJob | func (s *Server) DispatchJob(job *structs.Job) (*structs.Evaluation, error) {
// Commit this update via Raft
job.SetSubmitTime()
req := structs.JobRegisterRequest{
Job: job,
WriteRequest: structs.WriteRequest{
Namespace: job.Namespace,
},
}
fsmErr, index, err := s.raftApply(structs.JobRegisterRequestType,... | go | func (s *Server) DispatchJob(job *structs.Job) (*structs.Evaluation, error) {
// Commit this update via Raft
job.SetSubmitTime()
req := structs.JobRegisterRequest{
Job: job,
WriteRequest: structs.WriteRequest{
Namespace: job.Namespace,
},
}
fsmErr, index, err := s.raftApply(structs.JobRegisterRequestType,... | [
"func",
"(",
"s",
"*",
"Server",
")",
"DispatchJob",
"(",
"job",
"*",
"structs",
".",
"Job",
")",
"(",
"*",
"structs",
".",
"Evaluation",
",",
"error",
")",
"{",
"// Commit this update via Raft",
"job",
".",
"SetSubmitTime",
"(",
")",
"\n",
"req",
":=",
... | // DispatchJob creates an evaluation for the passed job and commits both the
// evaluation and the job to the raft log. It returns the eval. | [
"DispatchJob",
"creates",
"an",
"evaluation",
"for",
"the",
"passed",
"job",
"and",
"commits",
"both",
"the",
"evaluation",
"and",
"the",
"job",
"to",
"the",
"raft",
"log",
".",
"It",
"returns",
"the",
"eval",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L48-L92 |
133,281 | hashicorp/nomad | nomad/periodic.go | RunningChildren | func (s *Server) RunningChildren(job *structs.Job) (bool, error) {
state, err := s.fsm.State().Snapshot()
if err != nil {
return false, err
}
ws := memdb.NewWatchSet()
prefix := fmt.Sprintf("%s%s", job.ID, structs.PeriodicLaunchSuffix)
iter, err := state.JobsByIDPrefix(ws, job.Namespace, prefix)
if err != nil... | go | func (s *Server) RunningChildren(job *structs.Job) (bool, error) {
state, err := s.fsm.State().Snapshot()
if err != nil {
return false, err
}
ws := memdb.NewWatchSet()
prefix := fmt.Sprintf("%s%s", job.ID, structs.PeriodicLaunchSuffix)
iter, err := state.JobsByIDPrefix(ws, job.Namespace, prefix)
if err != nil... | [
"func",
"(",
"s",
"*",
"Server",
")",
"RunningChildren",
"(",
"job",
"*",
"structs",
".",
"Job",
")",
"(",
"bool",
",",
"error",
")",
"{",
"state",
",",
"err",
":=",
"s",
".",
"fsm",
".",
"State",
"(",
")",
".",
"Snapshot",
"(",
")",
"\n",
"if"... | // RunningChildren checks whether the passed job has any running children. | [
"RunningChildren",
"checks",
"whether",
"the",
"passed",
"job",
"has",
"any",
"running",
"children",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L95-L144 |
133,282 | hashicorp/nomad | nomad/periodic.go | NewPeriodicDispatch | func NewPeriodicDispatch(logger log.Logger, dispatcher JobEvalDispatcher) *PeriodicDispatch {
return &PeriodicDispatch{
dispatcher: dispatcher,
tracked: make(map[structs.NamespacedID]*structs.Job),
heap: NewPeriodicHeap(),
updateCh: make(chan struct{}, 1),
logger: logger.Named("periodic"),
}
... | go | func NewPeriodicDispatch(logger log.Logger, dispatcher JobEvalDispatcher) *PeriodicDispatch {
return &PeriodicDispatch{
dispatcher: dispatcher,
tracked: make(map[structs.NamespacedID]*structs.Job),
heap: NewPeriodicHeap(),
updateCh: make(chan struct{}, 1),
logger: logger.Named("periodic"),
}
... | [
"func",
"NewPeriodicDispatch",
"(",
"logger",
"log",
".",
"Logger",
",",
"dispatcher",
"JobEvalDispatcher",
")",
"*",
"PeriodicDispatch",
"{",
"return",
"&",
"PeriodicDispatch",
"{",
"dispatcher",
":",
"dispatcher",
",",
"tracked",
":",
"make",
"(",
"map",
"[",
... | // NewPeriodicDispatch returns a periodic dispatcher that is used to track and
// launch periodic jobs. | [
"NewPeriodicDispatch",
"returns",
"a",
"periodic",
"dispatcher",
"that",
"is",
"used",
"to",
"track",
"and",
"launch",
"periodic",
"jobs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L148-L156 |
133,283 | hashicorp/nomad | nomad/periodic.go | SetEnabled | func (p *PeriodicDispatch) SetEnabled(enabled bool) {
p.l.Lock()
defer p.l.Unlock()
wasRunning := p.enabled
p.enabled = enabled
// If we are transitioning from enabled to disabled, stop the daemon and
// flush.
if !enabled && wasRunning {
p.stopFn()
p.flush()
} else if enabled && !wasRunning {
// If we a... | go | func (p *PeriodicDispatch) SetEnabled(enabled bool) {
p.l.Lock()
defer p.l.Unlock()
wasRunning := p.enabled
p.enabled = enabled
// If we are transitioning from enabled to disabled, stop the daemon and
// flush.
if !enabled && wasRunning {
p.stopFn()
p.flush()
} else if enabled && !wasRunning {
// If we a... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"SetEnabled",
"(",
"enabled",
"bool",
")",
"{",
"p",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"wasRunning",
":=",
"p",
".",
"enabled",
"\n",
"p",... | // SetEnabled is used to control if the periodic dispatcher is enabled. It
// should only be enabled on the active leader. Disabling an active dispatcher
// will stop any launched go routine and flush the dispatcher. | [
"SetEnabled",
"is",
"used",
"to",
"control",
"if",
"the",
"periodic",
"dispatcher",
"is",
"enabled",
".",
"It",
"should",
"only",
"be",
"enabled",
"on",
"the",
"active",
"leader",
".",
"Disabling",
"an",
"active",
"dispatcher",
"will",
"stop",
"any",
"launch... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L161-L178 |
133,284 | hashicorp/nomad | nomad/periodic.go | Tracked | func (p *PeriodicDispatch) Tracked() []*structs.Job {
p.l.RLock()
defer p.l.RUnlock()
tracked := make([]*structs.Job, len(p.tracked))
i := 0
for _, job := range p.tracked {
tracked[i] = job
i++
}
return tracked
} | go | func (p *PeriodicDispatch) Tracked() []*structs.Job {
p.l.RLock()
defer p.l.RUnlock()
tracked := make([]*structs.Job, len(p.tracked))
i := 0
for _, job := range p.tracked {
tracked[i] = job
i++
}
return tracked
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"Tracked",
"(",
")",
"[",
"]",
"*",
"structs",
".",
"Job",
"{",
"p",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n",
"tracked",
":=",
"make",
"(",
... | // Tracked returns the set of tracked job IDs. | [
"Tracked",
"returns",
"the",
"set",
"of",
"tracked",
"job",
"IDs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L181-L191 |
133,285 | hashicorp/nomad | nomad/periodic.go | Add | func (p *PeriodicDispatch) Add(job *structs.Job) error {
p.l.Lock()
defer p.l.Unlock()
// Do nothing if not enabled
if !p.enabled {
return nil
}
// If we were tracking a job and it has been disabled, made non-periodic,
// stopped or is parameterized, remove it
disabled := !job.IsPeriodicActive()
tuple := ... | go | func (p *PeriodicDispatch) Add(job *structs.Job) error {
p.l.Lock()
defer p.l.Unlock()
// Do nothing if not enabled
if !p.enabled {
return nil
}
// If we were tracking a job and it has been disabled, made non-periodic,
// stopped or is parameterized, remove it
disabled := !job.IsPeriodicActive()
tuple := ... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"Add",
"(",
"job",
"*",
"structs",
".",
"Job",
")",
"error",
"{",
"p",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"... | // Add begins tracking of a periodic job. If it is already tracked, it acts as
// an update to the jobs periodic spec. The method returns whether the job was
// added and any error that may have occurred. | [
"Add",
"begins",
"tracking",
"of",
"a",
"periodic",
"job",
".",
"If",
"it",
"is",
"already",
"tracked",
"it",
"acts",
"as",
"an",
"update",
"to",
"the",
"jobs",
"periodic",
"spec",
".",
"The",
"method",
"returns",
"whether",
"the",
"job",
"was",
"added",... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L196-L248 |
133,286 | hashicorp/nomad | nomad/periodic.go | Remove | func (p *PeriodicDispatch) Remove(namespace, jobID string) error {
p.l.Lock()
defer p.l.Unlock()
return p.removeLocked(structs.NamespacedID{
ID: jobID,
Namespace: namespace,
})
} | go | func (p *PeriodicDispatch) Remove(namespace, jobID string) error {
p.l.Lock()
defer p.l.Unlock()
return p.removeLocked(structs.NamespacedID{
ID: jobID,
Namespace: namespace,
})
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"Remove",
"(",
"namespace",
",",
"jobID",
"string",
")",
"error",
"{",
"p",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"removeL... | // Remove stops tracking the passed job. If the job is not tracked, it is a
// no-op. | [
"Remove",
"stops",
"tracking",
"the",
"passed",
"job",
".",
"If",
"the",
"job",
"is",
"not",
"tracked",
"it",
"is",
"a",
"no",
"-",
"op",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L252-L259 |
133,287 | hashicorp/nomad | nomad/periodic.go | removeLocked | func (p *PeriodicDispatch) removeLocked(jobID structs.NamespacedID) error {
// Do nothing if not enabled
if !p.enabled {
return nil
}
job, tracked := p.tracked[jobID]
if !tracked {
return nil
}
delete(p.tracked, jobID)
if err := p.heap.Remove(job); err != nil {
return fmt.Errorf("failed to remove tracke... | go | func (p *PeriodicDispatch) removeLocked(jobID structs.NamespacedID) error {
// Do nothing if not enabled
if !p.enabled {
return nil
}
job, tracked := p.tracked[jobID]
if !tracked {
return nil
}
delete(p.tracked, jobID)
if err := p.heap.Remove(job); err != nil {
return fmt.Errorf("failed to remove tracke... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"removeLocked",
"(",
"jobID",
"structs",
".",
"NamespacedID",
")",
"error",
"{",
"// Do nothing if not enabled",
"if",
"!",
"p",
".",
"enabled",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"job",
",",
"tracked",
... | // Remove stops tracking the passed job. If the job is not tracked, it is a
// no-op. It assumes this is called while a lock is held. | [
"Remove",
"stops",
"tracking",
"the",
"passed",
"job",
".",
"If",
"the",
"job",
"is",
"not",
"tracked",
"it",
"is",
"a",
"no",
"-",
"op",
".",
"It",
"assumes",
"this",
"is",
"called",
"while",
"a",
"lock",
"is",
"held",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L263-L287 |
133,288 | hashicorp/nomad | nomad/periodic.go | ForceRun | func (p *PeriodicDispatch) ForceRun(namespace, jobID string) (*structs.Evaluation, error) {
p.l.Lock()
// Do nothing if not enabled
if !p.enabled {
p.l.Unlock()
return nil, fmt.Errorf("periodic dispatch disabled")
}
tuple := structs.NamespacedID{
ID: jobID,
Namespace: namespace,
}
job, tracked :... | go | func (p *PeriodicDispatch) ForceRun(namespace, jobID string) (*structs.Evaluation, error) {
p.l.Lock()
// Do nothing if not enabled
if !p.enabled {
p.l.Unlock()
return nil, fmt.Errorf("periodic dispatch disabled")
}
tuple := structs.NamespacedID{
ID: jobID,
Namespace: namespace,
}
job, tracked :... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"ForceRun",
"(",
"namespace",
",",
"jobID",
"string",
")",
"(",
"*",
"structs",
".",
"Evaluation",
",",
"error",
")",
"{",
"p",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"if",... | // ForceRun causes the periodic job to be evaluated immediately and returns the
// subsequent eval. | [
"ForceRun",
"causes",
"the",
"periodic",
"job",
"to",
"be",
"evaluated",
"immediately",
"and",
"returns",
"the",
"subsequent",
"eval",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L291-L312 |
133,289 | hashicorp/nomad | nomad/periodic.go | shouldRun | func (p *PeriodicDispatch) shouldRun() bool {
p.l.RLock()
defer p.l.RUnlock()
return p.enabled
} | go | func (p *PeriodicDispatch) shouldRun() bool {
p.l.RLock()
defer p.l.RUnlock()
return p.enabled
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"shouldRun",
"(",
")",
"bool",
"{",
"p",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"p",
".",
"enabled",
"\n",
"}"
] | // shouldRun returns whether the long lived run function should run. | [
"shouldRun",
"returns",
"whether",
"the",
"long",
"lived",
"run",
"function",
"should",
"run",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L315-L319 |
133,290 | hashicorp/nomad | nomad/periodic.go | run | func (p *PeriodicDispatch) run(ctx context.Context, updateCh <-chan struct{}) {
var launchCh <-chan time.Time
for p.shouldRun() {
job, launch := p.nextLaunch()
if launch.IsZero() {
launchCh = nil
} else {
launchDur := launch.Sub(time.Now().In(job.Periodic.GetLocation()))
launchCh = time.After(launchDur... | go | func (p *PeriodicDispatch) run(ctx context.Context, updateCh <-chan struct{}) {
var launchCh <-chan time.Time
for p.shouldRun() {
job, launch := p.nextLaunch()
if launch.IsZero() {
launchCh = nil
} else {
launchDur := launch.Sub(time.Now().In(job.Periodic.GetLocation()))
launchCh = time.After(launchDur... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"run",
"(",
"ctx",
"context",
".",
"Context",
",",
"updateCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"var",
"launchCh",
"<-",
"chan",
"time",
".",
"Time",
"\n",
"for",
"p",
".",
"shouldRun",
"(",
... | // run is a long-lived function that waits till a job's periodic spec is met and
// then creates an evaluation to run the job. | [
"run",
"is",
"a",
"long",
"-",
"lived",
"function",
"that",
"waits",
"till",
"a",
"job",
"s",
"periodic",
"spec",
"is",
"met",
"and",
"then",
"creates",
"an",
"evaluation",
"to",
"run",
"the",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L323-L344 |
133,291 | hashicorp/nomad | nomad/periodic.go | dispatch | func (p *PeriodicDispatch) dispatch(job *structs.Job, launchTime time.Time) {
p.l.Lock()
nextLaunch, err := job.Periodic.Next(launchTime)
if err != nil {
p.logger.Error("failed to parse next periodic launch", "job", job.NamespacedID(), "error", err)
} else if err := p.heap.Update(job, nextLaunch); err != nil {
... | go | func (p *PeriodicDispatch) dispatch(job *structs.Job, launchTime time.Time) {
p.l.Lock()
nextLaunch, err := job.Periodic.Next(launchTime)
if err != nil {
p.logger.Error("failed to parse next periodic launch", "job", job.NamespacedID(), "error", err)
} else if err := p.heap.Update(job, nextLaunch); err != nil {
... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"dispatch",
"(",
"job",
"*",
"structs",
".",
"Job",
",",
"launchTime",
"time",
".",
"Time",
")",
"{",
"p",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",
"nextLaunch",
",",
"err",
":=",
"job",
".",
"Periodi... | // dispatch creates an evaluation for the job and updates its next launchtime
// based on the passed launch time. | [
"dispatch",
"creates",
"an",
"evaluation",
"for",
"the",
"job",
"and",
"updates",
"its",
"next",
"launchtime",
"based",
"on",
"the",
"passed",
"launch",
"time",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L348-L378 |
133,292 | hashicorp/nomad | nomad/periodic.go | nextLaunch | func (p *PeriodicDispatch) nextLaunch() (*structs.Job, time.Time) {
// If there is nothing wait for an update.
p.l.RLock()
defer p.l.RUnlock()
if p.heap.Length() == 0 {
return nil, time.Time{}
}
nextJob := p.heap.Peek()
if nextJob == nil {
return nil, time.Time{}
}
return nextJob.job, nextJob.next
} | go | func (p *PeriodicDispatch) nextLaunch() (*structs.Job, time.Time) {
// If there is nothing wait for an update.
p.l.RLock()
defer p.l.RUnlock()
if p.heap.Length() == 0 {
return nil, time.Time{}
}
nextJob := p.heap.Peek()
if nextJob == nil {
return nil, time.Time{}
}
return nextJob.job, nextJob.next
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"nextLaunch",
"(",
")",
"(",
"*",
"structs",
".",
"Job",
",",
"time",
".",
"Time",
")",
"{",
"// If there is nothing wait for an update.",
"p",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"... | // nextLaunch returns the next job to launch and when it should be launched. If
// the next job can't be determined, an error is returned. If the dispatcher is
// stopped, a nil job will be returned. | [
"nextLaunch",
"returns",
"the",
"next",
"job",
"to",
"launch",
"and",
"when",
"it",
"should",
"be",
"launched",
".",
"If",
"the",
"next",
"job",
"can",
"t",
"be",
"determined",
"an",
"error",
"is",
"returned",
".",
"If",
"the",
"dispatcher",
"is",
"stopp... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L383-L397 |
133,293 | hashicorp/nomad | nomad/periodic.go | createEval | func (p *PeriodicDispatch) createEval(periodicJob *structs.Job, time time.Time) (*structs.Evaluation, error) {
derived, err := p.deriveJob(periodicJob, time)
if err != nil {
return nil, err
}
eval, err := p.dispatcher.DispatchJob(derived)
if err != nil {
p.logger.Error("failed to dispatch job", "job", periodi... | go | func (p *PeriodicDispatch) createEval(periodicJob *structs.Job, time time.Time) (*structs.Evaluation, error) {
derived, err := p.deriveJob(periodicJob, time)
if err != nil {
return nil, err
}
eval, err := p.dispatcher.DispatchJob(derived)
if err != nil {
p.logger.Error("failed to dispatch job", "job", periodi... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"createEval",
"(",
"periodicJob",
"*",
"structs",
".",
"Job",
",",
"time",
"time",
".",
"Time",
")",
"(",
"*",
"structs",
".",
"Evaluation",
",",
"error",
")",
"{",
"derived",
",",
"err",
":=",
"p",
"."... | // createEval instantiates a job based on the passed periodic job and submits an
// evaluation for it. This should not be called with the lock held. | [
"createEval",
"instantiates",
"a",
"job",
"based",
"on",
"the",
"passed",
"periodic",
"job",
"and",
"submits",
"an",
"evaluation",
"for",
"it",
".",
"This",
"should",
"not",
"be",
"called",
"with",
"the",
"lock",
"held",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L401-L414 |
133,294 | hashicorp/nomad | nomad/periodic.go | deriveJob | func (p *PeriodicDispatch) deriveJob(periodicJob *structs.Job, time time.Time) (
derived *structs.Job, err error) {
// Have to recover in case the job copy panics.
defer func() {
if r := recover(); r != nil {
p.logger.Error("deriving child job from periodic job failed; deregistering from periodic runner",
... | go | func (p *PeriodicDispatch) deriveJob(periodicJob *structs.Job, time time.Time) (
derived *structs.Job, err error) {
// Have to recover in case the job copy panics.
defer func() {
if r := recover(); r != nil {
p.logger.Error("deriving child job from periodic job failed; deregistering from periodic runner",
... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"deriveJob",
"(",
"periodicJob",
"*",
"structs",
".",
"Job",
",",
"time",
"time",
".",
"Time",
")",
"(",
"derived",
"*",
"structs",
".",
"Job",
",",
"err",
"error",
")",
"{",
"// Have to recover in case the j... | // deriveJob instantiates a new job based on the passed periodic job and the
// launch time. | [
"deriveJob",
"instantiates",
"a",
"new",
"job",
"based",
"on",
"the",
"passed",
"periodic",
"job",
"and",
"the",
"launch",
"time",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L418-L442 |
133,295 | hashicorp/nomad | nomad/periodic.go | derivedJobID | func (p *PeriodicDispatch) derivedJobID(periodicJob *structs.Job, time time.Time) string {
return fmt.Sprintf("%s%s%d", periodicJob.ID, structs.PeriodicLaunchSuffix, time.Unix())
} | go | func (p *PeriodicDispatch) derivedJobID(periodicJob *structs.Job, time time.Time) string {
return fmt.Sprintf("%s%s%d", periodicJob.ID, structs.PeriodicLaunchSuffix, time.Unix())
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"derivedJobID",
"(",
"periodicJob",
"*",
"structs",
".",
"Job",
",",
"time",
"time",
".",
"Time",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"periodicJob",
".",
"ID",
",",
... | // deriveJobID returns a job ID based on the parent periodic job and the launch
// time. | [
"deriveJobID",
"returns",
"a",
"job",
"ID",
"based",
"on",
"the",
"parent",
"periodic",
"job",
"and",
"the",
"launch",
"time",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L446-L448 |
133,296 | hashicorp/nomad | nomad/periodic.go | LaunchTime | func (p *PeriodicDispatch) LaunchTime(jobID string) (time.Time, error) {
index := strings.LastIndex(jobID, structs.PeriodicLaunchSuffix)
if index == -1 {
return time.Time{}, fmt.Errorf("couldn't parse launch time from eval: %v", jobID)
}
launch, err := strconv.Atoi(jobID[index+len(structs.PeriodicLaunchSuffix):]... | go | func (p *PeriodicDispatch) LaunchTime(jobID string) (time.Time, error) {
index := strings.LastIndex(jobID, structs.PeriodicLaunchSuffix)
if index == -1 {
return time.Time{}, fmt.Errorf("couldn't parse launch time from eval: %v", jobID)
}
launch, err := strconv.Atoi(jobID[index+len(structs.PeriodicLaunchSuffix):]... | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"LaunchTime",
"(",
"jobID",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"index",
":=",
"strings",
".",
"LastIndex",
"(",
"jobID",
",",
"structs",
".",
"PeriodicLaunchSuffix",
")",
"\n",... | // LaunchTime returns the launch time of the job. This is only valid for
// jobs created by PeriodicDispatch and will otherwise return an error. | [
"LaunchTime",
"returns",
"the",
"launch",
"time",
"of",
"the",
"job",
".",
"This",
"is",
"only",
"valid",
"for",
"jobs",
"created",
"by",
"PeriodicDispatch",
"and",
"will",
"otherwise",
"return",
"an",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L452-L464 |
133,297 | hashicorp/nomad | nomad/periodic.go | flush | func (p *PeriodicDispatch) flush() {
p.updateCh = make(chan struct{}, 1)
p.tracked = make(map[structs.NamespacedID]*structs.Job)
p.heap = NewPeriodicHeap()
p.stopFn = nil
} | go | func (p *PeriodicDispatch) flush() {
p.updateCh = make(chan struct{}, 1)
p.tracked = make(map[structs.NamespacedID]*structs.Job)
p.heap = NewPeriodicHeap()
p.stopFn = nil
} | [
"func",
"(",
"p",
"*",
"PeriodicDispatch",
")",
"flush",
"(",
")",
"{",
"p",
".",
"updateCh",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
"\n",
"p",
".",
"tracked",
"=",
"make",
"(",
"map",
"[",
"structs",
".",
"NamespacedID",
"]... | // flush clears the state of the PeriodicDispatcher | [
"flush",
"clears",
"the",
"state",
"of",
"the",
"PeriodicDispatcher"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic.go#L467-L472 |
133,298 | hashicorp/nomad | nomad/structs/network.go | NewNetworkIndex | func NewNetworkIndex() *NetworkIndex {
return &NetworkIndex{
AvailBandwidth: make(map[string]int),
UsedPorts: make(map[string]Bitmap),
UsedBandwidth: make(map[string]int),
}
} | go | func NewNetworkIndex() *NetworkIndex {
return &NetworkIndex{
AvailBandwidth: make(map[string]int),
UsedPorts: make(map[string]Bitmap),
UsedBandwidth: make(map[string]int),
}
} | [
"func",
"NewNetworkIndex",
"(",
")",
"*",
"NetworkIndex",
"{",
"return",
"&",
"NetworkIndex",
"{",
"AvailBandwidth",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
",",
"UsedPorts",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Bitmap",
")",
... | // NewNetworkIndex is used to construct a new network index | [
"NewNetworkIndex",
"is",
"used",
"to",
"construct",
"a",
"new",
"network",
"index"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L43-L49 |
133,299 | hashicorp/nomad | nomad/structs/network.go | Release | func (idx *NetworkIndex) Release() {
for _, b := range idx.UsedPorts {
bitmapPool.Put(b)
}
} | go | func (idx *NetworkIndex) Release() {
for _, b := range idx.UsedPorts {
bitmapPool.Put(b)
}
} | [
"func",
"(",
"idx",
"*",
"NetworkIndex",
")",
"Release",
"(",
")",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"idx",
".",
"UsedPorts",
"{",
"bitmapPool",
".",
"Put",
"(",
"b",
")",
"\n",
"}",
"\n",
"}"
] | // Release is called when the network index is no longer needed
// to attempt to re-use some of the memory it has allocated | [
"Release",
"is",
"called",
"when",
"the",
"network",
"index",
"is",
"no",
"longer",
"needed",
"to",
"attempt",
"to",
"re",
"-",
"use",
"some",
"of",
"the",
"memory",
"it",
"has",
"allocated"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L53-L57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.