change publish payload data type to []byte
This commit is contained in:
parent
27a0bb627d
commit
374a616387
|
@ -1,7 +1,6 @@
|
||||||
package natsio
|
package natsio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
@ -9,11 +8,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Publish ...
|
// Publish ...
|
||||||
func Publish(stream, subject string, data interface{}) error {
|
func Publish(stream, subject string, payload []byte) error {
|
||||||
channel := combineStreamAndSubjectName(stream, subject)
|
channel := combineStreamAndSubjectName(stream, subject)
|
||||||
|
|
||||||
b, _ := json.Marshal(data)
|
_, err := natsJS.PublishAsync(channel, payload)
|
||||||
_, err := natsJS.PublishAsync(channel, b)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("publish message to subject %s error: %s", channel, err.Error())
|
msg := fmt.Sprintf("publish message to subject %s error: %s", channel, err.Error())
|
||||||
return errors.New(msg)
|
return errors.New(msg)
|
||||||
|
|
Loading…
Reference in New Issue