registry

command
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

通过配置API生成实例化子模块

注册中心

例子:

// 通过配置 API 生成注册中心配置,此处为默认zk配置
registryConfig := config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")

// 调用注册中心配置API,获取注册中心实例 reg
reg, err := registryConfig.GetInstance(common.PROVIDER)
if err != nil {
    panic(err)
}

// 生成一个 provider URL
ivkURL, err := common.NewURL("mock://localhost:8080",
    common.WithPath("com.alibaba.dubbogo.HelloService"),
    common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)),
    common.WithMethods([]string{"GetUser", "SayHello"}),
)
if err != nil {
    panic(err)
}
// 使用新生成的注册中心实例注册
if err := reg.Register(ivkURL); err != nil {
    panic(err)
}
time.Sleep(time.Second * 30)
// 反注册
if err := reg.UnRegister(ivkURL); err != nil {
    panic(err)
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL