當前位置: 首頁>>代碼示例>>Golang>>正文


Golang xmlrpc.NewClient函數代碼示例

本文整理匯總了Golang中github.com/kolo/xmlrpc.NewClient函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewClient函數的具體用法?Golang NewClient怎麽用?Golang NewClient使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewClient函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getClient

func (d *Driver) getClient() *xmlrpc.Client {
	rpc, err := xmlrpc.NewClient(d.Url, nil)
	if err != nil {
		return nil
	}
	return rpc
}
開發者ID:jmbarbier,項目名稱:docker-machine-gandi,代碼行數:7,代碼來源:gandi.go

示例2: NewClient

func NewClient() *Client {
	client, _ := xmlrpc.NewClient(OpenSubtitlesAPI, nil)

	return &Client{
		NewUnauthenticatedClientState(*client),
	}
}
開發者ID:CentaurWarchief,項目名稱:subbs,代碼行數:7,代碼來源:client.go

示例3: Call

func (self *Client) Call(serviceMethod string, args []interface{}, reply interface{}) error {
	rpc, err := xmlrpc.NewClient(self.Url, nil)
	if err != nil {
		return err
	}
	return rpc.Call(serviceMethod, args, reply)
}
開發者ID:raphink,項目名稱:external-dns,代碼行數:7,代碼來源:client.go

示例4: SetClient

func SetClient(args ...string) error {
	var auth_token string
	var one_auth_path string

	if len(args) == 1 {
		auth_token = args[0]
	} else {
		one_auth_path = os.Getenv("ONE_AUTH")
		if one_auth_path == "" {
			one_auth_path = os.Getenv("HOME") + "/.one/one_auth"
		}

		token, err := ioutil.ReadFile(one_auth_path)
		if err == nil {
			auth_token = strings.TrimSpace(string(token))
		} else {
			auth_token = ""
		}
	}

	one_xmlrpc := os.Getenv("ONE_XMLRPC")
	if one_xmlrpc == "" {
		one_xmlrpc = "http://localhost:2633/RPC2"
	}

	xmlrpcClient, xmlrpcClientError := xmlrpc.NewClient(one_xmlrpc, nil)

	client = &oneClient{
		token:             auth_token,
		xmlrpcClient:      xmlrpcClient,
		xmlrpcClientError: xmlrpcClientError,
	}

	return nil
}
開發者ID:pkdevbox,項目名稱:machine,代碼行數:35,代碼來源:goca.go

示例5: run

func (si *supervisorInstance) run() {
	client, err := xmlrpc.NewClient(fmt.Sprintf("http://%s/RPC2", si.host), nil)
	if err != nil {
		si.err = err
		log.Printf("%s: client error: %v", si.host, err)
		return
	}
	waitTime := sleepTime
	if *signal {
		err = client.Call("supervisor.signalProcess", []interface{}{*program, *signalName}, nil)
		log.Printf("%s: signalProcess. err=%v", si.host, err)
		waitTime = shortSleepTime
	}
	if *stop {
		err = client.Call("supervisor.stopProcess", []interface{}{*program, true}, nil)
		log.Printf("%s: stopProcess. err=%v", si.host, err)
		waitTime = shortSleepTime
	}

	for {
		si.err = client.Call("supervisor.getProcessInfo", *program, &si.info)
		if si.err != nil {
			log.Printf("%s: call error: %v", si.host, err)
			break
		}
		log.Printf("%s: %s", si.host, si.info.StateName)

		if si.info.State != 20 { /* 20=RUNNING */
			break
		}

		time.Sleep(waitTime)
	}
}
開發者ID:BramGruneir,項目名稱:cockroach-prod,代碼行數:34,代碼來源:main.go

示例6: NewClient

// Get a new client suitable for communicating with a supervisord.
// url must contain a real url to a supervisord RPC-service.
//
// Url for local supervisord should be http://127.0.0.1:9001/RPC2 by default.
func NewClient(url string) (*Client, error) {
	rpc, err := xmlrpc.NewClient(url, nil)
	if err != nil {
		return nil, err
	}

	return &Client{rpc}, nil
}
開發者ID:abrander,項目名稱:go-supervisord,代碼行數:12,代碼來源:client.go

示例7: NewClient

// NewClient authenticates with Pulse server for a user session, creating
// a RPC client.
func NewClient(url, user, pass string) (Client, error) {
	c, err := &client{d: 15 * time.Second}, (error)(nil)
	if c.rpc, err = xmlrpc.NewClient(url, nil); err != nil {
		return nil, err
	}
	if err = c.rpc.Call("RemoteApi.login", []interface{}{user, pass}, &c.tok); err != nil {
		return nil, err
	}
	return c, nil
}
開發者ID:rjeczalik,項目名稱:pulsekit,代碼行數:12,代碼來源:client.go

