client.go 776 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package gorpc
  2. import (
  3. "context"
  4. "go-common/app/service/main/sms/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _appid = "sms.service"
  9. _send = "RPC.send"
  10. _sendBatch = "RPC.sendBatch"
  11. )
  12. var (
  13. _noRes = &struct{}{}
  14. )
  15. // Service struct info.
  16. type Service struct {
  17. client *rpc.Client2
  18. }
  19. // New new service instance and return.
  20. func New(c *rpc.ClientConfig) (s *Service) {
  21. s = &Service{}
  22. s.client = rpc.NewDiscoveryCli(_appid, c)
  23. return
  24. }
  25. // Send send sms
  26. func (s *Service) Send(c context.Context, arg *model.ArgSend) (err error) {
  27. err = s.client.Call(c, _send, arg, _noRes)
  28. return
  29. }
  30. // SendBatch batch send sms
  31. func (s *Service) SendBatch(c context.Context, arg *model.ArgSendBatch) (err error) {
  32. err = s.client.Call(c, _sendBatch, arg, _noRes)
  33. return
  34. }