本文整理汇总了Golang中github.com/cloudfoundry-incubator/nsync/recipebuilder.RecipeBuilder类的典型用法代码示例。如果您正苦于以下问题:Golang RecipeBuilder类的具体用法?Golang RecipeBuilder怎么用?Golang RecipeBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecipeBuilder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: createDesiredApp
func (h *DesireAppHandler) createDesiredApp(
logger lager.Logger,
desireAppMessage cc_messages.DesireAppRequestFromCC,
) error {
var builder recipebuilder.RecipeBuilder = h.recipeBuilders["buildpack"]
if desireAppMessage.DockerImageUrl != "" {
builder = h.recipeBuilders["docker"]
}
desiredLRP, err := builder.Build(&desireAppMessage)
if err != nil {
logger.Error("failed-to-build-recipe", err)
return err
}
logger.Debug("creating-desired-lrp", lager.Data{"routes": sanitizeRoutes(desiredLRP.Routes)})
err = h.bbsClient.DesireLRP(desiredLRP)
if err != nil {
logger.Error("failed-to-create-lrp", err)
return err
}
logger.Debug("created-desired-lrp")
return nil
}
开发者ID:cf-routing,项目名称:nsync,代码行数:25,代码来源:desire_app_handler.go
示例2: updateDesiredApp
func (h *DesireAppHandler) updateDesiredApp(
logger lager.Logger,
existingLRP *models.DesiredLRP,
desireAppMessage cc_messages.DesireAppRequestFromCC,
) error {
var builder recipebuilder.RecipeBuilder = h.recipeBuilders["buildpack"]
if desireAppMessage.DockerImageUrl != "" {
builder = h.recipeBuilders["docker"]
}
ports, err := builder.ExtractExposedPorts(&desireAppMessage)
if err != nil {
logger.Error("failed to-get-exposed-port", err)
return err
}
updateRoutes, err := helpers.CCRouteInfoToRoutes(desireAppMessage.RoutingInfo, ports)
if err != nil {
logger.Error("failed-to-marshal-routes", err)
return err
}
routes := existingLRP.Routes
if routes == nil {
routes = &models.Routes{}
}
if value, ok := updateRoutes[cfroutes.CF_ROUTER]; ok {
(*routes)[cfroutes.CF_ROUTER] = value
}
if value, ok := updateRoutes[tcp_routes.TCP_ROUTER]; ok {
(*routes)[tcp_routes.TCP_ROUTER] = value
}
instances := int32(desireAppMessage.NumInstances)
updateRequest := &models.DesiredLRPUpdate{
Annotation: &desireAppMessage.ETag,
Instances: &instances,
Routes: routes,
}
logger.Debug("updating-desired-lrp", lager.Data{"routes": sanitizeRoutes(existingLRP.Routes)})
err = h.bbsClient.UpdateDesiredLRP(desireAppMessage.ProcessGuid, updateRequest)
if err != nil {
logger.Error("failed-to-update-lrp", err)
return err
}
logger.Debug("updated-desired-lrp")
return nil
}
开发者ID:cf-routing,项目名称:nsync,代码行数:49,代码来源:desire_app_handler.go
示例3: updateStaleDesiredLRPs
func (p *Processor) updateStaleDesiredLRPs(
logger lager.Logger,
cancel <-chan struct{},
stale <-chan []cc_messages.DesireAppRequestFromCC,
existingSchedulingInfoMap map[string]*models.DesiredLRPSchedulingInfo,
invalidCount *int32,
) <-chan error {
logger = logger.Session("update-stale-desired-lrps")
errc := make(chan error, 1)
go func() {
defer close(errc)
for {
var staleAppRequests []cc_messages.DesireAppRequestFromCC
select {
case <-cancel:
return
case selected, open := <-stale:
if !open {
return
}
staleAppRequests = selected
}
works := make([]func(), len(staleAppRequests))
for i, desireAppRequest := range staleAppRequests {
desireAppRequest := desireAppRequest
var builder recipebuilder.RecipeBuilder = p.builders["buildpack"]
if desireAppRequest.DockerImageUrl != "" {
builder = p.builders["docker"]
}
works[i] = func() {
processGuid := desireAppRequest.ProcessGuid
existingSchedulingInfo := existingSchedulingInfoMap[desireAppRequest.ProcessGuid]
updateReq := &models.DesiredLRPUpdate{}
instances := int32(desireAppRequest.NumInstances)
updateReq.Instances = &instances
updateReq.Annotation = &desireAppRequest.ETag
exposedPorts, err := builder.ExtractExposedPorts(&desireAppRequest)
if err != nil {
logger.Error("failed-updating-stale-lrp", err, lager.Data{
"process-guid": processGuid,
"execution-metadata": desireAppRequest.ExecutionMetadata,
})
errc <- err
return
}
routes, err := helpers.CCRouteInfoToRoutes(desireAppRequest.RoutingInfo, exposedPorts)
if err != nil {
logger.Error("failed-to-marshal-routes", err)
errc <- err
return
}
updateReq.Routes = &routes
for k, v := range existingSchedulingInfo.Routes {
if k != cfroutes.CF_ROUTER {
(*updateReq.Routes)[k] = v
}
}
logger.Debug("updating-stale-lrp", updateDesiredRequestDebugData(processGuid, updateReq))
err = p.bbsClient.UpdateDesiredLRP(processGuid, updateReq)
if err != nil {
logger.Error("failed-updating-stale-lrp", err, lager.Data{
"process-guid": processGuid,
})
if models.ConvertError(err).Type == models.Error_InvalidRequest {
atomic.AddInt32(invalidCount, int32(1))
} else {
errc <- err
}
return
}
logger.Debug("succeeded-updating-stale-lrp", updateDesiredRequestDebugData(processGuid, updateReq))
}
}
throttler, err := workpool.NewThrottler(p.updateLRPWorkPoolSize, works)
if err != nil {
errc <- err
return
}
logger.Info("processing-batch", lager.Data{"size": len(staleAppRequests)})
throttler.Work()
logger.Info("done-processing-batch", lager.Data{"size": len(staleAppRequests)})
}
//.........这里部分代码省略.........
开发者ID:emc-xchallenge,项目名称:nsync,代码行数:101,代码来源:processor.go
示例4: createMissingDesiredLRPs
func (p *Processor) createMissingDesiredLRPs(
logger lager.Logger,
cancel <-chan struct{},
missing <-chan []cc_messages.DesireAppRequestFromCC,
invalidCount *int32,
) <-chan error {
logger = logger.Session("create-missing-desired-lrps")
errc := make(chan error, 1)
go func() {
defer close(errc)
for {
var desireAppRequests []cc_messages.DesireAppRequestFromCC
select {
case <-cancel:
return
case selected, open := <-missing:
if !open {
return
}
desireAppRequests = selected
}
works := make([]func(), len(desireAppRequests))
for i, desireAppRequest := range desireAppRequests {
desireAppRequest := desireAppRequest
var builder recipebuilder.RecipeBuilder = p.builders["buildpack"]
if desireAppRequest.DockerImageUrl != "" {
builder = p.builders["docker"]
}
works[i] = func() {
logger.Debug("building-create-desired-lrp-request", desireAppRequestDebugData(&desireAppRequest))
desired, err := builder.Build(&desireAppRequest)
if err != nil {
logger.Error("failed-building-create-desired-lrp-request", err, lager.Data{"process-guid": desireAppRequest.ProcessGuid})
errc <- err
return
}
logger.Debug("succeeded-building-create-desired-lrp-request", desireAppRequestDebugData(&desireAppRequest))
logger.Debug("creating-desired-lrp", createDesiredReqDebugData(desired))
err = p.bbsClient.DesireLRP(desired)
if err != nil {
logger.Error("failed-creating-desired-lrp", err, lager.Data{"process-guid": desired.ProcessGuid})
if models.ConvertError(err).Type == models.Error_InvalidRequest {
atomic.AddInt32(invalidCount, int32(1))
} else {
errc <- err
}
return
}
logger.Debug("succeeded-creating-desired-lrp", createDesiredReqDebugData(desired))
}
}
throttler, err := workpool.NewThrottler(p.updateLRPWorkPoolSize, works)
if err != nil {
errc <- err
return
}
logger.Info("processing-batch", lager.Data{"size": len(desireAppRequests)})
throttler.Work()
logger.Info("done-processing-batch", lager.Data{"size": len(desireAppRequests)})
}
}()
return errc
}
开发者ID:emc-xchallenge,项目名称:nsync,代码行数:76,代码来源:processor.go
注:本文中的github.com/cloudfoundry-incubator/nsync/recipebuilder.RecipeBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论