本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例6: Place
func (i *Instance) Place(on transport.Locator) {
i.on = on
s := on.String()
i.On = &s
}