Skip to content

Commit

Permalink
TypeNoResponse added
Browse files Browse the repository at this point in the history
  • Loading branch information
YourTechBud committed Nov 17, 2018
1 parent 1e6f9ca commit d5260f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
const (
// TypeResponse is used as callback type to give response
TypeResponse = "response"
// TypeNoResponse is used as callback type to not give any response
TypeNoResponse = "no-response"
)

// M is the type for json objects
Expand Down Expand Up @@ -48,13 +50,16 @@ func Init(name string, url string) (*Engine, error) {
func (engine *Engine) callFunc(fn Func, params M, auth M, replyTo string) {
fn(params, auth, func(cbType string, res M) {
switch cbType {
case "response":
case TypeResponse:
b, err := json.Marshal(res)
if err != nil {
engine.natsClient.Publish(replyTo, []byte("{\"ack\":false}"))
return
}
engine.natsClient.Publish(replyTo, b)
break
default:
engine.natsClient.Publish(replyTo, []byte("{\"ack\":true}"))
}
})
}
Expand Down

0 comments on commit d5260f0

Please sign in to comment.