2017-11-22 11:40:14 +08:00
|
|
|
package region
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
2017-11-23 15:05:46 +08:00
|
|
|
"fmt"
|
2017-12-19 18:46:49 +08:00
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/bitly/go-simplejson"
|
|
|
|
"github.com/goodrain/rainbond/pkg/node/api/model"
|
|
|
|
"github.com/pquerna/ffjson/ffjson"
|
2017-11-28 15:35:29 +08:00
|
|
|
//"github.com/goodrain/rainbond/pkg/grctl/cmd"
|
2017-11-29 17:13:42 +08:00
|
|
|
"errors"
|
2017-12-19 18:46:49 +08:00
|
|
|
|
|
|
|
utilhttp "github.com/goodrain/rainbond/pkg/util/http"
|
2017-11-22 11:40:14 +08:00
|
|
|
)
|
2017-12-19 18:46:49 +08:00
|
|
|
|
2017-11-22 11:40:14 +08:00
|
|
|
var nodeServer *RNodeServer
|
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func NewNode(nodeAPI string) {
|
|
|
|
if nodeServer == nil {
|
|
|
|
nodeServer = &RNodeServer{
|
|
|
|
NodeAPI: nodeAPI,
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func GetNode() *RNodeServer {
|
|
|
|
return nodeServer
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
|
2017-11-22 11:40:14 +08:00
|
|
|
type RNodeServer struct {
|
2017-11-23 16:13:45 +08:00
|
|
|
NodeAPI string
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func (r *RNodeServer) Tasks() TaskInterface {
|
2017-11-22 11:40:14 +08:00
|
|
|
return &Task{}
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (r *RNodeServer) Nodes() NodeInterface {
|
2017-11-22 11:40:14 +08:00
|
|
|
return &Node{}
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
|
2017-11-22 11:40:14 +08:00
|
|
|
type Task struct {
|
2017-12-19 18:46:49 +08:00
|
|
|
TaskID string `json:"task_id"`
|
|
|
|
Task *model.Task
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
type Node struct {
|
2017-12-19 18:46:49 +08:00
|
|
|
Id string
|
2017-11-23 16:13:45 +08:00
|
|
|
Node *model.HostNode `json:"node"`
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
type TaskInterface interface {
|
2017-12-19 18:46:49 +08:00
|
|
|
Get(name string) (*Task, error)
|
|
|
|
Add(task *model.Task) error
|
|
|
|
AddGroup(group *model.TaskGroup) error
|
|
|
|
Exec(name string, nodes []string) error
|
|
|
|
List() ([]*model.Task, error)
|
|
|
|
Refresh() error
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
type NodeInterface interface {
|
|
|
|
Add(node *model.APIHostNode)
|
2017-11-27 13:39:22 +08:00
|
|
|
Delete()
|
2017-11-27 15:18:05 +08:00
|
|
|
Rule(rule string) []*model.HostNode
|
2017-11-22 18:46:17 +08:00
|
|
|
Get(node string) *Node
|
|
|
|
List() []*model.HostNode
|
|
|
|
Up()
|
|
|
|
Down()
|
|
|
|
UnSchedulable()
|
|
|
|
ReSchedulable()
|
2017-11-27 15:18:05 +08:00
|
|
|
Label(label map[string]string)
|
|
|
|
}
|
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Label(label map[string]string) {
|
|
|
|
body, _ := json.Marshal(label)
|
|
|
|
_, _, err := nodeServer.Request("/nodes/"+t.Id+"/labels", "PUT", body)
|
2017-11-27 15:18:05 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error details %s", err.Error())
|
2017-11-27 15:18:05 +08:00
|
|
|
}
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Add(node *model.APIHostNode) {
|
|
|
|
body, _ := json.Marshal(node)
|
|
|
|
_, _, err := nodeServer.Request("/nodes", "POST", body)
|
2017-11-27 12:06:28 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error details %s", err.Error())
|
2017-11-27 12:06:28 +08:00
|
|
|
}
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
2017-11-27 13:39:22 +08:00
|
|
|
func (t *Node) Delete() {
|
2017-12-19 18:46:49 +08:00
|
|
|
_, _, err := nodeServer.Request("/nodes/"+t.Id, "DELETE", nil)
|
2017-11-27 13:39:22 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error details %s", err.Error())
|
2017-11-27 13:39:22 +08:00
|
|
|
}
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Up() {
|
|
|
|
nodeServer.Request("/nodes/"+t.Id+"/up", "POST", nil)
|
2017-11-22 18:46:17 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Down() {
|
|
|
|
nodeServer.Request("/nodes/"+t.Id+"/down", "POST", nil)
|
2017-11-22 18:46:17 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) UnSchedulable() {
|
|
|
|
nodeServer.Request("/nodes/"+t.Id+"/unschedulable", "PUT", nil)
|
2017-11-22 18:46:17 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) ReSchedulable() {
|
|
|
|
nodeServer.Request("/nodes/"+t.Id+"/reschedulable", "PUT", nil)
|
2017-11-22 18:46:17 +08:00
|
|
|
}
|
2017-11-27 15:18:05 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Get(node string) *Node {
|
|
|
|
body, _, err := nodeServer.Request("/nodes/"+node, "GET", nil)
|
2017-11-22 18:46:17 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get node %s,details %s", node, err.Error())
|
2017-11-22 18:46:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
t.Id = node
|
2017-11-22 18:46:17 +08:00
|
|
|
var stored model.HostNode
|
2017-12-19 18:46:49 +08:00
|
|
|
j, err := simplejson.NewJson(body)
|
2017-11-22 18:46:17 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get node %s 's json,details %s", node, err.Error())
|
2017-11-22 18:46:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
bean := j.Get("bean")
|
|
|
|
n, err := json.Marshal(bean)
|
2017-11-23 16:13:45 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get bean from response,details %s", err.Error())
|
2017-11-23 16:13:45 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
err = json.Unmarshal([]byte(n), &stored)
|
2017-11-23 16:13:45 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error unmarshal node %s,details %s", node, err.Error())
|
2017-11-23 16:13:45 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
t.Node = &stored
|
2017-11-22 18:46:17 +08:00
|
|
|
return t
|
|
|
|
}
|
2017-11-27 15:18:05 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) Rule(rule string) []*model.HostNode {
|
|
|
|
body, _, err := nodeServer.Request("/nodes/rule/"+rule, "GET", nil)
|
2017-11-27 15:18:05 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get rule %s ,details %s", rule, err.Error())
|
2017-11-27 15:18:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
j, err := simplejson.NewJson(body)
|
2017-11-27 15:18:05 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get json ,details %s", err.Error())
|
2017-11-27 15:18:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
nodeArr, err := j.Get("list").Array()
|
2017-11-27 15:18:05 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Infof("error occurd,details %s", err.Error())
|
2017-11-27 15:18:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
jsonA, _ := json.Marshal(nodeArr)
|
|
|
|
nodes := []*model.HostNode{}
|
2017-12-19 18:46:49 +08:00
|
|
|
err = json.Unmarshal(jsonA, &nodes)
|
2017-11-27 15:18:05 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Infof("error occurd,details %s", err.Error())
|
2017-11-27 15:18:05 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return nodes
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Node) List() []*model.HostNode {
|
|
|
|
body, _, err := nodeServer.Request("/nodes", "GET", nil)
|
2017-11-23 16:13:45 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get nodes ,details %s", err.Error())
|
2017-11-24 11:21:51 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
j, err := simplejson.NewJson(body)
|
2017-11-24 11:21:51 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error get json ,details %s", err.Error())
|
2017-11-24 11:21:51 +08:00
|
|
|
return nil
|
2017-11-23 16:13:45 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
nodeArr, err := j.Get("list").Array()
|
2017-11-22 18:46:17 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Infof("error occurd,details %s", err.Error())
|
2017-11-22 18:46:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
jsonA, _ := json.Marshal(nodeArr)
|
|
|
|
nodes := []*model.HostNode{}
|
2017-12-19 18:46:49 +08:00
|
|
|
err = json.Unmarshal(jsonA, &nodes)
|
2017-11-22 18:46:17 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Infof("error occurd,details %s", err.Error())
|
2017-11-22 18:46:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return nodes
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Task) Get(id string) (*Task, error) {
|
|
|
|
t.TaskID = id
|
|
|
|
url := "/tasks/" + id
|
|
|
|
resp, code, err := nodeServer.Request(url, "GET", nil)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("error request url %s,details %s", url, err.Error())
|
|
|
|
return nil, err
|
2017-11-28 16:33:11 +08:00
|
|
|
}
|
2017-11-29 09:43:37 +08:00
|
|
|
if code != 200 {
|
2017-12-19 18:46:49 +08:00
|
|
|
fmt.Println("executing failed:" + string(resp))
|
2017-11-29 09:43:37 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
jsonTop, err := simplejson.NewJson(resp)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("error get json from url %s", err.Error())
|
|
|
|
return nil, err
|
2017-11-28 16:33:11 +08:00
|
|
|
}
|
|
|
|
var task model.Task
|
2017-12-19 18:46:49 +08:00
|
|
|
beanJ := jsonTop.Get("bean")
|
|
|
|
taskB, err := json.Marshal(beanJ)
|
2017-11-29 18:44:39 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error marshal task %s", err.Error())
|
|
|
|
return nil, err
|
2017-11-29 18:44:39 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
err = json.Unmarshal(taskB, &task)
|
2017-11-29 18:44:39 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error unmarshal task %s", err.Error())
|
|
|
|
return nil, err
|
2017-11-29 18:44:39 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
t.Task = &task
|
|
|
|
return t, nil
|
|
|
|
}
|
2017-11-29 18:44:39 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
//List list all task
|
|
|
|
func (t *Task) List() ([]*model.Task, error) {
|
|
|
|
url := "/tasks"
|
|
|
|
resp, _, err := nodeServer.Request(url, "GET", nil)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("error request url %s,details %s", url, err.Error())
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var rb utilhttp.ResponseBody
|
|
|
|
var tasks = new([]*model.Task)
|
|
|
|
rb.List = tasks
|
|
|
|
if err := ffjson.Unmarshal(resp, &rb); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if rb.List == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
list, ok := rb.List.(*[]*model.Task)
|
|
|
|
if ok {
|
|
|
|
return *list, nil
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unmarshal tasks data error")
|
2017-11-29 18:44:39 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
|
|
|
|
//Exec 执行任务
|
|
|
|
func (t *Task) Exec(taskID string, nodes []string) error {
|
2017-11-22 11:40:14 +08:00
|
|
|
var nodesBody struct {
|
|
|
|
Nodes []string `json:"nodes"`
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
nodesBody.Nodes = nodes
|
|
|
|
body, _ := json.Marshal(nodesBody)
|
|
|
|
url := "/tasks/" + taskID + "/exec"
|
|
|
|
resp, code, err := nodeServer.Request(url, "POST", body)
|
2017-11-23 15:05:46 +08:00
|
|
|
if code != 200 {
|
2017-12-19 18:46:49 +08:00
|
|
|
fmt.Println("executing failed:" + string(resp))
|
|
|
|
return fmt.Errorf("exec failure," + string(resp))
|
2017-11-23 15:05:46 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
if err != nil {
|
2017-11-23 15:05:46 +08:00
|
|
|
return err
|
|
|
|
}
|
2017-11-22 11:40:14 +08:00
|
|
|
return err
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Task) Add(task *model.Task) error {
|
2017-11-30 14:43:24 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
body, _ := json.Marshal(task)
|
|
|
|
url := "/tasks"
|
|
|
|
resp, code, err := nodeServer.Request(url, "POST", body)
|
2017-11-30 15:16:22 +08:00
|
|
|
if code != 200 {
|
2017-12-19 18:46:49 +08:00
|
|
|
fmt.Println("executing failed:" + string(resp))
|
2017-11-30 15:16:22 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
if err != nil {
|
2017-11-30 15:16:22 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (t *Task) AddGroup(group *model.TaskGroup) error {
|
|
|
|
body, _ := json.Marshal(group)
|
|
|
|
url := "/taskgroups"
|
|
|
|
resp, code, err := nodeServer.Request(url, "POST", body)
|
2017-11-30 15:16:22 +08:00
|
|
|
if code != 200 {
|
2017-12-19 18:46:49 +08:00
|
|
|
fmt.Println("executing failed:" + string(resp))
|
2017-11-30 15:16:22 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
if err != nil {
|
2017-11-30 15:16:22 +08:00
|
|
|
return err
|
|
|
|
}
|
2017-11-30 14:43:24 +08:00
|
|
|
return nil
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
|
|
|
|
//Refresh 刷新静态配置
|
|
|
|
func (t *Task) Refresh() error {
|
|
|
|
url := "/tasks/taskreload"
|
|
|
|
resp, code, err := nodeServer.Request(url, "PUT", nil)
|
|
|
|
if code != 200 {
|
|
|
|
fmt.Println("executing failed:" + string(resp))
|
|
|
|
return fmt.Errorf("refresh error code,%d", code)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-11-22 11:40:14 +08:00
|
|
|
type TaskStatus struct {
|
|
|
|
Status map[string]model.TaskStatus `json:"status,omitempty"`
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
|
|
|
|
func (t *Task) Status() (*TaskStatus, error) {
|
|
|
|
taskId := t.TaskID
|
2017-11-28 15:35:29 +08:00
|
|
|
|
2017-11-28 11:22:04 +08:00
|
|
|
return HandleTaskStatus(taskId)
|
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func HandleTaskStatus(task string) (*TaskStatus, error) {
|
|
|
|
resp, code, err := nodeServer.Request("/tasks/"+task+"/status", "GET", nil)
|
2017-11-22 11:40:14 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Errorf("error execute status Request,details %s", err.Error())
|
|
|
|
return nil, err
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
2017-11-23 15:05:46 +08:00
|
|
|
if code == 200 {
|
2017-11-28 11:22:04 +08:00
|
|
|
j, _ := simplejson.NewJson(resp)
|
|
|
|
bean := j.Get("bean")
|
|
|
|
beanB, _ := json.Marshal(bean)
|
2017-11-23 15:05:46 +08:00
|
|
|
var status TaskStatus
|
2017-12-19 18:46:49 +08:00
|
|
|
statusMap := make(map[string]model.TaskStatus)
|
2017-11-27 19:24:59 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
json, _ := simplejson.NewJson(beanB)
|
2017-11-28 11:22:04 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
second := json.Interface()
|
2017-11-27 19:24:59 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
if second == nil {
|
|
|
|
return nil, errors.New("get status failed")
|
2017-11-29 17:13:42 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
m := second.(map[string]interface{})
|
2017-11-28 11:22:04 +08:00
|
|
|
|
2017-12-19 18:46:49 +08:00
|
|
|
for k, _ := range m {
|
2017-11-28 11:22:04 +08:00
|
|
|
var taskStatus model.TaskStatus
|
2017-12-19 18:46:49 +08:00
|
|
|
taskStatus.CompleStatus = m[k].(map[string]interface{})["comple_status"].(string)
|
|
|
|
taskStatus.Status = m[k].(map[string]interface{})["status"].(string)
|
|
|
|
taskStatus.JobID = k
|
|
|
|
statusMap[k] = taskStatus
|
2017-11-28 11:22:04 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
status.Status = statusMap
|
|
|
|
return &status, nil
|
2017-11-23 15:05:46 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
return nil, errors.New(fmt.Sprintf("response status is %s", code))
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
2017-12-19 18:46:49 +08:00
|
|
|
func (r *RNodeServer) Request(url, method string, body []byte) ([]byte, int, error) {
|
2017-12-01 11:38:46 +08:00
|
|
|
//logrus.Infof("requesting url: %s by method :%s,and body is ",r.NodeAPI+url,method,string(body))
|
2017-11-29 09:43:37 +08:00
|
|
|
request, err := http.NewRequest(method, "http://127.0.0.1:6100/v2"+url, bytes.NewBuffer(body))
|
2017-11-22 11:40:14 +08:00
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
return nil, 500, err
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
request.Header.Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
res, err := http.DefaultClient.Do(request)
|
|
|
|
if err != nil {
|
2017-12-19 18:46:49 +08:00
|
|
|
logrus.Infof("error when request region,details %s", err.Error())
|
|
|
|
return nil, 500, err
|
2017-11-22 11:40:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err := ioutil.ReadAll(res.Body)
|
|
|
|
defer res.Body.Close()
|
2017-12-01 11:38:46 +08:00
|
|
|
//logrus.Infof("response is %s,response code is %d",string(data),res.StatusCode)
|
2017-12-19 18:46:49 +08:00
|
|
|
return data, res.StatusCode, err
|
|
|
|
}
|