Skip to content
Snippets Groups Projects
Commit c236c87d authored by vito.he's avatar vito.he
Browse files

Add: mock registry fix

parent 189262f8
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ package config
import (
"context"
"fmt"
"github.com/dubbo/go-for-apache-dubbo/common/constant"
"net"
"net/url"
"strconv"
......@@ -13,6 +12,9 @@ import (
import (
jerrors "github.com/juju/errors"
)
import (
"github.com/dubbo/go-for-apache-dubbo/common/constant"
)
/////////////////////////////////
// dubbo role type
......
......@@ -47,7 +47,7 @@ func main() {
initProfiling()
time.Sleep(10e9)
time.Sleep(3e9)
gxlog.CInfo("\n\n\nstart to test jsonrpc")
user := &JsonRPCUser{}
......
......@@ -2,16 +2,17 @@ package registry
import (
"github.com/dubbo/go-for-apache-dubbo/config"
"github.com/tevino/abool"
)
type MockRegistry struct {
listener *listener
isClosed bool
listener *listener
destroyed *abool.AtomicBool
}
func NewMockRegistry() *MockRegistry {
registry := &MockRegistry{
isClosed: false,
destroyed: abool.NewBool(false),
}
listener := &listener{count: 0, registry: registry, listenChan: make(chan *ServiceEvent)}
registry.listener = listener
......@@ -22,10 +23,11 @@ func (*MockRegistry) Register(url config.URL) error {
}
func (r *MockRegistry) Destroy() {
r.isClosed = true
if r.destroyed.SetToIf(false, true) {
}
}
func (r *MockRegistry) IsAvailable() bool {
return r.isClosed
return !r.destroyed.IsSet()
}
func (r *MockRegistry) GetUrl() config.URL {
return config.URL{}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment