-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.go
42 lines (33 loc) · 1.04 KB
/
models.go
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
package internal
import "fmt"
const contentType = "application/json"
type Topology struct {
BaseName string `json:"baseName,omitempty"` // When defined, it represents the base name to build the broker names, e.g. "polar-"
Length int `json:"length"` // The ring size
BrokerNames []string `json:"names,omitempty"`
ProducerPort int `json:"producerPort"`
ProducerBinaryPort int `json:"producerBinaryPort"`
ConsumerPort int `json:"consumerPort"`
}
func (t *Topology) hostName(ordinal int) string {
if len(t.BrokerNames) > 0 {
return t.BrokerNames[ordinal]
}
return fmt.Sprintf("%s%d", t.BaseName, ordinal)
}
type defaultBrokerError struct {
err error
brokerOrdinal int
}
func (e *defaultBrokerError) Error() string {
return e.err.Error()
}
func (e *defaultBrokerError) BrokerOrdinal() int {
return e.brokerOrdinal
}
func newBrokerError(err error, ordinal int) *defaultBrokerError {
return &defaultBrokerError{
err: err,
brokerOrdinal: ordinal,
}
}