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


Golang ArvadosClient.Discovery方法代碼示例

本文整理匯總了Golang中git/curoverse/com/arvados/git/sdk/go/arvadosclient.ArvadosClient.Discovery方法的典型用法代碼示例。如果您正苦於以下問題:Golang ArvadosClient.Discovery方法的具體用法?Golang ArvadosClient.Discovery怎麽用?Golang ArvadosClient.Discovery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在git/curoverse/com/arvados/git/sdk/go/arvadosclient.ArvadosClient的用法示例。


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

示例1: setupKeepClient

// setup keepclient using the config provided
func setupKeepClient(config apiConfig, keepServicesJSON string, isDst bool, replications int, srcBlobSignatureTTL time.Duration) (kc *keepclient.KeepClient, blobSignatureTTL time.Duration, err error) {
	arv := arvadosclient.ArvadosClient{
		ApiToken:    config.APIToken,
		ApiServer:   config.APIHost,
		ApiInsecure: config.APIHostInsecure,
		Client: &http.Client{Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: config.APIHostInsecure}}},
		External: config.ExternalClient,
	}

	// if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
	if keepServicesJSON == "" {
		kc, err = keepclient.MakeKeepClient(&arv)
		if err != nil {
			return nil, 0, err
		}
	} else {
		kc = keepclient.New(&arv)
		err = kc.LoadKeepServicesFromJSON(keepServicesJSON)
		if err != nil {
			return kc, 0, err
		}
	}

	if isDst {
		// Get default replications value from destination, if it is not already provided
		if replications == 0 {
			value, err := arv.Discovery("defaultCollectionReplication")
			if err == nil {
				replications = int(value.(float64))
			} else {
				return nil, 0, err
			}
		}

		kc.Want_replicas = replications
	}

	// If srcBlobSignatureTTL is not provided, get it from API server discovery doc
	blobSignatureTTL = srcBlobSignatureTTL
	if !isDst && srcBlobSignatureTTL == 0 {
		value, err := arv.Discovery("blobSignatureTtl")
		if err == nil {
			blobSignatureTTL = time.Duration(int(value.(float64))) * time.Second
		} else {
			return nil, 0, err
		}
	}

	return kc, blobSignatureTTL, nil
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:52,代碼來源:keep-rsync.go

示例2: New

// New func creates a new KeepClient struct.
// This func does not discover keep servers. It is the caller's responsibility.
func New(arv *arvadosclient.ArvadosClient) *KeepClient {
	defaultReplicationLevel := 2
	value, err := arv.Discovery("defaultCollectionReplication")
	if err == nil {
		v, ok := value.(float64)
		if ok && v > 0 {
			defaultReplicationLevel = int(v)
		}
	}

	kc := &KeepClient{
		Arvados:       arv,
		Want_replicas: defaultReplicationLevel,
		Client: &http.Client{Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: arv.ApiInsecure}}},
		Retries: 2,
	}
	return kc
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:21,代碼來源:keepclient.go

示例3: setupKeepClient

// setup keepclient using the config provided
func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL time.Duration) (kc *keepclient.KeepClient, ttl time.Duration, err error) {
	arv := arvadosclient.ArvadosClient{
		ApiToken:    config.APIToken,
		ApiServer:   config.APIHost,
		ApiInsecure: config.APIHostInsecure,
		Client: &http.Client{Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: config.APIHostInsecure}}},
		External: config.ExternalClient,
	}

	// if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
	if keepServicesJSON == "" {
		kc, err = keepclient.MakeKeepClient(&arv)
		if err != nil {
			return
		}
	} else {
		kc = keepclient.New(&arv)
		err = kc.LoadKeepServicesFromJSON(keepServicesJSON)
		if err != nil {
			return
		}
	}

	// Get if blobSignatureTTL is not provided
	ttl = blobSignatureTTL
	if blobSignatureTTL == 0 {
		value, err := arv.Discovery("blobSignatureTtl")
		if err == nil {
			ttl = time.Duration(int(value.(float64))) * time.Second
		} else {
			return nil, 0, err
		}
	}

	return
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:38,代碼來源:keep-block-check.go


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