Removing redundant alias and reintroducing quitmtx
Martin Baillie
6 years ago
0 | 0 |
package eureka
|
1 | 1 |
|
2 | 2 |
import (
|
3 | |
fargo "github.com/hudl/fargo"
|
|
3 |
"github.com/hudl/fargo"
|
4 | 4 |
)
|
5 | 5 |
|
6 | 6 |
// Client is a wrapper around the Eureka API.
|
3 | 3 |
"errors"
|
4 | 4 |
"reflect"
|
5 | 5 |
|
6 | |
fargo "github.com/hudl/fargo"
|
|
6 |
"github.com/hudl/fargo"
|
7 | 7 |
|
8 | 8 |
"github.com/go-kit/kit/log"
|
9 | 9 |
)
|
7 | 7 |
"testing"
|
8 | 8 |
"time"
|
9 | 9 |
|
10 | |
fargo "github.com/hudl/fargo"
|
|
10 |
"github.com/hudl/fargo"
|
11 | 11 |
|
12 | 12 |
"github.com/go-kit/kit/endpoint"
|
13 | 13 |
"github.com/go-kit/kit/log"
|
1 | 1 |
|
2 | 2 |
import (
|
3 | 3 |
"fmt"
|
|
4 |
"sync"
|
4 | 5 |
"time"
|
5 | 6 |
|
6 | |
fargo "github.com/hudl/fargo"
|
|
7 |
"github.com/hudl/fargo"
|
7 | 8 |
|
8 | 9 |
"github.com/go-kit/kit/log"
|
9 | 10 |
)
|
|
14 | 15 |
instance *fargo.Instance
|
15 | 16 |
logger log.Logger
|
16 | 17 |
quit chan bool
|
|
18 |
quitmtx sync.Mutex
|
17 | 19 |
}
|
18 | 20 |
|
19 | 21 |
// NewRegistrar returns an Eureka Registrar acting on behalf of the provided
|
|
36 | 38 |
|
37 | 39 |
if r.instance.LeaseInfo.RenewalIntervalInSecs > 0 {
|
38 | 40 |
// User has opted for heartbeat functionality in Eureka.
|
|
41 |
r.quitmtx.Lock()
|
|
42 |
defer r.quitmtx.Unlock()
|
39 | 43 |
if r.quit == nil {
|
40 | 44 |
r.quit = make(chan bool)
|
41 | 45 |
go r.loop()
|
|
51 | 55 |
r.logger.Log("action", "deregister")
|
52 | 56 |
}
|
53 | 57 |
|
|
58 |
r.quitmtx.Lock()
|
|
59 |
defer r.quitmtx.Unlock()
|
54 | 60 |
if r.quit != nil {
|
55 | 61 |
r.quit <- true
|
56 | 62 |
r.quit = nil
|
3 | 3 |
"testing"
|
4 | 4 |
"time"
|
5 | 5 |
|
6 | |
fargo "github.com/hudl/fargo"
|
|
6 |
"github.com/hudl/fargo"
|
7 | 7 |
)
|
8 | 8 |
|
9 | 9 |
func TestRegistrar(t *testing.T) {
|
2 | 2 |
import (
|
3 | 3 |
"fmt"
|
4 | 4 |
|
5 | |
fargo "github.com/hudl/fargo"
|
|
5 |
"github.com/hudl/fargo"
|
6 | 6 |
|
7 | 7 |
"github.com/go-kit/kit/endpoint"
|
8 | 8 |
"github.com/go-kit/kit/log"
|
4 | 4 |
"testing"
|
5 | 5 |
"time"
|
6 | 6 |
|
7 | |
fargo "github.com/hudl/fargo"
|
|
7 |
"github.com/hudl/fargo"
|
8 | 8 |
|
9 | 9 |
"github.com/go-kit/kit/endpoint"
|
10 | 10 |
)
|