示例8: New

// New creates a Client, provided with a "host:port" string
func New(hostPort string) *Client {
	rpcClient, err := xmlrpc.NewClient(fmt.Sprintf("http://%s/RPC2", hostPort), nil)
	if err != nil {
		log.Fatalln("Couldn't create XML-RPC client:", err)
	}

	return &Client{
		rpcClient: rpcClient,
	}
}
開發者ID:abourget,項目名稱:ldtp,代碼行數:11,代碼來源:client.go

示例9: SetClient

func SetClient(conf OneConfig) error {

	xmlrpcClient, xmlrpcClientError := xmlrpc.NewClient(conf.XmlrpcUrl, nil)

	client = &oneClient{
		token:             conf.Token,
		xmlrpcClient:      xmlrpcClient,
		xmlrpcClientError: xmlrpcClientError,
	}

	return nil
}
開發者ID:OpenNebula,項目名稱:goca,代碼行數:12,代碼來源:goca.go

示例10: NewClient

func NewClient() (*Client, error) {
	rpc, err := xmlrpc.NewClient(DefaultOSDBServer, nil)
	if err != nil {
		return nil, err
	}

	c := &Client{
		UserAgent: DefaultUserAgent,
		Client:    rpc, // xmlrpc.Client
	}

	return c, nil
}
開發者ID:xfanity,項目名稱:pulsar,代碼行數:13,代碼來源:client.go

示例11: NewClient

// NewClient stand up a new XapiClient. Version should probably be "1.2" unless you know what you are doing.
func NewClient(uri, username, password, version string) (client Client) {
	client.URI = uri
	client.Username = username
	client.Password = password
	client.Version = version
	client.rpc, _ = xmlrpc.NewClient(
		client.URI,
		&http.Transport{
			Dial: TimeoutDialer(),
		})

	return
}
開發者ID:softlayer,項目名稱:xapi-go,代碼行數:14,代碼來源:xapi.go

示例12: NewRPCClient

/**
 *
 * Creates an RPCClient with endpoint and returns it
 *
 **/
func NewRPCClient(endpoint string, username string, password string) (*Rpc, error) {
	log.Debugf(cmd.Colorfy("  > [one-go] connecting", "blue", "", "bold"))

	RPCclient, err := xmlrpc.NewClient(endpoint, nil)

	if err != nil {
		//TO-DO: trap and send connRefused error.
		return nil, err
	}
	log.Debugf(cmd.Colorfy("  > [one-go] connected", "blue", "", "bold")+" %s", endpoint)

	return &Rpc{
		RPCClient: *RPCclient,
		Key:       username + ":" + password}, nil
}
開發者ID:morpheyesh,項目名稱:goca,代碼行數:20,代碼來源:api.go

示例13: NewClient

// 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
}
開發者ID:janqii,項目名稱:go-supervisor,代碼行數:18,代碼來源:rpc.go

示例14: NewClient

func NewClient(config map[string]string) (*Rpc, error) {
	log.Debugf(cmd.Colorfy("  > [one-go] connecting", "blue", "", "bold"))

	if !satisfied(config) {
		return nil, ErrArgsNotSatisfied
	}

	client, err := xmlrpc.NewClient(config[ENDPOINT], nil)
	if err != nil {
		return nil, err
	}
	//log.Debugf(cmd.Colorfy("  > [one-go] connection response", "blue", "", "bold")+"%#v",client)
	log.Debugf(cmd.Colorfy("  > [one-go] connected", "blue", "", "bold")+" %s", config[ENDPOINT])

	return &Rpc{
		Client: *client,
		Key:    config[USERID] + ":" + config[PASSWORD]}, nil
}
開發者ID:megamsys,項目名稱:opennebula-go,代碼行數:18,代碼來源:api.go

示例15: newBugzillaClient

func newBugzillaClient(url string, username string, password string) (*BugzillaClient, error) {
	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
	client, err := xmlrpc.NewClient(url, transport)
	if err != nil {
		return nil, err
	}

	// Get authentication token
	var resp struct {
		ID    int    `xmlrpc:"id"`
		Token string `xmlrpc:"token"`
	}
	if err = client.Call("User.login", params{"login": username, "password": password}, &resp); err != nil {
		return nil, err
	}

	return &BugzillaClient{
		client: client,
		token:  resp.Token,
	}, nil
}
開發者ID:kolo,項目名稱:telegram_bot,代碼行數:21,代碼來源:bugzilla.go


注:本文中的github.com/kolo/xmlrpc.NewClient函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。