natsio/client/communication.go

28 lines
631 B
Go
Raw Normal View History

2022-08-18 10:47:47 +00:00
package client
import (
"encoding/json"
2022-10-10 04:11:39 +00:00
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
2022-08-18 10:47:47 +00:00
)
// Communication ...
type Communication struct{}
// GetCommunication ...
func GetCommunication() Communication {
return Communication{}
}
// RequestHttp ...
2022-08-19 03:02:29 +00:00
func (c Communication) RequestHttp(p model.CommunicationRequestHttp) (r *model.CommunicationHttpResponse, err error) {
2022-08-26 08:56:36 +00:00
msg, err := natsio.GetServer().Request(subject.Communication.RequestHTTP, toBytes(p))
2022-08-18 10:47:47 +00:00
if err != nil {
return nil, err
}
err = json.Unmarshal(msg.Data, &r)
return r, err
}