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


Golang Vtworker_ExecuteVtworkerCommandServer.Context方法代碼示例

本文整理匯總了Golang中github.com/youtube/vitess/go/vt/proto/vtworkerservice.Vtworker_ExecuteVtworkerCommandServer.Context方法的典型用法代碼示例。如果您正苦於以下問題:Golang Vtworker_ExecuteVtworkerCommandServer.Context方法的具體用法?Golang Vtworker_ExecuteVtworkerCommandServer.Context怎麽用?Golang Vtworker_ExecuteVtworkerCommandServer.Context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/youtube/vitess/go/vt/proto/vtworkerservice.Vtworker_ExecuteVtworkerCommandServer的用法示例。


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

示例1: ExecuteVtworkerCommand

// ExecuteVtworkerCommand is part of the vtworkerdatapb.VtworkerServer interface
func (s *VtworkerServer) ExecuteVtworkerCommand(args *vtworkerdatapb.ExecuteVtworkerCommandRequest, stream vtworkerservicepb.Vtworker_ExecuteVtworkerCommandServer) (err error) {
	// Please note that this panic handler catches only panics occuring in the code below.
	// The actual execution of the vtworker command takes place in a new go routine
	// (started in Instance.setAndStartWorker()) which has its own panic handler.
	defer servenv.HandlePanic("vtworker", &err)

	// Stream everything back what the Wrangler is logging.
	logstream := logutil.NewCallbackLogger(func(e *logutilpb.Event) {
		stream.Send(&vtworkerdatapb.ExecuteVtworkerCommandResponse{
			Event: e,
		})
	})
	// Let the Wrangler also log everything to the console (and thereby
	// effectively to a logfile) to make sure that any information or errors
	// is preserved in the logs in case the RPC or vtworker crashes.
	logger := logutil.NewTeeLogger(logstream, logutil.NewConsoleLogger())

	wr := s.wi.CreateWrangler(logger)

	// Run the command as long as the RPC Context is valid.
	worker, done, err := s.wi.RunCommand(stream.Context(), args.Args, wr, false /*runFromCli*/)
	if err == nil && worker != nil && done != nil {
		err = s.wi.WaitForCommand(worker, done)
	}

	return vterrors.ToGRPCError(err)
}
開發者ID:dumbunny,項目名稱:vitess,代碼行數:28,代碼來源:server.go


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