Debian Codegraph @

api/v1/lib/extras/gen/callers.go

raw symbols SCIP
1 // +build ignore
2
3 package main
4
5 import (
6 "os"
7 "text/template"
8 )
9
10 func main() {
11 Run(handlersTemplate, nil, os.Args...)
12 }
13
14 var handlersTemplate = template.Must(template.New("").Parse(`package {{.Package}}
15
16 // go generate {{.Args}}
17 // GENERATED CODE FOLLOWS; DO NOT EDIT.
18
19 import (
20 "context"
21
22 "github.com/mesos/mesos-go/api/v1/lib"
23 {{range .Imports}}
24 {{ printf "%q" . -}}
25 {{end}}
26 )
27
28 {{.RequireType "C" -}}
29 type (
30 // Caller is the public interface this framework scheduler's should consume
31 Caller interface {
32 // Call issues a call to Mesos and properly manages call-specific HTTP response headers & data.
33 Call(context.Context, {{.Type "C"}}) (mesos.Response, error)
34 }
35
36 // CallerFunc is the functional adaptation of the Caller interface
37 CallerFunc func(context.Context, {{.Type "C"}}) (mesos.Response, error)
38 )
39
40 // Call implements the Caller interface for CallerFunc
41 func (f CallerFunc) Call(ctx context.Context, c {{.Type "C"}}) (mesos.Response, error) {
42 return f(ctx, c)
43 }
44
45 // CallNoData is a convenience func that executes the given Call using the provided Caller
46 // and always drops the response data.
47 func CallNoData(ctx context.Context, caller Caller, call {{.Type "C"}}) error {
48 resp, err := caller.Call(ctx, call)
49 if resp != nil {
50 resp.Close()
51 }
52 return err
53 }
54 `))