/
types.go
52 lines (44 loc) · 1.22 KB
/
types.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
43
44
45
46
47
48
49
50
51
52
package types
import (
"sync"
)
type Annotator interface {
Annotate(services []*Service) error
}
// A ConfigGenerator creates a configuration from several services.
type ConfigGenerator interface {
Generate(services []*Service) error
}
// A Notifier recognizes changes in your system. For example, it could regularly poll an API or listen on an event bus.
// If something changes, it notifies the Manager to trigger a refresh.
type Notifier interface {
Start(refresh chan string, quit chan int, wg *sync.WaitGroup)
}
// A ServiceGenerator reads information about nodes and creates a list of services.
type ServiceGenerator interface {
Generate() ([]*Service, error)
}
// A host is an IP and a port where traffic should be proxied to.
type Host struct {
Ip string
Port int
}
type Service struct {
ApplicationProtocol string
Config string
Domains []string
Hosts []Host
Id string
Port int
ProxyPath string
ServicePort int
Source string
TransportProtocol string
}
// Figure out the port on which a service is listening.
func (s *Service) ListenPort() int {
if s.ServicePort == 0 {
return s.Port
}
return s.ServicePort
}