natsio/client/communication.go

28 lines
622 B
Go
Raw Permalink Normal View History

2022-08-30 04:03:02 +00:00
package client
import (
"encoding/json"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// Communication ...
type Communication struct{}
// GetCommunication ...
func GetCommunication() Communication {
return Communication{}
}
// RequestHttp ...
func (c Communication) RequestHttp(p model.CommunicationRequestHttp) (r *model.CommunicationHttpResponse, err error) {
msg, err := natsio.GetServer().Request(subject.Communication.RequestHTTP, toBytes(p))
if err != nil {
return nil, err
}
err = json.Unmarshal(msg.Data, &r)
return r, err
}