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 (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/nats-io/nats.go"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/thoas/go-funk"
 | 
			
		||||
| 
						 | 
				
			
			@ -51,3 +52,9 @@ func BytesToInterface(b []byte, dest interface{}) error {
 | 
			
		|||
	}
 | 
			
		||||
	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