package client import ( "encoding/json" "errors" "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/subject" ) // Queue ... type Queue struct{} // GetQueue ... func GetQueue() Queue { return Queue{} } func (c Queue) ScheduleTask(p model.QueueScheduleTaskRequest) error { msg, err := natsio.GetServer().Request(subject.Queue.ScheduleTask, toBytes(p)) if err != nil { return err } var r struct { Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return err } if r.Error != "" { return errors.New(r.Error) } return nil }