Debian Codegraph @

api/v1/lib/client/client.go

raw symbols SCIP
1 package client
2
3 import (
4 "github.com/mesos/mesos-go/api/v1/lib/encoding"
5 )
6
7 type (
8 // ResponseClass indicates the kind of response that a caller is expecting from Mesos.
9 ResponseClass int
10
11 // Request is a non-streaming request from the client to the server.
12 // Marshaler always returns the same object; the object is sent once to the server and then
13 // a response is expected.
14 Request interface {
15 Marshaler() encoding.Marshaler
16 }
17
18 // RequestStreaming is a streaming request from the client to the server.
19 // Marshaler returns a new object for upon each invocation, nil when there are no more objects to send.
20 // Client implementations are expected to differentiate between Request and RequestStreaming either by
21 // type-switching or by attempting interface conversion.
22 RequestStreaming interface {
23 Request
24 IsStreaming()
25 }
26
27 RequestFunc func() encoding.Marshaler
28 RequestStreamingFunc func() encoding.Marshaler
29 )
30
31 var (
32 _ = Request(RequestFunc(nil))
33 _ = RequestStreaming(RequestStreamingFunc(nil))
34 )
35
36 func (f RequestFunc) Marshaler() encoding.Marshaler { return f() }
37 func (f RequestStreamingFunc) Marshaler() encoding.Marshaler { return f() }
38 func (f RequestStreamingFunc) IsStreaming() {}
39
40 // RequestSingleton generates a non-streaming Request that always returns the same marshaler
41 func RequestSingleton(m encoding.Marshaler) Request {
42 return RequestFunc(func() encoding.Marshaler { return m })
43 }
44
45 const (
46 ResponseClassSingleton ResponseClass = iota
47 ResponseClassStreaming
48 ResponseClassNoData
49
50 // ResponseClassAuto should be used with versions of Mesos prior to 1.2.x.
51 // Otherwise, this type is deprecated and callers should use ResponseClassSingleton
52 // or ResponseClassStreaming instead.
53 ResponseClassAuto
54 )