Commit d8e56e8 1 parent 71d79bb commit d8e56e8 Copy full SHA for d8e56e8
File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -21,25 +21,26 @@ func NewServiceRegistry() ServiceRegistry {
21
21
// Register registers a new service with a list of references
22
22
func (rlh * ServiceRegistry ) Register (listName string , svc Service ) * ServiceRegistry {
23
23
rlh .lock .Lock ()
24
- defer rlh .lock .Unlock ()
25
-
26
24
rlh .services [listName ] = svc
25
+ rlh .lock .Unlock ()
26
+
27
27
return rlh
28
28
}
29
29
30
30
// GetServiceForList returns a service able to handle a specific list
31
31
func (rlh ServiceRegistry ) GetServiceForList (name string ) Service {
32
32
rlh .lock .RLock ()
33
- defer rlh .lock .RUnlock ()
33
+ svc := rlh .services [name ]
34
+ rlh .lock .RUnlock ()
34
35
35
- return rlh . services [ name ]
36
+ return svc
36
37
}
37
38
38
39
// HasServiceForList returns true only if a service has been registered for a certain list
39
40
func (rlh ServiceRegistry ) HasServiceForList (name string ) bool {
40
41
rlh .lock .RLock ()
41
- defer rlh .lock .RUnlock ()
42
-
43
42
_ , ok := rlh .services [name ]
43
+ rlh .lock .RUnlock ()
44
+
44
45
return ok
45
46
}
You can’t perform that action at this time.
0 commit comments