Yongkan Huang

Results 12 comments of Yongkan Huang

I think it would be better to integrate the mutex inside the filter to make it a complete module, with which people can use without dealing with concurrent write problem....

Firstly you can update the db, then call cache.Delete(key) (delete all cache items impacted by the db change ) to delete cache, then next cache.GetObject will load the updated value....

In my use case, I use grpc as replacement of REST API in mobile development, and default transport for micro service on server side. And I did a stress test...

@xpunch sorry, I don't get you, could you show me the example code? in Location method, ctx only exposed Value, Deadline, Done, Err methods, I don't know how to make...

@xpunch This is not working.ctx can't be modified. As the one mentioned in the issue https://github.com/grpc/grpc-go/issues/4363 ``` func (w *wrappedStream) Context() context.Context { ctx := w.ServerStream.Context() md := metadata.FromIncomingContext(ctx) newMD...

@JeffreyBool 根据grpc最新的设计,outbound的context修改必须用metadata.NewIncomingContext,所以只能从micro框架内部做相应的修改,如果你选择grpc1.38.0,你会发现简单的set,get依然还是可以的。 我的需求很简单,本想统一处理错误码(读取response的code),现在只能通过json解析response了。 等待micro出一个官方的方案吧。

@JeffreyBool 业务层级的错误码,譬如response都有的固定结构,err_code, err_msg这样的。 既然context没法修改,可以尝试在rsp interface{}里面增加对应的临时字段,当然这个只是没有办法的办法。

@JeffreyBool 的确我也正在做接口监控统计的事情,目前遇到的问题是我可以在wrapper里面检测到错误码(err),业务层次的错误码(rsp提取),但是我没办法在wrapper里面上报到influxdb。 我看你用的是monitor.DefaultMetrics(应该是默认的配置吧,我希望能够自定义),如果希望传个对象给wrapper(比如处理上报influxdb的逻辑),有没有办法实现?如果context能存对象,这个就很方便了。

@JeffreyBool 想了一圈,发现还是你的这个接口监控,错误方案比较靠谱。 对了,NewClientWrapper这个怎么使用,似乎client.Wrapper用法说明比较少,我下面这么用server.HandlerWrapper是可以的,但是NewClientWrapper没反应。 ``` service := micro.NewService( micro.Name(constant.UtilServiceName), micro.Version("latest"), micro.RegisterTTL(time.Second*30), micro.RegisterInterval(time.Second*15), micro.Server(grpc.NewServer(server.Address(""), server.Name(constant.UtilServiceName))), micro.Registry(reg), micro.WrapHandler(NewHandlerWrapper()), micro.WrapClient(NewClientWrapper()), ) ```

@aleksraiden FYI, [NATS](https://github.com/nats-io/nats-server) is a good alternative of Kafka, lightweight and easy to run, it does support persistence in JetStream mode.