Debian Codegraph @

api/v1/lib/extras/scheduler/callrules/helpers.go

raw symbols SCIP
1 package callrules
2
3 import (
4 "context"
5
6 "github.com/mesos/mesos-go/api/v1/lib"
7 "github.com/mesos/mesos-go/api/v1/lib/scheduler"
8 )
9
10 // WithFrameworkID returns a Rule that injects a framework ID to outgoing calls, with the following exceptions:
11 // - SUBSCRIBE calls are never modified (schedulers should explicitly construct such calls)
12 // - calls are not modified when the detected framework ID is ""
13 func WithFrameworkID(frameworkID func() string) Rule {
14 return func(ctx context.Context, c *scheduler.Call, r mesos.Response, err error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) {
15 // never overwrite framework ID for subscribe calls; the scheduler must do that part
16 if c.GetType() != scheduler.Call_SUBSCRIBE {
17 if fid := frameworkID(); fid != "" {
18 c2 := *c
19 c2.FrameworkID = &mesos.FrameworkID{Value: fid}
20 c = &c2
21 }
22 }
23 return ch(ctx, c, r, err)
24 }
25 }