Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

看到注释里面提到etcd,但是实际注册的实现先的zookeeper #18

Open
cobain opened this issue Jul 26, 2022 · 6 comments
Open

Comments

@cobain
Copy link

cobain commented Jul 26, 2022

看到注释里面提到etcd,但是实际注册的实现先的zookeeper,请问etcd要支持吗

@cobain
Copy link
Author

cobain commented Jul 27, 2022

如果指定了registry,就是老在监听配置状态,但是不知道怎么给配置啊。比如redis,
默认的我打印了一下,是个json
{
"address": "8080",
"rTimeout": 30,
"rhTimeout": 30,
"status": "start",
"wTimeout": 30
}
但是redis,或者consul,etcd,zookeeper,不知道怎么给

@cobain
Copy link
Author

cobain commented Jul 27, 2022

意思就是,我想看看如何运行一个微服务,比如一个注册中心,我现在多个不同机器上的服务注册进去,然后去访问不同的服务,现在什么文档都没有,不知道怎么搞

@cobain
Copy link
Author

cobain commented Jul 27, 2022

知道了。咱们这个里面没有网关。

@zkfy
Copy link
Contributor

zkfy commented Aug 9, 2022

参考示例:
//OrderRefundHandle 订单退款
func (u *KxOrderInfoHandler) OrderRefundHandle(ctx hydra.IContext) (r interface{}) {

ctx.Log().Info("--------订单退款--------")

ctx.Log().Info("1.参数校验")
if err := ctx.Request().Check(field.OrderID, field.MerchantNO, field.RefundCause); err != nil {
	return errs.NewErrorf(http.StatusNotAcceptable, "参数校验错误:%+v", err)
}

ctx.Log().Info("2.RPC请求", model.GetConf().KxOrderRefundURL)
param := map[string]interface{}{
	field.OrderID:     ctx.Request().GetString(field.OrderID),
	field.MerchantNO:  ctx.Request().GetString(field.MerchantNO),
	field.RefundCause: ctx.Request().GetString(field.RefundCause),
}
**rpcClient := hydra.C.RPC().GetRegularRPC()**
rspn, err := rpcClient.Request(model.GetConf().KxOrderRefundURL, types.ToJSON(param), rpc.WithFailFast(true))
if err != nil {
	return errs.NewErrorf(400, "RPC请求失败:(err:%+v)", err)
}
if !rspn.IsSuccess() {
	return errs.NewErrorf(rspn.GetStatus(), "RPC请求错误:%+v", rspn.GetError())
}

ctx.Log().Info("3.返回结果")
return "success"

}

通过context包集成的函数可访问rpc服务,默认是轮询负载均衡器,可自行修改或扩展
实现代码在hydra\components\rpcs

@zkfy
Copy link
Contributor

zkfy commented Aug 9, 2022

目前只支持:内存、文件系统、mysql、redis、zookeeper 作为注册中心

@cobain
Copy link
Author

cobain commented Aug 10, 2022

好的,多谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants