From fa5d3510c294fa17dc081c3bdd295ce8d3b55c40 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期一, 17 六月 2019 19:09:11 +0800
Subject: [PATCH] add saveLinkRrulesByGroup
---
reqrepClient.go | 100 ++++++++++++++++++++++++++++++--------------------
1 files changed, 60 insertions(+), 40 deletions(-)
diff --git a/reqrepClient.go b/reqrepClient.go
index 1a32afc..8faf905 100644
--- a/reqrepClient.go
+++ b/reqrepClient.go
@@ -1,43 +1,63 @@
package dbapi
-import (
- "fmt"
- "os"
- "nanomsg.org/go-mangos"
- "nanomsg.org/go-mangos/protocol/req"
- "nanomsg.org/go-mangos/transport/ipc"
- "nanomsg.org/go-mangos/transport/tcp"
-)
+type ReqRepClient struct {}
-type ReqrepApi struct {
-
-}
-
-const (
- ReqRep_URL = "tcp://127.0.0.1:8002"
-)
-
-func (api ReqrepApi)SendRequest(reqStr string) string {
- var sock mangos.Socket
- var err error
- var msg []byte
-
- if sock, err = req.NewSocket(); err !=nil {
- fmt.Println("can't get new req socket!")
- os.Exit(1)
- }
- sock.AddTransport(ipc.NewTransport())
- sock.AddTransport(tcp.NewTransport())
- if err = sock.Dial(ReqRep_URL);err !=nil {
- fmt.Println("can't dial on req socket!!")
- os.Exit(1)
- }
- if err =sock.Send([]byte(reqStr));err !=nil {
- fmt.Println("can't send msg")
- }
- if msg,err = sock.Recv();err !=nil {
- fmt.Println("can't get msg from mangos reqrep server")
- }
- defer sock.Close()
- return string(msg)
-}
\ No newline at end of file
+//var ReqRep_URL = "tcp://192.168.1.11:8002"
+//
+////鍒濆鍖杛ply鐨勫湴鍧�
+//func InitRplyUrl(url string) {
+// ReqRep_URL = url
+//}
+//
+//func (api ReqRepClient) DoGetRequest(url string, params map[string]string, headers map[string]string) ([]byte, error) {
+// var reqBody RplyParamBody
+// reqBody.Action = url
+// var destMap map[string]interface{}
+// for idx,val := range params {
+// destMap[idx] = interface{}(val)
+// }
+// reqBody.Params = destMap
+// return doRply(reqBody)
+//}
+//
+//func (api ReqRepClient) DoPostRequest(url string, contentType string, body map[string]interface{}, params map[string]string, headers map[string]string) ([]byte, error) {
+// var reqBody RplyParamBody
+// reqBody.Action = url
+// reqBody.Params = body
+// return doRply(reqBody)
+//}
+//
+//func (api ReqRepClient) DoPutRequest(url string, contentType string, body map[string]interface{}, headers map[string]string) ([]byte, error) {
+// var reqBody RplyParamBody
+// reqBody.Action = url
+// reqBody.Params = body
+// return doRply(reqBody)
+//}
+//
+//func (api ReqRepClient) DoDeleteRequest(url string, contentType string, body map[string]interface{}, headers map[string]string) ([]byte, error) {
+// var reqBody RplyParamBody
+// reqBody.Action = url
+// reqBody.Params = body
+// return doRply(reqBody)
+//}
+//
+//type RplyParamBody struct {
+// Action string `json:"action"` //鏍规嵁action鍒ゆ柇鍋氫綍绉嶅搷搴�
+// Params map[string]interface{} `json:"params"`//鍙傛暟map
+//}
+//
+//func doRply(body RplyParamBody)([]byte,error){
+// sender := deliver.NewClient(deliver.Mode(deliver.ReqRep), ReqRep_URL)
+// bytes,err := json.Marshal(body)
+// if err !=nil {
+// return nil,err
+// }
+// err = sender.Send(bytes)
+// if err !=nil {
+// resMsg, _ := sender.Recv()
+// if resMsg !=nil {
+// return resMsg,nil
+// }
+// }
+// return nil,errors.New("nng no resp")
+//}
\ No newline at end of file
--
Gitblit v1.8.0