blob: 0b2ad33eb6c5a81299126ce3210a7ceabb11824a (
plain)
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
55
56
57
58
59
|
package _old
import (
"sync"
)
const (
// StatusUndefined when service bus can not find the service.
StatusUndefined = iota
// StatusInactive when service has been registered in container.
StatusInactive
// StatusOK when service has been properly configured.
StatusOK
// StatusServing when service is currently done.
StatusServing
// StatusStopping when service is currently stopping.
StatusStopping
// StatusStopped when service being stopped.
StatusStopped
)
// entry creates association between service instance and given name.
type entry struct {
name string
svc interface{}
mu sync.Mutex
status int
}
// status returns service status
func (e *entry) getStatus() int {
e.mu.Lock()
defer e.mu.Unlock()
return e.status
}
// setStarted indicates that service hasStatus status.
func (e *entry) setStatus(status int) {
e.mu.Lock()
defer e.mu.Unlock()
e.status = status
}
// hasStatus checks if entry in specific status
func (e *entry) hasStatus(status int) bool {
return e.getStatus() == status
}
// canServe returns true is service can serve.
func (e *entry) canServe() bool {
_, ok := e.svc.(Service)
return ok
}
|