Debian Codegraph @

api/v1/lib/httpcli/httpexec/httpexec_generated.go

raw symbols SCIP
1 package httpexec
2
3 // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type C:executor.Call:executor.Call{Type:executor.Call_MESSAGE}
4 // GENERATED CODE FOLLOWS; DO NOT EDIT.
5
6 import (
7 "context"
8
9 "github.com/mesos/mesos-go/api/v1/lib"
10 "github.com/mesos/mesos-go/api/v1/lib/client"
11 "github.com/mesos/mesos-go/api/v1/lib/httpcli"
12
13 "github.com/mesos/mesos-go/api/v1/lib/executor"
14 "github.com/mesos/mesos-go/api/v1/lib/executor/calls"
15 )
16
17 // ResponseClassifier determines the appropriate response class for the given call.
18 type ResponseClassifier func(*executor.Call) (client.ResponseClass, error)
19
20 // ClientFunc sends a Request to Mesos and returns the generated Response.
21 type ClientFunc func(client.Request, client.ResponseClass, ...httpcli.RequestOpt) (mesos.Response, error)
22
23 // DefaultResponseClassifier is a pluggable classifier.
24 var DefaultResponseClassifier = ResponseClassifier(classifyResponse)
25
26 // NewSender generates a sender that uses the Mesos v1 HTTP API for encoding/decoding requests/responses.
27 // The ResponseClass is inferred from the first object generated by the given Request.
28 func NewSender(cf ClientFunc, ro ...httpcli.RequestOpt) calls.Sender {
29 return calls.SenderFunc(func(ctx context.Context, r calls.Request) (mesos.Response, error) {
30 var (
31 obj = r.Call()
32 rc, err = DefaultResponseClassifier(obj)
33 )
34 if err != nil {
35 return nil, err
36 }
37
38 var req client.Request
39
40 switch r := r.(type) {
41 case calls.RequestStreaming:
42 req = calls.Push(r, obj)
43 default:
44 req = calls.NonStreaming(obj)
45 }
46
47 return cf(req, rc, append(ro, httpcli.Context(ctx))...)
48 })
49 }