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


Golang transport.Locator類代碼示例

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


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

示例1: RemoteJobFor

func (h *HttpTransport) RemoteJobFor(locator transport.Locator, j interface{}) (job jobs.Job, err error) {
	baseUrl, errl := urlForLocator(locator)
	if errl != nil {
		err = errors.New("The provided host is not valid '" + locator.String() + "': " + errl.Error())
		return
	}
	httpJob, errh := HttpJobFor(j)
	if errh == jobs.ErrNoJobForRequest {
		err = transport.ErrNotTransportable
		return
	}
	if errh != nil {
		err = errh
		return
	}
	if serverAware, ok := httpJob.(ServerAware); ok {
		serverAware.SetServer(baseUrl.Host)
	}

	job = jobs.JobFunction(func(res jobs.Response) {
		if err := h.ExecuteRemote(baseUrl, httpJob, res); err != nil {
			res.Failure(err)
		}
	})
	return
}
開發者ID:kshi0310,項目名稱:geard,代碼行數:26,代碼來源:transport.go

示例2: RemoveFromLocation

func (p SimplePlacement) RemoveFromLocation(on transport.Locator) bool {
	for _, l := range transport.Locators(p) {
		if l.String() == on.String() {
			return false
		}
	}
	return true
}
開發者ID:jcantrill,項目名稱:geard,代碼行數:8,代碼來源:placement.go

示例3: urlForLocator

func urlForLocator(locator transport.Locator) (*url.URL, error) {
	base := locator.String()
	if strings.Contains(base, ":") {
		host, port, err := net.SplitHostPort(base)
		if err != nil {
			return nil, err
		}
		if port == "" {
			base = net.JoinHostPort(host, DefaultHttpPort)
		}
	} else {
		base = net.JoinHostPort(base, DefaultHttpPort)
	}
	return &url.URL{Scheme: "http", Host: base}, nil
}
開發者ID:rajatchopra,項目名稱:geard,代碼行數:15,代碼來源:remote.go

示例4: RemoteJobFor

func (t *testTransport) RemoteJobFor(locator transport.Locator, job jobs.Job) (jobs.Job, error) {
	if t.Translated == nil {
		t.Translated = make(map[string]jobs.Job)
		t.Invoked = make(map[string]jobs.Response)
	}
	t.Translated[locator.String()] = job
	invoked := func(res jobs.Response) {
		if _, found := t.Invoked[locator.String()]; found {
			panic(fmt.Sprintf("Same job %+v invoked twice under %s", job, locator.String()))
		}
		t.Invoked[locator.String()] = res
		res.Success(jobs.ResponseOk)
	}
	return jobs.JobFunction(invoked), nil
}
開發者ID:rajatchopra,項目名稱:geard,代碼行數:15,代碼來源:executor_test.go

示例5: RemoteJobFor

func (h *HttpTransport) RemoteJobFor(locator transport.Locator, j jobs.Job) (job jobs.Job, err error) {
	if locator == transport.Local {
		job = j
		return
	}
	baseUrl, errl := urlForLocator(locator)
	if errl != nil {
		err = errors.New("The provided host is not valid '" + locator.String() + "': " + errl.Error())
		return
	}
	httpJob, errh := HttpJobFor(j)
	if errh != nil {
		err = errh
		return
	}

	job = jobs.JobFunction(func(res jobs.Response) {
		if err := h.ExecuteRemote(baseUrl, httpJob, res); err != nil {
			res.Failure(err)
		}
	})
	return
}
開發者ID:rajatchopra,項目名稱:geard,代碼行數:23,代碼來源:remote.go

示例6: Place

func (i *Instance) Place(on transport.Locator) {
	i.on = on
	s := on.String()
	i.On = &s
}
開發者ID:jcantrill,項目名稱:geard,代碼行數:5,代碼來源:instance.go


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