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
13,000
mesos/mesos-go
api/v1/lib/httpcli/httpsched/httpsched.go
redirectHandler
func (cli *client) redirectHandler() httpcli.Opt { return httpcli.HandleResponse(func(hres *http.Response, rc mesosclient.ResponseClass, err error) (mesos.Response, error) { resp, err := cli.HandleResponse(hres, rc, err) // default response handler if err == nil || !apierrors.CodeNotLeader.Matches(err) { return resp, err } // TODO(jdef) for now, we're tightly coupled to the httpcli package's Response type res, ok := resp.(*httpcli.Response) if !ok { if resp != nil { resp.Close() } return nil, errNotHTTPCli } if debug { log.Println("master changed?") } location, ok := buildNewEndpoint(res.Header.Get("Location"), cli.Endpoint()) if !ok { return nil, errBadLocation } res.Close() return nil, &mesosRedirectionError{location} }) }
go
func (cli *client) redirectHandler() httpcli.Opt { return httpcli.HandleResponse(func(hres *http.Response, rc mesosclient.ResponseClass, err error) (mesos.Response, error) { resp, err := cli.HandleResponse(hres, rc, err) // default response handler if err == nil || !apierrors.CodeNotLeader.Matches(err) { return resp, err } // TODO(jdef) for now, we're tightly coupled to the httpcli package's Response type res, ok := resp.(*httpcli.Response) if !ok { if resp != nil { resp.Close() } return nil, errNotHTTPCli } if debug { log.Println("master changed?") } location, ok := buildNewEndpoint(res.Header.Get("Location"), cli.Endpoint()) if !ok { return nil, errBadLocation } res.Close() return nil, &mesosRedirectionError{location} }) }
[ "func", "(", "cli", "*", "client", ")", "redirectHandler", "(", ")", "httpcli", ".", "Opt", "{", "return", "httpcli", ".", "HandleResponse", "(", "func", "(", "hres", "*", "http", ".", "Response", ",", "rc", "mesosclient", ".", "ResponseClass", ",", "err", "error", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "resp", ",", "err", ":=", "cli", ".", "HandleResponse", "(", "hres", ",", "rc", ",", "err", ")", "// default response handler", "\n", "if", "err", "==", "nil", "||", "!", "apierrors", ".", "CodeNotLeader", ".", "Matches", "(", "err", ")", "{", "return", "resp", ",", "err", "\n", "}", "\n", "// TODO(jdef) for now, we're tightly coupled to the httpcli package's Response type", "res", ",", "ok", ":=", "resp", ".", "(", "*", "httpcli", ".", "Response", ")", "\n", "if", "!", "ok", "{", "if", "resp", "!=", "nil", "{", "resp", ".", "Close", "(", ")", "\n", "}", "\n", "return", "nil", ",", "errNotHTTPCli", "\n", "}", "\n", "if", "debug", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "location", ",", "ok", ":=", "buildNewEndpoint", "(", "res", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ",", "cli", ".", "Endpoint", "(", ")", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errBadLocation", "\n", "}", "\n", "res", ".", "Close", "(", ")", "\n", "return", "nil", ",", "&", "mesosRedirectionError", "{", "location", "}", "\n", "}", ")", "\n", "}" ]
// redirectHandler returns a config options that decorates the default response handling routine; // it transforms normal Mesos redirect "errors" into mesosRedirectionErrors by parsing the Location // header and computing the address of the next endpoint that should be used to replay the failed // HTTP request.
[ "redirectHandler", "returns", "a", "config", "options", "that", "decorates", "the", "default", "response", "handling", "routine", ";", "it", "transforms", "normal", "Mesos", "redirect", "errors", "into", "mesosRedirectionErrors", "by", "parsing", "the", "Location", "header", "and", "computing", "the", "address", "of", "the", "next", "endpoint", "that", "should", "be", "used", "to", "replay", "the", "failed", "HTTP", "request", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/httpsched/httpsched.go#L244-L268
13,001
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Filters
func Filters(fo ...mesos.FilterOpt) scheduler.CallOpt { return func(c *scheduler.Call) { switch c.Type { case scheduler.Call_ACCEPT: c.Accept.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_ACCEPT_INVERSE_OFFERS: c.AcceptInverseOffers.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_DECLINE: c.Decline.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_DECLINE_INVERSE_OFFERS: c.DeclineInverseOffers.Filters = mesos.OptionalFilters(fo...) default: panic("filters not supported for type " + c.Type.String()) } } }
go
func Filters(fo ...mesos.FilterOpt) scheduler.CallOpt { return func(c *scheduler.Call) { switch c.Type { case scheduler.Call_ACCEPT: c.Accept.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_ACCEPT_INVERSE_OFFERS: c.AcceptInverseOffers.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_DECLINE: c.Decline.Filters = mesos.OptionalFilters(fo...) case scheduler.Call_DECLINE_INVERSE_OFFERS: c.DeclineInverseOffers.Filters = mesos.OptionalFilters(fo...) default: panic("filters not supported for type " + c.Type.String()) } } }
[ "func", "Filters", "(", "fo", "...", "mesos", ".", "FilterOpt", ")", "scheduler", ".", "CallOpt", "{", "return", "func", "(", "c", "*", "scheduler", ".", "Call", ")", "{", "switch", "c", ".", "Type", "{", "case", "scheduler", ".", "Call_ACCEPT", ":", "c", ".", "Accept", ".", "Filters", "=", "mesos", ".", "OptionalFilters", "(", "fo", "...", ")", "\n", "case", "scheduler", ".", "Call_ACCEPT_INVERSE_OFFERS", ":", "c", ".", "AcceptInverseOffers", ".", "Filters", "=", "mesos", ".", "OptionalFilters", "(", "fo", "...", ")", "\n", "case", "scheduler", ".", "Call_DECLINE", ":", "c", ".", "Decline", ".", "Filters", "=", "mesos", ".", "OptionalFilters", "(", "fo", "...", ")", "\n", "case", "scheduler", ".", "Call_DECLINE_INVERSE_OFFERS", ":", "c", ".", "DeclineInverseOffers", ".", "Filters", "=", "mesos", ".", "OptionalFilters", "(", "fo", "...", ")", "\n", "default", ":", "panic", "(", "\"", "\"", "+", "c", ".", "Type", ".", "String", "(", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Filters sets a scheduler.Call's internal Filters, required for Accept and Decline calls.
[ "Filters", "sets", "a", "scheduler", ".", "Call", "s", "internal", "Filters", "required", "for", "Accept", "and", "Decline", "calls", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L13-L28
13,002
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
RefuseSecondsWithJitter
func RefuseSecondsWithJitter(r *rand.Rand, d time.Duration) scheduler.CallOpt { return Filters(func(f *mesos.Filters) { s := time.Duration(r.Int63n(int64(d))).Seconds() f.RefuseSeconds = &s }) }
go
func RefuseSecondsWithJitter(r *rand.Rand, d time.Duration) scheduler.CallOpt { return Filters(func(f *mesos.Filters) { s := time.Duration(r.Int63n(int64(d))).Seconds() f.RefuseSeconds = &s }) }
[ "func", "RefuseSecondsWithJitter", "(", "r", "*", "rand", ".", "Rand", ",", "d", "time", ".", "Duration", ")", "scheduler", ".", "CallOpt", "{", "return", "Filters", "(", "func", "(", "f", "*", "mesos", ".", "Filters", ")", "{", "s", ":=", "time", ".", "Duration", "(", "r", ".", "Int63n", "(", "int64", "(", "d", ")", ")", ")", ".", "Seconds", "(", ")", "\n", "f", ".", "RefuseSeconds", "=", "&", "s", "\n", "}", ")", "\n", "}" ]
// RefuseSecondsWithJitter returns a calls.Filters option that sets RefuseSeconds to a random number // of seconds between 0 and the given duration.
[ "RefuseSecondsWithJitter", "returns", "a", "calls", ".", "Filters", "option", "that", "sets", "RefuseSeconds", "to", "a", "random", "number", "of", "seconds", "between", "0", "and", "the", "given", "duration", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L32-L37
13,003
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
RefuseSeconds
func RefuseSeconds(d time.Duration) scheduler.CallOpt { asFloat := d.Seconds() return Filters(func(f *mesos.Filters) { f.RefuseSeconds = &asFloat }) }
go
func RefuseSeconds(d time.Duration) scheduler.CallOpt { asFloat := d.Seconds() return Filters(func(f *mesos.Filters) { f.RefuseSeconds = &asFloat }) }
[ "func", "RefuseSeconds", "(", "d", "time", ".", "Duration", ")", "scheduler", ".", "CallOpt", "{", "asFloat", ":=", "d", ".", "Seconds", "(", ")", "\n", "return", "Filters", "(", "func", "(", "f", "*", "mesos", ".", "Filters", ")", "{", "f", ".", "RefuseSeconds", "=", "&", "asFloat", "\n", "}", ")", "\n", "}" ]
// RefuseSeconds returns a calls.Filters option that sets RefuseSeconds to the given duration
[ "RefuseSeconds", "returns", "a", "calls", ".", "Filters", "option", "that", "sets", "RefuseSeconds", "to", "the", "given", "duration" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L40-L45
13,004
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Subscribe
func Subscribe(info *mesos.FrameworkInfo) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SUBSCRIBE, FrameworkID: info.GetID(), Subscribe: &scheduler.Call_Subscribe{FrameworkInfo: info}, } }
go
func Subscribe(info *mesos.FrameworkInfo) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SUBSCRIBE, FrameworkID: info.GetID(), Subscribe: &scheduler.Call_Subscribe{FrameworkInfo: info}, } }
[ "func", "Subscribe", "(", "info", "*", "mesos", ".", "FrameworkInfo", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_SUBSCRIBE", ",", "FrameworkID", ":", "info", ".", "GetID", "(", ")", ",", "Subscribe", ":", "&", "scheduler", ".", "Call_Subscribe", "{", "FrameworkInfo", ":", "info", "}", ",", "}", "\n", "}" ]
// Subscribe returns a subscribe call with the given parameters. // The call's FrameworkID is automatically filled in from the info specification.
[ "Subscribe", "returns", "a", "subscribe", "call", "with", "the", "given", "parameters", ".", "The", "call", "s", "FrameworkID", "is", "automatically", "filled", "in", "from", "the", "info", "specification", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L56-L62
13,005
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Accept
func Accept(ops ...AcceptOpt) *scheduler.Call { ab := &acceptBuilder{ offerIDs: make(map[mesos.OfferID]struct{}, len(ops)), } for _, op := range ops { op(ab) } offerIDs := make([]mesos.OfferID, 0, len(ab.offerIDs)) for id := range ab.offerIDs { offerIDs = append(offerIDs, id) } return &scheduler.Call{ Type: scheduler.Call_ACCEPT, Accept: &scheduler.Call_Accept{ OfferIDs: offerIDs, Operations: ab.operations, }, } }
go
func Accept(ops ...AcceptOpt) *scheduler.Call { ab := &acceptBuilder{ offerIDs: make(map[mesos.OfferID]struct{}, len(ops)), } for _, op := range ops { op(ab) } offerIDs := make([]mesos.OfferID, 0, len(ab.offerIDs)) for id := range ab.offerIDs { offerIDs = append(offerIDs, id) } return &scheduler.Call{ Type: scheduler.Call_ACCEPT, Accept: &scheduler.Call_Accept{ OfferIDs: offerIDs, Operations: ab.operations, }, } }
[ "func", "Accept", "(", "ops", "...", "AcceptOpt", ")", "*", "scheduler", ".", "Call", "{", "ab", ":=", "&", "acceptBuilder", "{", "offerIDs", ":", "make", "(", "map", "[", "mesos", ".", "OfferID", "]", "struct", "{", "}", ",", "len", "(", "ops", ")", ")", ",", "}", "\n", "for", "_", ",", "op", ":=", "range", "ops", "{", "op", "(", "ab", ")", "\n", "}", "\n", "offerIDs", ":=", "make", "(", "[", "]", "mesos", ".", "OfferID", ",", "0", ",", "len", "(", "ab", ".", "offerIDs", ")", ")", "\n", "for", "id", ":=", "range", "ab", ".", "offerIDs", "{", "offerIDs", "=", "append", "(", "offerIDs", ",", "id", ")", "\n", "}", "\n", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_ACCEPT", ",", "Accept", ":", "&", "scheduler", ".", "Call_Accept", "{", "OfferIDs", ":", "offerIDs", ",", "Operations", ":", "ab", ".", "operations", ",", "}", ",", "}", "\n", "}" ]
// Accept returns an accept call with the given parameters. // Callers are expected to fill in the FrameworkID and Filters.
[ "Accept", "returns", "an", "accept", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "and", "Filters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L103-L121
13,006
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
AcceptInverseOffers
func AcceptInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_ACCEPT_INVERSE_OFFERS, AcceptInverseOffers: &scheduler.Call_AcceptInverseOffers{ InverseOfferIDs: offerIDs, }, } }
go
func AcceptInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_ACCEPT_INVERSE_OFFERS, AcceptInverseOffers: &scheduler.Call_AcceptInverseOffers{ InverseOfferIDs: offerIDs, }, } }
[ "func", "AcceptInverseOffers", "(", "offerIDs", "...", "mesos", ".", "OfferID", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_ACCEPT_INVERSE_OFFERS", ",", "AcceptInverseOffers", ":", "&", "scheduler", ".", "Call_AcceptInverseOffers", "{", "InverseOfferIDs", ":", "offerIDs", ",", "}", ",", "}", "\n", "}" ]
// AcceptInverseOffers returns an accept-inverse-offers call for the given offer IDs. // Callers are expected to fill in the FrameworkID and Filters.
[ "AcceptInverseOffers", "returns", "an", "accept", "-", "inverse", "-", "offers", "call", "for", "the", "given", "offer", "IDs", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "and", "Filters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L125-L132
13,007
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
DeclineInverseOffers
func DeclineInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_DECLINE_INVERSE_OFFERS, DeclineInverseOffers: &scheduler.Call_DeclineInverseOffers{ InverseOfferIDs: offerIDs, }, } }
go
func DeclineInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_DECLINE_INVERSE_OFFERS, DeclineInverseOffers: &scheduler.Call_DeclineInverseOffers{ InverseOfferIDs: offerIDs, }, } }
[ "func", "DeclineInverseOffers", "(", "offerIDs", "...", "mesos", ".", "OfferID", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_DECLINE_INVERSE_OFFERS", ",", "DeclineInverseOffers", ":", "&", "scheduler", ".", "Call_DeclineInverseOffers", "{", "InverseOfferIDs", ":", "offerIDs", ",", "}", ",", "}", "\n", "}" ]
// DeclineInverseOffers returns a decline-inverse-offers call for the given offer IDs. // Callers are expected to fill in the FrameworkID and Filters.
[ "DeclineInverseOffers", "returns", "a", "decline", "-", "inverse", "-", "offers", "call", "for", "the", "given", "offer", "IDs", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "and", "Filters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L136-L143
13,008
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
OpLaunch
func OpLaunch(ti ...mesos.TaskInfo) mesos.Offer_Operation { return mesos.Offer_Operation{ Type: mesos.Offer_Operation_LAUNCH, Launch: &mesos.Offer_Operation_Launch{ TaskInfos: ti, }, } }
go
func OpLaunch(ti ...mesos.TaskInfo) mesos.Offer_Operation { return mesos.Offer_Operation{ Type: mesos.Offer_Operation_LAUNCH, Launch: &mesos.Offer_Operation_Launch{ TaskInfos: ti, }, } }
[ "func", "OpLaunch", "(", "ti", "...", "mesos", ".", "TaskInfo", ")", "mesos", ".", "Offer_Operation", "{", "return", "mesos", ".", "Offer_Operation", "{", "Type", ":", "mesos", ".", "Offer_Operation_LAUNCH", ",", "Launch", ":", "&", "mesos", ".", "Offer_Operation_Launch", "{", "TaskInfos", ":", "ti", ",", "}", ",", "}", "\n", "}" ]
// OpLaunch returns a launch operation builder for the given tasks
[ "OpLaunch", "returns", "a", "launch", "operation", "builder", "for", "the", "given", "tasks" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L146-L153
13,009
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
ReviveWith
func ReviveWith(roles []string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_REVIVE, Revive: &scheduler.Call_Revive{Roles: roles}, } }
go
func ReviveWith(roles []string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_REVIVE, Revive: &scheduler.Call_Revive{Roles: roles}, } }
[ "func", "ReviveWith", "(", "roles", "[", "]", "string", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_REVIVE", ",", "Revive", ":", "&", "scheduler", ".", "Call_Revive", "{", "Roles", ":", "roles", "}", ",", "}", "\n", "}" ]
// Revive returns a revive call with the given filters. // Callers are expected to fill in the FrameworkID.
[ "Revive", "returns", "a", "revive", "call", "with", "the", "given", "filters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L250-L255
13,010
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
SuppressWith
func SuppressWith(roles []string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SUPPRESS, Suppress: &scheduler.Call_Suppress{Roles: roles}, } }
go
func SuppressWith(roles []string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SUPPRESS, Suppress: &scheduler.Call_Suppress{Roles: roles}, } }
[ "func", "SuppressWith", "(", "roles", "[", "]", "string", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_SUPPRESS", ",", "Suppress", ":", "&", "scheduler", ".", "Call_Suppress", "{", "Roles", ":", "roles", "}", ",", "}", "\n", "}" ]
// Suppress returns a suppress call with the given filters. // Callers are expected to fill in the FrameworkID.
[ "Suppress", "returns", "a", "suppress", "call", "with", "the", "given", "filters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L265-L270
13,011
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Decline
func Decline(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_DECLINE, Decline: &scheduler.Call_Decline{ OfferIDs: offerIDs, }, } }
go
func Decline(offerIDs ...mesos.OfferID) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_DECLINE, Decline: &scheduler.Call_Decline{ OfferIDs: offerIDs, }, } }
[ "func", "Decline", "(", "offerIDs", "...", "mesos", ".", "OfferID", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_DECLINE", ",", "Decline", ":", "&", "scheduler", ".", "Call_Decline", "{", "OfferIDs", ":", "offerIDs", ",", "}", ",", "}", "\n", "}" ]
// Decline returns a decline call with the given parameters. // Callers are expected to fill in the FrameworkID and Filters.
[ "Decline", "returns", "a", "decline", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "and", "Filters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L274-L281
13,012
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Kill
func Kill(taskID, agentID string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_KILL, Kill: &scheduler.Call_Kill{ TaskID: mesos.TaskID{Value: taskID}, AgentID: optionalAgentID(agentID), }, } }
go
func Kill(taskID, agentID string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_KILL, Kill: &scheduler.Call_Kill{ TaskID: mesos.TaskID{Value: taskID}, AgentID: optionalAgentID(agentID), }, } }
[ "func", "Kill", "(", "taskID", ",", "agentID", "string", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_KILL", ",", "Kill", ":", "&", "scheduler", ".", "Call_Kill", "{", "TaskID", ":", "mesos", ".", "TaskID", "{", "Value", ":", "taskID", "}", ",", "AgentID", ":", "optionalAgentID", "(", "agentID", ")", ",", "}", ",", "}", "\n", "}" ]
// Kill returns a kill call with the given parameters. // Callers are expected to fill in the FrameworkID.
[ "Kill", "returns", "a", "kill", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L285-L293
13,013
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Shutdown
func Shutdown(executorID, agentID string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SHUTDOWN, Shutdown: &scheduler.Call_Shutdown{ ExecutorID: mesos.ExecutorID{Value: executorID}, AgentID: mesos.AgentID{Value: agentID}, }, } }
go
func Shutdown(executorID, agentID string) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_SHUTDOWN, Shutdown: &scheduler.Call_Shutdown{ ExecutorID: mesos.ExecutorID{Value: executorID}, AgentID: mesos.AgentID{Value: agentID}, }, } }
[ "func", "Shutdown", "(", "executorID", ",", "agentID", "string", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_SHUTDOWN", ",", "Shutdown", ":", "&", "scheduler", ".", "Call_Shutdown", "{", "ExecutorID", ":", "mesos", ".", "ExecutorID", "{", "Value", ":", "executorID", "}", ",", "AgentID", ":", "mesos", ".", "AgentID", "{", "Value", ":", "agentID", "}", ",", "}", ",", "}", "\n", "}" ]
// Shutdown returns a shutdown call with the given parameters. // Callers are expected to fill in the FrameworkID.
[ "Shutdown", "returns", "a", "shutdown", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L297-L305
13,014
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Acknowledge
func Acknowledge(agentID, taskID string, uuid []byte) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_ACKNOWLEDGE, Acknowledge: &scheduler.Call_Acknowledge{ AgentID: mesos.AgentID{Value: agentID}, TaskID: mesos.TaskID{Value: taskID}, UUID: uuid, }, } }
go
func Acknowledge(agentID, taskID string, uuid []byte) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_ACKNOWLEDGE, Acknowledge: &scheduler.Call_Acknowledge{ AgentID: mesos.AgentID{Value: agentID}, TaskID: mesos.TaskID{Value: taskID}, UUID: uuid, }, } }
[ "func", "Acknowledge", "(", "agentID", ",", "taskID", "string", ",", "uuid", "[", "]", "byte", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_ACKNOWLEDGE", ",", "Acknowledge", ":", "&", "scheduler", ".", "Call_Acknowledge", "{", "AgentID", ":", "mesos", ".", "AgentID", "{", "Value", ":", "agentID", "}", ",", "TaskID", ":", "mesos", ".", "TaskID", "{", "Value", ":", "taskID", "}", ",", "UUID", ":", "uuid", ",", "}", ",", "}", "\n", "}" ]
// Acknowledge returns an acknowledge call with the given parameters. // Callers are expected to fill in the FrameworkID.
[ "Acknowledge", "returns", "an", "acknowledge", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L309-L318
13,015
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Reconcile
func Reconcile(opts ...scheduler.ReconcileOpt) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_RECONCILE, Reconcile: (&scheduler.Call_Reconcile{}).With(opts...), } }
go
func Reconcile(opts ...scheduler.ReconcileOpt) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_RECONCILE, Reconcile: (&scheduler.Call_Reconcile{}).With(opts...), } }
[ "func", "Reconcile", "(", "opts", "...", "scheduler", ".", "ReconcileOpt", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_RECONCILE", ",", "Reconcile", ":", "(", "&", "scheduler", ".", "Call_Reconcile", "{", "}", ")", ".", "With", "(", "opts", "...", ")", ",", "}", "\n", "}" ]
// Reconcile returns a reconcile call with the given parameters. // See ReconcileTask. // Callers are expected to fill in the FrameworkID.
[ "Reconcile", "returns", "a", "reconcile", "call", "with", "the", "given", "parameters", ".", "See", "ReconcileTask", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L343-L348
13,016
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Message
func Message(agentID, executorID string, data []byte) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_MESSAGE, Message: &scheduler.Call_Message{ AgentID: mesos.AgentID{Value: agentID}, ExecutorID: mesos.ExecutorID{Value: executorID}, Data: data, }, } }
go
func Message(agentID, executorID string, data []byte) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_MESSAGE, Message: &scheduler.Call_Message{ AgentID: mesos.AgentID{Value: agentID}, ExecutorID: mesos.ExecutorID{Value: executorID}, Data: data, }, } }
[ "func", "Message", "(", "agentID", ",", "executorID", "string", ",", "data", "[", "]", "byte", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_MESSAGE", ",", "Message", ":", "&", "scheduler", ".", "Call_Message", "{", "AgentID", ":", "mesos", ".", "AgentID", "{", "Value", ":", "agentID", "}", ",", "ExecutorID", ":", "mesos", ".", "ExecutorID", "{", "Value", ":", "executorID", "}", ",", "Data", ":", "data", ",", "}", ",", "}", "\n", "}" ]
// Message returns a message call with the given parameters. // Callers are expected to fill in the FrameworkID.
[ "Message", "returns", "a", "message", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L352-L361
13,017
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
Request
func Request(requests ...mesos.Request) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_REQUEST, Request: &scheduler.Call_Request{ Requests: requests, }, } }
go
func Request(requests ...mesos.Request) *scheduler.Call { return &scheduler.Call{ Type: scheduler.Call_REQUEST, Request: &scheduler.Call_Request{ Requests: requests, }, } }
[ "func", "Request", "(", "requests", "...", "mesos", ".", "Request", ")", "*", "scheduler", ".", "Call", "{", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_REQUEST", ",", "Request", ":", "&", "scheduler", ".", "Call_Request", "{", "Requests", ":", "requests", ",", "}", ",", "}", "\n", "}" ]
// Request returns a resource request call with the given parameters. // Callers are expected to fill in the FrameworkID.
[ "Request", "returns", "a", "resource", "request", "call", "with", "the", "given", "parameters", ".", "Callers", "are", "expected", "to", "fill", "in", "the", "FrameworkID", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L365-L372
13,018
mesos/mesos-go
api/v1/lib/scheduler/calls/calls.go
ReconcileOperations
func ReconcileOperations(req []ReconcileOperationRequest) *scheduler.Call { var operations []scheduler.Call_ReconcileOperations_Operation for i := range req { operations = append(operations, scheduler.Call_ReconcileOperations_Operation{ OperationID: mesos.OperationID{Value: req[i].OperationID}, AgentID: optionalAgentID(req[i].AgentID), ResourceProviderID: optionalResourceProviderID(req[i].ResourceProviderID), }) } return &scheduler.Call{ Type: scheduler.Call_RECONCILE_OPERATIONS, ReconcileOperations: &scheduler.Call_ReconcileOperations{ Operations: operations, }, } }
go
func ReconcileOperations(req []ReconcileOperationRequest) *scheduler.Call { var operations []scheduler.Call_ReconcileOperations_Operation for i := range req { operations = append(operations, scheduler.Call_ReconcileOperations_Operation{ OperationID: mesos.OperationID{Value: req[i].OperationID}, AgentID: optionalAgentID(req[i].AgentID), ResourceProviderID: optionalResourceProviderID(req[i].ResourceProviderID), }) } return &scheduler.Call{ Type: scheduler.Call_RECONCILE_OPERATIONS, ReconcileOperations: &scheduler.Call_ReconcileOperations{ Operations: operations, }, } }
[ "func", "ReconcileOperations", "(", "req", "[", "]", "ReconcileOperationRequest", ")", "*", "scheduler", ".", "Call", "{", "var", "operations", "[", "]", "scheduler", ".", "Call_ReconcileOperations_Operation", "\n", "for", "i", ":=", "range", "req", "{", "operations", "=", "append", "(", "operations", ",", "scheduler", ".", "Call_ReconcileOperations_Operation", "{", "OperationID", ":", "mesos", ".", "OperationID", "{", "Value", ":", "req", "[", "i", "]", ".", "OperationID", "}", ",", "AgentID", ":", "optionalAgentID", "(", "req", "[", "i", "]", ".", "AgentID", ")", ",", "ResourceProviderID", ":", "optionalResourceProviderID", "(", "req", "[", "i", "]", ".", "ResourceProviderID", ")", ",", "}", ")", "\n", "}", "\n", "return", "&", "scheduler", ".", "Call", "{", "Type", ":", "scheduler", ".", "Call_RECONCILE_OPERATIONS", ",", "ReconcileOperations", ":", "&", "scheduler", ".", "Call_ReconcileOperations", "{", "Operations", ":", "operations", ",", "}", ",", "}", "\n", "}" ]
// ReconcileOperations allows the scheduler to query the status of operations. This causes the master to send // back the latest status for each operation in 'req', if possible. If 'req' is empty, then the master will send // the latest status for each operation currently known.
[ "ReconcileOperations", "allows", "the", "scheduler", "to", "query", "the", "status", "of", "operations", ".", "This", "causes", "the", "master", "to", "send", "back", "the", "latest", "status", "for", "each", "operation", "in", "req", "if", "possible", ".", "If", "req", "is", "empty", "then", "the", "master", "will", "send", "the", "latest", "status", "for", "each", "operation", "currently", "known", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/scheduler/calls/calls.go#L419-L434
13,019
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/filters.go
Accept
func (f FilterFunc) Accept(o *mesos.Offer) bool { if f == nil { return true } return f(o) }
go
func (f FilterFunc) Accept(o *mesos.Offer) bool { if f == nil { return true } return f(o) }
[ "func", "(", "f", "FilterFunc", ")", "Accept", "(", "o", "*", "mesos", ".", "Offer", ")", "bool", "{", "if", "f", "==", "nil", "{", "return", "true", "\n", "}", "\n", "return", "f", "(", "o", ")", "\n", "}" ]
// Accept implements Filter for FilterFunc
[ "Accept", "implements", "Filter", "for", "FilterFunc" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/filters.go#L19-L24
13,020
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/filters.go
ByHostname
func ByHostname(hostname string) Filter { if hostname == "" { return FilterFunc(nil) } return FilterFunc(func(o *mesos.Offer) bool { return o.Hostname == hostname }) }
go
func ByHostname(hostname string) Filter { if hostname == "" { return FilterFunc(nil) } return FilterFunc(func(o *mesos.Offer) bool { return o.Hostname == hostname }) }
[ "func", "ByHostname", "(", "hostname", "string", ")", "Filter", "{", "if", "hostname", "==", "\"", "\"", "{", "return", "FilterFunc", "(", "nil", ")", "\n", "}", "\n", "return", "FilterFunc", "(", "func", "(", "o", "*", "mesos", ".", "Offer", ")", "bool", "{", "return", "o", ".", "Hostname", "==", "hostname", "\n", "}", ")", "\n", "}" ]
// ByHostname returns a Filter that accepts offers with a matching Hostname
[ "ByHostname", "returns", "a", "Filter", "that", "accepts", "offers", "with", "a", "matching", "Hostname" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/filters.go#L31-L38
13,021
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/filters.go
ByAttributes
func ByAttributes(f func(attr []mesos.Attribute) bool) Filter { if f == nil { return FilterFunc(nil) } return FilterFunc(func(o *mesos.Offer) bool { return f(o.Attributes) }) }
go
func ByAttributes(f func(attr []mesos.Attribute) bool) Filter { if f == nil { return FilterFunc(nil) } return FilterFunc(func(o *mesos.Offer) bool { return f(o.Attributes) }) }
[ "func", "ByAttributes", "(", "f", "func", "(", "attr", "[", "]", "mesos", ".", "Attribute", ")", "bool", ")", "Filter", "{", "if", "f", "==", "nil", "{", "return", "FilterFunc", "(", "nil", ")", "\n", "}", "\n", "return", "FilterFunc", "(", "func", "(", "o", "*", "mesos", ".", "Offer", ")", "bool", "{", "return", "f", "(", "o", ".", "Attributes", ")", "\n", "}", ")", "\n", "}" ]
// ByAttributes returns a Filter that accepts offers with an attribute set accepted by // the provided Attribute filter func.
[ "ByAttributes", "returns", "a", "Filter", "that", "accepts", "offers", "with", "an", "attribute", "set", "accepted", "by", "the", "provided", "Attribute", "filter", "func", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/filters.go#L42-L49
13,022
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/filters.go
ContainsResources
func ContainsResources(wanted mesos.Resources) Filter { return FilterFunc(func(o *mesos.Offer) bool { return resources.ContainsAll(resources.Flatten(mesos.Resources(o.Resources)), wanted) }) }
go
func ContainsResources(wanted mesos.Resources) Filter { return FilterFunc(func(o *mesos.Offer) bool { return resources.ContainsAll(resources.Flatten(mesos.Resources(o.Resources)), wanted) }) }
[ "func", "ContainsResources", "(", "wanted", "mesos", ".", "Resources", ")", "Filter", "{", "return", "FilterFunc", "(", "func", "(", "o", "*", "mesos", ".", "Offer", ")", "bool", "{", "return", "resources", ".", "ContainsAll", "(", "resources", ".", "Flatten", "(", "mesos", ".", "Resources", "(", "o", ".", "Resources", ")", ")", ",", "wanted", ")", "\n", "}", ")", "\n", "}" ]
// ContainsResources returns a filter that returns true if the Resources of an Offer // contain the wanted Resources.
[ "ContainsResources", "returns", "a", "filter", "that", "returns", "true", "if", "the", "Resources", "of", "an", "Offer", "contain", "the", "wanted", "Resources", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/filters.go#L71-L75
13,023
mesos/mesos-go
api/v1/lib/httpcli/apierrors/apierrors.go
Error
func (code Code) Error(details string) error { if !code.IsError() { return nil } err := &Error{ code: code, message: ErrorTable[code], } if details != "" { err.message = err.message + ": " + details } return err }
go
func (code Code) Error(details string) error { if !code.IsError() { return nil } err := &Error{ code: code, message: ErrorTable[code], } if details != "" { err.message = err.message + ": " + details } return err }
[ "func", "(", "code", "Code", ")", "Error", "(", "details", "string", ")", "error", "{", "if", "!", "code", ".", "IsError", "(", ")", "{", "return", "nil", "\n", "}", "\n", "err", ":=", "&", "Error", "{", "code", ":", "code", ",", "message", ":", "ErrorTable", "[", "code", "]", ",", "}", "\n", "if", "details", "!=", "\"", "\"", "{", "err", ".", "message", "=", "err", ".", "message", "+", "\"", "\"", "+", "details", "\n", "}", "\n", "return", "err", "\n", "}" ]
// Error generates an error from the given status code and detail string.
[ "Error", "generates", "an", "error", "from", "the", "given", "status", "code", "and", "detail", "string", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/apierrors/apierrors.go#L100-L112
13,024
mesos/mesos-go
api/v1/lib/httpcli/apierrors/apierrors.go
Temporary
func (e *Error) Temporary() bool { switch e.code { // TODO(jdef): NotFound **could** be a temporary error because there's a race at mesos startup in which the // HTTP server responds before the internal listeners have been initialized. But it could also be reported // because the client is accessing an invalid endpoint; as of right now, a client cannot distinguish between // these cases. // https://issues.apache.org/jira/browse/MESOS-7697 case CodeRateLimitExceeded, CodeMesosUnavailable: return true default: return false } }
go
func (e *Error) Temporary() bool { switch e.code { // TODO(jdef): NotFound **could** be a temporary error because there's a race at mesos startup in which the // HTTP server responds before the internal listeners have been initialized. But it could also be reported // because the client is accessing an invalid endpoint; as of right now, a client cannot distinguish between // these cases. // https://issues.apache.org/jira/browse/MESOS-7697 case CodeRateLimitExceeded, CodeMesosUnavailable: return true default: return false } }
[ "func", "(", "e", "*", "Error", ")", "Temporary", "(", ")", "bool", "{", "switch", "e", ".", "code", "{", "// TODO(jdef): NotFound **could** be a temporary error because there's a race at mesos startup in which the", "// HTTP server responds before the internal listeners have been initialized. But it could also be reported", "// because the client is accessing an invalid endpoint; as of right now, a client cannot distinguish between", "// these cases.", "// https://issues.apache.org/jira/browse/MESOS-7697", "case", "CodeRateLimitExceeded", ",", "CodeMesosUnavailable", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
// Temporary returns true if the error is a temporary condition that should eventually clear.
[ "Temporary", "returns", "true", "if", "the", "error", "is", "a", "temporary", "condition", "that", "should", "eventually", "clear", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/apierrors/apierrors.go#L118-L130
13,025
mesos/mesos-go
api/v1/lib/httpcli/apierrors/apierrors.go
SubscriptionLoss
func (e *Error) SubscriptionLoss() (result bool) { _, result = CodesIndicatingSubscriptionLoss[e.code] return }
go
func (e *Error) SubscriptionLoss() (result bool) { _, result = CodesIndicatingSubscriptionLoss[e.code] return }
[ "func", "(", "e", "*", "Error", ")", "SubscriptionLoss", "(", ")", "(", "result", "bool", ")", "{", "_", ",", "result", "=", "CodesIndicatingSubscriptionLoss", "[", "e", ".", "code", "]", "\n", "return", "\n", "}" ]
// SubscriptionLoss returns true if the error indicates that the event subscription stream has been severed // between mesos and a mesos client.
[ "SubscriptionLoss", "returns", "true", "if", "the", "error", "indicates", "that", "the", "event", "subscription", "stream", "has", "been", "severed", "between", "mesos", "and", "a", "mesos", "client", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/apierrors/apierrors.go#L149-L152
13,026
mesos/mesos-go
api/v1/lib/httpcli/apierrors/apierrors.go
Matches
func (code Code) Matches(err error) bool { if err == nil { return !code.IsError() } apiErr, ok := err.(*Error) return ok && apiErr.code == code }
go
func (code Code) Matches(err error) bool { if err == nil { return !code.IsError() } apiErr, ok := err.(*Error) return ok && apiErr.code == code }
[ "func", "(", "code", "Code", ")", "Matches", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "!", "code", ".", "IsError", "(", ")", "\n", "}", "\n", "apiErr", ",", "ok", ":=", "err", ".", "(", "*", "Error", ")", "\n", "return", "ok", "&&", "apiErr", ".", "code", "==", "code", "\n", "}" ]
// Matches returns true if the given error is an API error with a matching error code
[ "Matches", "returns", "true", "if", "the", "given", "error", "is", "an", "API", "error", "with", "a", "matching", "error", "code" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/httpcli/apierrors/apierrors.go#L155-L161
13,027
mesos/mesos-go
api/v0/scheduler/scheduler.go
context
func (driver *MesosSchedulerDriver) context() context.Context { // set a "session" attribute so that the messenger can see it // and use it for reporting delivery errors. return sessionid.NewContext(context.TODO(), driver.connection.String()) }
go
func (driver *MesosSchedulerDriver) context() context.Context { // set a "session" attribute so that the messenger can see it // and use it for reporting delivery errors. return sessionid.NewContext(context.TODO(), driver.connection.String()) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "context", "(", ")", "context", ".", "Context", "{", "// set a \"session\" attribute so that the messenger can see it", "// and use it for reporting delivery errors.", "return", "sessionid", ".", "NewContext", "(", "context", ".", "TODO", "(", ")", ",", "driver", ".", "connection", ".", "String", "(", ")", ")", "\n", "}" ]
// ctx returns the current context.Context for the driver, expects to be invoked // only when eventLock is locked.
[ "ctx", "returns", "the", "current", "context", ".", "Context", "for", "the", "driver", "expects", "to", "be", "invoked", "only", "when", "eventLock", "is", "locked", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L326-L330
13,028
mesos/mesos-go
api/v0/scheduler/scheduler.go
handleMasterChanged
func (driver *MesosSchedulerDriver) handleMasterChanged(_ context.Context, from *upid.UPID, pbMsg proto.Message) { if driver.status == mesos.Status_DRIVER_ABORTED { log.Info("Ignoring master change because the driver is aborted.") return } else if !from.Equal(driver.self) { log.Errorf("ignoring master changed message received from upid '%v'", from) return } // Reconnect every time a master is detected. wasConnected := driver.connected driver.connected = false driver.authenticated = false alertScheduler := false if wasConnected { log.V(3).Info("Disconnecting scheduler.") driver.masterPid = nil alertScheduler = true } msg := pbMsg.(*mesos.InternalMasterChangeDetected) master := msg.Master if master != nil { log.Infof("New master %s detected\n", master.GetPid()) pid, err := upid.Parse(master.GetPid()) if err != nil { panic("Unable to parse Master's PID value.") // this should not happen. } driver.masterPid = pid // save for downstream ops. defer driver.tryAuthentication() } else { log.Infoln("No master detected.") } if alertScheduler { driver.withScheduler(func(s Scheduler) { s.Disconnected(driver) }) } }
go
func (driver *MesosSchedulerDriver) handleMasterChanged(_ context.Context, from *upid.UPID, pbMsg proto.Message) { if driver.status == mesos.Status_DRIVER_ABORTED { log.Info("Ignoring master change because the driver is aborted.") return } else if !from.Equal(driver.self) { log.Errorf("ignoring master changed message received from upid '%v'", from) return } // Reconnect every time a master is detected. wasConnected := driver.connected driver.connected = false driver.authenticated = false alertScheduler := false if wasConnected { log.V(3).Info("Disconnecting scheduler.") driver.masterPid = nil alertScheduler = true } msg := pbMsg.(*mesos.InternalMasterChangeDetected) master := msg.Master if master != nil { log.Infof("New master %s detected\n", master.GetPid()) pid, err := upid.Parse(master.GetPid()) if err != nil { panic("Unable to parse Master's PID value.") // this should not happen. } driver.masterPid = pid // save for downstream ops. defer driver.tryAuthentication() } else { log.Infoln("No master detected.") } if alertScheduler { driver.withScheduler(func(s Scheduler) { s.Disconnected(driver) }) } }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "handleMasterChanged", "(", "_", "context", ".", "Context", ",", "from", "*", "upid", ".", "UPID", ",", "pbMsg", "proto", ".", "Message", ")", "{", "if", "driver", ".", "status", "==", "mesos", ".", "Status_DRIVER_ABORTED", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "else", "if", "!", "from", ".", "Equal", "(", "driver", ".", "self", ")", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "from", ")", "\n", "return", "\n", "}", "\n\n", "// Reconnect every time a master is detected.", "wasConnected", ":=", "driver", ".", "connected", "\n", "driver", ".", "connected", "=", "false", "\n", "driver", ".", "authenticated", "=", "false", "\n\n", "alertScheduler", ":=", "false", "\n", "if", "wasConnected", "{", "log", ".", "V", "(", "3", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "driver", ".", "masterPid", "=", "nil", "\n", "alertScheduler", "=", "true", "\n", "}", "\n\n", "msg", ":=", "pbMsg", ".", "(", "*", "mesos", ".", "InternalMasterChangeDetected", ")", "\n", "master", ":=", "msg", ".", "Master", "\n\n", "if", "master", "!=", "nil", "{", "log", ".", "Infof", "(", "\"", "\\n", "\"", ",", "master", ".", "GetPid", "(", ")", ")", "\n\n", "pid", ",", "err", ":=", "upid", ".", "Parse", "(", "master", ".", "GetPid", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "// this should not happen.", "\n", "}", "\n\n", "driver", ".", "masterPid", "=", "pid", "// save for downstream ops.", "\n", "defer", "driver", ".", "tryAuthentication", "(", ")", "\n", "}", "else", "{", "log", ".", "Infoln", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "alertScheduler", "{", "driver", ".", "withScheduler", "(", "func", "(", "s", "Scheduler", ")", "{", "s", ".", "Disconnected", "(", "driver", ")", "}", ")", "\n", "}", "\n", "}" ]
// lead master detection callback.
[ "lead", "master", "detection", "callback", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L394-L434
13,029
mesos/mesos-go
api/v0/scheduler/scheduler.go
tryAuthentication
func (driver *MesosSchedulerDriver) tryAuthentication() { if driver.authenticated { // programming error panic("already authenticated") } masterPid := driver.masterPid // save for referencing later in goroutine if masterPid == nil { log.Info("skipping authentication attempt because we lost the master") return } if driver.authenticating.inProgress() { // authentication is in progress, try to cancel it (we may too late already) driver.authenticating.cancel() driver.reauthenticate = true return } if driver.credential != nil { // authentication can block and we don't want to hold up the messenger loop authenticating := &authenticationAttempt{done: make(chan struct{})} go func() { defer authenticating.cancel() result := &mesos.InternalAuthenticationResult{ //TODO(jdef): is this really needed? Success: proto.Bool(false), Completed: proto.Bool(false), Pid: proto.String(masterPid.String()), } // don't reference driver.authenticating here since it may have changed if err := driver.authenticate(masterPid, authenticating); err != nil { log.Errorf("Scheduler failed to authenticate: %v\n", err) if err == auth.AuthenticationFailed { result.Completed = proto.Bool(true) } } else { result.Completed = proto.Bool(true) result.Success = proto.Bool(true) } pid := driver.messenger.UPID() driver.messenger.Route(context.TODO(), &pid, result) }() driver.authenticating = authenticating } else { log.Infoln("No credentials were provided. " + "Attempting to register scheduler without authentication.") driver.authenticated = true go driver.doReliableRegistration(float64(registrationBackoffFactor)) } }
go
func (driver *MesosSchedulerDriver) tryAuthentication() { if driver.authenticated { // programming error panic("already authenticated") } masterPid := driver.masterPid // save for referencing later in goroutine if masterPid == nil { log.Info("skipping authentication attempt because we lost the master") return } if driver.authenticating.inProgress() { // authentication is in progress, try to cancel it (we may too late already) driver.authenticating.cancel() driver.reauthenticate = true return } if driver.credential != nil { // authentication can block and we don't want to hold up the messenger loop authenticating := &authenticationAttempt{done: make(chan struct{})} go func() { defer authenticating.cancel() result := &mesos.InternalAuthenticationResult{ //TODO(jdef): is this really needed? Success: proto.Bool(false), Completed: proto.Bool(false), Pid: proto.String(masterPid.String()), } // don't reference driver.authenticating here since it may have changed if err := driver.authenticate(masterPid, authenticating); err != nil { log.Errorf("Scheduler failed to authenticate: %v\n", err) if err == auth.AuthenticationFailed { result.Completed = proto.Bool(true) } } else { result.Completed = proto.Bool(true) result.Success = proto.Bool(true) } pid := driver.messenger.UPID() driver.messenger.Route(context.TODO(), &pid, result) }() driver.authenticating = authenticating } else { log.Infoln("No credentials were provided. " + "Attempting to register scheduler without authentication.") driver.authenticated = true go driver.doReliableRegistration(float64(registrationBackoffFactor)) } }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "tryAuthentication", "(", ")", "{", "if", "driver", ".", "authenticated", "{", "// programming error", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "masterPid", ":=", "driver", ".", "masterPid", "// save for referencing later in goroutine", "\n", "if", "masterPid", "==", "nil", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "driver", ".", "authenticating", ".", "inProgress", "(", ")", "{", "// authentication is in progress, try to cancel it (we may too late already)", "driver", ".", "authenticating", ".", "cancel", "(", ")", "\n", "driver", ".", "reauthenticate", "=", "true", "\n", "return", "\n", "}", "\n\n", "if", "driver", ".", "credential", "!=", "nil", "{", "// authentication can block and we don't want to hold up the messenger loop", "authenticating", ":=", "&", "authenticationAttempt", "{", "done", ":", "make", "(", "chan", "struct", "{", "}", ")", "}", "\n", "go", "func", "(", ")", "{", "defer", "authenticating", ".", "cancel", "(", ")", "\n", "result", ":=", "&", "mesos", ".", "InternalAuthenticationResult", "{", "//TODO(jdef): is this really needed?", "Success", ":", "proto", ".", "Bool", "(", "false", ")", ",", "Completed", ":", "proto", ".", "Bool", "(", "false", ")", ",", "Pid", ":", "proto", ".", "String", "(", "masterPid", ".", "String", "(", ")", ")", ",", "}", "\n", "// don't reference driver.authenticating here since it may have changed", "if", "err", ":=", "driver", ".", "authenticate", "(", "masterPid", ",", "authenticating", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "if", "err", "==", "auth", ".", "AuthenticationFailed", "{", "result", ".", "Completed", "=", "proto", ".", "Bool", "(", "true", ")", "\n", "}", "\n", "}", "else", "{", "result", ".", "Completed", "=", "proto", ".", "Bool", "(", "true", ")", "\n", "result", ".", "Success", "=", "proto", ".", "Bool", "(", "true", ")", "\n", "}", "\n", "pid", ":=", "driver", ".", "messenger", ".", "UPID", "(", ")", "\n", "driver", ".", "messenger", ".", "Route", "(", "context", ".", "TODO", "(", ")", ",", "&", "pid", ",", "result", ")", "\n", "}", "(", ")", "\n", "driver", ".", "authenticating", "=", "authenticating", "\n", "}", "else", "{", "log", ".", "Infoln", "(", "\"", "\"", "+", "\"", "\"", ")", "\n", "driver", ".", "authenticated", "=", "true", "\n", "go", "driver", ".", "doReliableRegistration", "(", "float64", "(", "registrationBackoffFactor", ")", ")", "\n", "}", "\n", "}" ]
// tryAuthentication expects to be guarded by eventLock
[ "tryAuthentication", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L437-L487
13,030
mesos/mesos-go
api/v0/scheduler/scheduler.go
Running
func (driver *MesosSchedulerDriver) Running() bool { driver.eventLock.RLock() defer driver.eventLock.RUnlock() return driver.status == mesos.Status_DRIVER_RUNNING }
go
func (driver *MesosSchedulerDriver) Running() bool { driver.eventLock.RLock() defer driver.eventLock.RUnlock() return driver.status == mesos.Status_DRIVER_RUNNING }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "Running", "(", ")", "bool", "{", "driver", ".", "eventLock", ".", "RLock", "(", ")", "\n", "defer", "driver", ".", "eventLock", ".", "RUnlock", "(", ")", "\n", "return", "driver", ".", "status", "==", "mesos", ".", "Status_DRIVER_RUNNING", "\n", "}" ]
// Running returns true if the driver is in the DRIVER_RUNNING state
[ "Running", "returns", "true", "if", "the", "driver", "is", "in", "the", "DRIVER_RUNNING", "state" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L536-L540
13,031
mesos/mesos-go
api/v0/scheduler/scheduler.go
statusUpdated
func (driver *MesosSchedulerDriver) statusUpdated(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { msg := pbMsg.(*mesos.StatusUpdateMessage) if driver.status != mesos.Status_DRIVER_RUNNING { log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not running!") return } if !from.Equal(driver.self) { if !driver.connected { log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not connected!") return } if !driver.masterPid.Equal(from) { log.Warningf("ignoring status message because it was sent from '%v' instead of leading master '%v'", from, driver.masterPid) return } } log.V(2).Infof("Received status update from %q status source %q", from.String(), msg.GetPid()) status := msg.Update.GetStatus() // see https://github.com/apache/mesos/blob/master/src/sched/sched.cpp#L887 // If the update does not have a 'uuid', it does not need // acknowledging. However, prior to 0.23.0, the update uuid // was required and always set. We also don't want to ACK updates // that were internally generated. In 0.24.0, we can rely on the // update uuid check here, until then we must still check for // this being sent from the driver (from == UPID()) or from // the master (pid == UPID()). // TODO(vinod): Get rid of this logic in 0.25.0 because master // and slave correctly set task status in 0.24.0. if clearUUID := len(msg.Update.Uuid) == 0 || from.Equal(driver.self) || msg.GetPid() == driver.self.String(); clearUUID { status.Uuid = nil } else { status.Uuid = msg.Update.Uuid } if driver.status == mesos.Status_DRIVER_ABORTED { log.V(1).Infoln("Not sending StatusUpdate ACK, the driver is aborted!") } else { // Send StatusUpdate Acknowledgement; see above for the rules. // Only send ACK if udpate was not from this driver and spec'd a UUID; this is compat w/ 0.23+ ackRequired := len(msg.Update.Uuid) > 0 && !from.Equal(driver.self) && msg.GetPid() != driver.self.String() if ackRequired { ackMsg := &mesos.StatusUpdateAcknowledgementMessage{ SlaveId: msg.Update.SlaveId, FrameworkId: driver.frameworkInfo.Id, TaskId: msg.Update.Status.TaskId, Uuid: msg.Update.Uuid, } log.V(2).Infof("Sending ACK for status update %+v to %q", *msg.Update, from.String()) if err := driver.send(ctx, driver.masterPid, ackMsg); err != nil { log.Errorf("Failed to send StatusUpdate ACK message: %v", err) } } else { log.V(2).Infof("Not sending ACK, update is not from slave %q", from.String()) } } driver.withScheduler(func(s Scheduler) { s.StatusUpdate(driver, status) }) }
go
func (driver *MesosSchedulerDriver) statusUpdated(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { msg := pbMsg.(*mesos.StatusUpdateMessage) if driver.status != mesos.Status_DRIVER_RUNNING { log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not running!") return } if !from.Equal(driver.self) { if !driver.connected { log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not connected!") return } if !driver.masterPid.Equal(from) { log.Warningf("ignoring status message because it was sent from '%v' instead of leading master '%v'", from, driver.masterPid) return } } log.V(2).Infof("Received status update from %q status source %q", from.String(), msg.GetPid()) status := msg.Update.GetStatus() // see https://github.com/apache/mesos/blob/master/src/sched/sched.cpp#L887 // If the update does not have a 'uuid', it does not need // acknowledging. However, prior to 0.23.0, the update uuid // was required and always set. We also don't want to ACK updates // that were internally generated. In 0.24.0, we can rely on the // update uuid check here, until then we must still check for // this being sent from the driver (from == UPID()) or from // the master (pid == UPID()). // TODO(vinod): Get rid of this logic in 0.25.0 because master // and slave correctly set task status in 0.24.0. if clearUUID := len(msg.Update.Uuid) == 0 || from.Equal(driver.self) || msg.GetPid() == driver.self.String(); clearUUID { status.Uuid = nil } else { status.Uuid = msg.Update.Uuid } if driver.status == mesos.Status_DRIVER_ABORTED { log.V(1).Infoln("Not sending StatusUpdate ACK, the driver is aborted!") } else { // Send StatusUpdate Acknowledgement; see above for the rules. // Only send ACK if udpate was not from this driver and spec'd a UUID; this is compat w/ 0.23+ ackRequired := len(msg.Update.Uuid) > 0 && !from.Equal(driver.self) && msg.GetPid() != driver.self.String() if ackRequired { ackMsg := &mesos.StatusUpdateAcknowledgementMessage{ SlaveId: msg.Update.SlaveId, FrameworkId: driver.frameworkInfo.Id, TaskId: msg.Update.Status.TaskId, Uuid: msg.Update.Uuid, } log.V(2).Infof("Sending ACK for status update %+v to %q", *msg.Update, from.String()) if err := driver.send(ctx, driver.masterPid, ackMsg); err != nil { log.Errorf("Failed to send StatusUpdate ACK message: %v", err) } } else { log.V(2).Infof("Not sending ACK, update is not from slave %q", from.String()) } } driver.withScheduler(func(s Scheduler) { s.StatusUpdate(driver, status) }) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "statusUpdated", "(", "ctx", "context", ".", "Context", ",", "from", "*", "upid", ".", "UPID", ",", "pbMsg", "proto", ".", "Message", ")", "{", "msg", ":=", "pbMsg", ".", "(", "*", "mesos", ".", "StatusUpdateMessage", ")", "\n\n", "if", "driver", ".", "status", "!=", "mesos", ".", "Status_DRIVER_RUNNING", "{", "log", ".", "V", "(", "1", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "if", "!", "from", ".", "Equal", "(", "driver", ".", "self", ")", "{", "if", "!", "driver", ".", "connected", "{", "log", ".", "V", "(", "1", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "if", "!", "driver", ".", "masterPid", ".", "Equal", "(", "from", ")", "{", "log", ".", "Warningf", "(", "\"", "\"", ",", "from", ",", "driver", ".", "masterPid", ")", "\n", "return", "\n", "}", "\n", "}", "\n\n", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "from", ".", "String", "(", ")", ",", "msg", ".", "GetPid", "(", ")", ")", "\n\n", "status", ":=", "msg", ".", "Update", ".", "GetStatus", "(", ")", "\n\n", "// see https://github.com/apache/mesos/blob/master/src/sched/sched.cpp#L887", "// If the update does not have a 'uuid', it does not need", "// acknowledging. However, prior to 0.23.0, the update uuid", "// was required and always set. We also don't want to ACK updates", "// that were internally generated. In 0.24.0, we can rely on the", "// update uuid check here, until then we must still check for", "// this being sent from the driver (from == UPID()) or from", "// the master (pid == UPID()).", "// TODO(vinod): Get rid of this logic in 0.25.0 because master", "// and slave correctly set task status in 0.24.0.", "if", "clearUUID", ":=", "len", "(", "msg", ".", "Update", ".", "Uuid", ")", "==", "0", "||", "from", ".", "Equal", "(", "driver", ".", "self", ")", "||", "msg", ".", "GetPid", "(", ")", "==", "driver", ".", "self", ".", "String", "(", ")", ";", "clearUUID", "{", "status", ".", "Uuid", "=", "nil", "\n", "}", "else", "{", "status", ".", "Uuid", "=", "msg", ".", "Update", ".", "Uuid", "\n", "}", "\n\n", "if", "driver", ".", "status", "==", "mesos", ".", "Status_DRIVER_ABORTED", "{", "log", ".", "V", "(", "1", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "}", "else", "{", "// Send StatusUpdate Acknowledgement; see above for the rules.", "// Only send ACK if udpate was not from this driver and spec'd a UUID; this is compat w/ 0.23+", "ackRequired", ":=", "len", "(", "msg", ".", "Update", ".", "Uuid", ")", ">", "0", "&&", "!", "from", ".", "Equal", "(", "driver", ".", "self", ")", "&&", "msg", ".", "GetPid", "(", ")", "!=", "driver", ".", "self", ".", "String", "(", ")", "\n", "if", "ackRequired", "{", "ackMsg", ":=", "&", "mesos", ".", "StatusUpdateAcknowledgementMessage", "{", "SlaveId", ":", "msg", ".", "Update", ".", "SlaveId", ",", "FrameworkId", ":", "driver", ".", "frameworkInfo", ".", "Id", ",", "TaskId", ":", "msg", ".", "Update", ".", "Status", ".", "TaskId", ",", "Uuid", ":", "msg", ".", "Update", ".", "Uuid", ",", "}", "\n\n", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "*", "msg", ".", "Update", ",", "from", ".", "String", "(", ")", ")", "\n", "if", "err", ":=", "driver", ".", "send", "(", "ctx", ",", "driver", ".", "masterPid", ",", "ackMsg", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "else", "{", "log", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "from", ".", "String", "(", ")", ")", "\n", "}", "\n", "}", "\n", "driver", ".", "withScheduler", "(", "func", "(", "s", "Scheduler", ")", "{", "s", ".", "StatusUpdate", "(", "driver", ",", "status", ")", "}", ")", "\n", "}" ]
// statusUpdated expects to be guarded by eventLock
[ "statusUpdated", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L686-L748
13,032
mesos/mesos-go
api/v0/scheduler/scheduler.go
start
func (driver *MesosSchedulerDriver) start() (mesos.Status, error) { select { case <-driver.started: return driver.status, errors.New("Unable to Start: driver has already been started once.") default: // proceed } log.Infoln("Starting the scheduler driver...") if driver.status != mesos.Status_DRIVER_NOT_STARTED { return driver.status, fmt.Errorf("Unable to Start, expecting driver status %s, but is %s:", mesos.Status_DRIVER_NOT_STARTED, driver.status) } // Start the messenger. if err := driver.messenger.Start(); err != nil { log.Errorf("Scheduler failed to start the messenger: %v\n", err) return driver.status, err } pid := driver.messenger.UPID() driver.self = &pid driver.status = mesos.Status_DRIVER_RUNNING close(driver.started) log.Infof("Mesos scheduler driver started with PID=%v", driver.self) listener := detector.OnMasterChanged(func(m *mesos.MasterInfo) { driver.messenger.Route(context.TODO(), driver.self, &mesos.InternalMasterChangeDetected{ Master: m, }) }) if driver.masterDetector != nil { // register with Detect() AFTER we have a self pid from the messenger, otherwise things get ugly // because our internal messaging depends on it. detector callbacks are routed over the messenger // bus, maintaining serial (concurrency-safe) callback execution. log.V(1).Infof("starting master detector %T: %+v", driver.masterDetector, driver.masterDetector) driver.masterDetector.Detect(listener) log.V(2).Infoln("master detector started") } return driver.status, nil }
go
func (driver *MesosSchedulerDriver) start() (mesos.Status, error) { select { case <-driver.started: return driver.status, errors.New("Unable to Start: driver has already been started once.") default: // proceed } log.Infoln("Starting the scheduler driver...") if driver.status != mesos.Status_DRIVER_NOT_STARTED { return driver.status, fmt.Errorf("Unable to Start, expecting driver status %s, but is %s:", mesos.Status_DRIVER_NOT_STARTED, driver.status) } // Start the messenger. if err := driver.messenger.Start(); err != nil { log.Errorf("Scheduler failed to start the messenger: %v\n", err) return driver.status, err } pid := driver.messenger.UPID() driver.self = &pid driver.status = mesos.Status_DRIVER_RUNNING close(driver.started) log.Infof("Mesos scheduler driver started with PID=%v", driver.self) listener := detector.OnMasterChanged(func(m *mesos.MasterInfo) { driver.messenger.Route(context.TODO(), driver.self, &mesos.InternalMasterChangeDetected{ Master: m, }) }) if driver.masterDetector != nil { // register with Detect() AFTER we have a self pid from the messenger, otherwise things get ugly // because our internal messaging depends on it. detector callbacks are routed over the messenger // bus, maintaining serial (concurrency-safe) callback execution. log.V(1).Infof("starting master detector %T: %+v", driver.masterDetector, driver.masterDetector) driver.masterDetector.Detect(listener) log.V(2).Infoln("master detector started") } return driver.status, nil }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "start", "(", ")", "(", "mesos", ".", "Status", ",", "error", ")", "{", "select", "{", "case", "<-", "driver", ".", "started", ":", "return", "driver", ".", "status", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "default", ":", "// proceed", "}", "\n\n", "log", ".", "Infoln", "(", "\"", "\"", ")", "\n\n", "if", "driver", ".", "status", "!=", "mesos", ".", "Status_DRIVER_NOT_STARTED", "{", "return", "driver", ".", "status", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "mesos", ".", "Status_DRIVER_NOT_STARTED", ",", "driver", ".", "status", ")", "\n", "}", "\n\n", "// Start the messenger.", "if", "err", ":=", "driver", ".", "messenger", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "driver", ".", "status", ",", "err", "\n", "}", "\n\n", "pid", ":=", "driver", ".", "messenger", ".", "UPID", "(", ")", "\n", "driver", ".", "self", "=", "&", "pid", "\n", "driver", ".", "status", "=", "mesos", ".", "Status_DRIVER_RUNNING", "\n", "close", "(", "driver", ".", "started", ")", "\n\n", "log", ".", "Infof", "(", "\"", "\"", ",", "driver", ".", "self", ")", "\n\n", "listener", ":=", "detector", ".", "OnMasterChanged", "(", "func", "(", "m", "*", "mesos", ".", "MasterInfo", ")", "{", "driver", ".", "messenger", ".", "Route", "(", "context", ".", "TODO", "(", ")", ",", "driver", ".", "self", ",", "&", "mesos", ".", "InternalMasterChangeDetected", "{", "Master", ":", "m", ",", "}", ")", "\n", "}", ")", "\n\n", "if", "driver", ".", "masterDetector", "!=", "nil", "{", "// register with Detect() AFTER we have a self pid from the messenger, otherwise things get ugly", "// because our internal messaging depends on it. detector callbacks are routed over the messenger", "// bus, maintaining serial (concurrency-safe) callback execution.", "log", ".", "V", "(", "1", ")", ".", "Infof", "(", "\"", "\"", ",", "driver", ".", "masterDetector", ",", "driver", ".", "masterDetector", ")", "\n", "driver", ".", "masterDetector", ".", "Detect", "(", "listener", ")", "\n", "log", ".", "V", "(", "2", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "driver", ".", "status", ",", "nil", "\n", "}" ]
// start expected to be guarded by eventLock
[ "start", "expected", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L826-L867
13,033
mesos/mesos-go
api/v0/scheduler/scheduler.go
join
func (driver *MesosSchedulerDriver) join() (stat mesos.Status, err error) { if stat = driver.status; stat != mesos.Status_DRIVER_RUNNING { err = fmt.Errorf("Unable to Join, expecting driver status %s, but is %s", mesos.Status_DRIVER_RUNNING, stat) return } timeout := 1 * time.Second t := time.NewTimer(timeout) defer t.Stop() driver.eventLock.Unlock() defer func() { driver.eventLock.Lock() stat = driver.status }() waitForDeath: for { select { case <-driver.done: break waitForDeath case <-t.C: } t.Reset(timeout) } return }
go
func (driver *MesosSchedulerDriver) join() (stat mesos.Status, err error) { if stat = driver.status; stat != mesos.Status_DRIVER_RUNNING { err = fmt.Errorf("Unable to Join, expecting driver status %s, but is %s", mesos.Status_DRIVER_RUNNING, stat) return } timeout := 1 * time.Second t := time.NewTimer(timeout) defer t.Stop() driver.eventLock.Unlock() defer func() { driver.eventLock.Lock() stat = driver.status }() waitForDeath: for { select { case <-driver.done: break waitForDeath case <-t.C: } t.Reset(timeout) } return }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "join", "(", ")", "(", "stat", "mesos", ".", "Status", ",", "err", "error", ")", "{", "if", "stat", "=", "driver", ".", "status", ";", "stat", "!=", "mesos", ".", "Status_DRIVER_RUNNING", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "mesos", ".", "Status_DRIVER_RUNNING", ",", "stat", ")", "\n", "return", "\n", "}", "\n\n", "timeout", ":=", "1", "*", "time", ".", "Second", "\n", "t", ":=", "time", ".", "NewTimer", "(", "timeout", ")", "\n", "defer", "t", ".", "Stop", "(", ")", "\n\n", "driver", ".", "eventLock", ".", "Unlock", "(", ")", "\n", "defer", "func", "(", ")", "{", "driver", ".", "eventLock", ".", "Lock", "(", ")", "\n", "stat", "=", "driver", ".", "status", "\n", "}", "(", ")", "\n", "waitForDeath", ":", "for", "{", "select", "{", "case", "<-", "driver", ".", "done", ":", "break", "waitForDeath", "\n", "case", "<-", "t", ".", "C", ":", "}", "\n", "t", ".", "Reset", "(", "timeout", ")", "\n", "}", "\n", "return", "\n", "}" ]
// join expects to be guarded by eventLock
[ "join", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1007-L1032
13,034
mesos/mesos-go
api/v0/scheduler/scheduler.go
Run
func (driver *MesosSchedulerDriver) Run() (mesos.Status, error) { driver.eventLock.Lock() defer driver.eventLock.Unlock() return driver.run(driver.context()) }
go
func (driver *MesosSchedulerDriver) Run() (mesos.Status, error) { driver.eventLock.Lock() defer driver.eventLock.Unlock() return driver.run(driver.context()) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "Run", "(", ")", "(", "mesos", ".", "Status", ",", "error", ")", "{", "driver", ".", "eventLock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "eventLock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "run", "(", "driver", ".", "context", "(", ")", ")", "\n", "}" ]
//Run starts and joins driver process and waits to be stopped or aborted.
[ "Run", "starts", "and", "joins", "driver", "process", "and", "waits", "to", "be", "stopped", "or", "aborted", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1035-L1039
13,035
mesos/mesos-go
api/v0/scheduler/scheduler.go
run
func (driver *MesosSchedulerDriver) run(ctx context.Context) (mesos.Status, error) { stat, err := driver.start() if err != nil { return driver.stop(ctx, err, false) } if stat != mesos.Status_DRIVER_RUNNING { return stat, fmt.Errorf("Unable to Run, expecting driver status %s, but is %s:", mesos.Status_DRIVER_RUNNING, driver.status) } log.Infoln("Scheduler driver running. Waiting to be stopped.") return driver.join() }
go
func (driver *MesosSchedulerDriver) run(ctx context.Context) (mesos.Status, error) { stat, err := driver.start() if err != nil { return driver.stop(ctx, err, false) } if stat != mesos.Status_DRIVER_RUNNING { return stat, fmt.Errorf("Unable to Run, expecting driver status %s, but is %s:", mesos.Status_DRIVER_RUNNING, driver.status) } log.Infoln("Scheduler driver running. Waiting to be stopped.") return driver.join() }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "run", "(", "ctx", "context", ".", "Context", ")", "(", "mesos", ".", "Status", ",", "error", ")", "{", "stat", ",", "err", ":=", "driver", ".", "start", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "driver", ".", "stop", "(", "ctx", ",", "err", ",", "false", ")", "\n", "}", "\n\n", "if", "stat", "!=", "mesos", ".", "Status_DRIVER_RUNNING", "{", "return", "stat", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "mesos", ".", "Status_DRIVER_RUNNING", ",", "driver", ".", "status", ")", "\n", "}", "\n\n", "log", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "driver", ".", "join", "(", ")", "\n", "}" ]
// run expected to be guarded by eventLock
[ "run", "expected", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1042-L1055
13,036
mesos/mesos-go
api/v0/scheduler/scheduler.go
Stop
func (driver *MesosSchedulerDriver) Stop(failover bool) (mesos.Status, error) { driver.eventLock.Lock() defer driver.eventLock.Unlock() return driver.stop(driver.context(), nil, failover) }
go
func (driver *MesosSchedulerDriver) Stop(failover bool) (mesos.Status, error) { driver.eventLock.Lock() defer driver.eventLock.Unlock() return driver.stop(driver.context(), nil, failover) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "Stop", "(", "failover", "bool", ")", "(", "mesos", ".", "Status", ",", "error", ")", "{", "driver", ".", "eventLock", ".", "Lock", "(", ")", "\n", "defer", "driver", ".", "eventLock", ".", "Unlock", "(", ")", "\n", "return", "driver", ".", "stop", "(", "driver", ".", "context", "(", ")", ",", "nil", ",", "failover", ")", "\n", "}" ]
//Stop stops the driver.
[ "Stop", "stops", "the", "driver", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1058-L1062
13,037
mesos/mesos-go
api/v0/scheduler/scheduler.go
abort
func (driver *MesosSchedulerDriver) abort(ctx context.Context, cause error) (stat mesos.Status, err error) { if driver.masterDetector != nil { defer driver.masterDetector.Cancel() } log.Infof("Aborting framework [%+v]", driver.frameworkInfo.Id) if driver.connected { _, err = driver.stop(ctx, cause, true) } else { driver._stop(cause, mesos.Status_DRIVER_ABORTED) } stat = mesos.Status_DRIVER_ABORTED driver.status = stat return }
go
func (driver *MesosSchedulerDriver) abort(ctx context.Context, cause error) (stat mesos.Status, err error) { if driver.masterDetector != nil { defer driver.masterDetector.Cancel() } log.Infof("Aborting framework [%+v]", driver.frameworkInfo.Id) if driver.connected { _, err = driver.stop(ctx, cause, true) } else { driver._stop(cause, mesos.Status_DRIVER_ABORTED) } stat = mesos.Status_DRIVER_ABORTED driver.status = stat return }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "abort", "(", "ctx", "context", ".", "Context", ",", "cause", "error", ")", "(", "stat", "mesos", ".", "Status", ",", "err", "error", ")", "{", "if", "driver", ".", "masterDetector", "!=", "nil", "{", "defer", "driver", ".", "masterDetector", ".", "Cancel", "(", ")", "\n", "}", "\n\n", "log", ".", "Infof", "(", "\"", "\"", ",", "driver", ".", "frameworkInfo", ".", "Id", ")", "\n\n", "if", "driver", ".", "connected", "{", "_", ",", "err", "=", "driver", ".", "stop", "(", "ctx", ",", "cause", ",", "true", ")", "\n", "}", "else", "{", "driver", ".", "_stop", "(", "cause", ",", "mesos", ".", "Status_DRIVER_ABORTED", ")", "\n", "}", "\n\n", "stat", "=", "mesos", ".", "Status_DRIVER_ABORTED", "\n", "driver", ".", "status", "=", "stat", "\n", "return", "\n", "}" ]
// abort expects to be guarded by eventLock
[ "abort", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1136-L1152
13,038
mesos/mesos-go
api/v0/scheduler/scheduler.go
pushLostTask
func (driver *MesosSchedulerDriver) pushLostTask(ctx context.Context, taskInfo *mesos.TaskInfo, why string) { msg := &mesos.StatusUpdateMessage{ Update: &mesos.StatusUpdate{ FrameworkId: driver.frameworkInfo.Id, Status: &mesos.TaskStatus{ TaskId: taskInfo.TaskId, State: mesos.TaskState_TASK_LOST.Enum(), Source: mesos.TaskStatus_SOURCE_MASTER.Enum(), Message: proto.String(why), Reason: mesos.TaskStatus_REASON_MASTER_DISCONNECTED.Enum(), }, SlaveId: taskInfo.SlaveId, ExecutorId: taskInfo.Executor.ExecutorId, Timestamp: proto.Float64(float64(time.Now().Unix())), }, Pid: proto.String(driver.self.String()), } // put it on internal chanel // will cause handler to push to attached Scheduler driver.statusUpdated(ctx, driver.self, msg) }
go
func (driver *MesosSchedulerDriver) pushLostTask(ctx context.Context, taskInfo *mesos.TaskInfo, why string) { msg := &mesos.StatusUpdateMessage{ Update: &mesos.StatusUpdate{ FrameworkId: driver.frameworkInfo.Id, Status: &mesos.TaskStatus{ TaskId: taskInfo.TaskId, State: mesos.TaskState_TASK_LOST.Enum(), Source: mesos.TaskStatus_SOURCE_MASTER.Enum(), Message: proto.String(why), Reason: mesos.TaskStatus_REASON_MASTER_DISCONNECTED.Enum(), }, SlaveId: taskInfo.SlaveId, ExecutorId: taskInfo.Executor.ExecutorId, Timestamp: proto.Float64(float64(time.Now().Unix())), }, Pid: proto.String(driver.self.String()), } // put it on internal chanel // will cause handler to push to attached Scheduler driver.statusUpdated(ctx, driver.self, msg) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "pushLostTask", "(", "ctx", "context", ".", "Context", ",", "taskInfo", "*", "mesos", ".", "TaskInfo", ",", "why", "string", ")", "{", "msg", ":=", "&", "mesos", ".", "StatusUpdateMessage", "{", "Update", ":", "&", "mesos", ".", "StatusUpdate", "{", "FrameworkId", ":", "driver", ".", "frameworkInfo", ".", "Id", ",", "Status", ":", "&", "mesos", ".", "TaskStatus", "{", "TaskId", ":", "taskInfo", ".", "TaskId", ",", "State", ":", "mesos", ".", "TaskState_TASK_LOST", ".", "Enum", "(", ")", ",", "Source", ":", "mesos", ".", "TaskStatus_SOURCE_MASTER", ".", "Enum", "(", ")", ",", "Message", ":", "proto", ".", "String", "(", "why", ")", ",", "Reason", ":", "mesos", ".", "TaskStatus_REASON_MASTER_DISCONNECTED", ".", "Enum", "(", ")", ",", "}", ",", "SlaveId", ":", "taskInfo", ".", "SlaveId", ",", "ExecutorId", ":", "taskInfo", ".", "Executor", ".", "ExecutorId", ",", "Timestamp", ":", "proto", ".", "Float64", "(", "float64", "(", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", ")", ")", ",", "}", ",", "Pid", ":", "proto", ".", "String", "(", "driver", ".", "self", ".", "String", "(", ")", ")", ",", "}", "\n\n", "// put it on internal chanel", "// will cause handler to push to attached Scheduler", "driver", ".", "statusUpdated", "(", "ctx", ",", "driver", ".", "self", ",", "msg", ")", "\n", "}" ]
// pushLostTask expects to be guarded by eventLock
[ "pushLostTask", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1364-L1385
13,039
mesos/mesos-go
api/v0/scheduler/scheduler.go
fatal
func (driver *MesosSchedulerDriver) fatal(ctx context.Context, err string) { if driver.status == mesos.Status_DRIVER_ABORTED { log.V(3).Infoln("Ignoring error message, the driver is aborted!") return } driver.abort(ctx, &ErrDriverAborted{Reason: err}) }
go
func (driver *MesosSchedulerDriver) fatal(ctx context.Context, err string) { if driver.status == mesos.Status_DRIVER_ABORTED { log.V(3).Infoln("Ignoring error message, the driver is aborted!") return } driver.abort(ctx, &ErrDriverAborted{Reason: err}) }
[ "func", "(", "driver", "*", "MesosSchedulerDriver", ")", "fatal", "(", "ctx", "context", ".", "Context", ",", "err", "string", ")", "{", "if", "driver", ".", "status", "==", "mesos", ".", "Status_DRIVER_ABORTED", "{", "log", ".", "V", "(", "3", ")", ".", "Infoln", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "driver", ".", "abort", "(", "ctx", ",", "&", "ErrDriverAborted", "{", "Reason", ":", "err", "}", ")", "\n", "}" ]
// error expects to be guarded by eventLock
[ "error", "expects", "to", "be", "guarded", "by", "eventLock" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/scheduler/scheduler.go#L1533-L1539
13,040
mesos/mesos-go
api/v0/auth/login.go
LoginProviderFrom
func LoginProviderFrom(ctx context.Context) (name string, ok bool) { name, ok = ctx.Value(loginProviderNameKey).(string) return }
go
func LoginProviderFrom(ctx context.Context) (name string, ok bool) { name, ok = ctx.Value(loginProviderNameKey).(string) return }
[ "func", "LoginProviderFrom", "(", "ctx", "context", ".", "Context", ")", "(", "name", "string", ",", "ok", "bool", ")", "{", "name", ",", "ok", "=", "ctx", ".", "Value", "(", "loginProviderNameKey", ")", ".", "(", "string", ")", "\n", "return", "\n", "}" ]
// Return the name of the login provider specified in this context.
[ "Return", "the", "name", "of", "the", "login", "provider", "specified", "in", "this", "context", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/auth/login.go#L60-L63
13,041
mesos/mesos-go
api/v0/auth/login.go
LoginProvider
func LoginProvider(ctx context.Context) string { name, _ := LoginProviderFrom(ctx) return name }
go
func LoginProvider(ctx context.Context) string { name, _ := LoginProviderFrom(ctx) return name }
[ "func", "LoginProvider", "(", "ctx", "context", ".", "Context", ")", "string", "{", "name", ",", "_", ":=", "LoginProviderFrom", "(", "ctx", ")", "\n", "return", "name", "\n", "}" ]
// Return the name of the login provider specified in this context, or empty // string if none.
[ "Return", "the", "name", "of", "the", "login", "provider", "specified", "in", "this", "context", "or", "empty", "string", "if", "none", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/auth/login.go#L67-L70
13,042
mesos/mesos-go
api/v0/executor/mock/mock.go
Registered
func (e *Executor) Registered(executor.ExecutorDriver, *mesosproto.ExecutorInfo, *mesosproto.FrameworkInfo, *mesosproto.SlaveInfo) { e.Called() }
go
func (e *Executor) Registered(executor.ExecutorDriver, *mesosproto.ExecutorInfo, *mesosproto.FrameworkInfo, *mesosproto.SlaveInfo) { e.Called() }
[ "func", "(", "e", "*", "Executor", ")", "Registered", "(", "executor", ".", "ExecutorDriver", ",", "*", "mesosproto", ".", "ExecutorInfo", ",", "*", "mesosproto", ".", "FrameworkInfo", ",", "*", "mesosproto", ".", "SlaveInfo", ")", "{", "e", ".", "Called", "(", ")", "\n", "}" ]
// Registered implements the Registered handler.
[ "Registered", "implements", "the", "Registered", "handler", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/executor/mock/mock.go#L38-L40
13,043
mesos/mesos-go
api/v1/lib/encoding/json/json.go
NewEncoder
func NewEncoder(s encoding.Sink) encoding.Encoder { w := s() return encoding.EncoderFunc(func(m encoding.Marshaler) error { b, err := json.Marshal(m) if err != nil { return err } return w.WriteFrame(b) }) }
go
func NewEncoder(s encoding.Sink) encoding.Encoder { w := s() return encoding.EncoderFunc(func(m encoding.Marshaler) error { b, err := json.Marshal(m) if err != nil { return err } return w.WriteFrame(b) }) }
[ "func", "NewEncoder", "(", "s", "encoding", ".", "Sink", ")", "encoding", ".", "Encoder", "{", "w", ":=", "s", "(", ")", "\n", "return", "encoding", ".", "EncoderFunc", "(", "func", "(", "m", "encoding", ".", "Marshaler", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "w", ".", "WriteFrame", "(", "b", ")", "\n", "}", ")", "\n", "}" ]
// NewEncoder returns a new Encoder of Calls to JSON messages written to // the given io.Writer.
[ "NewEncoder", "returns", "a", "new", "Encoder", "of", "Calls", "to", "JSON", "messages", "written", "to", "the", "given", "io", ".", "Writer", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/json/json.go#L12-L21
13,044
mesos/mesos-go
api/v1/lib/encoding/json/json.go
NewDecoder
func NewDecoder(s encoding.Source) encoding.Decoder { r := s() dec := framing.NewDecoder(r, json.Unmarshal) return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) }
go
func NewDecoder(s encoding.Source) encoding.Decoder { r := s() dec := framing.NewDecoder(r, json.Unmarshal) return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) }
[ "func", "NewDecoder", "(", "s", "encoding", ".", "Source", ")", "encoding", ".", "Decoder", "{", "r", ":=", "s", "(", ")", "\n", "dec", ":=", "framing", ".", "NewDecoder", "(", "r", ",", "json", ".", "Unmarshal", ")", "\n", "return", "encoding", ".", "DecoderFunc", "(", "func", "(", "u", "encoding", ".", "Unmarshaler", ")", "error", "{", "return", "dec", ".", "Decode", "(", "u", ")", "}", ")", "\n", "}" ]
// NewDecoder returns a new Decoder of JSON messages read from the given source.
[ "NewDecoder", "returns", "a", "new", "Decoder", "of", "JSON", "messages", "read", "from", "the", "given", "source", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/json/json.go#L24-L28
13,045
mesos/mesos-go
api/v1/lib/agent/calls/calls.go
AttachContainerInput
func AttachContainerInput(cid mesos.ContainerID) *agent.Call { return &agent.Call{ Type: agent.Call_ATTACH_CONTAINER_INPUT, AttachContainerInput: &agent.Call_AttachContainerInput{ Type: agent.Call_AttachContainerInput_CONTAINER_ID, ContainerID: &cid, }, } }
go
func AttachContainerInput(cid mesos.ContainerID) *agent.Call { return &agent.Call{ Type: agent.Call_ATTACH_CONTAINER_INPUT, AttachContainerInput: &agent.Call_AttachContainerInput{ Type: agent.Call_AttachContainerInput_CONTAINER_ID, ContainerID: &cid, }, } }
[ "func", "AttachContainerInput", "(", "cid", "mesos", ".", "ContainerID", ")", "*", "agent", ".", "Call", "{", "return", "&", "agent", ".", "Call", "{", "Type", ":", "agent", ".", "Call_ATTACH_CONTAINER_INPUT", ",", "AttachContainerInput", ":", "&", "agent", ".", "Call_AttachContainerInput", "{", "Type", ":", "agent", ".", "Call_AttachContainerInput_CONTAINER_ID", ",", "ContainerID", ":", "&", "cid", ",", "}", ",", "}", "\n", "}" ]
// AttachContainerInput returns a Call that is used to initiate attachment to a container's stdin. // Callers should first send this Call followed by one or more AttachContainerInputXxx calls.
[ "AttachContainerInput", "returns", "a", "Call", "that", "is", "used", "to", "initiate", "attachment", "to", "a", "container", "s", "stdin", ".", "Callers", "should", "first", "send", "this", "Call", "followed", "by", "one", "or", "more", "AttachContainerInputXxx", "calls", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/agent/calls/calls.go#L181-L189
13,046
mesos/mesos-go
api/v0/healthchecker/slave_health_checker.go
NewSlaveHealthChecker
func NewSlaveHealthChecker(slaveUPID *upid.UPID, threshold int, checkDuration time.Duration, timeout time.Duration) *SlaveHealthChecker { tr := &http.Transport{} checker := &SlaveHealthChecker{ slaveUPID: slaveUPID, client: &http.Client{Timeout: timeout, Transport: tr}, threshold: int32(threshold), checkDuration: checkDuration, stop: make(chan struct{}), ch: make(chan time.Time, 1), tr: tr, } if timeout == 0 { checker.client.Timeout = defaultTimeout } if checkDuration == 0 { checker.checkDuration = defaultCheckDuration } if threshold <= 0 { checker.threshold = defaultThreshold } return checker }
go
func NewSlaveHealthChecker(slaveUPID *upid.UPID, threshold int, checkDuration time.Duration, timeout time.Duration) *SlaveHealthChecker { tr := &http.Transport{} checker := &SlaveHealthChecker{ slaveUPID: slaveUPID, client: &http.Client{Timeout: timeout, Transport: tr}, threshold: int32(threshold), checkDuration: checkDuration, stop: make(chan struct{}), ch: make(chan time.Time, 1), tr: tr, } if timeout == 0 { checker.client.Timeout = defaultTimeout } if checkDuration == 0 { checker.checkDuration = defaultCheckDuration } if threshold <= 0 { checker.threshold = defaultThreshold } return checker }
[ "func", "NewSlaveHealthChecker", "(", "slaveUPID", "*", "upid", ".", "UPID", ",", "threshold", "int", ",", "checkDuration", "time", ".", "Duration", ",", "timeout", "time", ".", "Duration", ")", "*", "SlaveHealthChecker", "{", "tr", ":=", "&", "http", ".", "Transport", "{", "}", "\n", "checker", ":=", "&", "SlaveHealthChecker", "{", "slaveUPID", ":", "slaveUPID", ",", "client", ":", "&", "http", ".", "Client", "{", "Timeout", ":", "timeout", ",", "Transport", ":", "tr", "}", ",", "threshold", ":", "int32", "(", "threshold", ")", ",", "checkDuration", ":", "checkDuration", ",", "stop", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "ch", ":", "make", "(", "chan", "time", ".", "Time", ",", "1", ")", ",", "tr", ":", "tr", ",", "}", "\n", "if", "timeout", "==", "0", "{", "checker", ".", "client", ".", "Timeout", "=", "defaultTimeout", "\n", "}", "\n", "if", "checkDuration", "==", "0", "{", "checker", ".", "checkDuration", "=", "defaultCheckDuration", "\n", "}", "\n", "if", "threshold", "<=", "0", "{", "checker", ".", "threshold", "=", "defaultThreshold", "\n", "}", "\n", "return", "checker", "\n", "}" ]
// NewSlaveHealthChecker creates a slave health checker and return a notification channel. // Each time the checker thinks the slave is unhealthy, it will send a notification through the channel.
[ "NewSlaveHealthChecker", "creates", "a", "slave", "health", "checker", "and", "return", "a", "notification", "channel", ".", "Each", "time", "the", "checker", "thinks", "the", "slave", "is", "unhealthy", "it", "will", "send", "a", "notification", "through", "the", "channel", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/healthchecker/slave_health_checker.go#L57-L78
13,047
mesos/mesos-go
api/v0/healthchecker/slave_health_checker.go
Start
func (s *SlaveHealthChecker) Start() <-chan time.Time { go func() { t := time.NewTicker(s.checkDuration) defer t.Stop() for { select { case <-t.C: select { case <-s.stop: return default: // continue } if paused, slavepid := func() (x bool, y upid.UPID) { s.RLock() defer s.RUnlock() x = s.paused if s.slaveUPID != nil { y = *s.slaveUPID } return }(); !paused { s.doCheck(slavepid) } case <-s.stop: return } } }() return s.ch }
go
func (s *SlaveHealthChecker) Start() <-chan time.Time { go func() { t := time.NewTicker(s.checkDuration) defer t.Stop() for { select { case <-t.C: select { case <-s.stop: return default: // continue } if paused, slavepid := func() (x bool, y upid.UPID) { s.RLock() defer s.RUnlock() x = s.paused if s.slaveUPID != nil { y = *s.slaveUPID } return }(); !paused { s.doCheck(slavepid) } case <-s.stop: return } } }() return s.ch }
[ "func", "(", "s", "*", "SlaveHealthChecker", ")", "Start", "(", ")", "<-", "chan", "time", ".", "Time", "{", "go", "func", "(", ")", "{", "t", ":=", "time", ".", "NewTicker", "(", "s", ".", "checkDuration", ")", "\n", "defer", "t", ".", "Stop", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "t", ".", "C", ":", "select", "{", "case", "<-", "s", ".", "stop", ":", "return", "\n", "default", ":", "// continue", "}", "\n", "if", "paused", ",", "slavepid", ":=", "func", "(", ")", "(", "x", "bool", ",", "y", "upid", ".", "UPID", ")", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "x", "=", "s", ".", "paused", "\n", "if", "s", ".", "slaveUPID", "!=", "nil", "{", "y", "=", "*", "s", ".", "slaveUPID", "\n", "}", "\n", "return", "\n", "}", "(", ")", ";", "!", "paused", "{", "s", ".", "doCheck", "(", "slavepid", ")", "\n", "}", "\n", "case", "<-", "s", ".", "stop", ":", "return", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "return", "s", ".", "ch", "\n", "}" ]
// Start will start the health checker and returns the notification channel.
[ "Start", "will", "start", "the", "health", "checker", "and", "returns", "the", "notification", "channel", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/healthchecker/slave_health_checker.go#L81-L111
13,048
mesos/mesos-go
api/v0/healthchecker/slave_health_checker.go
Pause
func (s *SlaveHealthChecker) Pause() { s.Lock() defer s.Unlock() s.paused = true }
go
func (s *SlaveHealthChecker) Pause() { s.Lock() defer s.Unlock() s.paused = true }
[ "func", "(", "s", "*", "SlaveHealthChecker", ")", "Pause", "(", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "paused", "=", "true", "\n", "}" ]
// Pause will pause the slave health checker.
[ "Pause", "will", "pause", "the", "slave", "health", "checker", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/healthchecker/slave_health_checker.go#L114-L118
13,049
mesos/mesos-go
api/v0/healthchecker/slave_health_checker.go
Continue
func (s *SlaveHealthChecker) Continue(slaveUPID *upid.UPID) { s.Lock() defer s.Unlock() s.paused = false s.slaveUPID = slaveUPID }
go
func (s *SlaveHealthChecker) Continue(slaveUPID *upid.UPID) { s.Lock() defer s.Unlock() s.paused = false s.slaveUPID = slaveUPID }
[ "func", "(", "s", "*", "SlaveHealthChecker", ")", "Continue", "(", "slaveUPID", "*", "upid", ".", "UPID", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "paused", "=", "false", "\n", "s", ".", "slaveUPID", "=", "slaveUPID", "\n", "}" ]
// Continue will continue the slave health checker with a new slave upid.
[ "Continue", "will", "continue", "the", "slave", "health", "checker", "with", "a", "new", "slave", "upid", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/healthchecker/slave_health_checker.go#L121-L126
13,050
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/rules.go
AckStatusUpdatesF
func AckStatusUpdatesF(callerLookup func() calls.Caller) Rule { return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { // aggressively attempt to ack updates: even if there's pre-existing error state attempt // to acknowledge all status updates. origErr := err if e.GetType() == scheduler.Event_UPDATE { var ( s = e.GetUpdate().GetStatus() uuid = s.GetUUID() ) // only ACK non-empty UUID's, as per mesos scheduler spec if len(uuid) > 0 { ack := calls.Acknowledge( s.GetAgentID().GetValue(), s.TaskID.Value, uuid, ) err = calls.CallNoData(ctx, callerLookup(), ack) if err != nil { // TODO(jdef): not sure how important this is; if there's an error ack'ing // because we beacame disconnected, then we'll just reconnect later and // Mesos will ask us to ACK anyway -- why pay special attention to these // call failures vs others? err = &calls.AckError{Ack: ack, Cause: err} return ctx, e, Error2(origErr, err) // drop (do not propagate to chain) } } } return chain(ctx, e, origErr) } }
go
func AckStatusUpdatesF(callerLookup func() calls.Caller) Rule { return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { // aggressively attempt to ack updates: even if there's pre-existing error state attempt // to acknowledge all status updates. origErr := err if e.GetType() == scheduler.Event_UPDATE { var ( s = e.GetUpdate().GetStatus() uuid = s.GetUUID() ) // only ACK non-empty UUID's, as per mesos scheduler spec if len(uuid) > 0 { ack := calls.Acknowledge( s.GetAgentID().GetValue(), s.TaskID.Value, uuid, ) err = calls.CallNoData(ctx, callerLookup(), ack) if err != nil { // TODO(jdef): not sure how important this is; if there's an error ack'ing // because we beacame disconnected, then we'll just reconnect later and // Mesos will ask us to ACK anyway -- why pay special attention to these // call failures vs others? err = &calls.AckError{Ack: ack, Cause: err} return ctx, e, Error2(origErr, err) // drop (do not propagate to chain) } } } return chain(ctx, e, origErr) } }
[ "func", "AckStatusUpdatesF", "(", "callerLookup", "func", "(", ")", "calls", ".", "Caller", ")", "Rule", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "chain", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "// aggressively attempt to ack updates: even if there's pre-existing error state attempt", "// to acknowledge all status updates.", "origErr", ":=", "err", "\n", "if", "e", ".", "GetType", "(", ")", "==", "scheduler", ".", "Event_UPDATE", "{", "var", "(", "s", "=", "e", ".", "GetUpdate", "(", ")", ".", "GetStatus", "(", ")", "\n", "uuid", "=", "s", ".", "GetUUID", "(", ")", "\n", ")", "\n", "// only ACK non-empty UUID's, as per mesos scheduler spec", "if", "len", "(", "uuid", ")", ">", "0", "{", "ack", ":=", "calls", ".", "Acknowledge", "(", "s", ".", "GetAgentID", "(", ")", ".", "GetValue", "(", ")", ",", "s", ".", "TaskID", ".", "Value", ",", "uuid", ",", ")", "\n", "err", "=", "calls", ".", "CallNoData", "(", "ctx", ",", "callerLookup", "(", ")", ",", "ack", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO(jdef): not sure how important this is; if there's an error ack'ing", "// because we beacame disconnected, then we'll just reconnect later and", "// Mesos will ask us to ACK anyway -- why pay special attention to these", "// call failures vs others?", "err", "=", "&", "calls", ".", "AckError", "{", "Ack", ":", "ack", ",", "Cause", ":", "err", "}", "\n", "return", "ctx", ",", "e", ",", "Error2", "(", "origErr", ",", "err", ")", "// drop (do not propagate to chain)", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "chain", "(", "ctx", ",", "e", ",", "origErr", ")", "\n", "}", "\n", "}" ]
// AckStatusUpdatesF is a functional adapter for AckStatusUpdates, useful for cases where the caller may // change over time. An error that occurs while ack'ing the status update is returned as a calls.AckError.
[ "AckStatusUpdatesF", "is", "a", "functional", "adapter", "for", "AckStatusUpdates", "useful", "for", "cases", "where", "the", "caller", "may", "change", "over", "time", ".", "An", "error", "that", "occurs", "while", "ack", "ing", "the", "status", "update", "is", "returned", "as", "a", "calls", ".", "AckError", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/rules.go#L84-L114
13,051
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/rules.go
DefaultEventLogger
func DefaultEventLogger(eventLabel string) func(*scheduler.Event) { if eventLabel == "" { return func(e *scheduler.Event) { log.Println(e) } } return func(e *scheduler.Event) { log.Println(eventLabel, e) } }
go
func DefaultEventLogger(eventLabel string) func(*scheduler.Event) { if eventLabel == "" { return func(e *scheduler.Event) { log.Println(e) } } return func(e *scheduler.Event) { log.Println(eventLabel, e) } }
[ "func", "DefaultEventLogger", "(", "eventLabel", "string", ")", "func", "(", "*", "scheduler", ".", "Event", ")", "{", "if", "eventLabel", "==", "\"", "\"", "{", "return", "func", "(", "e", "*", "scheduler", ".", "Event", ")", "{", "log", ".", "Println", "(", "e", ")", "}", "\n", "}", "\n", "return", "func", "(", "e", "*", "scheduler", ".", "Event", ")", "{", "log", ".", "Println", "(", "eventLabel", ",", "e", ")", "}", "\n", "}" ]
// DefaultEventLogger logs the event via the `log` package.
[ "DefaultEventLogger", "logs", "the", "event", "via", "the", "log", "package", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/rules.go#L120-L125
13,052
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/rules.go
LogEvents
func LogEvents(f func(*scheduler.Event)) Rule { if f == nil { f = DefaultEventLogger(DefaultEventLabel) } return Rule(func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { f(e) return chain(ctx, e, err) }) }
go
func LogEvents(f func(*scheduler.Event)) Rule { if f == nil { f = DefaultEventLogger(DefaultEventLabel) } return Rule(func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { f(e) return chain(ctx, e, err) }) }
[ "func", "LogEvents", "(", "f", "func", "(", "*", "scheduler", ".", "Event", ")", ")", "Rule", "{", "if", "f", "==", "nil", "{", "f", "=", "DefaultEventLogger", "(", "DefaultEventLabel", ")", "\n", "}", "\n", "return", "Rule", "(", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "chain", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "f", "(", "e", ")", "\n", "return", "chain", "(", "ctx", ",", "e", ",", "err", ")", "\n", "}", ")", "\n", "}" ]
// LogEvents returns a rule that logs scheduler events to the EventLogger
[ "LogEvents", "returns", "a", "rule", "that", "logs", "scheduler", "events", "to", "the", "EventLogger" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/rules.go#L128-L136
13,053
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/rules.go
AckOperationUpdatesF
func AckOperationUpdatesF(callerLookup func() calls.Caller) Rule { return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { // aggressively attempt to ack updates: even if there's pre-existing error state attempt // to acknowledge all offer operation status updates. origErr := err if e.GetType() == scheduler.Event_UPDATE_OPERATION_STATUS { var ( s = e.GetUpdateOperationStatus().GetStatus() uuid = s.GetUUID().GetValue() ) // only ACK non-empty UUID's, as per mesos scheduler spec. if len(uuid) > 0 { // the fact that we're receiving this offer operation status update means that the // framework supplied an operation_id to the master when executing the offer operation, // therefore the operation_id included in the status object here should be non-empty. opID := s.GetOperationID().GetValue() if opID == "" { panic("expected non-empty offer operation ID for offer operation status update") } // try to extract a resource provider ID; we can safely assume that all converted resources // are for the same provider ID (including a non-specified one). rpID := "" conv := s.GetConvertedResources() for i := range conv { id := conv[i].GetProviderID().GetValue() if id != "" { rpID = id break } } ack := calls.AcknowledgeOperationStatus( "", // agentID: optional rpID, // optional uuid, opID, ) err = calls.CallNoData(ctx, callerLookup(), ack) if err != nil { // TODO(jdef): not sure how important this is; if there's an error ack'ing // because we became disconnected, then we'll just reconnect later and // Mesos will ask us to ACK anyway -- why pay special attention to these // call failures vs others? err = &calls.AckError{Ack: ack, Cause: err} return ctx, e, Error2(origErr, err) // drop (do not propagate to chain) } } } return chain(ctx, e, origErr) } }
go
func AckOperationUpdatesF(callerLookup func() calls.Caller) Rule { return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { // aggressively attempt to ack updates: even if there's pre-existing error state attempt // to acknowledge all offer operation status updates. origErr := err if e.GetType() == scheduler.Event_UPDATE_OPERATION_STATUS { var ( s = e.GetUpdateOperationStatus().GetStatus() uuid = s.GetUUID().GetValue() ) // only ACK non-empty UUID's, as per mesos scheduler spec. if len(uuid) > 0 { // the fact that we're receiving this offer operation status update means that the // framework supplied an operation_id to the master when executing the offer operation, // therefore the operation_id included in the status object here should be non-empty. opID := s.GetOperationID().GetValue() if opID == "" { panic("expected non-empty offer operation ID for offer operation status update") } // try to extract a resource provider ID; we can safely assume that all converted resources // are for the same provider ID (including a non-specified one). rpID := "" conv := s.GetConvertedResources() for i := range conv { id := conv[i].GetProviderID().GetValue() if id != "" { rpID = id break } } ack := calls.AcknowledgeOperationStatus( "", // agentID: optional rpID, // optional uuid, opID, ) err = calls.CallNoData(ctx, callerLookup(), ack) if err != nil { // TODO(jdef): not sure how important this is; if there's an error ack'ing // because we became disconnected, then we'll just reconnect later and // Mesos will ask us to ACK anyway -- why pay special attention to these // call failures vs others? err = &calls.AckError{Ack: ack, Cause: err} return ctx, e, Error2(origErr, err) // drop (do not propagate to chain) } } } return chain(ctx, e, origErr) } }
[ "func", "AckOperationUpdatesF", "(", "callerLookup", "func", "(", ")", "calls", ".", "Caller", ")", "Rule", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "chain", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "// aggressively attempt to ack updates: even if there's pre-existing error state attempt", "// to acknowledge all offer operation status updates.", "origErr", ":=", "err", "\n", "if", "e", ".", "GetType", "(", ")", "==", "scheduler", ".", "Event_UPDATE_OPERATION_STATUS", "{", "var", "(", "s", "=", "e", ".", "GetUpdateOperationStatus", "(", ")", ".", "GetStatus", "(", ")", "\n", "uuid", "=", "s", ".", "GetUUID", "(", ")", ".", "GetValue", "(", ")", "\n", ")", "\n", "// only ACK non-empty UUID's, as per mesos scheduler spec.", "if", "len", "(", "uuid", ")", ">", "0", "{", "// the fact that we're receiving this offer operation status update means that the", "// framework supplied an operation_id to the master when executing the offer operation,", "// therefore the operation_id included in the status object here should be non-empty.", "opID", ":=", "s", ".", "GetOperationID", "(", ")", ".", "GetValue", "(", ")", "\n", "if", "opID", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "// try to extract a resource provider ID; we can safely assume that all converted resources", "// are for the same provider ID (including a non-specified one).", "rpID", ":=", "\"", "\"", "\n", "conv", ":=", "s", ".", "GetConvertedResources", "(", ")", "\n", "for", "i", ":=", "range", "conv", "{", "id", ":=", "conv", "[", "i", "]", ".", "GetProviderID", "(", ")", ".", "GetValue", "(", ")", "\n", "if", "id", "!=", "\"", "\"", "{", "rpID", "=", "id", "\n", "break", "\n", "}", "\n", "}", "\n", "ack", ":=", "calls", ".", "AcknowledgeOperationStatus", "(", "\"", "\"", ",", "// agentID: optional", "rpID", ",", "// optional", "uuid", ",", "opID", ",", ")", "\n", "err", "=", "calls", ".", "CallNoData", "(", "ctx", ",", "callerLookup", "(", ")", ",", "ack", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO(jdef): not sure how important this is; if there's an error ack'ing", "// because we became disconnected, then we'll just reconnect later and", "// Mesos will ask us to ACK anyway -- why pay special attention to these", "// call failures vs others?", "err", "=", "&", "calls", ".", "AckError", "{", "Ack", ":", "ack", ",", "Cause", ":", "err", "}", "\n", "return", "ctx", ",", "e", ",", "Error2", "(", "origErr", ",", "err", ")", "// drop (do not propagate to chain)", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "chain", "(", "ctx", ",", "e", ",", "origErr", ")", "\n", "}", "\n", "}" ]
// AckOperationUpdatesF is a functional adapter for AckOperationUpdates, useful for cases where the caller may // change over time. An error that occurs while ack'ing the status update is returned as a calls.AckError.
[ "AckOperationUpdatesF", "is", "a", "functional", "adapter", "for", "AckOperationUpdates", "useful", "for", "cases", "where", "the", "caller", "may", "change", "over", "time", ".", "An", "error", "that", "occurs", "while", "ack", "ing", "the", "status", "update", "is", "returned", "as", "a", "calls", ".", "AckError", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/rules.go#L146-L195
13,054
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/controller.go
WithSubscriptionTerminated
func WithSubscriptionTerminated(handler func(error)) Option { return func(c *Config) Option { old := c.subscriptionTerminated c.subscriptionTerminated = handler return WithSubscriptionTerminated(old) } }
go
func WithSubscriptionTerminated(handler func(error)) Option { return func(c *Config) Option { old := c.subscriptionTerminated c.subscriptionTerminated = handler return WithSubscriptionTerminated(old) } }
[ "func", "WithSubscriptionTerminated", "(", "handler", "func", "(", "error", ")", ")", "Option", "{", "return", "func", "(", "c", "*", "Config", ")", "Option", "{", "old", ":=", "c", ".", "subscriptionTerminated", "\n", "c", ".", "subscriptionTerminated", "=", "handler", "\n", "return", "WithSubscriptionTerminated", "(", "old", ")", "\n", "}", "\n", "}" ]
// WithSubscriptionTerminated sets a handler that is invoked at the end of every subscription cycle; the // given error may be nil if no error occurred. subscriptionTerminated is optional; if nil then errors are // swallowed.
[ "WithSubscriptionTerminated", "sets", "a", "handler", "that", "is", "invoked", "at", "the", "end", "of", "every", "subscription", "cycle", ";", "the", "given", "error", "may", "be", "nil", "if", "no", "error", "occurred", ".", "subscriptionTerminated", "is", "optional", ";", "if", "nil", "then", "errors", "are", "swallowed", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/controller.go#L75-L81
13,055
mesos/mesos-go
api/v1/lib/extras/scheduler/controller/controller.go
Run
func Run(ctx context.Context, framework *mesos.FrameworkInfo, caller calls.Caller, options ...Option) (lastErr error) { var config Config for _, opt := range options { if opt != nil { opt(&config) } } if config.handler == nil { config.handler = DefaultHandler } subscribe := calls.Subscribe(framework) subscribe.Subscribe.SuppressedRoles = config.initSuppressRoles for !isDone(ctx) { frameworkID := config.tryFrameworkID() if framework.GetFailoverTimeout() > 0 && frameworkID != "" { subscribe.With(calls.SubscribeTo(frameworkID)) } if config.registrationTokens != nil { select { case _, ok := <-config.registrationTokens: if !ok { // re-registration canceled, exit Run loop return } case <-ctx.Done(): return ctx.Err() } } resp, err := caller.Call(ctx, subscribe) lastErr = processSubscription(ctx, config, resp, err) if config.subscriptionTerminated != nil { config.subscriptionTerminated(lastErr) } } return }
go
func Run(ctx context.Context, framework *mesos.FrameworkInfo, caller calls.Caller, options ...Option) (lastErr error) { var config Config for _, opt := range options { if opt != nil { opt(&config) } } if config.handler == nil { config.handler = DefaultHandler } subscribe := calls.Subscribe(framework) subscribe.Subscribe.SuppressedRoles = config.initSuppressRoles for !isDone(ctx) { frameworkID := config.tryFrameworkID() if framework.GetFailoverTimeout() > 0 && frameworkID != "" { subscribe.With(calls.SubscribeTo(frameworkID)) } if config.registrationTokens != nil { select { case _, ok := <-config.registrationTokens: if !ok { // re-registration canceled, exit Run loop return } case <-ctx.Done(): return ctx.Err() } } resp, err := caller.Call(ctx, subscribe) lastErr = processSubscription(ctx, config, resp, err) if config.subscriptionTerminated != nil { config.subscriptionTerminated(lastErr) } } return }
[ "func", "Run", "(", "ctx", "context", ".", "Context", ",", "framework", "*", "mesos", ".", "FrameworkInfo", ",", "caller", "calls", ".", "Caller", ",", "options", "...", "Option", ")", "(", "lastErr", "error", ")", "{", "var", "config", "Config", "\n", "for", "_", ",", "opt", ":=", "range", "options", "{", "if", "opt", "!=", "nil", "{", "opt", "(", "&", "config", ")", "\n", "}", "\n", "}", "\n", "if", "config", ".", "handler", "==", "nil", "{", "config", ".", "handler", "=", "DefaultHandler", "\n", "}", "\n", "subscribe", ":=", "calls", ".", "Subscribe", "(", "framework", ")", "\n", "subscribe", ".", "Subscribe", ".", "SuppressedRoles", "=", "config", ".", "initSuppressRoles", "\n", "for", "!", "isDone", "(", "ctx", ")", "{", "frameworkID", ":=", "config", ".", "tryFrameworkID", "(", ")", "\n", "if", "framework", ".", "GetFailoverTimeout", "(", ")", ">", "0", "&&", "frameworkID", "!=", "\"", "\"", "{", "subscribe", ".", "With", "(", "calls", ".", "SubscribeTo", "(", "frameworkID", ")", ")", "\n", "}", "\n", "if", "config", ".", "registrationTokens", "!=", "nil", "{", "select", "{", "case", "_", ",", "ok", ":=", "<-", "config", ".", "registrationTokens", ":", "if", "!", "ok", "{", "// re-registration canceled, exit Run loop", "return", "\n", "}", "\n", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "ctx", ".", "Err", "(", ")", "\n", "}", "\n", "}", "\n", "resp", ",", "err", ":=", "caller", ".", "Call", "(", "ctx", ",", "subscribe", ")", "\n", "lastErr", "=", "processSubscription", "(", "ctx", ",", "config", ",", "resp", ",", "err", ")", "\n", "if", "config", ".", "subscriptionTerminated", "!=", "nil", "{", "config", ".", "subscriptionTerminated", "(", "lastErr", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// Run executes a control loop that registers a framework with Mesos and processes the scheduler events // that flow through the subscription. Upon disconnection, if the current configuration reports "not done" // then the controller will attempt to re-register the framework and continue processing events.
[ "Run", "executes", "a", "control", "loop", "that", "registers", "a", "framework", "with", "Mesos", "and", "processes", "the", "scheduler", "events", "that", "flow", "through", "the", "subscription", ".", "Upon", "disconnection", "if", "the", "current", "configuration", "reports", "not", "done", "then", "the", "controller", "will", "attempt", "to", "re", "-", "register", "the", "framework", "and", "continue", "processing", "events", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/controller/controller.go#L114-L149
13,056
mesos/mesos-go
api/v1/lib/agent/calls/calls_generated.go
Send
func (f SenderFunc) Send(ctx context.Context, r Request) (mesos.Response, error) { return f(ctx, r) }
go
func (f SenderFunc) Send(ctx context.Context, r Request) (mesos.Response, error) { return f(ctx, r) }
[ "func", "(", "f", "SenderFunc", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "r", "Request", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "return", "f", "(", "ctx", ",", "r", ")", "\n", "}" ]
// Send implements the Sender interface for SenderFunc
[ "Send", "implements", "the", "Sender", "interface", "for", "SenderFunc" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/agent/calls/calls_generated.go#L109-L111
13,057
mesos/mesos-go
api/v1/lib/agent/calls/calls_generated.go
IgnoreResponse
func IgnoreResponse(s Sender) SenderFunc { return func(ctx context.Context, r Request) (mesos.Response, error) { resp, err := s.Send(ctx, r) if resp != nil { resp.Close() } return nil, err } }
go
func IgnoreResponse(s Sender) SenderFunc { return func(ctx context.Context, r Request) (mesos.Response, error) { resp, err := s.Send(ctx, r) if resp != nil { resp.Close() } return nil, err } }
[ "func", "IgnoreResponse", "(", "s", "Sender", ")", "SenderFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "r", "Request", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "Send", "(", "ctx", ",", "r", ")", "\n", "if", "resp", "!=", "nil", "{", "resp", ".", "Close", "(", ")", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "}" ]
// IgnoreResponse generates a sender that closes any non-nil response received by Mesos.
[ "IgnoreResponse", "generates", "a", "sender", "that", "closes", "any", "non", "-", "nil", "response", "received", "by", "Mesos", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/agent/calls/calls_generated.go#L114-L122
13,058
mesos/mesos-go
api/v1/lib/agent/calls/calls_generated.go
SendNoData
func SendNoData(ctx context.Context, sender Sender, r Request) (err error) { _, err = IgnoreResponse(sender).Send(ctx, r) return }
go
func SendNoData(ctx context.Context, sender Sender, r Request) (err error) { _, err = IgnoreResponse(sender).Send(ctx, r) return }
[ "func", "SendNoData", "(", "ctx", "context", ".", "Context", ",", "sender", "Sender", ",", "r", "Request", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "IgnoreResponse", "(", "sender", ")", ".", "Send", "(", "ctx", ",", "r", ")", "\n", "return", "\n", "}" ]
// SendNoData is a convenience func that executes the given Call using the provided Sender // and always drops the response data.
[ "SendNoData", "is", "a", "convenience", "func", "that", "executes", "the", "given", "Call", "using", "the", "provided", "Sender", "and", "always", "drops", "the", "response", "data", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/agent/calls/calls_generated.go#L126-L129
13,059
mesos/mesos-go
api/v0/messenger/mock/messenger.go
NewMessenger
func NewMessenger() *Messenger { return &Messenger{ messageQueue: make(chan *message, 1), handlers: make(map[string]messenger.MessageHandler), stop: make(chan struct{}), } }
go
func NewMessenger() *Messenger { return &Messenger{ messageQueue: make(chan *message, 1), handlers: make(map[string]messenger.MessageHandler), stop: make(chan struct{}), } }
[ "func", "NewMessenger", "(", ")", "*", "Messenger", "{", "return", "&", "Messenger", "{", "messageQueue", ":", "make", "(", "chan", "*", "message", ",", "1", ")", ",", "handlers", ":", "make", "(", "map", "[", "string", "]", "messenger", ".", "MessageHandler", ")", ",", "stop", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "}" ]
// NewMessenger returns a mocked messenger used for testing.
[ "NewMessenger", "returns", "a", "mocked", "messenger", "used", "for", "testing", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L45-L51
13,060
mesos/mesos-go
api/v0/messenger/mock/messenger.go
Install
func (m *Messenger) Install(handler messenger.MessageHandler, msg proto.Message) error { m.handlers[reflect.TypeOf(msg).Elem().Name()] = handler return m.Called().Error(0) }
go
func (m *Messenger) Install(handler messenger.MessageHandler, msg proto.Message) error { m.handlers[reflect.TypeOf(msg).Elem().Name()] = handler return m.Called().Error(0) }
[ "func", "(", "m", "*", "Messenger", ")", "Install", "(", "handler", "messenger", ".", "MessageHandler", ",", "msg", "proto", ".", "Message", ")", "error", "{", "m", ".", "handlers", "[", "reflect", ".", "TypeOf", "(", "msg", ")", ".", "Elem", "(", ")", ".", "Name", "(", ")", "]", "=", "handler", "\n", "return", "m", ".", "Called", "(", ")", ".", "Error", "(", "0", ")", "\n", "}" ]
// Install is a mocked implementation.
[ "Install", "is", "a", "mocked", "implementation", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L54-L57
13,061
mesos/mesos-go
api/v0/messenger/mock/messenger.go
Send
func (m *Messenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { return m.Called().Error(0) }
go
func (m *Messenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { return m.Called().Error(0) }
[ "func", "(", "m", "*", "Messenger", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "upid", "*", "upid", ".", "UPID", ",", "msg", "proto", ".", "Message", ")", "error", "{", "return", "m", ".", "Called", "(", ")", ".", "Error", "(", "0", ")", "\n", "}" ]
// Send is a mocked implementation.
[ "Send", "is", "a", "mocked", "implementation", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L60-L62
13,062
mesos/mesos-go
api/v0/messenger/mock/messenger.go
Stop
func (m *Messenger) Stop() error { // don't close an already-closed channel select { case <-m.stop: // noop default: close(m.stop) } return m.Called().Error(0) }
go
func (m *Messenger) Stop() error { // don't close an already-closed channel select { case <-m.stop: // noop default: close(m.stop) } return m.Called().Error(0) }
[ "func", "(", "m", "*", "Messenger", ")", "Stop", "(", ")", "error", "{", "// don't close an already-closed channel", "select", "{", "case", "<-", "m", ".", "stop", ":", "// noop", "default", ":", "close", "(", "m", ".", "stop", ")", "\n", "}", "\n", "return", "m", ".", "Called", "(", ")", ".", "Error", "(", "0", ")", "\n", "}" ]
// Stop is a mocked implementation.
[ "Stop", "is", "a", "mocked", "implementation", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L75-L84
13,063
mesos/mesos-go
api/v0/messenger/mock/messenger.go
UPID
func (m *Messenger) UPID() upid.UPID { return m.Called().Get(0).(upid.UPID) }
go
func (m *Messenger) UPID() upid.UPID { return m.Called().Get(0).(upid.UPID) }
[ "func", "(", "m", "*", "Messenger", ")", "UPID", "(", ")", "upid", ".", "UPID", "{", "return", "m", ".", "Called", "(", ")", ".", "Get", "(", "0", ")", ".", "(", "upid", ".", "UPID", ")", "\n", "}" ]
// UPID is a mocked implementation.
[ "UPID", "is", "a", "mocked", "implementation", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L87-L89
13,064
mesos/mesos-go
api/v0/messenger/mock/messenger.go
Recv
func (m *Messenger) Recv(from *upid.UPID, msg proto.Message) { m.messageQueue <- &message{from, msg} }
go
func (m *Messenger) Recv(from *upid.UPID, msg proto.Message) { m.messageQueue <- &message{from, msg} }
[ "func", "(", "m", "*", "Messenger", ")", "Recv", "(", "from", "*", "upid", ".", "UPID", ",", "msg", "proto", ".", "Message", ")", "{", "m", ".", "messageQueue", "<-", "&", "message", "{", "from", ",", "msg", "}", "\n", "}" ]
// Recv receives a upid and a message, it will dispatch the message to its handler // with the upid. This is for testing.
[ "Recv", "receives", "a", "upid", "and", "a", "message", "it", "will", "dispatch", "the", "message", "to", "its", "handler", "with", "the", "upid", ".", "This", "is", "for", "testing", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/mock/messenger.go#L105-L107
13,065
mesos/mesos-go
api/v1/lib/extras/executor/callrules/callers_generated.go
Call
func (r Rule) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { if r == nil { return nil, nil } _, _, resp, err := r(ctx, c, nil, nil, ChainIdentity) return resp, err }
go
func (r Rule) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { if r == nil { return nil, nil } _, _, resp, err := r(ctx, c, nil, nil, ChainIdentity) return resp, err }
[ "func", "(", "r", "Rule", ")", "Call", "(", "ctx", "context", ".", "Context", ",", "c", "*", "executor", ".", "Call", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "if", "r", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "_", ",", "_", ",", "resp", ",", "err", ":=", "r", "(", "ctx", ",", "c", ",", "nil", ",", "nil", ",", "ChainIdentity", ")", "\n", "return", "resp", ",", "err", "\n", "}" ]
// Call implements the Caller interface for Rule
[ "Call", "implements", "the", "Caller", "interface", "for", "Rule" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/executor/callrules/callers_generated.go#L42-L48
13,066
mesos/mesos-go
api/v1/lib/extras/executor/callrules/callers_generated.go
Call
func (rs Rules) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { return Rule(rs.Eval).Call(ctx, c) }
go
func (rs Rules) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { return Rule(rs.Eval).Call(ctx, c) }
[ "func", "(", "rs", "Rules", ")", "Call", "(", "ctx", "context", ".", "Context", ",", "c", "*", "executor", ".", "Call", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "return", "Rule", "(", "rs", ".", "Eval", ")", ".", "Call", "(", "ctx", ",", "c", ")", "\n", "}" ]
// Call implements the Caller interface for Rules
[ "Call", "implements", "the", "Caller", "interface", "for", "Rules" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/executor/callrules/callers_generated.go#L51-L53
13,067
mesos/mesos-go
api/v1/lib/extras/scheduler/eventrules/eventrules_generated.go
Eval
func (r Rule) Eval(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) { if r != nil { return r(ctx, e, err, ch) } return ch(ctx, e, err) }
go
func (r Rule) Eval(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) { if r != nil { return r(ctx, e, err, ch) } return ch(ctx, e, err) }
[ "func", "(", "r", "Rule", ")", "Eval", "(", "ctx", "context", ".", "Context", ",", "e", "*", "scheduler", ".", "Event", ",", "err", "error", ",", "ch", "Chain", ")", "(", "context", ".", "Context", ",", "*", "scheduler", ".", "Event", ",", "error", ")", "{", "if", "r", "!=", "nil", "{", "return", "r", "(", "ctx", ",", "e", ",", "err", ",", "ch", ")", "\n", "}", "\n", "return", "ch", "(", "ctx", ",", "e", ",", "err", ")", "\n", "}" ]
// Eval is a convenience func that processes a nil Rule as a noop.
[ "Eval", "is", "a", "convenience", "func", "that", "processes", "a", "nil", "Rule", "as", "a", "noop", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/eventrules/eventrules_generated.go#L53-L58
13,068
mesos/mesos-go
api/v1/lib/roles/role.go
IsStrictSubroleOf
func IsStrictSubroleOf(left, right string) bool { return len(left) > len(right) && left[len(right)] == '/' && strings.HasPrefix(left, right) }
go
func IsStrictSubroleOf(left, right string) bool { return len(left) > len(right) && left[len(right)] == '/' && strings.HasPrefix(left, right) }
[ "func", "IsStrictSubroleOf", "(", "left", ",", "right", "string", ")", "bool", "{", "return", "len", "(", "left", ")", ">", "len", "(", "right", ")", "&&", "left", "[", "len", "(", "right", ")", "]", "==", "'/'", "&&", "strings", ".", "HasPrefix", "(", "left", ",", "right", ")", "\n", "}" ]
// IsStrictSubroleOf returns true if left is a strict subrole of right.
[ "IsStrictSubroleOf", "returns", "true", "if", "left", "is", "a", "strict", "subrole", "of", "right", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/roles/role.go#L35-L37
13,069
mesos/mesos-go
api/v1/lib/executor/calls/calls.go
Framework
func Framework(id string) executor.CallOpt { return func(c *executor.Call) { c.FrameworkID = mesos.FrameworkID{Value: id} } }
go
func Framework(id string) executor.CallOpt { return func(c *executor.Call) { c.FrameworkID = mesos.FrameworkID{Value: id} } }
[ "func", "Framework", "(", "id", "string", ")", "executor", ".", "CallOpt", "{", "return", "func", "(", "c", "*", "executor", ".", "Call", ")", "{", "c", ".", "FrameworkID", "=", "mesos", ".", "FrameworkID", "{", "Value", ":", "id", "}", "\n", "}", "\n", "}" ]
// Framework sets a executor.Call's FrameworkID
[ "Framework", "sets", "a", "executor", ".", "Call", "s", "FrameworkID" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls.go#L9-L13
13,070
mesos/mesos-go
api/v1/lib/executor/calls/calls.go
Executor
func Executor(id string) executor.CallOpt { return func(c *executor.Call) { c.ExecutorID = mesos.ExecutorID{Value: id} } }
go
func Executor(id string) executor.CallOpt { return func(c *executor.Call) { c.ExecutorID = mesos.ExecutorID{Value: id} } }
[ "func", "Executor", "(", "id", "string", ")", "executor", ".", "CallOpt", "{", "return", "func", "(", "c", "*", "executor", ".", "Call", ")", "{", "c", ".", "ExecutorID", "=", "mesos", ".", "ExecutorID", "{", "Value", ":", "id", "}", "\n", "}", "\n", "}" ]
// Executor sets a executor.Call's ExecutorID
[ "Executor", "sets", "a", "executor", ".", "Call", "s", "ExecutorID" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls.go#L16-L20
13,071
mesos/mesos-go
api/v1/lib/executor/calls/calls.go
Subscribe
func Subscribe(unackdTasks []mesos.TaskInfo, unackdUpdates []executor.Call_Update) *executor.Call { return &executor.Call{ Type: executor.Call_SUBSCRIBE, Subscribe: &executor.Call_Subscribe{ UnacknowledgedTasks: unackdTasks, UnacknowledgedUpdates: unackdUpdates, }, } }
go
func Subscribe(unackdTasks []mesos.TaskInfo, unackdUpdates []executor.Call_Update) *executor.Call { return &executor.Call{ Type: executor.Call_SUBSCRIBE, Subscribe: &executor.Call_Subscribe{ UnacknowledgedTasks: unackdTasks, UnacknowledgedUpdates: unackdUpdates, }, } }
[ "func", "Subscribe", "(", "unackdTasks", "[", "]", "mesos", ".", "TaskInfo", ",", "unackdUpdates", "[", "]", "executor", ".", "Call_Update", ")", "*", "executor", ".", "Call", "{", "return", "&", "executor", ".", "Call", "{", "Type", ":", "executor", ".", "Call_SUBSCRIBE", ",", "Subscribe", ":", "&", "executor", ".", "Call_Subscribe", "{", "UnacknowledgedTasks", ":", "unackdTasks", ",", "UnacknowledgedUpdates", ":", "unackdUpdates", ",", "}", ",", "}", "\n", "}" ]
// Subscribe returns an executor call with the given parameters.
[ "Subscribe", "returns", "an", "executor", "call", "with", "the", "given", "parameters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls.go#L23-L31
13,072
mesos/mesos-go
api/v1/lib/executor/calls/calls.go
Update
func Update(status mesos.TaskStatus) *executor.Call { return &executor.Call{ Type: executor.Call_UPDATE, Update: &executor.Call_Update{ Status: status, }, } }
go
func Update(status mesos.TaskStatus) *executor.Call { return &executor.Call{ Type: executor.Call_UPDATE, Update: &executor.Call_Update{ Status: status, }, } }
[ "func", "Update", "(", "status", "mesos", ".", "TaskStatus", ")", "*", "executor", ".", "Call", "{", "return", "&", "executor", ".", "Call", "{", "Type", ":", "executor", ".", "Call_UPDATE", ",", "Update", ":", "&", "executor", ".", "Call_Update", "{", "Status", ":", "status", ",", "}", ",", "}", "\n", "}" ]
// Update returns an executor call with the given parameters.
[ "Update", "returns", "an", "executor", "call", "with", "the", "given", "parameters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls.go#L34-L41
13,073
mesos/mesos-go
api/v1/lib/executor/calls/calls.go
Message
func Message(data []byte) *executor.Call { return &executor.Call{ Type: executor.Call_MESSAGE, Message: &executor.Call_Message{ Data: data, }, } }
go
func Message(data []byte) *executor.Call { return &executor.Call{ Type: executor.Call_MESSAGE, Message: &executor.Call_Message{ Data: data, }, } }
[ "func", "Message", "(", "data", "[", "]", "byte", ")", "*", "executor", ".", "Call", "{", "return", "&", "executor", ".", "Call", "{", "Type", ":", "executor", ".", "Call_MESSAGE", ",", "Message", ":", "&", "executor", ".", "Call_Message", "{", "Data", ":", "data", ",", "}", ",", "}", "\n", "}" ]
// Message returns an executor call with the given parameters.
[ "Message", "returns", "an", "executor", "call", "with", "the", "given", "parameters", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls.go#L44-L51
13,074
mesos/mesos-go
api/v1/lib/labels.go
Equivalent
func (left Label) Equivalent(right Label) bool { if left.Key != right.Key { return false } if left.Value == nil { return right.Value == nil } else { return right.Value != nil && *left.Value == *right.Value } }
go
func (left Label) Equivalent(right Label) bool { if left.Key != right.Key { return false } if left.Value == nil { return right.Value == nil } else { return right.Value != nil && *left.Value == *right.Value } }
[ "func", "(", "left", "Label", ")", "Equivalent", "(", "right", "Label", ")", "bool", "{", "if", "left", ".", "Key", "!=", "right", ".", "Key", "{", "return", "false", "\n", "}", "\n", "if", "left", ".", "Value", "==", "nil", "{", "return", "right", ".", "Value", "==", "nil", "\n", "}", "else", "{", "return", "right", ".", "Value", "!=", "nil", "&&", "*", "left", ".", "Value", "==", "*", "right", ".", "Value", "\n", "}", "\n", "}" ]
// Equivalent returns true if left and right represent the same Label.
[ "Equivalent", "returns", "true", "if", "left", "and", "right", "represent", "the", "same", "Label", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/labels.go#L37-L46
13,075
mesos/mesos-go
api/v1/lib/encoding/framing/decoder.go
NewDecoder
func NewDecoder(r Reader, uf UnmarshalFunc) DecoderFunc { return func(m interface{}) error { // Note: the buf returned by ReadFrame will change over time, it can't be sub-sliced // and then those sub-slices retained. Examination of generated proto code seems to indicate // that byte buffers are copied vs. referenced by sub-slice (gogo protoc). frame, err := r.ReadFrame() if err != nil { return err } return uf(frame, m) } }
go
func NewDecoder(r Reader, uf UnmarshalFunc) DecoderFunc { return func(m interface{}) error { // Note: the buf returned by ReadFrame will change over time, it can't be sub-sliced // and then those sub-slices retained. Examination of generated proto code seems to indicate // that byte buffers are copied vs. referenced by sub-slice (gogo protoc). frame, err := r.ReadFrame() if err != nil { return err } return uf(frame, m) } }
[ "func", "NewDecoder", "(", "r", "Reader", ",", "uf", "UnmarshalFunc", ")", "DecoderFunc", "{", "return", "func", "(", "m", "interface", "{", "}", ")", "error", "{", "// Note: the buf returned by ReadFrame will change over time, it can't be sub-sliced", "// and then those sub-slices retained. Examination of generated proto code seems to indicate", "// that byte buffers are copied vs. referenced by sub-slice (gogo protoc).", "frame", ",", "err", ":=", "r", ".", "ReadFrame", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "uf", "(", "frame", ",", "m", ")", "\n", "}", "\n", "}" ]
// NewDecoder returns a new Decoder that reads from the given frame Reader.
[ "NewDecoder", "returns", "a", "new", "Decoder", "that", "reads", "from", "the", "given", "frame", "Reader", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/encoding/framing/decoder.go#L23-L34
13,076
mesos/mesos-go
api/v1/lib/executor/options.go
With
func (c *Call) With(opts ...CallOpt) *Call { for _, opt := range opts { opt(c) } return c }
go
func (c *Call) With(opts ...CallOpt) *Call { for _, opt := range opts { opt(c) } return c }
[ "func", "(", "c", "*", "Call", ")", "With", "(", "opts", "...", "CallOpt", ")", "*", "Call", "{", "for", "_", ",", "opt", ":=", "range", "opts", "{", "opt", "(", "c", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// With applies the given CallOpts to the receiving Call, returning it.
[ "With", "applies", "the", "given", "CallOpts", "to", "the", "receiving", "Call", "returning", "it", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/options.go#L7-L12
13,077
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/offers.go
IDs
func (offers Slice) IDs() []mesos.OfferID { ids := make([]mesos.OfferID, len(offers)) for i := range offers { ids[i] = offers[i].ID } return ids }
go
func (offers Slice) IDs() []mesos.OfferID { ids := make([]mesos.OfferID, len(offers)) for i := range offers { ids[i] = offers[i].ID } return ids }
[ "func", "(", "offers", "Slice", ")", "IDs", "(", ")", "[", "]", "mesos", ".", "OfferID", "{", "ids", ":=", "make", "(", "[", "]", "mesos", ".", "OfferID", ",", "len", "(", "offers", ")", ")", "\n", "for", "i", ":=", "range", "offers", "{", "ids", "[", "i", "]", "=", "offers", "[", "i", "]", ".", "ID", "\n", "}", "\n", "return", "ids", "\n", "}" ]
// IDs extracts the ID field from a Slice of offers
[ "IDs", "extracts", "the", "ID", "field", "from", "a", "Slice", "of", "offers" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/offers.go#L17-L23
13,078
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/offers.go
IDs
func (offers Index) IDs() []mesos.OfferID { ids := make([]mesos.OfferID, 0, len(offers)) for _, offer := range offers { ids = append(ids, offer.GetID()) } return ids }
go
func (offers Index) IDs() []mesos.OfferID { ids := make([]mesos.OfferID, 0, len(offers)) for _, offer := range offers { ids = append(ids, offer.GetID()) } return ids }
[ "func", "(", "offers", "Index", ")", "IDs", "(", ")", "[", "]", "mesos", ".", "OfferID", "{", "ids", ":=", "make", "(", "[", "]", "mesos", ".", "OfferID", ",", "0", ",", "len", "(", "offers", ")", ")", "\n", "for", "_", ",", "offer", ":=", "range", "offers", "{", "ids", "=", "append", "(", "ids", ",", "offer", ".", "GetID", "(", ")", ")", "\n", "}", "\n", "return", "ids", "\n", "}" ]
// IDs extracts the ID field from a Index of offers
[ "IDs", "extracts", "the", "ID", "field", "from", "a", "Index", "of", "offers" ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/offers.go#L26-L32
13,079
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/offers.go
Filter
func (offers Slice) Filter(filter Filter) (result Slice) { if sz := len(result); sz > 0 { result = make(Slice, 0, sz) for i := range offers { if filter.Accept(&offers[i]) { result = append(result, offers[i]) } } } return }
go
func (offers Slice) Filter(filter Filter) (result Slice) { if sz := len(result); sz > 0 { result = make(Slice, 0, sz) for i := range offers { if filter.Accept(&offers[i]) { result = append(result, offers[i]) } } } return }
[ "func", "(", "offers", "Slice", ")", "Filter", "(", "filter", "Filter", ")", "(", "result", "Slice", ")", "{", "if", "sz", ":=", "len", "(", "result", ")", ";", "sz", ">", "0", "{", "result", "=", "make", "(", "Slice", ",", "0", ",", "sz", ")", "\n", "for", "i", ":=", "range", "offers", "{", "if", "filter", ".", "Accept", "(", "&", "offers", "[", "i", "]", ")", "{", "result", "=", "append", "(", "result", ",", "offers", "[", "i", "]", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// Filter returns the subset of the Slice that matches the given filter.
[ "Filter", "returns", "the", "subset", "of", "the", "Slice", "that", "matches", "the", "given", "filter", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/offers.go#L58-L68
13,080
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/offers.go
Filter
func (offers Index) Filter(filter Filter) (result Index) { if sz := len(result); sz > 0 { result = make(Index, sz) for id, offer := range offers { if filter.Accept(offer) { result[id] = offer } } } return }
go
func (offers Index) Filter(filter Filter) (result Index) { if sz := len(result); sz > 0 { result = make(Index, sz) for id, offer := range offers { if filter.Accept(offer) { result[id] = offer } } } return }
[ "func", "(", "offers", "Index", ")", "Filter", "(", "filter", "Filter", ")", "(", "result", "Index", ")", "{", "if", "sz", ":=", "len", "(", "result", ")", ";", "sz", ">", "0", "{", "result", "=", "make", "(", "Index", ",", "sz", ")", "\n", "for", "id", ",", "offer", ":=", "range", "offers", "{", "if", "filter", ".", "Accept", "(", "offer", ")", "{", "result", "[", "id", "]", "=", "offer", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// Filter returns the subset of the Index that matches the given filter.
[ "Filter", "returns", "the", "subset", "of", "the", "Index", "that", "matches", "the", "given", "filter", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/offers.go#L71-L81
13,081
mesos/mesos-go
api/v1/lib/extras/scheduler/offers/offers.go
ToSlice
func (offers Index) ToSlice() (slice Slice) { if sz := len(offers); sz > 0 { slice = make(Slice, 0, sz) for _, offer := range offers { slice = append(slice, *offer) } } return }
go
func (offers Index) ToSlice() (slice Slice) { if sz := len(offers); sz > 0 { slice = make(Slice, 0, sz) for _, offer := range offers { slice = append(slice, *offer) } } return }
[ "func", "(", "offers", "Index", ")", "ToSlice", "(", ")", "(", "slice", "Slice", ")", "{", "if", "sz", ":=", "len", "(", "offers", ")", ";", "sz", ">", "0", "{", "slice", "=", "make", "(", "Slice", ",", "0", ",", "sz", ")", "\n", "for", "_", ",", "offer", ":=", "range", "offers", "{", "slice", "=", "append", "(", "slice", ",", "*", "offer", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// ToSlice returns a Slice from the offers in the Index. // The returned slice will contain shallow copies of the offers from the Index.
[ "ToSlice", "returns", "a", "Slice", "from", "the", "offers", "in", "the", "Index", ".", "The", "returned", "slice", "will", "contain", "shallow", "copies", "of", "the", "offers", "from", "the", "Index", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/extras/scheduler/offers/offers.go#L114-L122
13,082
mesos/mesos-go
api/v1/lib/master/calls/calls_generated.go
Push
func Push(r RequestStreaming, c ...*master.Call) RequestStreamingFunc { return func() *master.Call { if len(c) == 0 { return r.Call() } head := c[0] c = c[1:] return head } }
go
func Push(r RequestStreaming, c ...*master.Call) RequestStreamingFunc { return func() *master.Call { if len(c) == 0 { return r.Call() } head := c[0] c = c[1:] return head } }
[ "func", "Push", "(", "r", "RequestStreaming", ",", "c", "...", "*", "master", ".", "Call", ")", "RequestStreamingFunc", "{", "return", "func", "(", ")", "*", "master", ".", "Call", "{", "if", "len", "(", "c", ")", "==", "0", "{", "return", "r", ".", "Call", "(", ")", "\n", "}", "\n", "head", ":=", "c", "[", "0", "]", "\n", "c", "=", "c", "[", "1", ":", "]", "\n", "return", "head", "\n", "}", "\n", "}" ]
// Push prepends one or more calls onto a request stream. If no calls are given then the original stream is returned.
[ "Push", "prepends", "one", "or", "more", "calls", "onto", "a", "request", "stream", ".", "If", "no", "calls", "are", "given", "then", "the", "original", "stream", "is", "returned", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/master/calls/calls_generated.go#L70-L79
13,083
mesos/mesos-go
api/v1/lib/executor/calls/calls_sender_generated.go
SenderWith
func SenderWith(s Sender, opts ...executor.CallOpt) SenderFunc { if len(opts) == 0 { return s.Send } return func(ctx context.Context, r Request) (mesos.Response, error) { f := func() (c *executor.Call) { if c = r.Call(); c != nil { c = c.With(opts...) } return } switch r.(type) { case RequestStreaming: return s.Send(ctx, RequestStreamingFunc(f)) default: return s.Send(ctx, RequestFunc(f)) } } }
go
func SenderWith(s Sender, opts ...executor.CallOpt) SenderFunc { if len(opts) == 0 { return s.Send } return func(ctx context.Context, r Request) (mesos.Response, error) { f := func() (c *executor.Call) { if c = r.Call(); c != nil { c = c.With(opts...) } return } switch r.(type) { case RequestStreaming: return s.Send(ctx, RequestStreamingFunc(f)) default: return s.Send(ctx, RequestFunc(f)) } } }
[ "func", "SenderWith", "(", "s", "Sender", ",", "opts", "...", "executor", ".", "CallOpt", ")", "SenderFunc", "{", "if", "len", "(", "opts", ")", "==", "0", "{", "return", "s", ".", "Send", "\n", "}", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "r", "Request", ")", "(", "mesos", ".", "Response", ",", "error", ")", "{", "f", ":=", "func", "(", ")", "(", "c", "*", "executor", ".", "Call", ")", "{", "if", "c", "=", "r", ".", "Call", "(", ")", ";", "c", "!=", "nil", "{", "c", "=", "c", ".", "With", "(", "opts", "...", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "switch", "r", ".", "(", "type", ")", "{", "case", "RequestStreaming", ":", "return", "s", ".", "Send", "(", "ctx", ",", "RequestStreamingFunc", "(", "f", ")", ")", "\n", "default", ":", "return", "s", ".", "Send", "(", "ctx", ",", "RequestFunc", "(", "f", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
// SendWith injects the given options for all calls.
[ "SendWith", "injects", "the", "given", "options", "for", "all", "calls", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v1/lib/executor/calls/calls_sender_generated.go#L132-L150
13,084
mesos/mesos-go
api/v0/messenger/message.go
RequestURI
func (m *Message) RequestURI() string { if m.isV1API() { return fmt.Sprintf("/api/v1/%s", m.Name) } return fmt.Sprintf("/%s/%s", m.UPID.ID, m.Name) }
go
func (m *Message) RequestURI() string { if m.isV1API() { return fmt.Sprintf("/api/v1/%s", m.Name) } return fmt.Sprintf("/%s/%s", m.UPID.ID, m.Name) }
[ "func", "(", "m", "*", "Message", ")", "RequestURI", "(", ")", "string", "{", "if", "m", ".", "isV1API", "(", ")", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "Name", ")", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "UPID", ".", "ID", ",", "m", ".", "Name", ")", "\n", "}" ]
// RequestURI returns the request URI of the message.
[ "RequestURI", "returns", "the", "request", "URI", "of", "the", "message", "." ]
ee67238bbd943c751ec0a5dffb09af2b0182d361
https://github.com/mesos/mesos-go/blob/ee67238bbd943c751ec0a5dffb09af2b0182d361/api/v0/messenger/message.go#L38-L44
13,085
emersion/go-message
mail/header.go
AddressList
func (h *Header) AddressList(key string) ([]*Address, error) { v := h.Get(key) if v == "" { return nil, nil } return parseAddressList(v) }
go
func (h *Header) AddressList(key string) ([]*Address, error) { v := h.Get(key) if v == "" { return nil, nil } return parseAddressList(v) }
[ "func", "(", "h", "*", "Header", ")", "AddressList", "(", "key", "string", ")", "(", "[", "]", "*", "Address", ",", "error", ")", "{", "v", ":=", "h", ".", "Get", "(", "key", ")", "\n", "if", "v", "==", "\"", "\"", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "parseAddressList", "(", "v", ")", "\n", "}" ]
// AddressList parses the named header field as a list of addresses. If the // header is missing, it returns nil.
[ "AddressList", "parses", "the", "named", "header", "field", "as", "a", "list", "of", "addresses", ".", "If", "the", "header", "is", "missing", "it", "returns", "nil", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/header.go#L19-L25
13,086
emersion/go-message
mail/header.go
SetAddressList
func (h *Header) SetAddressList(key string, addrs []*Address) { h.Set(key, formatAddressList(addrs)) }
go
func (h *Header) SetAddressList(key string, addrs []*Address) { h.Set(key, formatAddressList(addrs)) }
[ "func", "(", "h", "*", "Header", ")", "SetAddressList", "(", "key", "string", ",", "addrs", "[", "]", "*", "Address", ")", "{", "h", ".", "Set", "(", "key", ",", "formatAddressList", "(", "addrs", ")", ")", "\n", "}" ]
// SetAddressList formats the named header to the provided list of addresses.
[ "SetAddressList", "formats", "the", "named", "header", "to", "the", "provided", "list", "of", "addresses", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/header.go#L28-L30
13,087
emersion/go-message
mail/header.go
Date
func (h *Header) Date() (time.Time, error) { return mail.ParseDate(h.Get("Date")) }
go
func (h *Header) Date() (time.Time, error) { return mail.ParseDate(h.Get("Date")) }
[ "func", "(", "h", "*", "Header", ")", "Date", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "mail", ".", "ParseDate", "(", "h", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "}" ]
// Date parses the Date header field.
[ "Date", "parses", "the", "Date", "header", "field", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/header.go#L33-L35
13,088
emersion/go-message
mail/header.go
SetDate
func (h *Header) SetDate(t time.Time) { h.Set("Date", t.Format(dateLayout)) }
go
func (h *Header) SetDate(t time.Time) { h.Set("Date", t.Format(dateLayout)) }
[ "func", "(", "h", "*", "Header", ")", "SetDate", "(", "t", "time", ".", "Time", ")", "{", "h", ".", "Set", "(", "\"", "\"", ",", "t", ".", "Format", "(", "dateLayout", ")", ")", "\n", "}" ]
// SetDate formats the Date header field.
[ "SetDate", "formats", "the", "Date", "header", "field", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/header.go#L38-L40
13,089
emersion/go-message
mail/attachment.go
Filename
func (h *AttachmentHeader) Filename() (string, error) { _, params, err := h.ContentDisposition() filename, ok := params["filename"] if !ok { // Using "name" in Content-Type is discouraged _, params, err = h.ContentType() filename = params["name"] } return filename, err }
go
func (h *AttachmentHeader) Filename() (string, error) { _, params, err := h.ContentDisposition() filename, ok := params["filename"] if !ok { // Using "name" in Content-Type is discouraged _, params, err = h.ContentType() filename = params["name"] } return filename, err }
[ "func", "(", "h", "*", "AttachmentHeader", ")", "Filename", "(", ")", "(", "string", ",", "error", ")", "{", "_", ",", "params", ",", "err", ":=", "h", ".", "ContentDisposition", "(", ")", "\n\n", "filename", ",", "ok", ":=", "params", "[", "\"", "\"", "]", "\n", "if", "!", "ok", "{", "// Using \"name\" in Content-Type is discouraged", "_", ",", "params", ",", "err", "=", "h", ".", "ContentType", "(", ")", "\n", "filename", "=", "params", "[", "\"", "\"", "]", "\n", "}", "\n\n", "return", "filename", ",", "err", "\n", "}" ]
// Filename parses the attachment's filename.
[ "Filename", "parses", "the", "attachment", "s", "filename", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/attachment.go#L13-L24
13,090
emersion/go-message
mail/attachment.go
SetFilename
func (h *AttachmentHeader) SetFilename(filename string) { dispParams := map[string]string{"filename": filename} h.SetContentDisposition("attachment", dispParams) }
go
func (h *AttachmentHeader) SetFilename(filename string) { dispParams := map[string]string{"filename": filename} h.SetContentDisposition("attachment", dispParams) }
[ "func", "(", "h", "*", "AttachmentHeader", ")", "SetFilename", "(", "filename", "string", ")", "{", "dispParams", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "filename", "}", "\n", "h", ".", "SetContentDisposition", "(", "\"", "\"", ",", "dispParams", ")", "\n", "}" ]
// SetFilename formats the attachment's filename.
[ "SetFilename", "formats", "the", "attachment", "s", "filename", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/mail/attachment.go#L27-L30
13,091
emersion/go-message
header.go
headerToMap
func headerToMap(h textproto.Header) stdtextproto.MIMEHeader { m := make(stdtextproto.MIMEHeader) fields := h.Fields() for fields.Next() { m.Add(fields.Key(), fields.Value()) } return m }
go
func headerToMap(h textproto.Header) stdtextproto.MIMEHeader { m := make(stdtextproto.MIMEHeader) fields := h.Fields() for fields.Next() { m.Add(fields.Key(), fields.Value()) } return m }
[ "func", "headerToMap", "(", "h", "textproto", ".", "Header", ")", "stdtextproto", ".", "MIMEHeader", "{", "m", ":=", "make", "(", "stdtextproto", ".", "MIMEHeader", ")", "\n", "fields", ":=", "h", ".", "Fields", "(", ")", "\n", "for", "fields", ".", "Next", "(", ")", "{", "m", ".", "Add", "(", "fields", ".", "Key", "(", ")", ",", "fields", ".", "Value", "(", ")", ")", "\n", "}", "\n", "return", "m", "\n", "}" ]
// headerToMap converts a textproto.Header to a map. It looses information.
[ "headerToMap", "converts", "a", "textproto", ".", "Header", "to", "a", "map", ".", "It", "looses", "information", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L40-L47
13,092
emersion/go-message
header.go
SetContentType
func (h *Header) SetContentType(t string, params map[string]string) { h.Set("Content-Type", formatHeaderWithParams(t, params)) }
go
func (h *Header) SetContentType(t string, params map[string]string) { h.Set("Content-Type", formatHeaderWithParams(t, params)) }
[ "func", "(", "h", "*", "Header", ")", "SetContentType", "(", "t", "string", ",", "params", "map", "[", "string", "]", "string", ")", "{", "h", ".", "Set", "(", "\"", "\"", ",", "formatHeaderWithParams", "(", "t", ",", "params", ")", ")", "\n", "}" ]
// SetContentType formats the Content-Type header field.
[ "SetContentType", "formats", "the", "Content", "-", "Type", "header", "field", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L66-L68
13,093
emersion/go-message
header.go
ContentDisposition
func (h *Header) ContentDisposition() (disp string, params map[string]string, err error) { return parseHeaderWithParams(h.Get("Content-Disposition")) }
go
func (h *Header) ContentDisposition() (disp string, params map[string]string, err error) { return parseHeaderWithParams(h.Get("Content-Disposition")) }
[ "func", "(", "h", "*", "Header", ")", "ContentDisposition", "(", ")", "(", "disp", "string", ",", "params", "map", "[", "string", "]", "string", ",", "err", "error", ")", "{", "return", "parseHeaderWithParams", "(", "h", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "}" ]
// ContentDisposition parses the Content-Disposition header field, as defined in // RFC 2183.
[ "ContentDisposition", "parses", "the", "Content", "-", "Disposition", "header", "field", "as", "defined", "in", "RFC", "2183", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L72-L74
13,094
emersion/go-message
header.go
SetContentDisposition
func (h *Header) SetContentDisposition(disp string, params map[string]string) { h.Set("Content-Disposition", formatHeaderWithParams(disp, params)) }
go
func (h *Header) SetContentDisposition(disp string, params map[string]string) { h.Set("Content-Disposition", formatHeaderWithParams(disp, params)) }
[ "func", "(", "h", "*", "Header", ")", "SetContentDisposition", "(", "disp", "string", ",", "params", "map", "[", "string", "]", "string", ")", "{", "h", ".", "Set", "(", "\"", "\"", ",", "formatHeaderWithParams", "(", "disp", ",", "params", ")", ")", "\n", "}" ]
// SetContentDisposition formats the Content-Disposition header field, as // defined in RFC 2183.
[ "SetContentDisposition", "formats", "the", "Content", "-", "Disposition", "header", "field", "as", "defined", "in", "RFC", "2183", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L78-L80
13,095
emersion/go-message
header.go
Text
func (h *Header) Text(k string) (string, error) { return decodeHeader(h.Get(k)) }
go
func (h *Header) Text(k string) (string, error) { return decodeHeader(h.Get(k)) }
[ "func", "(", "h", "*", "Header", ")", "Text", "(", "k", "string", ")", "(", "string", ",", "error", ")", "{", "return", "decodeHeader", "(", "h", ".", "Get", "(", "k", ")", ")", "\n", "}" ]
// Text parses a plaintext header field. The field charset is automatically // decoded to UTF-8.
[ "Text", "parses", "a", "plaintext", "header", "field", ".", "The", "field", "charset", "is", "automatically", "decoded", "to", "UTF", "-", "8", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L84-L86
13,096
emersion/go-message
header.go
SetText
func (h *Header) SetText(k, v string) { h.Set(k, encodeHeader(v)) }
go
func (h *Header) SetText(k, v string) { h.Set(k, encodeHeader(v)) }
[ "func", "(", "h", "*", "Header", ")", "SetText", "(", "k", ",", "v", "string", ")", "{", "h", ".", "Set", "(", "k", ",", "encodeHeader", "(", "v", ")", ")", "\n", "}" ]
// SetText sets a plaintext header field.
[ "SetText", "sets", "a", "plaintext", "header", "field", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/header.go#L89-L91
13,097
emersion/go-message
entity.go
New
func New(header Header, body io.Reader) (*Entity, error) { var err error enc := header.Get("Content-Transfer-Encoding") if decoded, encErr := encodingReader(enc, body); encErr != nil { err = unknownEncodingError{encErr} } else { body = decoded } mediaType, mediaParams, _ := header.ContentType() if ch, ok := mediaParams["charset"]; ok { if converted, charsetErr := charsetReader(ch, body); charsetErr != nil { err = unknownCharsetError{charsetErr} } else { body = converted } } return &Entity{ Header: header, Body: body, mediaType: mediaType, mediaParams: mediaParams, }, err }
go
func New(header Header, body io.Reader) (*Entity, error) { var err error enc := header.Get("Content-Transfer-Encoding") if decoded, encErr := encodingReader(enc, body); encErr != nil { err = unknownEncodingError{encErr} } else { body = decoded } mediaType, mediaParams, _ := header.ContentType() if ch, ok := mediaParams["charset"]; ok { if converted, charsetErr := charsetReader(ch, body); charsetErr != nil { err = unknownCharsetError{charsetErr} } else { body = converted } } return &Entity{ Header: header, Body: body, mediaType: mediaType, mediaParams: mediaParams, }, err }
[ "func", "New", "(", "header", "Header", ",", "body", "io", ".", "Reader", ")", "(", "*", "Entity", ",", "error", ")", "{", "var", "err", "error", "\n\n", "enc", ":=", "header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "decoded", ",", "encErr", ":=", "encodingReader", "(", "enc", ",", "body", ")", ";", "encErr", "!=", "nil", "{", "err", "=", "unknownEncodingError", "{", "encErr", "}", "\n", "}", "else", "{", "body", "=", "decoded", "\n", "}", "\n\n", "mediaType", ",", "mediaParams", ",", "_", ":=", "header", ".", "ContentType", "(", ")", "\n", "if", "ch", ",", "ok", ":=", "mediaParams", "[", "\"", "\"", "]", ";", "ok", "{", "if", "converted", ",", "charsetErr", ":=", "charsetReader", "(", "ch", ",", "body", ")", ";", "charsetErr", "!=", "nil", "{", "err", "=", "unknownCharsetError", "{", "charsetErr", "}", "\n", "}", "else", "{", "body", "=", "converted", "\n", "}", "\n", "}", "\n\n", "return", "&", "Entity", "{", "Header", ":", "header", ",", "Body", ":", "body", ",", "mediaType", ":", "mediaType", ",", "mediaParams", ":", "mediaParams", ",", "}", ",", "err", "\n", "}" ]
// New makes a new message with the provided header and body. The entity's // transfer encoding and charset are automatically decoded to UTF-8. // // If the message uses an unknown transfer encoding or charset, New returns an // error that verifies IsUnknownCharset, but also returns an Entity that can // be read.
[ "New", "makes", "a", "new", "message", "with", "the", "provided", "header", "and", "body", ".", "The", "entity", "s", "transfer", "encoding", "and", "charset", "are", "automatically", "decoded", "to", "UTF", "-", "8", ".", "If", "the", "message", "uses", "an", "unknown", "transfer", "encoding", "or", "charset", "New", "returns", "an", "error", "that", "verifies", "IsUnknownCharset", "but", "also", "returns", "an", "Entity", "that", "can", "be", "read", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/entity.go#L28-L53
13,098
emersion/go-message
entity.go
Read
func Read(r io.Reader) (*Entity, error) { br := bufio.NewReader(r) h, err := textproto.ReadHeader(br) if err != nil { return nil, err } return New(Header{h}, br) }
go
func Read(r io.Reader) (*Entity, error) { br := bufio.NewReader(r) h, err := textproto.ReadHeader(br) if err != nil { return nil, err } return New(Header{h}, br) }
[ "func", "Read", "(", "r", "io", ".", "Reader", ")", "(", "*", "Entity", ",", "error", ")", "{", "br", ":=", "bufio", ".", "NewReader", "(", "r", ")", "\n", "h", ",", "err", ":=", "textproto", ".", "ReadHeader", "(", "br", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "New", "(", "Header", "{", "h", "}", ",", "br", ")", "\n", "}" ]
// Read reads a message from r. The message's encoding and charset are // automatically decoded to raw UTF-8. Note that this function only reads the // message header. // // If the message uses an unknown transfer encoding or charset, Read returns an // error that verifies IsUnknownCharset, but also returns an Entity that can // be read.
[ "Read", "reads", "a", "message", "from", "r", ".", "The", "message", "s", "encoding", "and", "charset", "are", "automatically", "decoded", "to", "raw", "UTF", "-", "8", ".", "Note", "that", "this", "function", "only", "reads", "the", "message", "header", ".", "If", "the", "message", "uses", "an", "unknown", "transfer", "encoding", "or", "charset", "Read", "returns", "an", "error", "that", "verifies", "IsUnknownCharset", "but", "also", "returns", "an", "Entity", "that", "can", "be", "read", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/entity.go#L77-L85
13,099
emersion/go-message
entity.go
MultipartReader
func (e *Entity) MultipartReader() MultipartReader { if !strings.HasPrefix(e.mediaType, "multipart/") { return nil } if mb, ok := e.Body.(*multipartBody); ok { return mb } return &multipartReader{multipart.NewReader(e.Body, e.mediaParams["boundary"])} }
go
func (e *Entity) MultipartReader() MultipartReader { if !strings.HasPrefix(e.mediaType, "multipart/") { return nil } if mb, ok := e.Body.(*multipartBody); ok { return mb } return &multipartReader{multipart.NewReader(e.Body, e.mediaParams["boundary"])} }
[ "func", "(", "e", "*", "Entity", ")", "MultipartReader", "(", ")", "MultipartReader", "{", "if", "!", "strings", ".", "HasPrefix", "(", "e", ".", "mediaType", ",", "\"", "\"", ")", "{", "return", "nil", "\n", "}", "\n", "if", "mb", ",", "ok", ":=", "e", ".", "Body", ".", "(", "*", "multipartBody", ")", ";", "ok", "{", "return", "mb", "\n", "}", "\n", "return", "&", "multipartReader", "{", "multipart", ".", "NewReader", "(", "e", ".", "Body", ",", "e", ".", "mediaParams", "[", "\"", "\"", "]", ")", "}", "\n", "}" ]
// MultipartReader returns a MultipartReader that reads parts from this entity's // body. If this entity is not multipart, it returns nil.
[ "MultipartReader", "returns", "a", "MultipartReader", "that", "reads", "parts", "from", "this", "entity", "s", "body", ".", "If", "this", "entity", "is", "not", "multipart", "it", "returns", "nil", "." ]
1e345aac1fa8858087e0443e26fd3db3dc0fc867
https://github.com/emersion/go-message/blob/1e345aac1fa8858087e0443e26fd3db3dc0fc867/entity.go#L89-L97