Exemplo n.º 1
0
/**
 *
 * Do an RPC Call
 *
 **/
func (c *Rpc) Call(RPC xmlrpc.Client, command string, args []interface{}) ([]interface{}, error) {
	log.Debugf(cmd.Colorfy("  > [one-go] ", "blue", "", "bold")+"%s", command)
	//log.Debugf(cmd.Colorfy("\n> args   ", "cyan", "", "bold")+" %v\n", args)

	result := []interface{}{}
	err := RPC.Call(command, args, &result)

	if err != nil {
		return nil, err
	}
	//log.Debugf(cmd.Colorfy("\n> response ", "cyan", "", "bold")+" %v", result)
	log.Debugf(cmd.Colorfy("  > [one-go] ( ´ ▽ ` ) SUCCESS", "blue", "", "bold"))
	return result, nil
}
Exemplo n.º 2
0
// NewClient creates a new supervisor RPC client.
func NewClient(url string) (client Client, err error) {
	var rpc *xmlrpc.Client
	if rpc, err = xmlrpc.NewClient(url, nil); err != nil {
		return
	}

	version := ""
	if err = rpc.Call("supervisor.getAPIVersion", nil, &version); err != nil {
		return
	}
	if version != apiVersion {
		err = errors.New(fmt.Sprintf("want Supervisor API version %s, got %s instead", apiVersion, version))
		return
	}
	client = Client{rpc, version}
	return
}