add methods MsgRespond
This commit is contained in:
		
							parent
							
								
									32b13fbf86
								
							
						
					
					
						commit
						5c7283413d
					
				
							
								
								
									
										7
									
								
								utils.go
								
								
								
								
							
							
						
						
									
										7
									
								
								utils.go
								
								
								
								
							| 
						 | 
					@ -3,6 +3,7 @@ package natsio
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"github.com/nats-io/nats.go"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/thoas/go-funk"
 | 
						"github.com/thoas/go-funk"
 | 
				
			||||||
| 
						 | 
					@ -51,3 +52,9 @@ func BytesToInterface(b []byte, dest interface{}) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return err
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MsgRespond(msg *nats.Msg, data interface{}) {
 | 
				
			||||||
 | 
						if err := msg.Respond(InterfaceToBytes(data)); err != nil {
 | 
				
			||||||
 | 
							fmt.Printf("[natsio.MsgRespond] error when response msg %s", msg.Reply)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue