track log reqrep
This commit is contained in:
parent
5c7283413d
commit
b92c8f4b9a
|
@ -30,12 +30,17 @@ func (s Server) Request(subject string, payload []byte) (*nats.Msg, error) {
|
||||||
// RequestWithBindData ...
|
// RequestWithBindData ...
|
||||||
func (s Server) RequestWithBindData(subject string, payload []byte, result interface{}) error {
|
func (s Server) RequestWithBindData(subject string, payload []byte, result interface{}) error {
|
||||||
msg, err := s.Request(subject, payload)
|
msg, err := s.Request(subject, payload)
|
||||||
|
fmt.Println("data", msg.Data)
|
||||||
|
fmt.Println("err", err.Error())
|
||||||
if msg == nil || err != nil {
|
if msg == nil || err != nil {
|
||||||
|
fmt.Println("1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("2")
|
||||||
|
|
||||||
// map
|
// map
|
||||||
return BytesToInterface(msg.Data, &result)
|
return BytesToInterface(msg.Data, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply ...
|
// Reply ...
|
||||||
|
|
2
utils.go
2
utils.go
|
@ -46,7 +46,7 @@ func InterfaceToBytes(data interface{}) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BytesToInterface(b []byte, dest interface{}) error {
|
func BytesToInterface(b []byte, dest interface{}) error {
|
||||||
err := json.Unmarshal(b, dest)
|
err := json.Unmarshal(b, &dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("[natsio.BytesToInterface] error: %v with data: %s\n", err, string(b))
|
fmt.Printf("[natsio.BytesToInterface] error: %v with data: %s\n", err, string(b))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue