File: callers_generated.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (58 lines) | stat: -rw-r--r-- 1,777 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package callrules

// go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -import github.com/mesos/mesos-go/api/v1/lib/scheduler/calls -type E:*scheduler.Call -type C:calls.Caller -type CF:calls.CallerFunc -output callers_generated.go
// GENERATED CODE FOLLOWS; DO NOT EDIT.

import (
	"context"

	"github.com/mesos/mesos-go/api/v1/lib"

	"github.com/mesos/mesos-go/api/v1/lib/scheduler"
	"github.com/mesos/mesos-go/api/v1/lib/scheduler/calls"
)

// Call returns a Rule that invokes the given Caller
func Call(caller calls.Caller) Rule {
	if caller == nil {
		return nil
	}
	return func(ctx context.Context, c *scheduler.Call, _ mesos.Response, _ error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) {
		resp, err := caller.Call(ctx, c)
		return ch(ctx, c, resp, err)
	}
}

// CallF returns a Rule that invokes the given CallerFunc
func CallF(cf calls.CallerFunc) Rule {
	return Call(calls.Caller(cf))
}

// Caller returns a Rule that invokes the receiver and then calls the given Caller
func (r Rule) Caller(caller calls.Caller) Rule {
	return Rules{r, Call(caller)}.Eval
}

// CallerF returns a Rule that invokes the receiver and then calls the given CallerFunc
func (r Rule) CallerF(cf calls.CallerFunc) Rule {
	return r.Caller(calls.Caller(cf))
}

// Call implements the Caller interface for Rule
func (r Rule) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) {
	if r == nil {
		return nil, nil
	}
	_, _, resp, err := r(ctx, c, nil, nil, ChainIdentity)
	return resp, err
}

// Call implements the Caller interface for Rules
func (rs Rules) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) {
	return Rule(rs.Eval).Call(ctx, c)
}

var (
	_ = calls.Caller(Rule(nil))
	_ = calls.Caller(Rules(nil))
)