当前位置: 首页>>代码示例>>Golang>>正文


Golang Operation.Complete方法代码示例

本文整理汇总了Golang中xenon/operation.Operation.Complete方法的典型用法代码示例。如果您正苦于以下问题:Golang Operation.Complete方法的具体用法?Golang Operation.Complete怎么用?Golang Operation.Complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xenon/operation.Operation的用法示例。


在下文中一共展示了Operation.Complete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: HandlePatch

func (s *pingService) HandlePatch(ctx context.Context, op *operation.Operation) {
	req := &pingRequest{}
	err := op.DecodeBody(req)
	if err != nil {
		op.Fail(err)
		return
	}

	op.SetStatusCode(http.StatusCreated)
	op.Complete()

	// Ping specified URL
	pingOp := operation.NewPatch(ctx, req.URI, nil)
	pingOp.SetBody(req)
	client.Send(pingOp)
}
开发者ID:vmware,项目名称:xenon,代码行数:16,代码来源:ping_service.go

示例2: HandleStart

func (s *ServiceContext) HandleStart(ctx context.Context, op *operation.Operation) {
	err := op.DecodeBody(s.h.GetState())
	if err != nil && err != operation.ErrBodyNotSet {
		op.Fail(err)
		return
	}

	// Run the service handler's start handler if available
	if h, ok := s.h.(StartHandler); ok {
		err = op.CreateChild(ctx).Go(ctx, h.HandleStart).Wait()
		if err != nil {
			op.Fail(err)
			return
		}
	}

	op.Complete()
}
开发者ID:vmware,项目名称:xenon,代码行数:18,代码来源:service_context.go

示例3: handlePost

// handlePost calls out to the factory service implementation's POST handler,
// if it exists, and waits for completion. If this runs and completes without
// error, the returned body is passed to the start operation for the service
// created by this factory.
func (f *FactoryServiceContext) handlePost(ctx context.Context, op *operation.Operation) {
	var err error
	var sd *common.ServiceDocument

	if h, ok := f.h.(PostHandler); ok {
		// Run the factory service's POST handler and wait for completion.
		err = op.CreateChild(ctx).Go(ctx, h.HandlePost).Wait()
		if err != nil {
			op.Fail(err)
			return
		}
	}

	doc := f.h.CreateDocument()
	err = op.DecodeBody(doc)
	if err != nil && err != io.EOF {
		op.Fail(err)
		return
	}

	sd = doc.GetServiceDocument()
	sd.SelfLink = path.Join(f.SelfLink(), uuid.New())
	op.SetBody(doc)

	buf, err := op.EncodeBodyAsBuffer()
	if err != nil {
		op.Fail(err)
		return
	}

	// Start child service at service document's selflink
	startOp := op.NewPost(ctx, uri.Extend(uri.Local(), sd.SelfLink), buf)
	f.Host().StartService(startOp, f.h.CreateService())
	err = startOp.Wait()
	if err != nil {
		op.Fail(err)
		return
	}

	op.Complete()
}
开发者ID:vmware,项目名称:xenon,代码行数:45,代码来源:factory_service_context.go

示例4: startService

// startService executes the necessary actions to move a service from
// the available stage, to the started stage, to the available stage.
func (h *ServiceHost) startService(op *operation.Operation, s Service) {
	ctx := context.Background()
	err := op.CreateChild(ctx).Go(ctx, s.HandleStart).Wait()
	if err != nil {
		op.Fail(err)
		return
	}

	if err := s.SetStage(StageStarted); err != nil {
		op.Fail(err)
		return
	}

	// Stuff may happen between the started and available stages.
	// This separation is kept here for parity with the Java XENON implementation.

	if err := s.SetStage(StageAvailable); err != nil {
		op.Fail(err)
		return
	}

	op.Complete()
}
开发者ID:vmware,项目名称:xenon,代码行数:25,代码来源:service_host.go

示例5: HandleStart

func (m *MinimalService) HandleStart(ctx context.Context, op *operation.Operation) {
	op.Complete()
}
开发者ID:vmware,项目名称:xenon,代码行数:3,代码来源:minimal_service.go

示例6: HandleStart

func (f *FactoryServiceContext) HandleStart(ctx context.Context, op *operation.Operation) {
	op.Complete()
}
开发者ID:vmware,项目名称:xenon,代码行数:3,代码来源:factory_service_context.go


注:本文中的xenon/operation.Operation.Complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。