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


Golang flux.Token類代碼示例

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


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

示例1: invokePostRelease

func invokePostRelease(client *http.Client, t flux.Token, router *mux.Router, endpoint string, s jobs.ReleaseJobParams) (jobs.JobID, error) {
	args := []string{"service", string(s.ServiceSpec), "image", string(s.ImageSpec), "kind", string(s.Kind)}
	for _, ex := range s.Excludes {
		args = append(args, "exclude", string(ex))
	}

	u, err := makeURL(endpoint, router, "PostRelease", args...)
	if err != nil {
		return "", errors.Wrap(err, "constructing URL")
	}

	req, err := http.NewRequest("POST", u.String(), nil)
	if err != nil {
		return "", errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	resp, err := executeRequest(client, req)
	if err != nil {
		return "", errors.Wrap(err, "executing HTTP request")
	}

	var res postReleaseResponse
	if err := json.NewDecoder(resp.Body).Decode(&res); err != nil {
		return "", errors.Wrap(err, "decoding response from server")
	}
	return res.ReleaseID, nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:28,代碼來源:transport.go

示例2: invokeUnlock

func invokeUnlock(client *http.Client, t flux.Token, router *mux.Router, endpoint string, id flux.ServiceID) error {
	u, err := makeURL(endpoint, router, "Unlock", "service", string(id))
	if err != nil {
		return errors.Wrap(err, "constructing URL")
	}

	req, err := http.NewRequest("POST", u.String(), nil)
	if err != nil {
		return errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	if _, err = executeRequest(client, req); err != nil {
		return errors.Wrap(err, "executing HTTP request")
	}

	return nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:18,代碼來源:transport.go

示例3: Dial

// Dial initiates a new websocket connection.
func Dial(client *http.Client, token flux.Token, u *url.URL) (Websocket, error) {
	// Build the http request
	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, errors.Wrapf(err, "constructing request %s", u)
	}

	// Add authentication if provided
	token.Set(req)

	// Use http client to do the http request
	conn, _, err := dialer(client).Dial(u.String(), req.Header)
	if err != nil {
		return nil, errors.Wrapf(err, "connecting websocket %s", u)
	}

	// Set up the ping heartbeat
	return Ping(conn), nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:20,代碼來源:client.go

示例4: invokeSetConfig

func invokeSetConfig(client *http.Client, t flux.Token, router *mux.Router, endpoint string, updates flux.UnsafeInstanceConfig) error {
	u, err := makeURL(endpoint, router, "SetConfig")
	if err != nil {
		return errors.Wrap(err, "constructing URL")
	}

	var configBytes bytes.Buffer
	if err = json.NewEncoder(&configBytes).Encode(updates); err != nil {
		return errors.Wrap(err, "encoding config updates")
	}

	req, err := http.NewRequest("POST", u.String(), &configBytes)
	if err != nil {
		return errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	if _, err = executeRequest(client, req); err != nil {
		return errors.Wrap(err, "executing HTTP request")
	}

	return nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:23,代碼來源:transport.go

示例5: invokeGetConfig

func invokeGetConfig(client *http.Client, t flux.Token, router *mux.Router, endpoint string) (flux.InstanceConfig, error) {
	u, err := makeURL(endpoint, router, "GetConfig")
	if err != nil {
		return flux.InstanceConfig{}, errors.Wrap(err, "constructing URL")
	}

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return flux.InstanceConfig{}, errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	resp, err := executeRequest(client, req)
	if err != nil {
		return flux.InstanceConfig{}, errors.Wrap(err, "executing HTTP request")
	}

	var res flux.InstanceConfig
	if err := json.NewDecoder(resp.Body).Decode(&res); err != nil {
		return res, errors.Wrap(err, "decoding response body")
	}
	return res, nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:23,代碼來源:transport.go

示例6: invokeGetRelease

func invokeGetRelease(client *http.Client, t flux.Token, router *mux.Router, endpoint string, id jobs.JobID) (jobs.Job, error) {
	u, err := makeURL(endpoint, router, "GetRelease", "id", string(id))
	if err != nil {
		return jobs.Job{}, errors.Wrap(err, "constructing URL")
	}

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return jobs.Job{}, errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	resp, err := executeRequest(client, req)
	if err != nil {
		return jobs.Job{}, errors.Wrap(err, "executing HTTP request")
	}

	var res jobs.Job
	if err := json.NewDecoder(resp.Body).Decode(&res); err != nil {
		return jobs.Job{}, errors.Wrap(err, "decoding response from server")
	}
	return res, nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:23,代碼來源:transport.go

示例7: invokeListImages

func invokeListImages(client *http.Client, t flux.Token, router *mux.Router, endpoint string, s flux.ServiceSpec) ([]flux.ImageStatus, error) {
	u, err := makeURL(endpoint, router, "ListImages", "service", string(s))
	if err != nil {
		return nil, errors.Wrap(err, "constructing URL")
	}

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, errors.Wrapf(err, "constructing request %s", u)
	}
	t.Set(req)

	resp, err := executeRequest(client, req)
	if err != nil {
		return nil, errors.Wrap(err, "executing HTTP request")
	}

	var res []flux.ImageStatus
	if err := json.NewDecoder(resp.Body).Decode(&res); err != nil {
		return nil, errors.Wrap(err, "decoding response from server")
	}
	return res, nil
}
開發者ID:weaveworks,項目名稱:flux,代碼行數:23,代碼來源:transport.go


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