|
|
@ -4,27 +4,25 @@ import ( |
|
|
|
"fmt" |
|
|
|
hbtp "github.com/mgr9525/HyperByte-Transfer-Protocol" |
|
|
|
gocloud "github.com/mgr9525/go-cloud" |
|
|
|
"net/url" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
RPCHostCode = 1 |
|
|
|
) |
|
|
|
|
|
|
|
func NewReq(method string, ipr string) (*hbtp.Request, error) { |
|
|
|
func NewReq(cmds string, iprs string, tmots ...time.Duration) *hbtp.Request { |
|
|
|
host := fmt.Sprintf("%v", gocloud.CloudConf.Custom["sysHbtpHost"]) |
|
|
|
return hbtp.NewDoRPCReq(host, RPCHostCode, method, ipr, nil) |
|
|
|
} |
|
|
|
func DoJson(method string, in, out interface{}, hd ...map[string]interface{}) error { |
|
|
|
req, err := NewReq(method, "") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
pars := url.Values{} |
|
|
|
pars.Set("iprs", iprs) |
|
|
|
return hbtp.NewRequest(host, RPCHostCode, tmots...).Command(cmds).Args(pars) |
|
|
|
} |
|
|
|
func DoJson(cmds string, in, out interface{}, hd ...hbtp.Map) error { |
|
|
|
req := NewReq(cmds, "") |
|
|
|
return hbtp.DoJson(req, in, out, hd...) |
|
|
|
} |
|
|
|
func DoString(method string, in interface{}, hd ...hbtp.Mp) (int, []byte, error) { |
|
|
|
req, err := NewReq(method, "") |
|
|
|
if err != nil { |
|
|
|
return 0, nil, err |
|
|
|
} |
|
|
|
func DoString(cmds string, in interface{}, hd ...hbtp.Map) (int32, []byte, error) { |
|
|
|
req := NewReq(cmds, "") |
|
|
|
return hbtp.DoString(req, in, hd...) |
|
|
|
} |