id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
12,900
mesos/mesos-go
api/v1/lib/httpcli/http.go
Timeout
func Timeout(d time.Duration) ConfigOpt { return func(c *Config) { c.transport.ResponseHeaderTimeout = d c.transport.TLSHandshakeTimeout = d c.dialer.Timeout = d } }
go
func Timeout(d time.Duration) ConfigOpt { return func(c *Config) { c.transport.ResponseHeaderTimeout = d c.transport.TLSHandshakeTimeout = d c.dialer.Timeout = d } }
[ "func", "Timeout", "(", "d", "time", ".", "Duration", ")", "ConfigOpt", "{", "return", "func", "(", "c", "*", "Config", ")", "{", "c", ".", "transport", ".", "ResponseHeaderTimeout", "=", "d", "\n", "c", ".", "transport", ".", "TLSHandshakeTimeout", "=", "d", "\n", "c", ".", "dialer", ".", "Timeout", "=", "d", "\n", "}", "\n", "}" ]
// Timeout returns an ConfigOpt that sets a Config's response header timeout, tls handshake timeout, // and dialer timeout.
[ "Timeout", "returns", "an", "ConfigOpt", "that", "sets", "a", "Config", "s", "response", "header", "timeout", "tls", "handshake", "timeout", "and", "dialer", "timeout", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/http.go#L556-L562
12,901
mesos/mesos-go
api/v1/lib/httpcli/http.go
RoundTripper
func RoundTripper(rt http.RoundTripper) ConfigOpt { return func(c *Config) { c.client.Transport = rt } }
go
func RoundTripper(rt http.RoundTripper) ConfigOpt { return func(c *Config) { c.client.Transport = rt } }
[ "func", "RoundTripper", "(", "rt", "http", ".", "RoundTripper", ")", "ConfigOpt", "{", "return", "func", "(", "c", "*", "Config", ")", "{", "c", ".", "client", ".", "Transport", "=", "rt", "\n", "}", "\n", "}" ]
// RoundTripper returns a ConfigOpt that sets a Config's round-tripper.
[ "RoundTripper", "returns", "a", "ConfigOpt", "that", "sets", "a", "Config", "s", "round", "-", "tripper", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/http.go#L565-L569
12,902
mesos/mesos-go
api/v1/lib/httpcli/http.go
TLSConfig
func TLSConfig(tc *tls.Config) ConfigOpt { return func(c *Config) { c.transport.TLSClientConfig = tc } }
go
func TLSConfig(tc *tls.Config) ConfigOpt { return func(c *Config) { c.transport.TLSClientConfig = tc } }
[ "func", "TLSConfig", "(", "tc", "*", "tls", ".", "Config", ")", "ConfigOpt", "{", "return", "func", "(", "c", "*", "Config", ")", "{", "c", ".", "transport", ".", "TLSClientConfig", "=", "tc", "\n", "}", "\n", "}" ]
// TLSConfig returns a ConfigOpt that sets a Config's TLS configuration.
[ "TLSConfig", "returns", "a", "ConfigOpt", "that", "sets", "a", "Config", "s", "TLS", "configuration", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/http.go#L572-L576
12,903
mesos/mesos-go
api/v1/lib/httpcli/http.go
Transport
func Transport(modifyTransport func(*http.Transport)) ConfigOpt { return func(c *Config) { if modifyTransport != nil { modifyTransport(c.transport) } } }
go
func Transport(modifyTransport func(*http.Transport)) ConfigOpt { return func(c *Config) { if modifyTransport != nil { modifyTransport(c.transport) } } }
[ "func", "Transport", "(", "modifyTransport", "func", "(", "*", "http", ".", "Transport", ")", ")", "ConfigOpt", "{", "return", "func", "(", "c", "*", "Config", ")", "{", "if", "modifyTransport", "!=", "nil", "{", "modifyTransport", "(", "c", ".", "transport", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Transport returns a ConfigOpt that allows tweaks of the default Config's http.Transport
[ "Transport", "returns", "a", "ConfigOpt", "that", "allows", "tweaks", "of", "the", "default", "Config", "s", "http", ".", "Transport" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/http.go#L579-L585
12,904
mesos/mesos-go
api/v1/lib/httpcli/http.go
WrapRoundTripper
func WrapRoundTripper(f func(http.RoundTripper) http.RoundTripper) ConfigOpt { return func(c *Config) { if f != nil { if rt := f(c.client.Transport); rt != nil { c.client.Transport = rt } } } }
go
func WrapRoundTripper(f func(http.RoundTripper) http.RoundTripper) ConfigOpt { return func(c *Config) { if f != nil { if rt := f(c.client.Transport); rt != nil { c.client.Transport = rt } } } }
[ "func", "WrapRoundTripper", "(", "f", "func", "(", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", ")", "ConfigOpt", "{", "return", "func", "(", "c", "*", "Config", ")", "{", "if", "f", "!=", "nil", "{", "if", "rt", ":=", "f", "(", "c", ".", "client", ".", "Transport", ")", ";", "rt", "!=", "nil", "{", "c", ".", "client", ".", "Transport", "=", "rt", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// WrapRoundTripper allows a caller to customize a configuration's HTTP exchanger. Useful // for authentication protocols that operate over stock HTTP.
[ "WrapRoundTripper", "allows", "a", "caller", "to", "customize", "a", "configuration", "s", "HTTP", "exchanger", ".", "Useful", "for", "authentication", "protocols", "that", "operate", "over", "stock", "HTTP", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/http.go#L589-L597
12,905
mesos/mesos-go
api/v1/lib/resources.go
Minus
func (resources Resources) Minus(that ...Resource) Resources { x := resources.Clone() return x.Subtract(that...) }
go
func (resources Resources) Minus(that ...Resource) Resources { x := resources.Clone() return x.Subtract(that...) }
[ "func", "(", "resources", "Resources", ")", "Minus", "(", "that", "...", "Resource", ")", "Resources", "{", "x", ":=", "resources", ".", "Clone", "(", ")", "\n", "return", "x", ".", "Subtract", "(", "that", "...", ")", "\n", "}" ]
// Minus calculates and returns the result of `resources - that` without modifying either // the receiving `resources` or `that`.
[ "Minus", "calculates", "and", "returns", "the", "result", "of", "resources", "-", "that", "without", "modifying", "either", "the", "receiving", "resources", "or", "that", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L115-L118
12,906
mesos/mesos-go
api/v1/lib/resources.go
Plus
func (resources Resources) Plus(that ...Resource) Resources { x := resources.Clone() return x.Add(that...) }
go
func (resources Resources) Plus(that ...Resource) Resources { x := resources.Clone() return x.Add(that...) }
[ "func", "(", "resources", "Resources", ")", "Plus", "(", "that", "...", "Resource", ")", "Resources", "{", "x", ":=", "resources", ".", "Clone", "(", ")", "\n", "return", "x", ".", "Add", "(", "that", "...", ")", "\n", "}" ]
// Plus calculates and returns the result of `resources + that` without modifying either // the receiving `resources` or `that`.
[ "Plus", "calculates", "and", "returns", "the", "result", "of", "resources", "+", "that", "without", "modifying", "either", "the", "receiving", "resources", "or", "that", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L140-L143
12,907
mesos/mesos-go
api/v1/lib/resources.go
Minus1
func (resources *Resources) Minus1(that Resource) Resources { x := resources.Clone() return x.Subtract1(that) }
go
func (resources *Resources) Minus1(that Resource) Resources { x := resources.Clone() return x.Subtract1(that) }
[ "func", "(", "resources", "*", "Resources", ")", "Minus1", "(", "that", "Resource", ")", "Resources", "{", "x", ":=", "resources", ".", "Clone", "(", ")", "\n", "return", "x", ".", "Subtract1", "(", "that", ")", "\n", "}" ]
// Minus1 calculates and returns the result of `resources - that` without modifying either // the receiving `resources` or `that`.
[ "Minus1", "calculates", "and", "returns", "the", "result", "of", "resources", "-", "that", "without", "modifying", "either", "the", "receiving", "resources", "or", "that", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L191-L194
12,908
mesos/mesos-go
api/v1/lib/resources.go
Addable
func (left *Resource) Addable(right Resource) bool { if left == nil { return true } if left.GetName() != right.GetName() || left.GetType() != right.GetType() { return false } if !IsCapabilityReservationRefinementEnabled() && left.GetRole() != right.GetRole() { return false } if a, b := left.GetShared(), right.GetShared(); (a == nil) != (b == nil) { // shared has no fields return false } else if a != nil { // For shared resources, they can be added only if left == right. return left.Equivalent(right) } if a, b := left.GetAllocationInfo(), right.GetAllocationInfo(); !a.Equivalent(b) { return false } if !left.GetReservation().Equivalent(right.GetReservation()) { return false } if a, b := left.Reservations, right.Reservations; len(a) != len(b) { return false } else { for i := range a { aa := &a[i] if !aa.Equivalent(&b[i]) { return false } } } if !left.GetDisk().Equivalent(right.GetDisk()) { return false } if ls := left.GetDisk().GetSource(); ls != nil { switch ls.GetType() { case Resource_DiskInfo_Source_PATH: // Two PATH resources can be added if their disks are identical case Resource_DiskInfo_Source_BLOCK, Resource_DiskInfo_Source_MOUNT: // Two resources that represent exclusive 'MOUNT' or 'RAW' disks // cannot be added together; this would defeat the exclusivity. return false case Resource_DiskInfo_Source_RAW: // We can only add resources representing 'RAW' disks if // they have no identity. if ls.GetID() != "" { return false } case Resource_DiskInfo_Source_UNKNOWN: panic("unreachable") } } // from apache/mesos: src/common/resources.cpp // TODO(jieyu): Even if two Resource objects with DiskInfo have the // same persistence ID, they cannot be added together. In fact, this // shouldn't happen if we do not add resources from different // namespaces (e.g., across slave). Consider adding a warning. if left.GetDisk().GetPersistence() != nil { return false } if (left.GetRevocable() == nil) != (right.GetRevocable() == nil) { return false } if a, b := left.GetProviderID(), right.GetProviderID(); (a == nil) != (b == nil) { return false } else if a != nil && a.Value != b.Value { return false } return true }
go
func (left *Resource) Addable(right Resource) bool { if left == nil { return true } if left.GetName() != right.GetName() || left.GetType() != right.GetType() { return false } if !IsCapabilityReservationRefinementEnabled() && left.GetRole() != right.GetRole() { return false } if a, b := left.GetShared(), right.GetShared(); (a == nil) != (b == nil) { // shared has no fields return false } else if a != nil { // For shared resources, they can be added only if left == right. return left.Equivalent(right) } if a, b := left.GetAllocationInfo(), right.GetAllocationInfo(); !a.Equivalent(b) { return false } if !left.GetReservation().Equivalent(right.GetReservation()) { return false } if a, b := left.Reservations, right.Reservations; len(a) != len(b) { return false } else { for i := range a { aa := &a[i] if !aa.Equivalent(&b[i]) { return false } } } if !left.GetDisk().Equivalent(right.GetDisk()) { return false } if ls := left.GetDisk().GetSource(); ls != nil { switch ls.GetType() { case Resource_DiskInfo_Source_PATH: // Two PATH resources can be added if their disks are identical case Resource_DiskInfo_Source_BLOCK, Resource_DiskInfo_Source_MOUNT: // Two resources that represent exclusive 'MOUNT' or 'RAW' disks // cannot be added together; this would defeat the exclusivity. return false case Resource_DiskInfo_Source_RAW: // We can only add resources representing 'RAW' disks if // they have no identity. if ls.GetID() != "" { return false } case Resource_DiskInfo_Source_UNKNOWN: panic("unreachable") } } // from apache/mesos: src/common/resources.cpp // TODO(jieyu): Even if two Resource objects with DiskInfo have the // same persistence ID, they cannot be added together. In fact, this // shouldn't happen if we do not add resources from different // namespaces (e.g., across slave). Consider adding a warning. if left.GetDisk().GetPersistence() != nil { return false } if (left.GetRevocable() == nil) != (right.GetRevocable() == nil) { return false } if a, b := left.GetProviderID(), right.GetProviderID(); (a == nil) != (b == nil) { return false } else if a != nil && a.Value != b.Value { return false } return true }
[ "func", "(", "left", "*", "Resource", ")", "Addable", "(", "right", "Resource", ")", "bool", "{", "if", "left", "==", "nil", "{", "return", "true", "\n", "}", "\n", "if", "left", ".", "GetName", "(", ")", "!=", "right", ".", "GetName", "(", ")", "||", "left", ".", "GetType", "(", ")", "!=", "right", ".", "GetType", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "IsCapabilityReservationRefinementEnabled", "(", ")", "&&", "left", ".", "GetRole", "(", ")", "!=", "right", ".", "GetRole", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "a", ",", "b", ":=", "left", ".", "GetShared", "(", ")", ",", "right", ".", "GetShared", "(", ")", ";", "(", "a", "==", "nil", ")", "!=", "(", "b", "==", "nil", ")", "{", "// shared has no fields", "return", "false", "\n", "}", "else", "if", "a", "!=", "nil", "{", "// For shared resources, they can be added only if left == right.", "return", "left", ".", "Equivalent", "(", "right", ")", "\n", "}", "\n\n", "if", "a", ",", "b", ":=", "left", ".", "GetAllocationInfo", "(", ")", ",", "right", ".", "GetAllocationInfo", "(", ")", ";", "!", "a", ".", "Equivalent", "(", "b", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "left", ".", "GetReservation", "(", ")", ".", "Equivalent", "(", "right", ".", "GetReservation", "(", ")", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "a", ",", "b", ":=", "left", ".", "Reservations", ",", "right", ".", "Reservations", ";", "len", "(", "a", ")", "!=", "len", "(", "b", ")", "{", "return", "false", "\n", "}", "else", "{", "for", "i", ":=", "range", "a", "{", "aa", ":=", "&", "a", "[", "i", "]", "\n", "if", "!", "aa", ".", "Equivalent", "(", "&", "b", "[", "i", "]", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "!", "left", ".", "GetDisk", "(", ")", ".", "Equivalent", "(", "right", ".", "GetDisk", "(", ")", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "ls", ":=", "left", ".", "GetDisk", "(", ")", ".", "GetSource", "(", ")", ";", "ls", "!=", "nil", "{", "switch", "ls", ".", "GetType", "(", ")", "{", "case", "Resource_DiskInfo_Source_PATH", ":", "// Two PATH resources can be added if their disks are identical", "case", "Resource_DiskInfo_Source_BLOCK", ",", "Resource_DiskInfo_Source_MOUNT", ":", "// Two resources that represent exclusive 'MOUNT' or 'RAW' disks", "// cannot be added together; this would defeat the exclusivity.", "return", "false", "\n", "case", "Resource_DiskInfo_Source_RAW", ":", "// We can only add resources representing 'RAW' disks if", "// they have no identity.", "if", "ls", ".", "GetID", "(", ")", "!=", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "case", "Resource_DiskInfo_Source_UNKNOWN", ":", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "// from apache/mesos: src/common/resources.cpp", "// TODO(jieyu): Even if two Resource objects with DiskInfo have the", "// same persistence ID, they cannot be added together. In fact, this", "// shouldn't happen if we do not add resources from different", "// namespaces (e.g., across slave). Consider adding a warning.", "if", "left", ".", "GetDisk", "(", ")", ".", "GetPersistence", "(", ")", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "if", "(", "left", ".", "GetRevocable", "(", ")", "==", "nil", ")", "!=", "(", "right", ".", "GetRevocable", "(", ")", "==", "nil", ")", "{", "return", "false", "\n", "}", "\n", "if", "a", ",", "b", ":=", "left", ".", "GetProviderID", "(", ")", ",", "right", ".", "GetProviderID", "(", ")", ";", "(", "a", "==", "nil", ")", "!=", "(", "b", "==", "nil", ")", "{", "return", "false", "\n", "}", "else", "if", "a", "!=", "nil", "&&", "a", ".", "Value", "!=", "b", ".", "Value", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Addable tests if we can add two Resource objects together resulting in one // valid Resource object. For example, two Resource objects with // different name, type or role are not addable.
[ "Addable", "tests", "if", "we", "can", "add", "two", "Resource", "objects", "together", "resulting", "in", "one", "valid", "Resource", "object", ".", "For", "example", "two", "Resource", "objects", "with", "different", "name", "type", "or", "role", "are", "not", "addable", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L756-L836
12,909
mesos/mesos-go
api/v1/lib/resources.go
Contains
func (left Resource) Contains(right Resource) bool { if !left.Subtractable(right) { return false } switch left.GetType() { case SCALAR: return right.GetScalar().Compare(left.GetScalar()) <= 0 case RANGES: return right.GetRanges().Compare(left.GetRanges()) <= 0 case SET: return right.GetSet().Compare(left.GetSet()) <= 0 default: return false } }
go
func (left Resource) Contains(right Resource) bool { if !left.Subtractable(right) { return false } switch left.GetType() { case SCALAR: return right.GetScalar().Compare(left.GetScalar()) <= 0 case RANGES: return right.GetRanges().Compare(left.GetRanges()) <= 0 case SET: return right.GetSet().Compare(left.GetSet()) <= 0 default: return false } }
[ "func", "(", "left", "Resource", ")", "Contains", "(", "right", "Resource", ")", "bool", "{", "if", "!", "left", ".", "Subtractable", "(", "right", ")", "{", "return", "false", "\n", "}", "\n", "switch", "left", ".", "GetType", "(", ")", "{", "case", "SCALAR", ":", "return", "right", ".", "GetScalar", "(", ")", ".", "Compare", "(", "left", ".", "GetScalar", "(", ")", ")", "<=", "0", "\n", "case", "RANGES", ":", "return", "right", ".", "GetRanges", "(", ")", ".", "Compare", "(", "left", ".", "GetRanges", "(", ")", ")", "<=", "0", "\n", "case", "SET", ":", "return", "right", ".", "GetSet", "(", ")", ".", "Compare", "(", "left", ".", "GetSet", "(", ")", ")", "<=", "0", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
// Contains tests if "right" is contained in "left".
[ "Contains", "tests", "if", "right", "is", "contained", "in", "left", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L923-L937
12,910
mesos/mesos-go
api/v1/lib/resources.go
Subtract
func (left *Resource) Subtract(right Resource) { switch right.checkType(left.GetType()) { case SCALAR: left.Scalar = left.GetScalar().Subtract(right.GetScalar()) case RANGES: left.Ranges = left.GetRanges().Subtract(right.GetRanges()) case SET: left.Set = left.GetSet().Subtract(right.GetSet()) } }
go
func (left *Resource) Subtract(right Resource) { switch right.checkType(left.GetType()) { case SCALAR: left.Scalar = left.GetScalar().Subtract(right.GetScalar()) case RANGES: left.Ranges = left.GetRanges().Subtract(right.GetRanges()) case SET: left.Set = left.GetSet().Subtract(right.GetSet()) } }
[ "func", "(", "left", "*", "Resource", ")", "Subtract", "(", "right", "Resource", ")", "{", "switch", "right", ".", "checkType", "(", "left", ".", "GetType", "(", ")", ")", "{", "case", "SCALAR", ":", "left", ".", "Scalar", "=", "left", ".", "GetScalar", "(", ")", ".", "Subtract", "(", "right", ".", "GetScalar", "(", ")", ")", "\n", "case", "RANGES", ":", "left", ".", "Ranges", "=", "left", ".", "GetRanges", "(", ")", ".", "Subtract", "(", "right", ".", "GetRanges", "(", ")", ")", "\n", "case", "SET", ":", "left", ".", "Set", "=", "left", ".", "GetSet", "(", ")", ".", "Subtract", "(", "right", ".", "GetSet", "(", ")", ")", "\n", "}", "\n", "}" ]
// Subtract removes right from left. // This func panics if the resource types don't match.
[ "Subtract", "removes", "right", "from", "left", ".", "This", "func", "panics", "if", "the", "resource", "types", "don", "t", "match", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L941-L950
12,911
mesos/mesos-go
api/v1/lib/resources.go
checkType
func (left *Resource) checkType(t Value_Type) Value_Type { if left != nil && left.GetType() != t { panic(fmt.Sprintf("expected type %v instead of %v", t, left.GetType())) } return t }
go
func (left *Resource) checkType(t Value_Type) Value_Type { if left != nil && left.GetType() != t { panic(fmt.Sprintf("expected type %v instead of %v", t, left.GetType())) } return t }
[ "func", "(", "left", "*", "Resource", ")", "checkType", "(", "t", "Value_Type", ")", "Value_Type", "{", "if", "left", "!=", "nil", "&&", "left", ".", "GetType", "(", ")", "!=", "t", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ",", "left", ".", "GetType", "(", ")", ")", ")", "\n", "}", "\n", "return", "t", "\n", "}" ]
// checkType panics if the type of this resources != t
[ "checkType", "panics", "if", "the", "type", "of", "this", "resources", "!", "=", "t" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L966-L971
12,912
mesos/mesos-go
api/v1/lib/resources.go
IsEmpty
func (left *Resource) IsEmpty() bool { if left == nil { return true } switch left.GetType() { case SCALAR: return left.GetScalar().GetValue() == 0 case RANGES: return len(left.GetRanges().GetRange()) == 0 case SET: return len(left.GetSet().GetItem()) == 0 } return false }
go
func (left *Resource) IsEmpty() bool { if left == nil { return true } switch left.GetType() { case SCALAR: return left.GetScalar().GetValue() == 0 case RANGES: return len(left.GetRanges().GetRange()) == 0 case SET: return len(left.GetSet().GetItem()) == 0 } return false }
[ "func", "(", "left", "*", "Resource", ")", "IsEmpty", "(", ")", "bool", "{", "if", "left", "==", "nil", "{", "return", "true", "\n", "}", "\n", "switch", "left", ".", "GetType", "(", ")", "{", "case", "SCALAR", ":", "return", "left", ".", "GetScalar", "(", ")", ".", "GetValue", "(", ")", "==", "0", "\n", "case", "RANGES", ":", "return", "len", "(", "left", ".", "GetRanges", "(", ")", ".", "GetRange", "(", ")", ")", "==", "0", "\n", "case", "SET", ":", "return", "len", "(", "left", ".", "GetSet", "(", ")", ".", "GetItem", "(", ")", ")", "==", "0", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsEmpty returns true if the value of this resource is equivalent to the zero-value, // where a zero-length slice or map is equivalent to a nil reference to such.
[ "IsEmpty", "returns", "true", "if", "the", "value", "of", "this", "resource", "is", "equivalent", "to", "the", "zero", "-", "value", "where", "a", "zero", "-", "length", "slice", "or", "map", "is", "equivalent", "to", "a", "nil", "reference", "to", "such", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L975-L988
12,913
mesos/mesos-go
api/v1/lib/resources.go
IsUnreserved
func (left *Resource) IsUnreserved() bool { // role != RoleDefault -> static reservation // GetReservation() != nil -> dynamic reservation // return {no-static-reservation} && {no-dynamic-reservation} return (left.Role == nil || left.GetRole() == "*") && left.GetReservation() == nil && len(left.GetReservations()) == 0 }
go
func (left *Resource) IsUnreserved() bool { // role != RoleDefault -> static reservation // GetReservation() != nil -> dynamic reservation // return {no-static-reservation} && {no-dynamic-reservation} return (left.Role == nil || left.GetRole() == "*") && left.GetReservation() == nil && len(left.GetReservations()) == 0 }
[ "func", "(", "left", "*", "Resource", ")", "IsUnreserved", "(", ")", "bool", "{", "// role != RoleDefault -> static reservation", "// GetReservation() != nil -> dynamic reservation", "// return {no-static-reservation} && {no-dynamic-reservation}", "return", "(", "left", ".", "Role", "==", "nil", "||", "left", ".", "GetRole", "(", ")", "==", "\"", "\"", ")", "&&", "left", ".", "GetReservation", "(", ")", "==", "nil", "&&", "len", "(", "left", ".", "GetReservations", "(", ")", ")", "==", "0", "\n", "}" ]
// IsUnreserved returns true if this resource neither statically or dynamically reserved. // A resource is considered statically reserved if it has a non-default role.
[ "IsUnreserved", "returns", "true", "if", "this", "resource", "neither", "statically", "or", "dynamically", "reserved", ".", "A", "resource", "is", "considered", "statically", "reserved", "if", "it", "has", "a", "non", "-", "default", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L992-L997
12,914
mesos/mesos-go
api/v1/lib/resources.go
ReservationRole
func (r *Resource) ReservationRole() string { // if using reservation refinement, return the role of the last refinement rs := r.GetReservations() if x := len(rs); x > 0 { return rs[x-1].GetRole() } // if using the old reservation API, role is a first class field of Resource // (and it's never stored in Resource.Reservation). return r.GetRole() }
go
func (r *Resource) ReservationRole() string { // if using reservation refinement, return the role of the last refinement rs := r.GetReservations() if x := len(rs); x > 0 { return rs[x-1].GetRole() } // if using the old reservation API, role is a first class field of Resource // (and it's never stored in Resource.Reservation). return r.GetRole() }
[ "func", "(", "r", "*", "Resource", ")", "ReservationRole", "(", ")", "string", "{", "// if using reservation refinement, return the role of the last refinement", "rs", ":=", "r", ".", "GetReservations", "(", ")", "\n", "if", "x", ":=", "len", "(", "rs", ")", ";", "x", ">", "0", "{", "return", "rs", "[", "x", "-", "1", "]", ".", "GetRole", "(", ")", "\n", "}", "\n", "// if using the old reservation API, role is a first class field of Resource", "// (and it's never stored in Resource.Reservation).", "return", "r", ".", "GetRole", "(", ")", "\n", "}" ]
// ReservationRole returns the role for which the resource is reserved. Callers should check the // reservation status of the resource via IsReserved prior to invoking this func.
[ "ReservationRole", "returns", "the", "role", "for", "which", "the", "resource", "is", "reserved", ".", "Callers", "should", "check", "the", "reservation", "status", "of", "the", "resource", "via", "IsReserved", "prior", "to", "invoking", "this", "func", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1008-L1017
12,915
mesos/mesos-go
api/v1/lib/resources.go
IsAllocatableTo
func (left *Resource) IsAllocatableTo(role string) bool { if left.IsUnreserved() { return true } r := left.ReservationRole() return role == r || roles.IsStrictSubroleOf(role, r) }
go
func (left *Resource) IsAllocatableTo(role string) bool { if left.IsUnreserved() { return true } r := left.ReservationRole() return role == r || roles.IsStrictSubroleOf(role, r) }
[ "func", "(", "left", "*", "Resource", ")", "IsAllocatableTo", "(", "role", "string", ")", "bool", "{", "if", "left", ".", "IsUnreserved", "(", ")", "{", "return", "true", "\n", "}", "\n", "r", ":=", "left", ".", "ReservationRole", "(", ")", "\n", "return", "role", "==", "r", "||", "roles", ".", "IsStrictSubroleOf", "(", "role", ",", "r", ")", "\n", "}" ]
// IsAllocatableTo returns true if the resource may be allocated to the given role.
[ "IsAllocatableTo", "returns", "true", "if", "the", "resource", "may", "be", "allocated", "to", "the", "given", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1020-L1026
12,916
mesos/mesos-go
api/v1/lib/resources.go
IsDynamicallyReserved
func (left *Resource) IsDynamicallyReserved() bool { if left.IsReserved("") { if left.GetReservation() != nil { return true } rs := left.GetReservations() return rs[len(rs)-1].GetType() == Resource_ReservationInfo_DYNAMIC } return false }
go
func (left *Resource) IsDynamicallyReserved() bool { if left.IsReserved("") { if left.GetReservation() != nil { return true } rs := left.GetReservations() return rs[len(rs)-1].GetType() == Resource_ReservationInfo_DYNAMIC } return false }
[ "func", "(", "left", "*", "Resource", ")", "IsDynamicallyReserved", "(", ")", "bool", "{", "if", "left", ".", "IsReserved", "(", "\"", "\"", ")", "{", "if", "left", ".", "GetReservation", "(", ")", "!=", "nil", "{", "return", "true", "\n", "}", "\n", "rs", ":=", "left", ".", "GetReservations", "(", ")", "\n", "return", "rs", "[", "len", "(", "rs", ")", "-", "1", "]", ".", "GetType", "(", ")", "==", "Resource_ReservationInfo_DYNAMIC", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsDynamicallyReserved returns true if this resource has a non-nil reservation descriptor
[ "IsDynamicallyReserved", "returns", "true", "if", "this", "resource", "has", "a", "non", "-", "nil", "reservation", "descriptor" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1029-L1038
12,917
mesos/mesos-go
api/v1/lib/resources.go
IsDisk
func (left *Resource) IsDisk(t Resource_DiskInfo_Source_Type) bool { if s := left.GetDisk().GetSource(); s != nil { return s.GetType() == t } return false }
go
func (left *Resource) IsDisk(t Resource_DiskInfo_Source_Type) bool { if s := left.GetDisk().GetSource(); s != nil { return s.GetType() == t } return false }
[ "func", "(", "left", "*", "Resource", ")", "IsDisk", "(", "t", "Resource_DiskInfo_Source_Type", ")", "bool", "{", "if", "s", ":=", "left", ".", "GetDisk", "(", ")", ".", "GetSource", "(", ")", ";", "s", "!=", "nil", "{", "return", "s", ".", "GetType", "(", ")", "==", "t", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsDisk returns true if this is a disk resource of the specified type.
[ "IsDisk", "returns", "true", "if", "this", "is", "a", "disk", "resource", "of", "the", "specified", "type", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1051-L1056
12,918
mesos/mesos-go
api/v1/lib/resources.go
PopReservation
func (rs Resources) PopReservation() (result Resources) { pop_next: for i := range rs { r := &rs[i] ls := len(r.Reservations) if ls == 0 { panic(fmt.Sprintf("no reservations exist for resource %q", r)) } r = proto.Clone(r).(*Resource) // avoid modifying rs r.Reservations[ls-1] = Resource_ReservationInfo{} // don't leak nested pointers r.Reservations = r.Reservations[:ls-1] // shrink the slice // unroll Add1 to avoid additional calls to Clone rr := *r for j := range result { r2 := &result[j] if r2.Addable(rr) { r2.Add(rr) continue pop_next } } // cannot be combined with an existing resource result = append(result, rr) } return }
go
func (rs Resources) PopReservation() (result Resources) { pop_next: for i := range rs { r := &rs[i] ls := len(r.Reservations) if ls == 0 { panic(fmt.Sprintf("no reservations exist for resource %q", r)) } r = proto.Clone(r).(*Resource) // avoid modifying rs r.Reservations[ls-1] = Resource_ReservationInfo{} // don't leak nested pointers r.Reservations = r.Reservations[:ls-1] // shrink the slice // unroll Add1 to avoid additional calls to Clone rr := *r for j := range result { r2 := &result[j] if r2.Addable(rr) { r2.Add(rr) continue pop_next } } // cannot be combined with an existing resource result = append(result, rr) } return }
[ "func", "(", "rs", "Resources", ")", "PopReservation", "(", ")", "(", "result", "Resources", ")", "{", "pop_next", ":", "for", "i", ":=", "range", "rs", "{", "r", ":=", "&", "rs", "[", "i", "]", "\n", "ls", ":=", "len", "(", "r", ".", "Reservations", ")", "\n", "if", "ls", "==", "0", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ")", ")", "\n", "}", "\n\n", "r", "=", "proto", ".", "Clone", "(", "r", ")", ".", "(", "*", "Resource", ")", "// avoid modifying rs", "\n", "r", ".", "Reservations", "[", "ls", "-", "1", "]", "=", "Resource_ReservationInfo", "{", "}", "// don't leak nested pointers", "\n", "r", ".", "Reservations", "=", "r", ".", "Reservations", "[", ":", "ls", "-", "1", "]", "// shrink the slice", "\n\n", "// unroll Add1 to avoid additional calls to Clone", "rr", ":=", "*", "r", "\n", "for", "j", ":=", "range", "result", "{", "r2", ":=", "&", "result", "[", "j", "]", "\n", "if", "r2", ".", "Addable", "(", "rr", ")", "{", "r2", ".", "Add", "(", "rr", ")", "\n", "continue", "pop_next", "\n", "}", "\n", "}", "\n\n", "// cannot be combined with an existing resource", "result", "=", "append", "(", "result", ",", "rr", ")", "\n", "}", "\n", "return", "\n", "}" ]
// PopReservation returns a cloned set of Resources wherein the most recent reservation refeinement has been // removed. Panics if for any resource in the collection there is no "last refinement" to remove.
[ "PopReservation", "returns", "a", "cloned", "set", "of", "Resources", "wherein", "the", "most", "recent", "reservation", "refeinement", "has", "been", "removed", ".", "Panics", "if", "for", "any", "resource", "in", "the", "collection", "there", "is", "no", "last", "refinement", "to", "remove", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1112-L1139
12,919
mesos/mesos-go
api/v1/lib/resources.go
Allocate
func (r *Resource) Allocate(role string) { if role == "" { panic(fmt.Sprintf("cannot allocate resource to an empty-string role: %q", r)) } r.AllocationInfo = &Resource_AllocationInfo{Role: &role} }
go
func (r *Resource) Allocate(role string) { if role == "" { panic(fmt.Sprintf("cannot allocate resource to an empty-string role: %q", r)) } r.AllocationInfo = &Resource_AllocationInfo{Role: &role} }
[ "func", "(", "r", "*", "Resource", ")", "Allocate", "(", "role", "string", ")", "{", "if", "role", "==", "\"", "\"", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ")", ")", "\n", "}", "\n", "r", ".", "AllocationInfo", "=", "&", "Resource_AllocationInfo", "{", "Role", ":", "&", "role", "}", "\n", "}" ]
// Allocate sets the AllocationInfo for the resource, panics if role is "".
[ "Allocate", "sets", "the", "AllocationInfo", "for", "the", "resource", "panics", "if", "role", "is", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1142-L1147
12,920
mesos/mesos-go
api/v1/lib/resources.go
Allocate
func (rs Resources) Allocate(role string) Resources { if role == "" { panic(fmt.Sprintf("cannot allocate resources to an empty-string role: %q", rs)) } for i := range rs { rs[i].AllocationInfo = &Resource_AllocationInfo{Role: &role} } return rs }
go
func (rs Resources) Allocate(role string) Resources { if role == "" { panic(fmt.Sprintf("cannot allocate resources to an empty-string role: %q", rs)) } for i := range rs { rs[i].AllocationInfo = &Resource_AllocationInfo{Role: &role} } return rs }
[ "func", "(", "rs", "Resources", ")", "Allocate", "(", "role", "string", ")", "Resources", "{", "if", "role", "==", "\"", "\"", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "rs", ")", ")", "\n", "}", "\n", "for", "i", ":=", "range", "rs", "{", "rs", "[", "i", "]", ".", "AllocationInfo", "=", "&", "Resource_AllocationInfo", "{", "Role", ":", "&", "role", "}", "\n", "}", "\n", "return", "rs", "\n", "}" ]
// Allocate sets the AllocationInfo for all the resources. // Returns a reference to the receiver to allow for chaining.
[ "Allocate", "sets", "the", "AllocationInfo", "for", "all", "the", "resources", ".", "Returns", "a", "reference", "to", "the", "receiver", "to", "allow", "for", "chaining", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1156-L1164
12,921
mesos/mesos-go
api/v1/lib/resources.go
Unallocate
func (rs Resources) Unallocate() Resources { for i := range rs { rs[i].AllocationInfo = nil } return rs }
go
func (rs Resources) Unallocate() Resources { for i := range rs { rs[i].AllocationInfo = nil } return rs }
[ "func", "(", "rs", "Resources", ")", "Unallocate", "(", ")", "Resources", "{", "for", "i", ":=", "range", "rs", "{", "rs", "[", "i", "]", ".", "AllocationInfo", "=", "nil", "\n", "}", "\n", "return", "rs", "\n", "}" ]
// Unallocate clears the AllocationInfo for all the resources. // Returns a reference to the receiver to allow for chaining.
[ "Unallocate", "clears", "the", "AllocationInfo", "for", "all", "the", "resources", ".", "Returns", "a", "reference", "to", "the", "receiver", "to", "allow", "for", "chaining", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources.go#L1168-L1173
12,922
mesos/mesos-go
api/v1/lib/httpcli/opts.go
Merged
func (opts Opts) Merged() Opt { if len(opts) == 0 { return nil } return func(c *Client) Opt { var ( size = len(opts) undo = make(Opts, size) ) size-- // make this a zero-based offset for i, opt := range opts { if opt != nil { undo[size-i] = opt(c) } } return undo.Merged() } }
go
func (opts Opts) Merged() Opt { if len(opts) == 0 { return nil } return func(c *Client) Opt { var ( size = len(opts) undo = make(Opts, size) ) size-- // make this a zero-based offset for i, opt := range opts { if opt != nil { undo[size-i] = opt(c) } } return undo.Merged() } }
[ "func", "(", "opts", "Opts", ")", "Merged", "(", ")", "Opt", "{", "if", "len", "(", "opts", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "func", "(", "c", "*", "Client", ")", "Opt", "{", "var", "(", "size", "=", "len", "(", "opts", ")", "\n", "undo", "=", "make", "(", "Opts", ",", "size", ")", "\n", ")", "\n", "size", "--", "// make this a zero-based offset", "\n", "for", "i", ",", "opt", ":=", "range", "opts", "{", "if", "opt", "!=", "nil", "{", "undo", "[", "size", "-", "i", "]", "=", "opt", "(", "c", ")", "\n", "}", "\n", "}", "\n", "return", "undo", ".", "Merged", "(", ")", "\n", "}", "\n", "}" ]
// Merged generates a single Opt that applies all the functional options, in-order
[ "Merged", "generates", "a", "single", "Opt", "that", "applies", "all", "the", "functional", "options", "in", "-", "order" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/opts.go#L22-L39
12,923
mesos/mesos-go
api/v1/lib/httpcli/opts.go
And
func (o Opt) And(other Opt) Opt { if o == nil { if other == nil { return nil } return other } if other == nil { return o } return Opts{o, other}.Merged() }
go
func (o Opt) And(other Opt) Opt { if o == nil { if other == nil { return nil } return other } if other == nil { return o } return Opts{o, other}.Merged() }
[ "func", "(", "o", "Opt", ")", "And", "(", "other", "Opt", ")", "Opt", "{", "if", "o", "==", "nil", "{", "if", "other", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "other", "\n", "}", "\n", "if", "other", "==", "nil", "{", "return", "o", "\n", "}", "\n", "return", "Opts", "{", "o", ",", "other", "}", ".", "Merged", "(", ")", "\n", "}" ]
// And combines two functional options into a single Opt
[ "And", "combines", "two", "functional", "options", "into", "a", "single", "Opt" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/opts.go#L42-L53
12,924
mesos/mesos-go
api/v0/messenger/http_transporter.go
NewHTTPTransporter
func NewHTTPTransporter(upid upid.UPID, address net.IP, opts ...httpOpt) *HTTPTransporter { transport := httpTransport client := HttpClient client.Transport = &transport mux := http.NewServeMux() result := &HTTPTransporter{ upid: upid, messageQueue: make(chan *Message, defaultQueueSize), mux: mux, client: &client, tr: &transport, address: address, shouldQuit: make(chan struct{}), server: &http.Server{ ReadTimeout: ReadTimeout, WriteTimeout: WriteTimeout, Handler: mux, }, } for _, f := range opts { f(result) } result.state = &notStartedState{result} return result }
go
func NewHTTPTransporter(upid upid.UPID, address net.IP, opts ...httpOpt) *HTTPTransporter { transport := httpTransport client := HttpClient client.Transport = &transport mux := http.NewServeMux() result := &HTTPTransporter{ upid: upid, messageQueue: make(chan *Message, defaultQueueSize), mux: mux, client: &client, tr: &transport, address: address, shouldQuit: make(chan struct{}), server: &http.Server{ ReadTimeout: ReadTimeout, WriteTimeout: WriteTimeout, Handler: mux, }, } for _, f := range opts { f(result) } result.state = &notStartedState{result} return result }
[ "func", "NewHTTPTransporter", "(", "upid", "upid", ".", "UPID", ",", "address", "net", ".", "IP", ",", "opts", "...", "httpOpt", ")", "*", "HTTPTransporter", "{", "transport", ":=", "httpTransport", "\n", "client", ":=", "HttpClient", "\n", "client", ".", "Transport", "=", "&", "transport", "\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n\n", "result", ":=", "&", "HTTPTransporter", "{", "upid", ":", "upid", ",", "messageQueue", ":", "make", "(", "chan", "*", "Message", ",", "defaultQueueSize", ")", ",", "mux", ":", "mux", ",", "client", ":", "&", "client", ",", "tr", ":", "&", "transport", ",", "address", ":", "address", ",", "shouldQuit", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "server", ":", "&", "http", ".", "Server", "{", "ReadTimeout", ":", "ReadTimeout", ",", "WriteTimeout", ":", "WriteTimeout", ",", "Handler", ":", "mux", ",", "}", ",", "}", "\n", "for", "_", ",", "f", ":=", "range", "opts", "{", "f", "(", "result", ")", "\n", "}", "\n", "result", ".", "state", "=", "&", "notStartedState", "{", "result", "}", "\n", "return", "result", "\n", "}" ]
// NewHTTPTransporter creates a new http transporter with an optional binding address.
[ "NewHTTPTransporter", "creates", "a", "new", "http", "transporter", "with", "an", "optional", "binding", "address", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L147-L172
12,925
mesos/mesos-go
api/v0/messenger/http_transporter.go
Send
func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error) { return t.getState().Send(ctx, msg) }
go
func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error) { return t.getState().Send(ctx, msg) }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "Message", ")", "(", "sendError", "error", ")", "{", "return", "t", ".", "getState", "(", ")", ".", "Send", "(", "ctx", ",", "msg", ")", "\n", "}" ]
// Send sends the message to its specified upid.
[ "Send", "sends", "the", "message", "to", "its", "specified", "upid", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L195-L197
12,926
mesos/mesos-go
api/v0/messenger/http_transporter.go
send
func (t *HTTPTransporter) send(ctx context.Context, msg *Message) (sendError error) { log.V(2).Infof("Sending message to %v via http\n", msg.UPID) req, err := t.makeLibprocessRequest(msg) if err != nil { return err } return t.httpDo(ctx, req, func(resp *http.Response, err error) error { if err != nil { log.V(1).Infof("Failed to POST: %v\n", err) return &networkError{err} } defer resp.Body.Close() // ensure master acknowledgement. if (resp.StatusCode != http.StatusOK) && (resp.StatusCode != http.StatusAccepted) { return &mesosError{ errorCode: resp.StatusCode, upid: msg.UPID.String(), uri: msg.RequestURI(), status: resp.Status, } } return nil }) }
go
func (t *HTTPTransporter) send(ctx context.Context, msg *Message) (sendError error) { log.V(2).Infof("Sending message to %v via http\n", msg.UPID) req, err := t.makeLibprocessRequest(msg) if err != nil { return err } return t.httpDo(ctx, req, func(resp *http.Response, err error) error { if err != nil { log.V(1).Infof("Failed to POST: %v\n", err) return &networkError{err} } defer resp.Body.Close() // ensure master acknowledgement. if (resp.StatusCode != http.StatusOK) && (resp.StatusCode != http.StatusAccepted) { return &mesosError{ errorCode: resp.StatusCode, upid: msg.UPID.String(), uri: msg.RequestURI(), status: resp.Status, } } return nil }) }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "send", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "Message", ")", "(", "sendError", "error", ")", "{", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\\n", "\"", ",", "msg", ".", "UPID", ")", "\n", "req", ",", "err", ":=", "t", ".", "makeLibprocessRequest", "(", "msg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "t", ".", "httpDo", "(", "ctx", ",", "req", ",", "func", "(", "resp", "*", "http", ".", "Response", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "&", "networkError", "{", "err", "}", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n\n", "// ensure master acknowledgement.", "if", "(", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", ")", "&&", "(", "resp", ".", "StatusCode", "!=", "http", ".", "StatusAccepted", ")", "{", "return", "&", "mesosError", "{", "errorCode", ":", "resp", ".", "StatusCode", ",", "upid", ":", "msg", ".", "UPID", ".", "String", "(", ")", ",", "uri", ":", "msg", ".", "RequestURI", "(", ")", ",", "status", ":", "resp", ".", "Status", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "}" ]
// send delivers a message to a mesos component via HTTP, returns a mesosError if the // communication with the remote process was successful but rejected. A networkError // error indicates that communication with the remote process failed at the network layer.
[ "send", "delivers", "a", "message", "to", "a", "mesos", "component", "via", "HTTP", "returns", "a", "mesosError", "if", "the", "communication", "with", "the", "remote", "process", "was", "successful", "but", "rejected", ".", "A", "networkError", "error", "indicates", "that", "communication", "with", "the", "remote", "process", "failed", "at", "the", "network", "layer", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L222-L247
12,927
mesos/mesos-go
api/v0/messenger/http_transporter.go
Start
func (t *HTTPTransporter) Start() (upid.UPID, <-chan error) { t.stateLock.Lock() defer t.stateLock.Unlock() return t.state.Start() }
go
func (t *HTTPTransporter) Start() (upid.UPID, <-chan error) { t.stateLock.Lock() defer t.stateLock.Unlock() return t.state.Start() }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "Start", "(", ")", "(", "upid", ".", "UPID", ",", "<-", "chan", "error", ")", "{", "t", ".", "stateLock", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "stateLock", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "state", ".", "Start", "(", ")", "\n", "}" ]
// Start starts the http transporter
[ "Start", "starts", "the", "http", "transporter" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L402-L406
12,928
mesos/mesos-go
api/v0/messenger/http_transporter.go
start
func (t *HTTPTransporter) start() (upid.UPID, <-chan error) { ch := make(chan error, 1) if err := t.listen(); err != nil { ch <- err return upid.UPID{}, ch } // TODO(yifan): Set read/write deadline. go func() { err := t.server.Serve(t.listener) select { case <-t.shouldQuit: log.V(1).Infof("HTTP server stopped because of shutdown") ch <- nil default: if err != nil && log.V(1) { log.Errorln("HTTP server stopped with error", err.Error()) } else { log.V(1).Infof("HTTP server stopped") } ch <- err t.Stop(false) } }() return t.upid, ch }
go
func (t *HTTPTransporter) start() (upid.UPID, <-chan error) { ch := make(chan error, 1) if err := t.listen(); err != nil { ch <- err return upid.UPID{}, ch } // TODO(yifan): Set read/write deadline. go func() { err := t.server.Serve(t.listener) select { case <-t.shouldQuit: log.V(1).Infof("HTTP server stopped because of shutdown") ch <- nil default: if err != nil && log.V(1) { log.Errorln("HTTP server stopped with error", err.Error()) } else { log.V(1).Infof("HTTP server stopped") } ch <- err t.Stop(false) } }() return t.upid, ch }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "start", "(", ")", "(", "upid", ".", "UPID", ",", "<-", "chan", "error", ")", "{", "ch", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "if", "err", ":=", "t", ".", "listen", "(", ")", ";", "err", "!=", "nil", "{", "ch", "<-", "err", "\n", "return", "upid", ".", "UPID", "{", "}", ",", "ch", "\n", "}", "\n\n", "// TODO(yifan): Set read/write deadline.", "go", "func", "(", ")", "{", "err", ":=", "t", ".", "server", ".", "Serve", "(", "t", ".", "listener", ")", "\n", "select", "{", "case", "<-", "t", ".", "shouldQuit", ":", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "ch", "<-", "nil", "\n", "default", ":", "if", "err", "!=", "nil", "&&", "log", ".", "V", "(", "1", ")", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "else", "{", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "}", "\n", "ch", "<-", "err", "\n", "t", ".", "Stop", "(", "false", ")", "\n", "}", "\n", "}", "(", ")", "\n", "return", "t", ".", "upid", ",", "ch", "\n", "}" ]
// start expects to be guarded by stateLock
[ "start", "expects", "to", "be", "guarded", "by", "stateLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L409-L434
12,929
mesos/mesos-go
api/v0/messenger/http_transporter.go
Stop
func (t *HTTPTransporter) Stop(graceful bool) error { t.stateLock.Lock() defer t.stateLock.Unlock() return t.state.Stop(graceful) }
go
func (t *HTTPTransporter) Stop(graceful bool) error { t.stateLock.Lock() defer t.stateLock.Unlock() return t.state.Stop(graceful) }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "Stop", "(", "graceful", "bool", ")", "error", "{", "t", ".", "stateLock", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "stateLock", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "state", ".", "Stop", "(", "graceful", ")", "\n", "}" ]
// Stop stops the http transporter by closing the listener.
[ "Stop", "stops", "the", "http", "transporter", "by", "closing", "the", "listener", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L437-L441
12,930
mesos/mesos-go
api/v0/messenger/http_transporter.go
stop
func (t *HTTPTransporter) stop(graceful bool) error { close(t.shouldQuit) log.Info("stopping HTTP transport") //TODO(jdef) if graceful, wait for pending requests to terminate err := t.listener.Close() return err }
go
func (t *HTTPTransporter) stop(graceful bool) error { close(t.shouldQuit) log.Info("stopping HTTP transport") //TODO(jdef) if graceful, wait for pending requests to terminate err := t.listener.Close() return err }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "stop", "(", "graceful", "bool", ")", "error", "{", "close", "(", "t", ".", "shouldQuit", ")", "\n\n", "log", ".", "Info", "(", "\"", "\"", ")", "\n\n", "//TODO(jdef) if graceful, wait for pending requests to terminate", "err", ":=", "t", ".", "listener", ".", "Close", "(", ")", "\n", "return", "err", "\n", "}" ]
// stop expects to be guarded by stateLock
[ "stop", "expects", "to", "be", "guarded", "by", "stateLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L444-L453
12,931
mesos/mesos-go
api/v0/messenger/http_transporter.go
UPID
func (t *HTTPTransporter) UPID() upid.UPID { t.stateLock.Lock() defer t.stateLock.Unlock() return t.upid }
go
func (t *HTTPTransporter) UPID() upid.UPID { t.stateLock.Lock() defer t.stateLock.Unlock() return t.upid }
[ "func", "(", "t", "*", "HTTPTransporter", ")", "UPID", "(", ")", "upid", ".", "UPID", "{", "t", ".", "stateLock", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "stateLock", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "upid", "\n", "}" ]
// UPID returns the upid of the transporter.
[ "UPID", "returns", "the", "upid", "of", "the", "transporter", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/http_transporter.go#L456-L460
12,932
mesos/mesos-go
api/v1/lib/encoding/proto/encoding.go
NewDecoder
func NewDecoder(s encoding.Source) encoding.Decoder { r := s() var ( uf = func(b []byte, m interface{}) error { return proto.Unmarshal(b, m.(proto.Message)) } dec = framing.NewDecoder(r, uf) ) return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) }
go
func NewDecoder(s encoding.Source) encoding.Decoder { r := s() var ( uf = func(b []byte, m interface{}) error { return proto.Unmarshal(b, m.(proto.Message)) } dec = framing.NewDecoder(r, uf) ) return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) }
[ "func", "NewDecoder", "(", "s", "encoding", ".", "Source", ")", "encoding", ".", "Decoder", "{", "r", ":=", "s", "(", ")", "\n", "var", "(", "uf", "=", "func", "(", "b", "[", "]", "byte", ",", "m", "interface", "{", "}", ")", "error", "{", "return", "proto", ".", "Unmarshal", "(", "b", ",", "m", ".", "(", "proto", ".", "Message", ")", ")", "}", "\n", "dec", "=", "framing", ".", "NewDecoder", "(", "r", ",", "uf", ")", "\n", ")", "\n", "return", "encoding", ".", "DecoderFunc", "(", "func", "(", "u", "encoding", ".", "Unmarshaler", ")", "error", "{", "return", "dec", ".", "Decode", "(", "u", ")", "}", ")", "\n", "}" ]
// NewDecoder returns a new Decoder of Protobuf messages read from the given Source.
[ "NewDecoder", "returns", "a", "new", "Decoder", "of", "Protobuf", "messages", "read", "from", "the", "given", "Source", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/proto/encoding.go#L23-L30
12,933
mesos/mesos-go
api/v1/lib/scheduler/calls/calls_generated.go
Call
func (f CallerFunc) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) { return f(ctx, c) }
go
func (f CallerFunc) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) { return f(ctx, c) }
[ "func", "(", "f", "CallerFunc", ")", "Call", "(", "ctx", "context", ".", "Context", ",", "c", "*", "scheduler", ".", "Call", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "return", "f", "(", "ctx", ",", "c", ")", "\n", "}" ]
// Call implements the Caller interface for CallerFunc
[ "Call", "implements", "the", "Caller", "interface", "for", "CallerFunc" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls_generated.go#L26-L28
12,934
mesos/mesos-go
api/v1/lib/scheduler/calls/calls_generated.go
CallNoData
func CallNoData(ctx context.Context, caller Caller, call *scheduler.Call) error { resp, err := caller.Call(ctx, call) if resp != nil { resp.Close() } return err }
go
func CallNoData(ctx context.Context, caller Caller, call *scheduler.Call) error { resp, err := caller.Call(ctx, call) if resp != nil { resp.Close() } return err }
[ "func", "CallNoData", "(", "ctx", "context", ".", "Context", ",", "caller", "Caller", ",", "call", "*", "scheduler", ".", "Call", ")", "error", "{", "resp", ",", "err", ":=", "caller", ".", "Call", "(", "ctx", ",", "call", ")", "\n", "if", "resp", "!=", "nil", "{", "resp", ".", "Close", "(", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// CallNoData is a convenience func that executes the given Call using the provided Caller // and always drops the response data.
[ "CallNoData", "is", "a", "convenience", "func", "that", "executes", "the", "given", "Call", "using", "the", "provided", "Caller", "and", "always", "drops", "the", "response", "data", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls_generated.go#L32-L38
12,935
mesos/mesos-go
api/v1/lib/extras/scheduler/eventrules/metrics_generated.go
Metrics
func Metrics(harness metrics.Harness, labeler Labeler) Rule { if harness == nil { panic("harness is a required parameter") } if labeler == nil { labeler = defaultLabeler } return func(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) { labels := labeler(ctx, e) harness(func() error { ctx, e, err = ch(ctx, e, err) return err }, labels...) return ctx, e, err } }
go
func Metrics(harness metrics.Harness, labeler Labeler) Rule { if harness == nil { panic("harness is a required parameter") } if labeler == nil { labeler = defaultLabeler } return func(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) { labels := labeler(ctx, e) harness(func() error { ctx, e, err = ch(ctx, e, err) return err }, labels...) return ctx, e, err } }
[ "func", "Metrics", "(", "harness", "metrics", ".", "Harness", ",", "labeler", "Labeler", ")", "Rule", "{", "if", "harness", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "labeler", "==", "nil", "{", "labeler", "=", "defaultLabeler", "\n", "}", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "ch", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "labels", ":=", "labeler", "(", "ctx", ",", "e", ")", "\n", "harness", "(", "func", "(", ")", "error", "{", "ctx", ",", "e", ",", "err", "=", "ch", "(", "ctx", ",", "e", ",", "err", ")", "\n", "return", "err", "\n", "}", ",", "labels", "...", ")", "\n", "return", "ctx", ",", "e", ",", "err", "\n", "}", "\n", "}" ]
// Metrics generates a Rule that invokes the given harness for each event, using the labels generated by the Labeler. // Panics if harness or labeler is nil.
[ "Metrics", "generates", "a", "Rule", "that", "invokes", "the", "given", "harness", "for", "each", "event", "using", "the", "labels", "generated", "by", "the", "Labeler", ".", "Panics", "if", "harness", "or", "labeler", "is", "nil", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/eventrules/metrics_generated.go#L33-L48
12,936
mesos/mesos-go
api/v1/lib/extras/scheduler/eventrules/handlers_generated.go
Handle
func Handle(h events.Handler) Rule { if h == nil { return nil } return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { newErr := h.HandleEvent(ctx, e) return chain(ctx, e, Error2(err, newErr)) } }
go
func Handle(h events.Handler) Rule { if h == nil { return nil } return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { newErr := h.HandleEvent(ctx, e) return chain(ctx, e, Error2(err, newErr)) } }
[ "func", "Handle", "(", "h", "events", ".", "Handler", ")", "Rule", "{", "if", "h", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "chain", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "newErr", ":=", "h", ".", "HandleEvent", "(", "ctx", ",", "e", ")", "\n", "return", "chain", "(", "ctx", ",", "e", ",", "Error2", "(", "err", ",", "newErr", ")", ")", "\n", "}", "\n", "}" ]
// Handle generates a rule that executes the given events.Handler.
[ "Handle", "generates", "a", "rule", "that", "executes", "the", "given", "events", ".", "Handler", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/eventrules/handlers_generated.go#L14-L22
12,937
mesos/mesos-go
api/v0/scheduler/schedcache.go
putOffer
func (cache *schedCache) putOffer(offer *mesos.Offer, pid *upid.UPID) { if offer == nil || pid == nil { log.V(3).Infoln("WARN: Offer not cached. The offer or pid cannot be nil") return } log.V(3).Infoln("Caching offer ", offer.Id.GetValue(), " with slavePID ", pid.String()) cache.lock.Lock() cache.savedOffers[offer.Id.GetValue()] = &cachedOffer{offer: offer, slavePid: pid} cache.lock.Unlock() }
go
func (cache *schedCache) putOffer(offer *mesos.Offer, pid *upid.UPID) { if offer == nil || pid == nil { log.V(3).Infoln("WARN: Offer not cached. The offer or pid cannot be nil") return } log.V(3).Infoln("Caching offer ", offer.Id.GetValue(), " with slavePID ", pid.String()) cache.lock.Lock() cache.savedOffers[offer.Id.GetValue()] = &cachedOffer{offer: offer, slavePid: pid} cache.lock.Unlock() }
[ "func", "(", "cache", "*", "schedCache", ")", "putOffer", "(", "offer", "*", "mesos", ".", "Offer", ",", "pid", "*", "upid", ".", "UPID", ")", "{", "if", "offer", "==", "nil", "||", "pid", "==", "nil", "{", "log", ".", "V", "(", "3", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "V", "(", "3", ")", ".", "Infoln", "(", "\"", "\"", ",", "offer", ".", "Id", ".", "GetValue", "(", ")", ",", "\"", "\"", ",", "pid", ".", "String", "(", ")", ")", "\n", "cache", ".", "lock", ".", "Lock", "(", ")", "\n", "cache", ".", "savedOffers", "[", "offer", ".", "Id", ".", "GetValue", "(", ")", "]", "=", "&", "cachedOffer", "{", "offer", ":", "offer", ",", "slavePid", ":", "pid", "}", "\n", "cache", ".", "lock", ".", "Unlock", "(", ")", "\n", "}" ]
// putOffer stores an offer and the slavePID associated with offer.
[ "putOffer", "stores", "an", "offer", "and", "the", "slavePID", "associated", "with", "offer", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/schedcache.go#L35-L44
12,938
mesos/mesos-go
api/v0/scheduler/schedcache.go
getOffer
func (cache *schedCache) getOffer(offerId *mesos.OfferID) *cachedOffer { if offerId == nil { log.V(3).Infoln("WARN: OfferId == nil, returning nil") return nil } cache.lock.RLock() defer cache.lock.RUnlock() return cache.savedOffers[offerId.GetValue()] }
go
func (cache *schedCache) getOffer(offerId *mesos.OfferID) *cachedOffer { if offerId == nil { log.V(3).Infoln("WARN: OfferId == nil, returning nil") return nil } cache.lock.RLock() defer cache.lock.RUnlock() return cache.savedOffers[offerId.GetValue()] }
[ "func", "(", "cache", "*", "schedCache", ")", "getOffer", "(", "offerId", "*", "mesos", ".", "OfferID", ")", "*", "cachedOffer", "{", "if", "offerId", "==", "nil", "{", "log", ".", "V", "(", "3", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "cache", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "lock", ".", "RUnlock", "(", ")", "\n", "return", "cache", ".", "savedOffers", "[", "offerId", ".", "GetValue", "(", ")", "]", "\n", "}" ]
// getOffer returns cached offer
[ "getOffer", "returns", "cached", "offer" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/schedcache.go#L47-L55
12,939
mesos/mesos-go
api/v1/lib/encoding/types.go
SourceReader
func SourceReader(r io.Reader) Source { ch := make(chan framing.ReaderFunc, 1) ch <- framing.ReadAll(r) return func() framing.Reader { select { case f := <-ch: return f default: return framing.ReaderFunc(framing.EOFReaderFunc) } } }
go
func SourceReader(r io.Reader) Source { ch := make(chan framing.ReaderFunc, 1) ch <- framing.ReadAll(r) return func() framing.Reader { select { case f := <-ch: return f default: return framing.ReaderFunc(framing.EOFReaderFunc) } } }
[ "func", "SourceReader", "(", "r", "io", ".", "Reader", ")", "Source", "{", "ch", ":=", "make", "(", "chan", "framing", ".", "ReaderFunc", ",", "1", ")", "\n", "ch", "<-", "framing", ".", "ReadAll", "(", "r", ")", "\n", "return", "func", "(", ")", "framing", ".", "Reader", "{", "select", "{", "case", "f", ":=", "<-", "ch", ":", "return", "f", "\n", "default", ":", "return", "framing", ".", "ReaderFunc", "(", "framing", ".", "EOFReaderFunc", ")", "\n", "}", "\n", "}", "\n", "}" ]
// SourceReader returns a Source that buffers all input from the given io.Reader // and returns the contents in a single frame.
[ "SourceReader", "returns", "a", "Source", "that", "buffers", "all", "input", "from", "the", "given", "io", ".", "Reader", "and", "returns", "the", "contents", "in", "a", "single", "frame", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/types.go#L50-L61
12,940
mesos/mesos-go
api/v1/lib/encoding/framing/framing.go
ReadAll
func ReadAll(r io.Reader) ReaderFunc { return func() (b []byte, err error) { b, err = ioutil.ReadAll(r) if len(b) == 0 && err == nil { err = io.EOF } return } }
go
func ReadAll(r io.Reader) ReaderFunc { return func() (b []byte, err error) { b, err = ioutil.ReadAll(r) if len(b) == 0 && err == nil { err = io.EOF } return } }
[ "func", "ReadAll", "(", "r", "io", ".", "Reader", ")", "ReaderFunc", "{", "return", "func", "(", ")", "(", "b", "[", "]", "byte", ",", "err", "error", ")", "{", "b", ",", "err", "=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "len", "(", "b", ")", "==", "0", "&&", "err", "==", "nil", "{", "err", "=", "io", ".", "EOF", "\n", "}", "\n", "return", "\n", "}", "\n", "}" ]
// ReadAll returns a reader func that returns the complete contents of `r` in a single frame. // A zero length frame is treated as an "end of stream" condition, returning io.EOF.
[ "ReadAll", "returns", "a", "reader", "func", "that", "returns", "the", "complete", "contents", "of", "r", "in", "a", "single", "frame", ".", "A", "zero", "length", "frame", "is", "treated", "as", "an", "end", "of", "stream", "condition", "returning", "io", ".", "EOF", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/framing/framing.go#L50-L58
12,941
mesos/mesos-go
api/v1/lib/encoding/framing/framing.go
WriterFor
func WriterFor(w io.Writer) WriterFunc { return func(b []byte) error { n, err := w.Write(b) if err == nil && n != len(b) { return io.ErrShortWrite } return err } }
go
func WriterFor(w io.Writer) WriterFunc { return func(b []byte) error { n, err := w.Write(b) if err == nil && n != len(b) { return io.ErrShortWrite } return err } }
[ "func", "WriterFor", "(", "w", "io", ".", "Writer", ")", "WriterFunc", "{", "return", "func", "(", "b", "[", "]", "byte", ")", "error", "{", "n", ",", "err", ":=", "w", ".", "Write", "(", "b", ")", "\n", "if", "err", "==", "nil", "&&", "n", "!=", "len", "(", "b", ")", "{", "return", "io", ".", "ErrShortWrite", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}" ]
// WriterFor adapts an io.Writer to the Writer interface. All buffers are written to `w` without decoration or // modification.
[ "WriterFor", "adapts", "an", "io", ".", "Writer", "to", "the", "Writer", "interface", ".", "All", "buffers", "are", "written", "to", "w", "without", "decoration", "or", "modification", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/framing/framing.go#L62-L70
12,942
mesos/mesos-go
api/v1/lib/extras/metrics/metrics.go
Int
func (a Adder) Int(x int, s ...string) { a(float64(x), s...) }
go
func (a Adder) Int(x int, s ...string) { a(float64(x), s...) }
[ "func", "(", "a", "Adder", ")", "Int", "(", "x", "int", ",", "s", "...", "string", ")", "{", "a", "(", "float64", "(", "x", ")", ",", "s", "...", ")", "\n", "}" ]
// Int adds the value of `x`; convenience func for adding integers.
[ "Int", "adds", "the", "value", "of", "x", ";", "convenience", "func", "for", "adding", "integers", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/metrics/metrics.go#L18-L20
12,943
mesos/mesos-go
api/v1/lib/extras/metrics/metrics.go
NewHarness
func NewHarness(counts, errors Counter, timed Watcher, clock func() time.Time) Harness { var harness Harness if timed != nil && clock != nil { harness = func(f func() error, labels ...string) error { counts(labels...) var ( t = clock() err = f() ) timed.Since(t, labels...) if err != nil { errors(labels...) } return err } } else { harness = func(f func() error, labels ...string) error { counts(labels...) err := f() if err != nil { errors(labels...) } return err } } return harness }
go
func NewHarness(counts, errors Counter, timed Watcher, clock func() time.Time) Harness { var harness Harness if timed != nil && clock != nil { harness = func(f func() error, labels ...string) error { counts(labels...) var ( t = clock() err = f() ) timed.Since(t, labels...) if err != nil { errors(labels...) } return err } } else { harness = func(f func() error, labels ...string) error { counts(labels...) err := f() if err != nil { errors(labels...) } return err } } return harness }
[ "func", "NewHarness", "(", "counts", ",", "errors", "Counter", ",", "timed", "Watcher", ",", "clock", "func", "(", ")", "time", ".", "Time", ")", "Harness", "{", "var", "harness", "Harness", "\n", "if", "timed", "!=", "nil", "&&", "clock", "!=", "nil", "{", "harness", "=", "func", "(", "f", "func", "(", ")", "error", ",", "labels", "...", "string", ")", "error", "{", "counts", "(", "labels", "...", ")", "\n", "var", "(", "t", "=", "clock", "(", ")", "\n", "err", "=", "f", "(", ")", "\n", ")", "\n", "timed", ".", "Since", "(", "t", ",", "labels", "...", ")", "\n", "if", "err", "!=", "nil", "{", "errors", "(", "labels", "...", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "else", "{", "harness", "=", "func", "(", "f", "func", "(", ")", "error", ",", "labels", "...", "string", ")", "error", "{", "counts", "(", "labels", "...", ")", "\n", "err", ":=", "f", "(", ")", "\n", "if", "err", "!=", "nil", "{", "errors", "(", "labels", "...", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "return", "harness", "\n", "}" ]
// NewHarness generates and returns an execution harness that records metrics. `counts` and `errors` // are required; `timed` and `clock` must either both be nil, or both be non-nil.
[ "NewHarness", "generates", "and", "returns", "an", "execution", "harness", "that", "records", "metrics", ".", "counts", "and", "errors", "are", "required", ";", "timed", "and", "clock", "must", "either", "both", "be", "nil", "or", "both", "be", "non", "-", "nil", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/metrics/metrics.go#L33-L59
12,944
mesos/mesos-go
api/v1/lib/httpcli/auth_basic.go
BasicAuth
func BasicAuth(username, passwd string) ConfigOpt { // TODO(jdef) this could be more efficient. according to the stdlib we're not supposed to // mutate the original Request, so we copy here (including headers). another approach would // be to generate a functional RequestOpt that adds the right header. return WrapRoundTripper(func(rt http.RoundTripper) http.RoundTripper { return roundTripperFunc(func(req *http.Request) (*http.Response, error) { var h http.Header if req.Header != nil { h = make(http.Header, len(req.Header)) for k, v := range req.Header { h[k] = append(make([]string, 0, len(v)), v...) } } clonedReq := *req clonedReq.Header = h clonedReq.SetBasicAuth(username, passwd) return rt.RoundTrip(&clonedReq) }) }) }
go
func BasicAuth(username, passwd string) ConfigOpt { // TODO(jdef) this could be more efficient. according to the stdlib we're not supposed to // mutate the original Request, so we copy here (including headers). another approach would // be to generate a functional RequestOpt that adds the right header. return WrapRoundTripper(func(rt http.RoundTripper) http.RoundTripper { return roundTripperFunc(func(req *http.Request) (*http.Response, error) { var h http.Header if req.Header != nil { h = make(http.Header, len(req.Header)) for k, v := range req.Header { h[k] = append(make([]string, 0, len(v)), v...) } } clonedReq := *req clonedReq.Header = h clonedReq.SetBasicAuth(username, passwd) return rt.RoundTrip(&clonedReq) }) }) }
[ "func", "BasicAuth", "(", "username", ",", "passwd", "string", ")", "ConfigOpt", "{", "// TODO(jdef) this could be more efficient. according to the stdlib we're not supposed to", "// mutate the original Request, so we copy here (including headers). another approach would", "// be to generate a functional RequestOpt that adds the right header.", "return", "WrapRoundTripper", "(", "func", "(", "rt", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", "{", "return", "roundTripperFunc", "(", "func", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "var", "h", "http", ".", "Header", "\n", "if", "req", ".", "Header", "!=", "nil", "{", "h", "=", "make", "(", "http", ".", "Header", ",", "len", "(", "req", ".", "Header", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "req", ".", "Header", "{", "h", "[", "k", "]", "=", "append", "(", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "v", ")", ")", ",", "v", "...", ")", "\n", "}", "\n", "}", "\n", "clonedReq", ":=", "*", "req", "\n", "clonedReq", ".", "Header", "=", "h", "\n", "clonedReq", ".", "SetBasicAuth", "(", "username", ",", "passwd", ")", "\n", "return", "rt", ".", "RoundTrip", "(", "&", "clonedReq", ")", "\n", "}", ")", "\n", "}", ")", "\n", "}" ]
// BasicAuth generates a functional config option that sets HTTP Basic authentication for a Client
[ "BasicAuth", "generates", "a", "functional", "config", "option", "that", "sets", "HTTP", "Basic", "authentication", "for", "a", "Client" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/auth_basic.go#L14-L33
12,945
mesos/mesos-go
api/v1/lib/extras/scheduler/callrules/callers_generated.go
Call
func Call(caller calls.Caller) Rule { if caller == nil { return nil } return func(ctx context.Context, c *scheduler.Call, _ mesos.Response, _ error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) { resp, err := caller.Call(ctx, c) return ch(ctx, c, resp, err) } }
go
func Call(caller calls.Caller) Rule { if caller == nil { return nil } return func(ctx context.Context, c *scheduler.Call, _ mesos.Response, _ error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) { resp, err := caller.Call(ctx, c) return ch(ctx, c, resp, err) } }
[ "func", "Call", "(", "caller", "calls", ".", "Caller", ")", "Rule", "{", "if", "caller", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "c", "*", "scheduler", ".", "Call", ",", "_", "mesos", ".", "Response", ",", "_", "error", ",", "ch", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Call", ",", "mesos", ".", "Response", ",", "error", ")", "{", "resp", ",", "err", ":=", "caller", ".", "Call", "(", "ctx", ",", "c", ")", "\n", "return", "ch", "(", "ctx", ",", "c", ",", "resp", ",", "err", ")", "\n", "}", "\n", "}" ]
// Call returns a Rule that invokes the given Caller
[ "Call", "returns", "a", "Rule", "that", "invokes", "the", "given", "Caller" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/callrules/callers_generated.go#L16-L24
12,946
mesos/mesos-go
api/v1/lib/extras/scheduler/callrules/callers_generated.go
Caller
func (r Rule) Caller(caller calls.Caller) Rule { return Rules{r, Call(caller)}.Eval }
go
func (r Rule) Caller(caller calls.Caller) Rule { return Rules{r, Call(caller)}.Eval }
[ "func", "(", "r", "Rule", ")", "Caller", "(", "caller", "calls", ".", "Caller", ")", "Rule", "{", "return", "Rules", "{", "r", ",", "Call", "(", "caller", ")", "}", ".", "Eval", "\n", "}" ]
// Caller returns a Rule that invokes the receiver and then calls the given Caller
[ "Caller", "returns", "a", "Rule", "that", "invokes", "the", "receiver", "and", "then", "calls", "the", "given", "Caller" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/callrules/callers_generated.go#L32-L34
12,947
mesos/mesos-go
api/v1/lib/extras/scheduler/callrules/callers_generated.go
CallerF
func (r Rule) CallerF(cf calls.CallerFunc) Rule { return r.Caller(calls.Caller(cf)) }
go
func (r Rule) CallerF(cf calls.CallerFunc) Rule { return r.Caller(calls.Caller(cf)) }
[ "func", "(", "r", "Rule", ")", "CallerF", "(", "cf", "calls", ".", "CallerFunc", ")", "Rule", "{", "return", "r", ".", "Caller", "(", "calls", ".", "Caller", "(", "cf", ")", ")", "\n", "}" ]
// CallerF returns a Rule that invokes the receiver and then calls the given CallerFunc
[ "CallerF", "returns", "a", "Rule", "that", "invokes", "the", "receiver", "and", "then", "calls", "the", "given", "CallerFunc" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/callrules/callers_generated.go#L37-L39
12,948
mesos/mesos-go
api/v1/lib/extras/latch/latch.go
Close
func (l *L) Close() { if atomic.AddInt32(&l.value, 1) == 1 { close(l.line) } <-l.line // concurrent calls to Close block until the latch is actually closed }
go
func (l *L) Close() { if atomic.AddInt32(&l.value, 1) == 1 { close(l.line) } <-l.line // concurrent calls to Close block until the latch is actually closed }
[ "func", "(", "l", "*", "L", ")", "Close", "(", ")", "{", "if", "atomic", ".", "AddInt32", "(", "&", "l", ".", "value", ",", "1", ")", "==", "1", "{", "close", "(", "l", ".", "line", ")", "\n", "}", "\n", "<-", "l", ".", "line", "// concurrent calls to Close block until the latch is actually closed", "\n", "}" ]
// Close may panic for an uninitialized L
[ "Close", "may", "panic", "for", "an", "uninitialized", "L" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/latch/latch.go#L28-L33
12,949
mesos/mesos-go
api/v1/lib/extras/latch/latch.go
Reset
func (l *L) Reset() *L { l.line, l.value = make(chan struct{}), 0 return l }
go
func (l *L) Reset() *L { l.line, l.value = make(chan struct{}), 0 return l }
[ "func", "(", "l", "*", "L", ")", "Reset", "(", ")", "*", "L", "{", "l", ".", "line", ",", "l", ".", "value", "=", "make", "(", "chan", "struct", "{", "}", ")", ",", "0", "\n", "return", "l", "\n", "}" ]
// Reset clears the state of the latch, not safe to execute concurrently with other L methods.
[ "Reset", "clears", "the", "state", "of", "the", "latch", "not", "safe", "to", "execute", "concurrently", "with", "other", "L", "methods", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/latch/latch.go#L45-L48
12,950
mesos/mesos-go
api/v1/lib/resources/reduce.go
If
func (rf Reducer) If(f func(*mesos.Resource) bool) Reducer { if f == nil { return rf } return func(acc, x *mesos.Resource) *mesos.Resource { if f(x) { return rf(acc, x) } return acc } }
go
func (rf Reducer) If(f func(*mesos.Resource) bool) Reducer { if f == nil { return rf } return func(acc, x *mesos.Resource) *mesos.Resource { if f(x) { return rf(acc, x) } return acc } }
[ "func", "(", "rf", "Reducer", ")", "If", "(", "f", "func", "(", "*", "mesos", ".", "Resource", ")", "bool", ")", "Reducer", "{", "if", "f", "==", "nil", "{", "return", "rf", "\n", "}", "\n", "return", "func", "(", "acc", ",", "x", "*", "mesos", ".", "Resource", ")", "*", "mesos", ".", "Resource", "{", "if", "f", "(", "x", ")", "{", "return", "rf", "(", "acc", ",", "x", ")", "\n", "}", "\n", "return", "acc", "\n", "}", "\n", "}" ]
// If applies a filter func to a resource reducer; rejected resources are not processed by the receiving reducer.
[ "If", "applies", "a", "filter", "func", "to", "a", "resource", "reducer", ";", "rejected", "resources", "are", "not", "processed", "by", "the", "receiving", "reducer", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources/reduce.go#L13-L23
12,951
mesos/mesos-go
api/v1/lib/resources/reduce.go
IfNot
func (rf Reducer) IfNot(f func(*mesos.Resource) bool) Reducer { if f == nil { return rf } return rf.If(func(r *mesos.Resource) bool { return !f(r) }) }
go
func (rf Reducer) IfNot(f func(*mesos.Resource) bool) Reducer { if f == nil { return rf } return rf.If(func(r *mesos.Resource) bool { return !f(r) }) }
[ "func", "(", "rf", "Reducer", ")", "IfNot", "(", "f", "func", "(", "*", "mesos", ".", "Resource", ")", "bool", ")", "Reducer", "{", "if", "f", "==", "nil", "{", "return", "rf", "\n", "}", "\n", "return", "rf", ".", "If", "(", "func", "(", "r", "*", "mesos", ".", "Resource", ")", "bool", "{", "return", "!", "f", "(", "r", ")", "\n", "}", ")", "\n", "}" ]
// IfNot applies a filter func to a resource reducer; accepted resources are not processed by the receiving reducer.
[ "IfNot", "applies", "a", "filter", "func", "to", "a", "resource", "reducer", ";", "accepted", "resources", "are", "not", "processed", "by", "the", "receiving", "reducer", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources/reduce.go#L26-L33
12,952
mesos/mesos-go
api/v1/lib/resources/reduce.go
Reduce
func Reduce(rf Reducer, rs ...mesos.Resource) (r *mesos.Resource) { if rf == nil { panic("Reduce: reducer func may not be nil") } for i := range rs { r = rf(r, &rs[i]) } return }
go
func Reduce(rf Reducer, rs ...mesos.Resource) (r *mesos.Resource) { if rf == nil { panic("Reduce: reducer func may not be nil") } for i := range rs { r = rf(r, &rs[i]) } return }
[ "func", "Reduce", "(", "rf", "Reducer", ",", "rs", "...", "mesos", ".", "Resource", ")", "(", "r", "*", "mesos", ".", "Resource", ")", "{", "if", "rf", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "i", ":=", "range", "rs", "{", "r", "=", "rf", "(", "r", ",", "&", "rs", "[", "i", "]", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Reduce applies the given Reducer to produce a final Resource, iterating left-to-right over the given // resources; panics if the Reducer is nil.
[ "Reduce", "applies", "the", "given", "Reducer", "to", "produce", "a", "final", "Resource", "iterating", "left", "-", "to", "-", "right", "over", "the", "given", "resources", ";", "panics", "if", "the", "Reducer", "is", "nil", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources/reduce.go#L37-L45
12,953
mesos/mesos-go
api/v1/lib/scheduler/options.go
With
func (r *Call_Reconcile) With(opts ...ReconcileOpt) *Call_Reconcile { for _, opt := range opts { if opt != nil { opt(r) } } return r }
go
func (r *Call_Reconcile) With(opts ...ReconcileOpt) *Call_Reconcile { for _, opt := range opts { if opt != nil { opt(r) } } return r }
[ "func", "(", "r", "*", "Call_Reconcile", ")", "With", "(", "opts", "...", "ReconcileOpt", ")", "*", "Call_Reconcile", "{", "for", "_", ",", "opt", ":=", "range", "opts", "{", "if", "opt", "!=", "nil", "{", "opt", "(", "r", ")", "\n", "}", "\n", "}", "\n", "return", "r", "\n", "}" ]
// With applies the given ReconcileOpt's to the receiving Call_Reconcile, returning it.
[ "With", "applies", "the", "given", "ReconcileOpt", "s", "to", "the", "receiving", "Call_Reconcile", "returning", "it", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/options.go#L20-L27
12,954
mesos/mesos-go
api/v1/lib/scheduler/options.go
Copy
func (co CallOptions) Copy() CallOptions { if len(co) == 0 { return nil } x := make(CallOptions, len(co)) copy(x, co) return x }
go
func (co CallOptions) Copy() CallOptions { if len(co) == 0 { return nil } x := make(CallOptions, len(co)) copy(x, co) return x }
[ "func", "(", "co", "CallOptions", ")", "Copy", "(", ")", "CallOptions", "{", "if", "len", "(", "co", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "x", ":=", "make", "(", "CallOptions", ",", "len", "(", "co", ")", ")", "\n", "copy", "(", "x", ",", "co", ")", "\n", "return", "x", "\n", "}" ]
// Copy returns a cloned copy of CallOptions
[ "Copy", "returns", "a", "cloned", "copy", "of", "CallOptions" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/options.go#L32-L39
12,955
mesos/mesos-go
api/v0/auth/sasl/mech/interface.go
IllegalState
func IllegalState(m Interface, data []byte) (StepFunc, []byte, error) { return IllegalState, nil, IllegalStateErr }
go
func IllegalState(m Interface, data []byte) (StepFunc, []byte, error) { return IllegalState, nil, IllegalStateErr }
[ "func", "IllegalState", "(", "m", "Interface", ",", "data", "[", "]", "byte", ")", "(", "StepFunc", ",", "[", "]", "byte", ",", "error", ")", "{", "return", "IllegalState", ",", "nil", ",", "IllegalStateErr", "\n", "}" ]
// reflects an unrecoverable, illegal mechanism state; always returns IllegalState // as the next step along with an IllegalStateErr
[ "reflects", "an", "unrecoverable", "illegal", "mechanism", "state", ";", "always", "returns", "IllegalState", "as", "the", "next", "step", "along", "with", "an", "IllegalStateErr" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/auth/sasl/mech/interface.go#L31-L33
12,956
mesos/mesos-go
api/v1/lib/recordio/reader.go
NewReader
func NewReader(read io.Reader, opt ...Opt) framing.Reader { debug.Log("new frame reader") r := &reader{Scanner: bufio.NewScanner(read)} r.Split(func(data []byte, atEOF bool) (int, []byte, error) { // Scanner panics if we invoke Split after scanning has started, // use this proxy func as a work-around. return r.splitf(data, atEOF) }) buf := make([]byte, 16*1024) r.Buffer(buf, 1<<22) // 1<<22 == max protobuf size r.splitf = r.splitSize // apply options for _, f := range opt { if f != nil { f(r) } } return r }
go
func NewReader(read io.Reader, opt ...Opt) framing.Reader { debug.Log("new frame reader") r := &reader{Scanner: bufio.NewScanner(read)} r.Split(func(data []byte, atEOF bool) (int, []byte, error) { // Scanner panics if we invoke Split after scanning has started, // use this proxy func as a work-around. return r.splitf(data, atEOF) }) buf := make([]byte, 16*1024) r.Buffer(buf, 1<<22) // 1<<22 == max protobuf size r.splitf = r.splitSize // apply options for _, f := range opt { if f != nil { f(r) } } return r }
[ "func", "NewReader", "(", "read", "io", ".", "Reader", ",", "opt", "...", "Opt", ")", "framing", ".", "Reader", "{", "debug", ".", "Log", "(", "\"", "\"", ")", "\n", "r", ":=", "&", "reader", "{", "Scanner", ":", "bufio", ".", "NewScanner", "(", "read", ")", "}", "\n", "r", ".", "Split", "(", "func", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "int", ",", "[", "]", "byte", ",", "error", ")", "{", "// Scanner panics if we invoke Split after scanning has started,", "// use this proxy func as a work-around.", "return", "r", ".", "splitf", "(", "data", ",", "atEOF", ")", "\n", "}", ")", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "16", "*", "1024", ")", "\n", "r", ".", "Buffer", "(", "buf", ",", "1", "<<", "22", ")", "// 1<<22 == max protobuf size", "\n", "r", ".", "splitf", "=", "r", ".", "splitSize", "\n", "// apply options", "for", "_", ",", "f", ":=", "range", "opt", "{", "if", "f", "!=", "nil", "{", "f", "(", "r", ")", "\n", "}", "\n", "}", "\n", "return", "r", "\n", "}" ]
// NewReader returns a reader that parses frames from a recordio stream.
[ "NewReader", "returns", "a", "reader", "that", "parses", "frames", "from", "a", "recordio", "stream", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/recordio/reader.go#L26-L44
12,957
mesos/mesos-go
api/v1/lib/recordio/reader.go
ReadFrame
func (r *reader) ReadFrame() (tok []byte, err error) { for r.Scan() { b := r.Bytes() if len(b) == 0 { continue } tok = b debug.Log("len(tok)", len(tok)) break } // either scan failed, or it succeeded and we have a token... err = r.Err() if err == nil && len(tok) == 0 { err = io.EOF } return }
go
func (r *reader) ReadFrame() (tok []byte, err error) { for r.Scan() { b := r.Bytes() if len(b) == 0 { continue } tok = b debug.Log("len(tok)", len(tok)) break } // either scan failed, or it succeeded and we have a token... err = r.Err() if err == nil && len(tok) == 0 { err = io.EOF } return }
[ "func", "(", "r", "*", "reader", ")", "ReadFrame", "(", ")", "(", "tok", "[", "]", "byte", ",", "err", "error", ")", "{", "for", "r", ".", "Scan", "(", ")", "{", "b", ":=", "r", ".", "Bytes", "(", ")", "\n", "if", "len", "(", "b", ")", "==", "0", "{", "continue", "\n", "}", "\n", "tok", "=", "b", "\n", "debug", ".", "Log", "(", "\"", "\"", ",", "len", "(", "tok", ")", ")", "\n", "break", "\n", "}", "\n", "// either scan failed, or it succeeded and we have a token...", "err", "=", "r", ".", "Err", "(", ")", "\n", "if", "err", "==", "nil", "&&", "len", "(", "tok", ")", "==", "0", "{", "err", "=", "io", ".", "EOF", "\n", "}", "\n", "return", "\n", "}" ]
// ReadFrame implements framing.Reader
[ "ReadFrame", "implements", "framing", ".", "Reader" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/recordio/reader.go#L129-L145
12,958
mesos/mesos-go
api/v0/executor/executor.go
NewMesosExecutorDriver
func NewMesosExecutorDriver(config DriverConfig) (*MesosExecutorDriver, error) { if config.Executor == nil { msg := "Executor callback interface cannot be nil." log.Errorln(msg) return nil, fmt.Errorf(msg) } hostname := mesosutil.GetHostname(config.HostnameOverride) newMessenger := config.NewMessenger if newMessenger == nil { newMessenger = func() (messenger.Messenger, error) { process := process.New("executor") return messenger.ForHostname(process, hostname, config.BindingAddress, config.BindingPort, config.PublishedAddress) } } driver := &MesosExecutorDriver{ status: mesosproto.Status_DRIVER_NOT_STARTED, stopCh: make(chan struct{}), updates: make(map[string]*mesosproto.StatusUpdate), tasks: make(map[string]*mesosproto.TaskInfo), workDir: ".", started: make(chan struct{}), recoveryTimeout: defaultRecoveryTimeout, } driver.cond = sync.NewCond(&driver.lock) // decouple serialized executor callback execution from goroutines of this driver var execLock sync.Mutex driver.withExecutor = func(f func(e Executor)) { go func() { execLock.Lock() defer execLock.Unlock() f(config.Executor) }() } var err error if driver.messenger, err = newMessenger(); err != nil { return nil, err } if err = driver.init(); err != nil { log.Errorf("failed to initialize the driver: %v", err) return nil, err } return driver, nil }
go
func NewMesosExecutorDriver(config DriverConfig) (*MesosExecutorDriver, error) { if config.Executor == nil { msg := "Executor callback interface cannot be nil." log.Errorln(msg) return nil, fmt.Errorf(msg) } hostname := mesosutil.GetHostname(config.HostnameOverride) newMessenger := config.NewMessenger if newMessenger == nil { newMessenger = func() (messenger.Messenger, error) { process := process.New("executor") return messenger.ForHostname(process, hostname, config.BindingAddress, config.BindingPort, config.PublishedAddress) } } driver := &MesosExecutorDriver{ status: mesosproto.Status_DRIVER_NOT_STARTED, stopCh: make(chan struct{}), updates: make(map[string]*mesosproto.StatusUpdate), tasks: make(map[string]*mesosproto.TaskInfo), workDir: ".", started: make(chan struct{}), recoveryTimeout: defaultRecoveryTimeout, } driver.cond = sync.NewCond(&driver.lock) // decouple serialized executor callback execution from goroutines of this driver var execLock sync.Mutex driver.withExecutor = func(f func(e Executor)) { go func() { execLock.Lock() defer execLock.Unlock() f(config.Executor) }() } var err error if driver.messenger, err = newMessenger(); err != nil { return nil, err } if err = driver.init(); err != nil { log.Errorf("failed to initialize the driver: %v", err) return nil, err } return driver, nil }
[ "func", "NewMesosExecutorDriver", "(", "config", "DriverConfig", ")", "(", "*", "MesosExecutorDriver", ",", "error", ")", "{", "if", "config", ".", "Executor", "==", "nil", "{", "msg", ":=", "\"", "\"", "\n", "log", ".", "Errorln", "(", "msg", ")", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "msg", ")", "\n", "}", "\n\n", "hostname", ":=", "mesosutil", ".", "GetHostname", "(", "config", ".", "HostnameOverride", ")", "\n", "newMessenger", ":=", "config", ".", "NewMessenger", "\n", "if", "newMessenger", "==", "nil", "{", "newMessenger", "=", "func", "(", ")", "(", "messenger", ".", "Messenger", ",", "error", ")", "{", "process", ":=", "process", ".", "New", "(", "\"", "\"", ")", "\n", "return", "messenger", ".", "ForHostname", "(", "process", ",", "hostname", ",", "config", ".", "BindingAddress", ",", "config", ".", "BindingPort", ",", "config", ".", "PublishedAddress", ")", "\n", "}", "\n", "}", "\n\n", "driver", ":=", "&", "MesosExecutorDriver", "{", "status", ":", "mesosproto", ".", "Status_DRIVER_NOT_STARTED", ",", "stopCh", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "updates", ":", "make", "(", "map", "[", "string", "]", "*", "mesosproto", ".", "StatusUpdate", ")", ",", "tasks", ":", "make", "(", "map", "[", "string", "]", "*", "mesosproto", ".", "TaskInfo", ")", ",", "workDir", ":", "\"", "\"", ",", "started", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "recoveryTimeout", ":", "defaultRecoveryTimeout", ",", "}", "\n", "driver", ".", "cond", "=", "sync", ".", "NewCond", "(", "&", "driver", ".", "lock", ")", "\n", "// decouple serialized executor callback execution from goroutines of this driver", "var", "execLock", "sync", ".", "Mutex", "\n", "driver", ".", "withExecutor", "=", "func", "(", "f", "func", "(", "e", "Executor", ")", ")", "{", "go", "func", "(", ")", "{", "execLock", ".", "Lock", "(", ")", "\n", "defer", "execLock", ".", "Unlock", "(", ")", "\n", "f", "(", "config", ".", "Executor", ")", "\n", "}", "(", ")", "\n", "}", "\n", "var", "err", "error", "\n", "if", "driver", ".", "messenger", ",", "err", "=", "newMessenger", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "err", "=", "driver", ".", "init", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "driver", ",", "nil", "\n", "}" ]
// NewMesosExecutorDriver creates a new mesos executor driver.
[ "NewMesosExecutorDriver", "creates", "a", "new", "mesos", "executor", "driver", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L80-L124
12,959
mesos/mesos-go
api/v0/executor/executor.go
Stop
func (driver *MesosExecutorDriver) Stop() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.stop() }
go
func (driver *MesosExecutorDriver) Stop() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.stop() }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "Stop", "(", ")", "(", "mesosproto", ".", "Status", ",", "error", ")", "{", "driver", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "stop", "(", ")", "\n", "}" ]
// Stop stops the driver by sending a 'stopEvent' to the event loop, and // receives the result from the response channel.
[ "Stop", "stops", "the", "driver", "by", "sending", "a", "stopEvent", "to", "the", "event", "loop", "and", "receives", "the", "result", "from", "the", "response", "channel", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L565-L569
12,960
mesos/mesos-go
api/v0/executor/executor.go
_stop
func (driver *MesosExecutorDriver) _stop(stopStatus mesosproto.Status) error { err := driver.messenger.Stop() defer func() { select { case <-driver.stopCh: // already closed default: close(driver.stopCh) } driver.cond.Broadcast() }() driver.status = stopStatus if err != nil { return err } return nil }
go
func (driver *MesosExecutorDriver) _stop(stopStatus mesosproto.Status) error { err := driver.messenger.Stop() defer func() { select { case <-driver.stopCh: // already closed default: close(driver.stopCh) } driver.cond.Broadcast() }() driver.status = stopStatus if err != nil { return err } return nil }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "_stop", "(", "stopStatus", "mesosproto", ".", "Status", ")", "error", "{", "err", ":=", "driver", ".", "messenger", ".", "Stop", "(", ")", "\n", "defer", "func", "(", ")", "{", "select", "{", "case", "<-", "driver", ".", "stopCh", ":", "// already closed", "default", ":", "close", "(", "driver", ".", "stopCh", ")", "\n", "}", "\n", "driver", ".", "cond", ".", "Broadcast", "(", ")", "\n", "}", "(", ")", "\n\n", "driver", ".", "status", "=", "stopStatus", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// internal function for stopping the driver and set reason for stopping // Note that messages inflight or queued will not be processed.
[ "internal", "function", "for", "stopping", "the", "driver", "and", "set", "reason", "for", "stopping", "Note", "that", "messages", "inflight", "or", "queued", "will", "not", "be", "processed", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L581-L598
12,961
mesos/mesos-go
api/v0/executor/executor.go
Abort
func (driver *MesosExecutorDriver) Abort() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.abort() }
go
func (driver *MesosExecutorDriver) Abort() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.abort() }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "Abort", "(", ")", "(", "mesosproto", ".", "Status", ",", "error", ")", "{", "driver", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "abort", "(", ")", "\n", "}" ]
// Abort aborts the driver by sending an 'abortEvent' to the event loop, and // receives the result from the response channel.
[ "Abort", "aborts", "the", "driver", "by", "sending", "an", "abortEvent", "to", "the", "event", "loop", "and", "receives", "the", "result", "from", "the", "response", "channel", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L602-L606
12,962
mesos/mesos-go
api/v0/executor/executor.go
Join
func (driver *MesosExecutorDriver) Join() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.join() }
go
func (driver *MesosExecutorDriver) Join() (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.join() }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "Join", "(", ")", "(", "mesosproto", ".", "Status", ",", "error", ")", "{", "driver", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "join", "(", ")", "\n", "}" ]
// Join waits for the driver by sending a 'joinEvent' to the event loop, and wait // on a channel for the notification of driver termination.
[ "Join", "waits", "for", "the", "driver", "by", "sending", "a", "joinEvent", "to", "the", "event", "loop", "and", "wait", "on", "a", "channel", "for", "the", "notification", "of", "driver", "termination", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L619-L623
12,963
mesos/mesos-go
api/v0/executor/executor.go
SendStatusUpdate
func (driver *MesosExecutorDriver) SendStatusUpdate(taskStatus *mesosproto.TaskStatus) (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.sendStatusUpdate(taskStatus) }
go
func (driver *MesosExecutorDriver) SendStatusUpdate(taskStatus *mesosproto.TaskStatus) (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.sendStatusUpdate(taskStatus) }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "SendStatusUpdate", "(", "taskStatus", "*", "mesosproto", ".", "TaskStatus", ")", "(", "mesosproto", ".", "Status", ",", "error", ")", "{", "driver", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "sendStatusUpdate", "(", "taskStatus", ")", "\n", "}" ]
// SendStatusUpdate sends status updates to the slave.
[ "SendStatusUpdate", "sends", "status", "updates", "to", "the", "slave", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L662-L666
12,964
mesos/mesos-go
api/v0/executor/executor.go
SendFrameworkMessage
func (driver *MesosExecutorDriver) SendFrameworkMessage(data string) (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.sendFrameworkMessage(data) }
go
func (driver *MesosExecutorDriver) SendFrameworkMessage(data string) (mesosproto.Status, error) { driver.lock.Lock() defer driver.lock.Unlock() return driver.sendFrameworkMessage(data) }
[ "func", "(", "driver", "*", "MesosExecutorDriver", ")", "SendFrameworkMessage", "(", "data", "string", ")", "(", "mesosproto", ".", "Status", ",", "error", ")", "{", "driver", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "sendFrameworkMessage", "(", "data", ")", "\n", "}" ]
// SendFrameworkMessage sends the framework message by sending a 'sendFrameworkMessageEvent' // to the event loop, and receives the result from the response channel.
[ "SendFrameworkMessage", "sends", "the", "framework", "message", "by", "sending", "a", "sendFrameworkMessageEvent", "to", "the", "event", "loop", "and", "receives", "the", "result", "from", "the", "response", "channel", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/executor.go#L724-L728
12,965
mesos/mesos-go
api/v1/cmd/example-executor/main.go
unacknowledgedTasks
func unacknowledgedTasks(state *internalState) (result []mesos.TaskInfo) { if n := len(state.unackedTasks); n > 0 { result = make([]mesos.TaskInfo, 0, n) for k := range state.unackedTasks { result = append(result, state.unackedTasks[k]) } } return }
go
func unacknowledgedTasks(state *internalState) (result []mesos.TaskInfo) { if n := len(state.unackedTasks); n > 0 { result = make([]mesos.TaskInfo, 0, n) for k := range state.unackedTasks { result = append(result, state.unackedTasks[k]) } } return }
[ "func", "unacknowledgedTasks", "(", "state", "*", "internalState", ")", "(", "result", "[", "]", "mesos", ".", "TaskInfo", ")", "{", "if", "n", ":=", "len", "(", "state", ".", "unackedTasks", ")", ";", "n", ">", "0", "{", "result", "=", "make", "(", "[", "]", "mesos", ".", "TaskInfo", ",", "0", ",", "n", ")", "\n", "for", "k", ":=", "range", "state", ".", "unackedTasks", "{", "result", "=", "append", "(", "result", ",", "state", ".", "unackedTasks", "[", "k", "]", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// unacknowledgedTasks generates the value of the UnacknowledgedTasks field of a Subscribe call.
[ "unacknowledgedTasks", "generates", "the", "value", "of", "the", "UnacknowledgedTasks", "field", "of", "a", "Subscribe", "call", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/cmd/example-executor/main.go#L120-L128
12,966
mesos/mesos-go
api/v1/cmd/example-executor/main.go
unacknowledgedUpdates
func unacknowledgedUpdates(state *internalState) (result []executor.Call_Update) { if n := len(state.unackedUpdates); n > 0 { result = make([]executor.Call_Update, 0, n) for k := range state.unackedUpdates { result = append(result, state.unackedUpdates[k]) } } return }
go
func unacknowledgedUpdates(state *internalState) (result []executor.Call_Update) { if n := len(state.unackedUpdates); n > 0 { result = make([]executor.Call_Update, 0, n) for k := range state.unackedUpdates { result = append(result, state.unackedUpdates[k]) } } return }
[ "func", "unacknowledgedUpdates", "(", "state", "*", "internalState", ")", "(", "result", "[", "]", "executor", ".", "Call_Update", ")", "{", "if", "n", ":=", "len", "(", "state", ".", "unackedUpdates", ")", ";", "n", ">", "0", "{", "result", "=", "make", "(", "[", "]", "executor", ".", "Call_Update", ",", "0", ",", "n", ")", "\n", "for", "k", ":=", "range", "state", ".", "unackedUpdates", "{", "result", "=", "append", "(", "result", ",", "state", ".", "unackedUpdates", "[", "k", "]", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// unacknowledgedUpdates generates the value of the UnacknowledgedUpdates field of a Subscribe call.
[ "unacknowledgedUpdates", "generates", "the", "value", "of", "the", "UnacknowledgedUpdates", "field", "of", "a", "Subscribe", "call", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/cmd/example-executor/main.go#L131-L139
12,967
mesos/mesos-go
api/v0/detector/standalone.go
NewStandalone
func NewStandalone(mi *mesos.MasterInfo) *Standalone { log.V(2).Infof("creating new standalone detector for %+v", mi) stand := &Standalone{ ch: make(chan *mesos.MasterInfo), tr: &http.Transport{}, initial: mi, done: make(chan struct{}), leaderSyncInterval: defaultMesosLeaderSyncInterval, httpClientTimeout: defaultMesosHttpClientTimeout, assumedMasterPort: defaultMesosMasterPort, } stand.poller = stand._poller stand.fetchPid = stand._fetchPid return stand }
go
func NewStandalone(mi *mesos.MasterInfo) *Standalone { log.V(2).Infof("creating new standalone detector for %+v", mi) stand := &Standalone{ ch: make(chan *mesos.MasterInfo), tr: &http.Transport{}, initial: mi, done: make(chan struct{}), leaderSyncInterval: defaultMesosLeaderSyncInterval, httpClientTimeout: defaultMesosHttpClientTimeout, assumedMasterPort: defaultMesosMasterPort, } stand.poller = stand._poller stand.fetchPid = stand._fetchPid return stand }
[ "func", "NewStandalone", "(", "mi", "*", "mesos", ".", "MasterInfo", ")", "*", "Standalone", "{", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "mi", ")", "\n", "stand", ":=", "&", "Standalone", "{", "ch", ":", "make", "(", "chan", "*", "mesos", ".", "MasterInfo", ")", ",", "tr", ":", "&", "http", ".", "Transport", "{", "}", ",", "initial", ":", "mi", ",", "done", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "leaderSyncInterval", ":", "defaultMesosLeaderSyncInterval", ",", "httpClientTimeout", ":", "defaultMesosHttpClientTimeout", ",", "assumedMasterPort", ":", "defaultMesosMasterPort", ",", "}", "\n", "stand", ".", "poller", "=", "stand", ".", "_poller", "\n", "stand", ".", "fetchPid", "=", "stand", ".", "_fetchPid", "\n", "return", "stand", "\n", "}" ]
// Create a new stand alone master detector.
[ "Create", "a", "new", "stand", "alone", "master", "detector", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/detector/standalone.go#L45-L59
12,968
mesos/mesos-go
api/v0/detector/standalone.go
Detect
func (s *Standalone) Detect(o MasterChanged) error { log.V(2).Info("Detect()") s.pollOnce.Do(func() { log.V(1).Info("spinning up asyc master detector poller") // delayed initialization allows unit tests to modify timeouts before detection starts s.client = &http.Client{ Transport: s.tr, Timeout: s.httpClientTimeout, } go s.poller(s.fetchPid) }) if o != nil { log.V(1).Info("spawning asyc master detector listener") go func() { log.V(2).Infof("waiting for polled to send updates") pollWaiter: for { select { case mi, ok := <-s.ch: if !ok { break pollWaiter } log.V(1).Infof("detected master change: %+v", mi) o.OnMasterChanged(mi) case <-s.done: return } } o.OnMasterChanged(nil) }() } else { log.Warningf("detect called with a nil master change listener") } return nil }
go
func (s *Standalone) Detect(o MasterChanged) error { log.V(2).Info("Detect()") s.pollOnce.Do(func() { log.V(1).Info("spinning up asyc master detector poller") // delayed initialization allows unit tests to modify timeouts before detection starts s.client = &http.Client{ Transport: s.tr, Timeout: s.httpClientTimeout, } go s.poller(s.fetchPid) }) if o != nil { log.V(1).Info("spawning asyc master detector listener") go func() { log.V(2).Infof("waiting for polled to send updates") pollWaiter: for { select { case mi, ok := <-s.ch: if !ok { break pollWaiter } log.V(1).Infof("detected master change: %+v", mi) o.OnMasterChanged(mi) case <-s.done: return } } o.OnMasterChanged(nil) }() } else { log.Warningf("detect called with a nil master change listener") } return nil }
[ "func", "(", "s", "*", "Standalone", ")", "Detect", "(", "o", "MasterChanged", ")", "error", "{", "log", ".", "V", "(", "2", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "s", ".", "pollOnce", ".", "Do", "(", "func", "(", ")", "{", "log", ".", "V", "(", "1", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "// delayed initialization allows unit tests to modify timeouts before detection starts", "s", ".", "client", "=", "&", "http", ".", "Client", "{", "Transport", ":", "s", ".", "tr", ",", "Timeout", ":", "s", ".", "httpClientTimeout", ",", "}", "\n", "go", "s", ".", "poller", "(", "s", ".", "fetchPid", ")", "\n", "}", ")", "\n", "if", "o", "!=", "nil", "{", "log", ".", "V", "(", "1", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "go", "func", "(", ")", "{", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "pollWaiter", ":", "for", "{", "select", "{", "case", "mi", ",", "ok", ":=", "<-", "s", ".", "ch", ":", "if", "!", "ok", "{", "break", "pollWaiter", "\n", "}", "\n", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\"", ",", "mi", ")", "\n", "o", ".", "OnMasterChanged", "(", "mi", ")", "\n", "case", "<-", "s", ".", "done", ":", "return", "\n", "}", "\n", "}", "\n", "o", ".", "OnMasterChanged", "(", "nil", ")", "\n", "}", "(", ")", "\n", "}", "else", "{", "log", ".", "Warningf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Detecting the new master.
[ "Detecting", "the", "new", "master", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/detector/standalone.go#L66-L100
12,969
mesos/mesos-go
api/v1/lib/executor/events/events_generated.go
HandleEvent
func (hs Handlers) HandleEvent(ctx context.Context, e *executor.Event) (err error) { if h := hs[e.GetType()]; h != nil { return h.HandleEvent(ctx, e) } return nil }
go
func (hs Handlers) HandleEvent(ctx context.Context, e *executor.Event) (err error) { if h := hs[e.GetType()]; h != nil { return h.HandleEvent(ctx, e) } return nil }
[ "func", "(", "hs", "Handlers", ")", "HandleEvent", "(", "ctx", "context", ".", "Context", ",", "e", "*", "executor", ".", "Event", ")", "(", "err", "error", ")", "{", "if", "h", ":=", "hs", "[", "e", ".", "GetType", "(", ")", "]", ";", "h", "!=", "nil", "{", "return", "h", ".", "HandleEvent", "(", "ctx", ",", "e", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// HandleEvent implements Handler for Handlers
[ "HandleEvent", "implements", "Handler", "for", "Handlers" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/events/events_generated.go#L40-L45
12,970
mesos/mesos-go
api/v0/upid/upid.go
Parse
func Parse(input string) (*UPID, error) { upid := new(UPID) splits := strings.Split(input, "@") if len(splits) != 2 { return nil, fmt.Errorf("Expect one `@' in the input") } upid.ID = splits[0] if _, err := net.ResolveTCPAddr("tcp4", splits[1]); err != nil { return nil, err } upid.Host, upid.Port, _ = net.SplitHostPort(splits[1]) return upid, nil }
go
func Parse(input string) (*UPID, error) { upid := new(UPID) splits := strings.Split(input, "@") if len(splits) != 2 { return nil, fmt.Errorf("Expect one `@' in the input") } upid.ID = splits[0] if _, err := net.ResolveTCPAddr("tcp4", splits[1]); err != nil { return nil, err } upid.Host, upid.Port, _ = net.SplitHostPort(splits[1]) return upid, nil }
[ "func", "Parse", "(", "input", "string", ")", "(", "*", "UPID", ",", "error", ")", "{", "upid", ":=", "new", "(", "UPID", ")", "\n\n", "splits", ":=", "strings", ".", "Split", "(", "input", ",", "\"", "\"", ")", "\n", "if", "len", "(", "splits", ")", "!=", "2", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "upid", ".", "ID", "=", "splits", "[", "0", "]", "\n\n", "if", "_", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "\"", "\"", ",", "splits", "[", "1", "]", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "upid", ".", "Host", ",", "upid", ".", "Port", ",", "_", "=", "net", ".", "SplitHostPort", "(", "splits", "[", "1", "]", ")", "\n", "return", "upid", ",", "nil", "\n", "}" ]
// Parse parses the UPID from the input string.
[ "Parse", "parses", "the", "UPID", "from", "the", "input", "string", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/upid/upid.go#L35-L49
12,971
mesos/mesos-go
api/v0/upid/upid.go
Equal
func (u *UPID) Equal(upid *UPID) bool { if u == nil { return upid == nil } else { return upid != nil && u.ID == upid.ID && u.Host == upid.Host && u.Port == upid.Port } }
go
func (u *UPID) Equal(upid *UPID) bool { if u == nil { return upid == nil } else { return upid != nil && u.ID == upid.ID && u.Host == upid.Host && u.Port == upid.Port } }
[ "func", "(", "u", "*", "UPID", ")", "Equal", "(", "upid", "*", "UPID", ")", "bool", "{", "if", "u", "==", "nil", "{", "return", "upid", "==", "nil", "\n", "}", "else", "{", "return", "upid", "!=", "nil", "&&", "u", ".", "ID", "==", "upid", ".", "ID", "&&", "u", ".", "Host", "==", "upid", ".", "Host", "&&", "u", ".", "Port", "==", "upid", ".", "Port", "\n", "}", "\n", "}" ]
// Equal returns true if two upid is equal
[ "Equal", "returns", "true", "if", "two", "upid", "is", "equal" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/upid/upid.go#L57-L63
12,972
mesos/mesos-go
api/v1/lib/master/calls/calls.go
GetMetrics
func GetMetrics(d *time.Duration) (call *master.Call) { call = &master.Call{ Type: master.Call_GET_METRICS, GetMetrics: &master.Call_GetMetrics{}, } if d != nil { call.GetMetrics.Timeout = &mesos.DurationInfo{ Nanoseconds: d.Nanoseconds(), } } return }
go
func GetMetrics(d *time.Duration) (call *master.Call) { call = &master.Call{ Type: master.Call_GET_METRICS, GetMetrics: &master.Call_GetMetrics{}, } if d != nil { call.GetMetrics.Timeout = &mesos.DurationInfo{ Nanoseconds: d.Nanoseconds(), } } return }
[ "func", "GetMetrics", "(", "d", "*", "time", ".", "Duration", ")", "(", "call", "*", "master", ".", "Call", ")", "{", "call", "=", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_GET_METRICS", ",", "GetMetrics", ":", "&", "master", ".", "Call_GetMetrics", "{", "}", ",", "}", "\n", "if", "d", "!=", "nil", "{", "call", ".", "GetMetrics", ".", "Timeout", "=", "&", "mesos", ".", "DurationInfo", "{", "Nanoseconds", ":", "d", ".", "Nanoseconds", "(", ")", ",", "}", "\n", "}", "\n", "return", "\n", "}" ]
// GetMetrics gives the snapshot of current metrics to the end user. If timeout is set in the call, it will be used to // determine the maximum amount of time the API will take to respond. If the timeout is exceeded, some metrics may not // be included in the response.
[ "GetMetrics", "gives", "the", "snapshot", "of", "current", "metrics", "to", "the", "end", "user", ".", "If", "timeout", "is", "set", "in", "the", "call", "it", "will", "be", "used", "to", "determine", "the", "maximum", "amount", "of", "time", "the", "API", "will", "take", "to", "respond", ".", "If", "the", "timeout", "is", "exceeded", "some", "metrics", "may", "not", "be", "included", "in", "the", "response", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L36-L47
12,973
mesos/mesos-go
api/v1/lib/master/calls/calls.go
ListFiles
func ListFiles(path string) *master.Call { return &master.Call{ Type: master.Call_LIST_FILES, ListFiles: &master.Call_ListFiles{ Path: path, }, } }
go
func ListFiles(path string) *master.Call { return &master.Call{ Type: master.Call_LIST_FILES, ListFiles: &master.Call_ListFiles{ Path: path, }, } }
[ "func", "ListFiles", "(", "path", "string", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_LIST_FILES", ",", "ListFiles", ":", "&", "master", ".", "Call_ListFiles", "{", "Path", ":", "path", ",", "}", ",", "}", "\n", "}" ]
// ListFiles retrieves the file listing for a directory in master.
[ "ListFiles", "retrieves", "the", "file", "listing", "for", "a", "directory", "in", "master", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L72-L79
12,974
mesos/mesos-go
api/v1/lib/master/calls/calls.go
ReadFile
func ReadFile(path string, offset uint64) *master.Call { return &master.Call{ Type: master.Call_READ_FILE, ReadFile: &master.Call_ReadFile{ Path: path, Offset: offset, }, } }
go
func ReadFile(path string, offset uint64) *master.Call { return &master.Call{ Type: master.Call_READ_FILE, ReadFile: &master.Call_ReadFile{ Path: path, Offset: offset, }, } }
[ "func", "ReadFile", "(", "path", "string", ",", "offset", "uint64", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_READ_FILE", ",", "ReadFile", ":", "&", "master", ".", "Call_ReadFile", "{", "Path", ":", "path", ",", "Offset", ":", "offset", ",", "}", ",", "}", "\n", "}" ]
// ReadFile reads data from a file on the master. This call takes the path of the file to be read and the offset to // start reading.
[ "ReadFile", "reads", "data", "from", "a", "file", "on", "the", "master", ".", "This", "call", "takes", "the", "path", "of", "the", "file", "to", "be", "read", "and", "the", "offset", "to", "start", "reading", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L83-L91
12,975
mesos/mesos-go
api/v1/lib/master/calls/calls.go
UpdateWeights
func UpdateWeights(weights ...mesos.WeightInfo) *master.Call { return &master.Call{ Type: master.Call_UPDATE_WEIGHTS, UpdateWeights: &master.Call_UpdateWeights{ WeightInfos: weights, }, } }
go
func UpdateWeights(weights ...mesos.WeightInfo) *master.Call { return &master.Call{ Type: master.Call_UPDATE_WEIGHTS, UpdateWeights: &master.Call_UpdateWeights{ WeightInfos: weights, }, } }
[ "func", "UpdateWeights", "(", "weights", "...", "mesos", ".", "WeightInfo", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_UPDATE_WEIGHTS", ",", "UpdateWeights", ":", "&", "master", ".", "Call_UpdateWeights", "{", "WeightInfos", ":", "weights", ",", "}", ",", "}", "\n", "}" ]
// UpdateWeights updates weights for specific roles.
[ "UpdateWeights", "updates", "weights", "for", "specific", "roles", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L157-L164
12,976
mesos/mesos-go
api/v1/lib/master/calls/calls.go
ReserveResources
func ReserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_RESERVE_RESOURCES, ReserveResources: &master.Call_ReserveResources{ AgentID: a, Resources: r, }, } }
go
func ReserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_RESERVE_RESOURCES, ReserveResources: &master.Call_ReserveResources{ AgentID: a, Resources: r, }, } }
[ "func", "ReserveResources", "(", "a", "mesos", ".", "AgentID", ",", "r", "...", "mesos", ".", "Resource", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_RESERVE_RESOURCES", ",", "ReserveResources", ":", "&", "master", ".", "Call_ReserveResources", "{", "AgentID", ":", "a", ",", "Resources", ":", "r", ",", "}", ",", "}", "\n", "}" ]
// ReserveResources reserves resources dynamically on a specific agent.
[ "ReserveResources", "reserves", "resources", "dynamically", "on", "a", "specific", "agent", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L185-L193
12,977
mesos/mesos-go
api/v1/lib/master/calls/calls.go
UnreserveResources
func UnreserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_UNRESERVE_RESOURCES, UnreserveResources: &master.Call_UnreserveResources{ AgentID: a, Resources: r, }, } }
go
func UnreserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_UNRESERVE_RESOURCES, UnreserveResources: &master.Call_UnreserveResources{ AgentID: a, Resources: r, }, } }
[ "func", "UnreserveResources", "(", "a", "mesos", ".", "AgentID", ",", "r", "...", "mesos", ".", "Resource", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_UNRESERVE_RESOURCES", ",", "UnreserveResources", ":", "&", "master", ".", "Call_UnreserveResources", "{", "AgentID", ":", "a", ",", "Resources", ":", "r", ",", "}", ",", "}", "\n", "}" ]
// UnreserveResources unreserves resources dynamically on a specific agent.
[ "UnreserveResources", "unreserves", "resources", "dynamically", "on", "a", "specific", "agent", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L196-L204
12,978
mesos/mesos-go
api/v1/lib/master/calls/calls.go
CreateVolumes
func CreateVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_CREATE_VOLUMES, CreateVolumes: &master.Call_CreateVolumes{ AgentID: a, Volumes: v, }, } }
go
func CreateVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_CREATE_VOLUMES, CreateVolumes: &master.Call_CreateVolumes{ AgentID: a, Volumes: v, }, } }
[ "func", "CreateVolumes", "(", "a", "mesos", ".", "AgentID", ",", "v", "...", "mesos", ".", "Resource", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_CREATE_VOLUMES", ",", "CreateVolumes", ":", "&", "master", ".", "Call_CreateVolumes", "{", "AgentID", ":", "a", ",", "Volumes", ":", "v", ",", "}", ",", "}", "\n", "}" ]
// CreateVolumes creates persistent volumes on reserved resources. The request is forwarded asynchronously to the Mesos // agent where the reserved resources are located. That asynchronous message may not be delivered or creating the // volumes at the agent might fail.
[ "CreateVolumes", "creates", "persistent", "volumes", "on", "reserved", "resources", ".", "The", "request", "is", "forwarded", "asynchronously", "to", "the", "Mesos", "agent", "where", "the", "reserved", "resources", "are", "located", ".", "That", "asynchronous", "message", "may", "not", "be", "delivered", "or", "creating", "the", "volumes", "at", "the", "agent", "might", "fail", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L209-L217
12,979
mesos/mesos-go
api/v1/lib/master/calls/calls.go
DestroyVolumes
func DestroyVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_DESTROY_VOLUMES, DestroyVolumes: &master.Call_DestroyVolumes{ AgentID: a, Volumes: v, }, } }
go
func DestroyVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_DESTROY_VOLUMES, DestroyVolumes: &master.Call_DestroyVolumes{ AgentID: a, Volumes: v, }, } }
[ "func", "DestroyVolumes", "(", "a", "mesos", ".", "AgentID", ",", "v", "...", "mesos", ".", "Resource", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_DESTROY_VOLUMES", ",", "DestroyVolumes", ":", "&", "master", ".", "Call_DestroyVolumes", "{", "AgentID", ":", "a", ",", "Volumes", ":", "v", ",", "}", ",", "}", "\n", "}" ]
// DestroyVolumes destroys persistent volumes. The request is forwarded asynchronously to the Mesos agent where the // reserved resources are located.
[ "DestroyVolumes", "destroys", "persistent", "volumes", ".", "The", "request", "is", "forwarded", "asynchronously", "to", "the", "Mesos", "agent", "where", "the", "reserved", "resources", "are", "located", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L221-L229
12,980
mesos/mesos-go
api/v1/lib/master/calls/calls.go
GrowVolume
func GrowVolume(a *mesos.AgentID, volume, addition mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_GROW_VOLUME, GrowVolume: &master.Call_GrowVolume{ AgentID: a, Volume: volume, Addition: addition, }, } }
go
func GrowVolume(a *mesos.AgentID, volume, addition mesos.Resource) *master.Call { return &master.Call{ Type: master.Call_GROW_VOLUME, GrowVolume: &master.Call_GrowVolume{ AgentID: a, Volume: volume, Addition: addition, }, } }
[ "func", "GrowVolume", "(", "a", "*", "mesos", ".", "AgentID", ",", "volume", ",", "addition", "mesos", ".", "Resource", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_GROW_VOLUME", ",", "GrowVolume", ":", "&", "master", ".", "Call_GrowVolume", "{", "AgentID", ":", "a", ",", "Volume", ":", "volume", ",", "Addition", ":", "addition", ",", "}", ",", "}", "\n", "}" ]
// GrowVolume grows a persistent volume on an agent's ROOT or PATH disks. The request is forwarded asynchronously to // the Mesos agent where the persistent volume is located.
[ "GrowVolume", "grows", "a", "persistent", "volume", "on", "an", "agent", "s", "ROOT", "or", "PATH", "disks", ".", "The", "request", "is", "forwarded", "asynchronously", "to", "the", "Mesos", "agent", "where", "the", "persistent", "volume", "is", "located", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L233-L242
12,981
mesos/mesos-go
api/v1/lib/master/calls/calls.go
ShrinkVolume
func ShrinkVolume(a *mesos.AgentID, volume mesos.Resource, subtract mesos.Value_Scalar) *master.Call { return &master.Call{ Type: master.Call_SHRINK_VOLUME, ShrinkVolume: &master.Call_ShrinkVolume{ AgentID: a, Volume: volume, Subtract: subtract, }, } }
go
func ShrinkVolume(a *mesos.AgentID, volume mesos.Resource, subtract mesos.Value_Scalar) *master.Call { return &master.Call{ Type: master.Call_SHRINK_VOLUME, ShrinkVolume: &master.Call_ShrinkVolume{ AgentID: a, Volume: volume, Subtract: subtract, }, } }
[ "func", "ShrinkVolume", "(", "a", "*", "mesos", ".", "AgentID", ",", "volume", "mesos", ".", "Resource", ",", "subtract", "mesos", ".", "Value_Scalar", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_SHRINK_VOLUME", ",", "ShrinkVolume", ":", "&", "master", ".", "Call_ShrinkVolume", "{", "AgentID", ":", "a", ",", "Volume", ":", "volume", ",", "Subtract", ":", "subtract", ",", "}", ",", "}", "\n", "}" ]
// ShrinkVolume shrinks a persistent volume on an agent's ROOT or PATH disks. The request is forwarded asynchronously // to the Mesos agent where the persistent volume is located.
[ "ShrinkVolume", "shrinks", "a", "persistent", "volume", "on", "an", "agent", "s", "ROOT", "or", "PATH", "disks", ".", "The", "request", "is", "forwarded", "asynchronously", "to", "the", "Mesos", "agent", "where", "the", "persistent", "volume", "is", "located", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L246-L255
12,982
mesos/mesos-go
api/v1/lib/master/calls/calls.go
UpdateMaintenanceSchedule
func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call { return &master.Call{ Type: master.Call_UPDATE_MAINTENANCE_SCHEDULE, UpdateMaintenanceSchedule: &master.Call_UpdateMaintenanceSchedule{ Schedule: s, }, } }
go
func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call { return &master.Call{ Type: master.Call_UPDATE_MAINTENANCE_SCHEDULE, UpdateMaintenanceSchedule: &master.Call_UpdateMaintenanceSchedule{ Schedule: s, }, } }
[ "func", "UpdateMaintenanceSchedule", "(", "s", "maintenance", ".", "Schedule", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_UPDATE_MAINTENANCE_SCHEDULE", ",", "UpdateMaintenanceSchedule", ":", "&", "master", ".", "Call_UpdateMaintenanceSchedule", "{", "Schedule", ":", "s", ",", "}", ",", "}", "\n", "}" ]
// UpdateMaintenanceSchedule updates the cluster's maintenance schedule.
[ "UpdateMaintenanceSchedule", "updates", "the", "cluster", "s", "maintenance", "schedule", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L272-L279
12,983
mesos/mesos-go
api/v1/lib/master/calls/calls.go
StartMaintenance
func StartMaintenance(m ...mesos.MachineID) *master.Call { return &master.Call{ Type: master.Call_START_MAINTENANCE, StartMaintenance: &master.Call_StartMaintenance{ Machines: m, }, } }
go
func StartMaintenance(m ...mesos.MachineID) *master.Call { return &master.Call{ Type: master.Call_START_MAINTENANCE, StartMaintenance: &master.Call_StartMaintenance{ Machines: m, }, } }
[ "func", "StartMaintenance", "(", "m", "...", "mesos", ".", "MachineID", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_START_MAINTENANCE", ",", "StartMaintenance", ":", "&", "master", ".", "Call_StartMaintenance", "{", "Machines", ":", "m", ",", "}", ",", "}", "\n", "}" ]
// StartMaintenance starts the maintenance of the cluster, this would bring a set of machines down.
[ "StartMaintenance", "starts", "the", "maintenance", "of", "the", "cluster", "this", "would", "bring", "a", "set", "of", "machines", "down", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L282-L289
12,984
mesos/mesos-go
api/v1/lib/master/calls/calls.go
StopMaintenance
func StopMaintenance(m ...mesos.MachineID) *master.Call { return &master.Call{ Type: master.Call_STOP_MAINTENANCE, StopMaintenance: &master.Call_StopMaintenance{ Machines: m, }, } }
go
func StopMaintenance(m ...mesos.MachineID) *master.Call { return &master.Call{ Type: master.Call_STOP_MAINTENANCE, StopMaintenance: &master.Call_StopMaintenance{ Machines: m, }, } }
[ "func", "StopMaintenance", "(", "m", "...", "mesos", ".", "MachineID", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_STOP_MAINTENANCE", ",", "StopMaintenance", ":", "&", "master", ".", "Call_StopMaintenance", "{", "Machines", ":", "m", ",", "}", ",", "}", "\n", "}" ]
// StopMaintenance stops the maintenance of the cluster, this would bring a set of machines back up.
[ "StopMaintenance", "stops", "the", "maintenance", "of", "the", "cluster", "this", "would", "bring", "a", "set", "of", "machines", "back", "up", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L292-L299
12,985
mesos/mesos-go
api/v1/lib/master/calls/calls.go
SetQuota
func SetQuota(qr quota.QuotaRequest) *master.Call { return &master.Call{ Type: master.Call_SET_QUOTA, SetQuota: &master.Call_SetQuota{ QuotaRequest: qr, }, } }
go
func SetQuota(qr quota.QuotaRequest) *master.Call { return &master.Call{ Type: master.Call_SET_QUOTA, SetQuota: &master.Call_SetQuota{ QuotaRequest: qr, }, } }
[ "func", "SetQuota", "(", "qr", "quota", ".", "QuotaRequest", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_SET_QUOTA", ",", "SetQuota", ":", "&", "master", ".", "Call_SetQuota", "{", "QuotaRequest", ":", "qr", ",", "}", ",", "}", "\n", "}" ]
// SetQuota sets the quota for resources to be used by a particular role.
[ "SetQuota", "sets", "the", "quota", "for", "resources", "to", "be", "used", "by", "a", "particular", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L309-L316
12,986
mesos/mesos-go
api/v1/lib/master/calls/calls.go
RemoveQuota
func RemoveQuota(role string) *master.Call { return &master.Call{ Type: master.Call_REMOVE_QUOTA, RemoveQuota: &master.Call_RemoveQuota{ Role: role, }, } }
go
func RemoveQuota(role string) *master.Call { return &master.Call{ Type: master.Call_REMOVE_QUOTA, RemoveQuota: &master.Call_RemoveQuota{ Role: role, }, } }
[ "func", "RemoveQuota", "(", "role", "string", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_REMOVE_QUOTA", ",", "RemoveQuota", ":", "&", "master", ".", "Call_RemoveQuota", "{", "Role", ":", "role", ",", "}", ",", "}", "\n", "}" ]
// RemoveQuota removes the quota for a particular role.
[ "RemoveQuota", "removes", "the", "quota", "for", "a", "particular", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L319-L326
12,987
mesos/mesos-go
api/v1/lib/master/calls/calls.go
MarkAgentGone
func MarkAgentGone(id mesos.AgentID) *master.Call { return &master.Call{ Type: master.Call_MARK_AGENT_GONE, MarkAgentGone: &master.Call_MarkAgentGone{ AgentID: id, }, } }
go
func MarkAgentGone(id mesos.AgentID) *master.Call { return &master.Call{ Type: master.Call_MARK_AGENT_GONE, MarkAgentGone: &master.Call_MarkAgentGone{ AgentID: id, }, } }
[ "func", "MarkAgentGone", "(", "id", "mesos", ".", "AgentID", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_MARK_AGENT_GONE", ",", "MarkAgentGone", ":", "&", "master", ".", "Call_MarkAgentGone", "{", "AgentID", ":", "id", ",", "}", ",", "}", "\n", "}" ]
// MarkAgentGone removes the quota for a particular role.
[ "MarkAgentGone", "removes", "the", "quota", "for", "a", "particular", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L329-L336
12,988
mesos/mesos-go
api/v1/lib/master/calls/calls.go
Teardown
func Teardown(id mesos.FrameworkID) *master.Call { return &master.Call{ Type: master.Call_TEARDOWN, Teardown: &master.Call_Teardown{ FrameworkID: id, }, } }
go
func Teardown(id mesos.FrameworkID) *master.Call { return &master.Call{ Type: master.Call_TEARDOWN, Teardown: &master.Call_Teardown{ FrameworkID: id, }, } }
[ "func", "Teardown", "(", "id", "mesos", ".", "FrameworkID", ")", "*", "master", ".", "Call", "{", "return", "&", "master", ".", "Call", "{", "Type", ":", "master", ".", "Call_TEARDOWN", ",", "Teardown", ":", "&", "master", ".", "Call_Teardown", "{", "FrameworkID", ":", "id", ",", "}", ",", "}", "\n", "}" ]
// Teardown removes the quota for a particular role.
[ "Teardown", "removes", "the", "quota", "for", "a", "particular", "role", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls.go#L339-L346
12,989
mesos/mesos-go
api/v1/lib/resources/builders.go
Span
func (rb *RangeBuilder) Span(bp, ep uint64) *RangeBuilder { rb.Ranges = append(rb.Ranges, mesos.Value_Range{Begin: bp, End: ep}) return rb }
go
func (rb *RangeBuilder) Span(bp, ep uint64) *RangeBuilder { rb.Ranges = append(rb.Ranges, mesos.Value_Range{Begin: bp, End: ep}) return rb }
[ "func", "(", "rb", "*", "RangeBuilder", ")", "Span", "(", "bp", ",", "ep", "uint64", ")", "*", "RangeBuilder", "{", "rb", ".", "Ranges", "=", "append", "(", "rb", ".", "Ranges", ",", "mesos", ".", "Value_Range", "{", "Begin", ":", "bp", ",", "End", ":", "ep", "}", ")", "\n", "return", "rb", "\n", "}" ]
// Span is a functional option for Ranges, defines the begin and end points of a // continuous span within a range
[ "Span", "is", "a", "functional", "option", "for", "Ranges", "defines", "the", "begin", "and", "end", "points", "of", "a", "continuous", "span", "within", "a", "range" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/resources/builders.go#L38-L41
12,990
mesos/mesos-go
api/v1/lib/scheduler/events/events_generated.go
Otherwise
func (hs Handlers) Otherwise(f HandlerFunc) HandlerFunc { if f == nil { return hs.HandleEvent } return func(ctx context.Context, e *scheduler.Event) error { if h := hs[e.GetType()]; h != nil { return h.HandleEvent(ctx, e) } return f(ctx, e) } }
go
func (hs Handlers) Otherwise(f HandlerFunc) HandlerFunc { if f == nil { return hs.HandleEvent } return func(ctx context.Context, e *scheduler.Event) error { if h := hs[e.GetType()]; h != nil { return h.HandleEvent(ctx, e) } return f(ctx, e) } }
[ "func", "(", "hs", "Handlers", ")", "Otherwise", "(", "f", "HandlerFunc", ")", "HandlerFunc", "{", "if", "f", "==", "nil", "{", "return", "hs", ".", "HandleEvent", "\n", "}", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ")", "error", "{", "if", "h", ":=", "hs", "[", "e", ".", "GetType", "(", ")", "]", ";", "h", "!=", "nil", "{", "return", "h", ".", "HandleEvent", "(", "ctx", ",", "e", ")", "\n", "}", "\n", "return", "f", "(", "ctx", ",", "e", ")", "\n", "}", "\n", "}" ]
// Otherwise returns a HandlerFunc that attempts to process an event with the Handlers map; unmatched event types are // processed by the given HandlerFunc. A nil HandlerFunc parameter is effecitvely a noop.
[ "Otherwise", "returns", "a", "HandlerFunc", "that", "attempts", "to", "process", "an", "event", "with", "the", "Handlers", "map", ";", "unmatched", "event", "types", "are", "processed", "by", "the", "given", "HandlerFunc", ".", "A", "nil", "HandlerFunc", "parameter", "is", "effecitvely", "a", "noop", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/events/events_generated.go#L57-L67
12,991
mesos/mesos-go
api/v0/messenger/decoder.go
Cancel
func (d *httpDecoder) Cancel(graceful bool) { log.V(2).Infof("%scancel:%t", d.idtag, graceful) d.cancelGuard.Lock() defer d.cancelGuard.Unlock() select { case <-d.shouldQuit: // already quitting, but perhaps gracefully? default: close(d.shouldQuit) } // allow caller to "upgrade" from a graceful cancel to a forced one if !graceful { select { case <-d.forceQuit: // already forcefully quitting default: close(d.forceQuit) // push it! } } }
go
func (d *httpDecoder) Cancel(graceful bool) { log.V(2).Infof("%scancel:%t", d.idtag, graceful) d.cancelGuard.Lock() defer d.cancelGuard.Unlock() select { case <-d.shouldQuit: // already quitting, but perhaps gracefully? default: close(d.shouldQuit) } // allow caller to "upgrade" from a graceful cancel to a forced one if !graceful { select { case <-d.forceQuit: // already forcefully quitting default: close(d.forceQuit) // push it! } } }
[ "func", "(", "d", "*", "httpDecoder", ")", "Cancel", "(", "graceful", "bool", ")", "{", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "d", ".", "idtag", ",", "graceful", ")", "\n", "d", ".", "cancelGuard", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "cancelGuard", ".", "Unlock", "(", ")", "\n", "select", "{", "case", "<-", "d", ".", "shouldQuit", ":", "// already quitting, but perhaps gracefully?", "default", ":", "close", "(", "d", ".", "shouldQuit", ")", "\n", "}", "\n", "// allow caller to \"upgrade\" from a graceful cancel to a forced one", "if", "!", "graceful", "{", "select", "{", "case", "<-", "d", ".", "forceQuit", ":", "// already forcefully quitting", "default", ":", "close", "(", "d", ".", "forceQuit", ")", "// push it!", "\n", "}", "\n", "}", "\n", "}" ]
// Cancel the decoding process; if graceful then process pending responses before terminating
[ "Cancel", "the", "decoding", "process", ";", "if", "graceful", "then", "process", "pending", "responses", "before", "terminating" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/decoder.go#L113-L132
12,992
mesos/mesos-go
api/v0/messenger/decoder.go
updateForRequest
func (d *httpDecoder) updateForRequest(bootstrapping bool) { // check "Transfer-Encoding" for "chunked" d.chunked = false for _, v := range d.req.Header["Transfer-Encoding"] { if v == "chunked" { d.chunked = true break } } if !d.chunked && d.req.ContentLength < 0 { if bootstrapping { // strongly suspect that Go's internal net/http lib is stripping // the Transfer-Encoding header from the initial request, so this // workaround makes a very mesos-specific assumption: an unknown // Content-Length indicates a chunked stream. d.chunked = true } else { // via https://tools.ietf.org/html/rfc7230#section-3.3.2 d.req.ContentLength = 0 } } // check "Connection" for "Keep-Alive" d.kalive = d.req.Header.Get("Connection") == "Keep-Alive" log.V(2).Infof(d.idtag+"update-for-request: chunked %v keep-alive %v", d.chunked, d.kalive) }
go
func (d *httpDecoder) updateForRequest(bootstrapping bool) { // check "Transfer-Encoding" for "chunked" d.chunked = false for _, v := range d.req.Header["Transfer-Encoding"] { if v == "chunked" { d.chunked = true break } } if !d.chunked && d.req.ContentLength < 0 { if bootstrapping { // strongly suspect that Go's internal net/http lib is stripping // the Transfer-Encoding header from the initial request, so this // workaround makes a very mesos-specific assumption: an unknown // Content-Length indicates a chunked stream. d.chunked = true } else { // via https://tools.ietf.org/html/rfc7230#section-3.3.2 d.req.ContentLength = 0 } } // check "Connection" for "Keep-Alive" d.kalive = d.req.Header.Get("Connection") == "Keep-Alive" log.V(2).Infof(d.idtag+"update-for-request: chunked %v keep-alive %v", d.chunked, d.kalive) }
[ "func", "(", "d", "*", "httpDecoder", ")", "updateForRequest", "(", "bootstrapping", "bool", ")", "{", "// check \"Transfer-Encoding\" for \"chunked\"", "d", ".", "chunked", "=", "false", "\n", "for", "_", ",", "v", ":=", "range", "d", ".", "req", ".", "Header", "[", "\"", "\"", "]", "{", "if", "v", "==", "\"", "\"", "{", "d", ".", "chunked", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "d", ".", "chunked", "&&", "d", ".", "req", ".", "ContentLength", "<", "0", "{", "if", "bootstrapping", "{", "// strongly suspect that Go's internal net/http lib is stripping", "// the Transfer-Encoding header from the initial request, so this", "// workaround makes a very mesos-specific assumption: an unknown", "// Content-Length indicates a chunked stream.", "d", ".", "chunked", "=", "true", "\n", "}", "else", "{", "// via https://tools.ietf.org/html/rfc7230#section-3.3.2", "d", ".", "req", ".", "ContentLength", "=", "0", "\n", "}", "\n", "}", "\n\n", "// check \"Connection\" for \"Keep-Alive\"", "d", ".", "kalive", "=", "d", ".", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "==", "\"", "\"", "\n\n", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "d", ".", "idtag", "+", "\"", "\"", ",", "d", ".", "chunked", ",", "d", ".", "kalive", ")", "\n", "}" ]
// updateForRequest updates the chunked and kalive fields of the decoder to align // with the header values of the request
[ "updateForRequest", "updates", "the", "chunked", "and", "kalive", "fields", "of", "the", "decoder", "to", "align", "with", "the", "header", "values", "of", "the", "request" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/decoder.go#L204-L230
12,993
mesos/mesos-go
api/v0/messenger/decoder.go
terminateState
func terminateState(d *httpDecoder) httpState { log.V(2).Infoln(d.idtag + "terminate-state") // closing these chans tells Decoder users that it's wrapping up close(d.msg) close(d.errCh) // attempt to forcefully close the connection and signal response handlers that // no further responses should be written d.Cancel(false) if d.con != nil { d.con.Close() } // there is no spoon return nil }
go
func terminateState(d *httpDecoder) httpState { log.V(2).Infoln(d.idtag + "terminate-state") // closing these chans tells Decoder users that it's wrapping up close(d.msg) close(d.errCh) // attempt to forcefully close the connection and signal response handlers that // no further responses should be written d.Cancel(false) if d.con != nil { d.con.Close() } // there is no spoon return nil }
[ "func", "terminateState", "(", "d", "*", "httpDecoder", ")", "httpState", "{", "log", ".", "V", "(", "2", ")", ".", "Infoln", "(", "d", ".", "idtag", "+", "\"", "\"", ")", "\n", "// closing these chans tells Decoder users that it's wrapping up", "close", "(", "d", ".", "msg", ")", "\n", "close", "(", "d", ".", "errCh", ")", "\n\n", "// attempt to forcefully close the connection and signal response handlers that", "// no further responses should be written", "d", ".", "Cancel", "(", "false", ")", "\n\n", "if", "d", ".", "con", "!=", "nil", "{", "d", ".", "con", ".", "Close", "(", ")", "\n", "}", "\n\n", "// there is no spoon", "return", "nil", "\n", "}" ]
// terminateState forcefully shuts down the state machine
[ "terminateState", "forcefully", "shuts", "down", "the", "state", "machine" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/decoder.go#L307-L323
12,994
mesos/mesos-go
api/v0/messenger/decoder.go
checkTimeoutOrFail
func (d *httpDecoder) checkTimeoutOrFail(err error, stateContinue httpState) (httpState, bool) { if err != nil { if neterr, ok := err.(net.Error); ok && neterr.Timeout() { select { case <-d.forceQuit: return terminateState, true case <-d.shouldQuit: return gracefulTerminateState, true default: return stateContinue, true } } d.sendError(err) return terminateState, true } return nil, false }
go
func (d *httpDecoder) checkTimeoutOrFail(err error, stateContinue httpState) (httpState, bool) { if err != nil { if neterr, ok := err.(net.Error); ok && neterr.Timeout() { select { case <-d.forceQuit: return terminateState, true case <-d.shouldQuit: return gracefulTerminateState, true default: return stateContinue, true } } d.sendError(err) return terminateState, true } return nil, false }
[ "func", "(", "d", "*", "httpDecoder", ")", "checkTimeoutOrFail", "(", "err", "error", ",", "stateContinue", "httpState", ")", "(", "httpState", ",", "bool", ")", "{", "if", "err", "!=", "nil", "{", "if", "neterr", ",", "ok", ":=", "err", ".", "(", "net", ".", "Error", ")", ";", "ok", "&&", "neterr", ".", "Timeout", "(", ")", "{", "select", "{", "case", "<-", "d", ".", "forceQuit", ":", "return", "terminateState", ",", "true", "\n", "case", "<-", "d", ".", "shouldQuit", ":", "return", "gracefulTerminateState", ",", "true", "\n", "default", ":", "return", "stateContinue", ",", "true", "\n", "}", "\n", "}", "\n", "d", ".", "sendError", "(", "err", ")", "\n", "return", "terminateState", ",", "true", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
// checkTimeoutOrFail tests whether the given error is related to a timeout condition. // returns true if the caller should advance to the returned state.
[ "checkTimeoutOrFail", "tests", "whether", "the", "given", "error", "is", "related", "to", "a", "timeout", "condition", ".", "returns", "true", "if", "the", "caller", "should", "advance", "to", "the", "returned", "state", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/decoder.go#L412-L428
12,995
mesos/mesos-go
api/v1/lib/extras/executor/eventrules/eventrules_generated.go
Eval
func (rs Rules) Eval(ctx context.Context, e *executor.Event, err error, ch Chain) (context.Context, *executor.Event, error) { return ch(rs.Chain()(ctx, e, err)) }
go
func (rs Rules) Eval(ctx context.Context, e *executor.Event, err error, ch Chain) (context.Context, *executor.Event, error) { return ch(rs.Chain()(ctx, e, err)) }
[ "func", "(", "rs", "Rules", ")", "Eval", "(", "ctx", "context", ".", "Context", ",", "e", "*", "executor", ".", "Event", ",", "err", "error", ",", "ch", "Chain", ")", "(", "context", ".", "Context", ",", "*", "executor", ".", "Event", ",", "error", ")", "{", "return", "ch", "(", "rs", ".", "Chain", "(", ")", "(", "ctx", ",", "e", ",", "err", ")", ")", "\n", "}" ]
// Eval is a Rule func that processes the set of all Rules. If there are no rules in the // set then control is simply passed to the Chain.
[ "Eval", "is", "a", "Rule", "func", "that", "processes", "the", "set", "of", "all", "Rules", ".", "If", "there", "are", "no", "rules", "in", "the", "set", "then", "control", "is", "simply", "passed", "to", "the", "Chain", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/executor/eventrules/eventrules_generated.go#L62-L64
12,996
mesos/mesos-go
api/v1/lib/httpcli/httpsched/httpsched.go
MaxRedirects
func MaxRedirects(mr int) Option { return func(c *client) Option { old := c.redirect.MaxAttempts c.redirect.MaxAttempts = mr return MaxRedirects(old) } }
go
func MaxRedirects(mr int) Option { return func(c *client) Option { old := c.redirect.MaxAttempts c.redirect.MaxAttempts = mr return MaxRedirects(old) } }
[ "func", "MaxRedirects", "(", "mr", "int", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "Option", "{", "old", ":=", "c", ".", "redirect", ".", "MaxAttempts", "\n", "c", ".", "redirect", ".", "MaxAttempts", "=", "mr", "\n", "return", "MaxRedirects", "(", "old", ")", "\n", "}", "\n", "}" ]
// MaxRedirects is a functional option that sets the maximum number of per-call HTTP redirects for a scheduler client
[ "MaxRedirects", "is", "a", "functional", "option", "that", "sets", "the", "maximum", "number", "of", "per", "-", "call", "HTTP", "redirects", "for", "a", "scheduler", "client" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/httpsched/httpsched.go#L123-L129
12,997
mesos/mesos-go
api/v1/lib/httpcli/httpsched/httpsched.go
AllowReconnection
func AllowReconnection(v bool) Option { return func(c *client) Option { old := c.allowReconnect c.allowReconnect = v return AllowReconnection(old) } }
go
func AllowReconnection(v bool) Option { return func(c *client) Option { old := c.allowReconnect c.allowReconnect = v return AllowReconnection(old) } }
[ "func", "AllowReconnection", "(", "v", "bool", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "Option", "{", "old", ":=", "c", ".", "allowReconnect", "\n", "c", ".", "allowReconnect", "=", "v", "\n", "return", "AllowReconnection", "(", "old", ")", "\n", "}", "\n", "}" ]
// AllowReconnection allows a subsequent SUBSCRIBE call before a prior SUBSCRIBE has experienced a network // or protocol error. Useful in concert with heartbeat detection and for other edge error cases not handled // by the connection state machine.
[ "AllowReconnection", "allows", "a", "subsequent", "SUBSCRIBE", "call", "before", "a", "prior", "SUBSCRIBE", "has", "experienced", "a", "network", "or", "protocol", "error", ".", "Useful", "in", "concert", "with", "heartbeat", "detection", "and", "for", "other", "edge", "error", "cases", "not", "handled", "by", "the", "connection", "state", "machine", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/httpsched/httpsched.go#L134-L140
12,998
mesos/mesos-go
api/v1/lib/httpcli/httpsched/httpsched.go
NewCaller
func NewCaller(cl *httpcli.Client, opts ...Option) calls.Caller { result := &client{Client: cl, redirect: DefaultRedirectSettings} cl.With(result.redirectHandler()) for _, o := range opts { if o != nil { o(result) } } return &state{ client: result, fn: disconnectedFn, } }
go
func NewCaller(cl *httpcli.Client, opts ...Option) calls.Caller { result := &client{Client: cl, redirect: DefaultRedirectSettings} cl.With(result.redirectHandler()) for _, o := range opts { if o != nil { o(result) } } return &state{ client: result, fn: disconnectedFn, } }
[ "func", "NewCaller", "(", "cl", "*", "httpcli", ".", "Client", ",", "opts", "...", "Option", ")", "calls", ".", "Caller", "{", "result", ":=", "&", "client", "{", "Client", ":", "cl", ",", "redirect", ":", "DefaultRedirectSettings", "}", "\n", "cl", ".", "With", "(", "result", ".", "redirectHandler", "(", ")", ")", "\n", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "o", "!=", "nil", "{", "o", "(", "result", ")", "\n", "}", "\n", "}", "\n", "return", "&", "state", "{", "client", ":", "result", ",", "fn", ":", "disconnectedFn", ",", "}", "\n", "}" ]
// NewCaller returns a scheduler API Client in the form of a Caller. Concurrent invocations // of Call upon the returned caller are safely executed in a serial fashion. It is expected that // there are no other users of the given Client since its state may be modified by this impl.
[ "NewCaller", "returns", "a", "scheduler", "API", "Client", "in", "the", "form", "of", "a", "Caller", ".", "Concurrent", "invocations", "of", "Call", "upon", "the", "returned", "caller", "are", "safely", "executed", "in", "a", "serial", "fashion", ".", "It", "is", "expected", "that", "there", "are", "no", "other", "users", "of", "the", "given", "Client", "since", "its", "state", "may", "be", "modified", "by", "this", "impl", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/httpsched/httpsched.go#L153-L165
12,999
mesos/mesos-go
api/v1/lib/httpcli/httpsched/httpsched.go
Call
func (cli *client) Call(ctx context.Context, call *scheduler.Call) (mesos.Response, error) { return cli.httpDo(ctx, call) }
go
func (cli *client) Call(ctx context.Context, call *scheduler.Call) (mesos.Response, error) { return cli.httpDo(ctx, call) }
[ "func", "(", "cli", "*", "client", ")", "Call", "(", "ctx", "context", ".", "Context", ",", "call", "*", "scheduler", ".", "Call", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "return", "cli", ".", "httpDo", "(", "ctx", ",", "call", ")", "\n", "}" ]
// Call implements Client
[ "Call", "implements", "Client" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/httpsched/httpsched.go#L230-L232