本文整理匯總了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)
}