本文整理汇总了Golang中github.com/concourse/atc.Worker类的典型用法代码示例。如果您正苦于以下问题:Golang Worker类的具体用法?Golang Worker怎么用?Golang Worker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Worker类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: beaconRunner
func (cmd *WorkerCommand) beaconRunner(logger lager.Logger, worker atc.Worker) ifrit.Runner {
beacon := Beacon{
Logger: logger,
Config: cmd.TSA,
}
var beaconRunner ifrit.RunFunc
if cmd.PeerIP != "" {
worker.GardenAddr = fmt.Sprintf("%s:%d", cmd.PeerIP, cmd.BindPort)
worker.BaggageclaimURL = fmt.Sprintf("http://%s:%d", cmd.PeerIP, cmd.Baggageclaim.BindPort)
beaconRunner = beacon.Register
} else {
worker.GardenAddr = fmt.Sprintf("%s:%d", cmd.BindIP, cmd.BindPort)
worker.BaggageclaimURL = fmt.Sprintf("http://%s:%d", cmd.Baggageclaim.BindIP, cmd.Baggageclaim.BindPort)
beaconRunner = beacon.Forward
}
beacon.Worker = worker
return restart.Restarter{
Runner: beaconRunner,
Load: func(prevRunner ifrit.Runner, prevErr error) ifrit.Runner {
if _, ok := prevErr.(*ssh.ExitError); !ok {
logger.Error("restarting", prevErr)
time.Sleep(5 * time.Second)
return beaconRunner
}
return nil
},
}
}
开发者ID:Jonty,项目名称:concourse-bin,代码行数:32,代码来源:worker.go
示例2: RegisterWorker
func (s *Server) RegisterWorker(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("register-worker")
var registration atc.Worker
err := json.NewDecoder(r.Body).Decode(®istration)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
if len(registration.GardenAddr) == 0 {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "missing address")
return
}
var ttl time.Duration
ttlStr := r.URL.Query().Get("ttl")
if len(ttlStr) > 0 {
ttl, err = time.ParseDuration(ttlStr)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "malformed ttl")
return
}
}
metric.WorkerContainers{
WorkerAddr: registration.GardenAddr,
Containers: registration.ActiveContainers,
}.Emit(s.logger)
if registration.Name == "" {
registration.Name = registration.GardenAddr
}
_, err = s.db.SaveWorker(db.WorkerInfo{
GardenAddr: registration.GardenAddr,
BaggageclaimURL: registration.BaggageclaimURL,
HTTPProxyURL: registration.HTTPProxyURL,
HTTPSProxyURL: registration.HTTPSProxyURL,
NoProxy: registration.NoProxy,
ActiveContainers: registration.ActiveContainers,
ResourceTypes: registration.ResourceTypes,
Platform: registration.Platform,
Tags: registration.Tags,
Name: registration.Name,
}, ttl)
if err != nil {
logger.Error("failed-to-save-worker", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}
开发者ID:xoebus,项目名称:checkin,代码行数:56,代码来源:register.go
示例3: continuouslyRegisterForwardedWorker
func (server *registrarSSHServer) continuouslyRegisterForwardedWorker(
logger lager.Logger,
channel ssh.Channel,
boundPort uint32,
) (ifrit.Process, error) {
logger.Session("start")
defer logger.Session("done")
var worker atc.Worker
err := json.NewDecoder(channel).Decode(&worker)
if err != nil {
return nil, err
}
worker.Addr = fmt.Sprintf("%s:%d", server.forwardHost, boundPort)
return server.heartbeatWorker(logger, worker, channel), nil
}
开发者ID:savaki,项目名称:tsa,代码行数:18,代码来源:server.go
示例4:
)
var _ = Describe("Heartbeater", func() {
type registration struct {
worker atc.Worker
ttl time.Duration
}
var (
logger lager.Logger
addrToRegister string
interval time.Duration
resourceTypes []atc.WorkerResourceType
expectedWorker atc.Worker
fakeGardenClient *gfakes.FakeClient
fakeATC *ghttp.Server
heartbeater ifrit.Process
registrations <-chan registration
)
BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
addrToRegister = "1.2.3.4:7777"
interval = time.Second
resourceTypes = []atc.WorkerResourceType{
{
开发者ID:savaki,项目名称:gate,代码行数:32,代码来源:heartbeater_test.go
示例5:
Context("when not authenticated", func() {
BeforeEach(func() {
authValidator.IsAuthenticatedReturns(false)
})
It("returns 401", func() {
Expect(response.StatusCode).To(Equal(http.StatusUnauthorized))
})
})
})
Describe("POST /api/v1/workers", func() {
var (
worker atc.Worker
ttl string
response *http.Response
)
BeforeEach(func() {
worker = atc.Worker{
GardenAddr: "1.2.3.4:7777",
BaggageclaimURL: "5.6.7.8:7788",
ActiveContainers: 2,
ResourceTypes: []atc.WorkerResourceType{
{Type: "some-resource", Image: "some-resource-image"},
},
Platform: "haiku",
Tags: []string{"not", "a", "limerick"},
}
开发者ID:ACPK,项目名称:atc,代码行数:30,代码来源:workers_test.go
注:本文中的github.com/concourse/atc.Worker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论