File: client.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 (54 lines) | stat: -rw-r--r-- 1,778 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
package client

import (
	"github.com/mesos/mesos-go/api/v1/lib/encoding"
)

type (
	// ResponseClass indicates the kind of response that a caller is expecting from Mesos.
	ResponseClass int

	// Request is a non-streaming request from the client to the server.
	// Marshaler always returns the same object; the object is sent once to the server and then
	// a response is expected.
	Request interface {
		Marshaler() encoding.Marshaler
	}

	// RequestStreaming is a streaming request from the client to the server.
	// Marshaler returns a new object for upon each invocation, nil when there are no more objects to send.
	// Client implementations are expected to differentiate between Request and RequestStreaming either by
	// type-switching or by attempting interface conversion.
	RequestStreaming interface {
		Request
		IsStreaming()
	}

	RequestFunc          func() encoding.Marshaler
	RequestStreamingFunc func() encoding.Marshaler
)

var (
	_ = Request(RequestFunc(nil))
	_ = RequestStreaming(RequestStreamingFunc(nil))
)

func (f RequestFunc) Marshaler() encoding.Marshaler          { return f() }
func (f RequestStreamingFunc) Marshaler() encoding.Marshaler { return f() }
func (f RequestStreamingFunc) IsStreaming()                  {}

// RequestSingleton generates a non-streaming Request that always returns the same marshaler
func RequestSingleton(m encoding.Marshaler) Request {
	return RequestFunc(func() encoding.Marshaler { return m })
}

const (
	ResponseClassSingleton ResponseClass = iota
	ResponseClassStreaming
	ResponseClassNoData

	// ResponseClassAuto should be used with versions of Mesos prior to 1.2.x.
	// Otherwise, this type is deprecated and callers should use ResponseClassSingleton
	// or ResponseClassStreaming instead.
	ResponseClassAuto
)