本文整理汇总了Golang中github.com/youtube/vitess/go/vt/logutil.NewChannelLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewChannelLogger函数的具体用法?Golang NewChannelLogger怎么用?Golang NewChannelLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewChannelLogger函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Backup
// Backup wraps RPCAgent.Backup
func (tm *TabletManager) Backup(ctx context.Context, args *gorpcproto.BackupArgs, sendReply func(interface{}) error) error {
ctx = callinfo.RPCWrapCallInfo(ctx)
return tm.agent.RPCWrapLockAction(ctx, actionnode.TabletActionBackup, args, nil, true, func() error {
// create a logger, send the result back to the caller
logger := logutil.NewChannelLogger(10)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logger {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying
// to send.
sendReply(&e)
}
wg.Done()
}()
err := tm.agent.Backup(ctx, args.Concurrency, logger)
close(logger)
wg.Wait()
return err
})
}
开发者ID:hadmagic,项目名称:vitess,代码行数:26,代码来源:gorpc_server.go
示例2: ExecuteVtctlCommand
// ExecuteVtctlCommand is the server side method that will execute the query,
// and stream the results.
func (s *VtctlServer) ExecuteVtctlCommand(context context.Context, query *gorpcproto.ExecuteVtctlCommandArgs, sendReply func(interface{}) error) error {
// create a logger, send the result back to the caller
logstream := logutil.NewChannelLogger(10)
logger := logutil.NewTeeLogger(logstream, logutil.NewConsoleLogger())
// send logs to the caller
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logstream {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying.
sendReply(&e)
}
wg.Done()
}()
// create the wrangler
wr := wrangler.New(logger, s.ts, query.ActionTimeout, query.LockTimeout)
// execute the command
err := vtctl.RunCommand(wr, query.Args)
// close the log channel, and wait for them all to be sent
close(logstream)
wg.Wait()
return err
}
开发者ID:nangong92t,项目名称:go_src,代码行数:33,代码来源:server.go
示例3: MultiSnapshot
func (tm *TabletManager) MultiSnapshot(context *rpcproto.Context, args *actionnode.MultiSnapshotArgs, sendReply func(interface{}) error) error {
return tm.agent.RpcWrapLockAction(context, actionnode.TABLET_ACTION_MULTI_SNAPSHOT, args, nil, true, func() error {
// create a logger, send the result back to the caller
logger := logutil.NewChannelLogger(10)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logger {
ssr := &gorpcproto.MultiSnapshotStreamingReply{
Log: &e,
}
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying to send.
sendReply(ssr)
}
wg.Done()
}()
sr, err := tm.agent.MultiSnapshot(args, logger)
close(logger)
wg.Wait()
if err != nil {
return err
}
ssr := &gorpcproto.MultiSnapshotStreamingReply{
Result: sr,
}
sendReply(ssr)
return nil
})
}
开发者ID:miffa,项目名称:vitess,代码行数:33,代码来源:gorpc_server.go
示例4: ExecuteVtctlCommand
// ExecuteVtctlCommand is the server side method that will execute the query,
// and stream the results.
func (s *VtctlServer) ExecuteVtctlCommand(context context.Context, query *gorpcproto.ExecuteVtctlCommandArgs, sendReply func(interface{}) error) error {
// create a logger, send the result back to the caller
logger := logutil.NewChannelLogger(10)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logger {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep logging the lines.
if err := sendReply(&e); err != nil {
log.Warningf("Cannot send vtctl log line: %v", e)
}
}
wg.Done()
}()
// create the wrangler
wr := wrangler.New(logger, s.ts, query.ActionTimeout, query.LockTimeout)
// execute the command, wait for it to finish if required
actionPath, err := vtctl.RunCommand(wr, query.Args)
if err == nil && actionPath != "" {
err = wr.WaitForCompletion(actionPath)
}
// close the log channel, and wait for them all to be sent
close(logger)
wg.Wait()
return err
}
开发者ID:chinna1986,项目名称:vitess,代码行数:35,代码来源:server.go
示例5: ExecuteVtctlCommand
// ExecuteVtctlCommand is part of the pb.VtctlServer interface
func (s *VtctlServer) ExecuteVtctlCommand(args *pb.ExecuteVtctlCommandRequest, stream pbs.Vtctl_ExecuteVtctlCommandServer) (err error) {
defer servenv.HandlePanic("vtctl", &err)
// create a logger, send the result back to the caller
logstream := logutil.NewChannelLogger(10)
logger := logutil.NewTeeLogger(logstream, logutil.NewConsoleLogger())
// send logs to the caller
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logstream {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying.
stream.Send(&pb.ExecuteVtctlCommandResponse{
Event: logutil.LoggerEventToProto(&e),
})
}
wg.Done()
}()
// create the wrangler
wr := wrangler.New(logger, s.ts, tmclient.NewTabletManagerClient(), time.Duration(args.LockTimeout))
// execute the command
err = vtctl.RunCommand(stream.Context(), wr, args.Args)
// close the log channel, and wait for them all to be sent
close(logstream)
wg.Wait()
return err
}
开发者ID:richarwu,项目名称:vitess,代码行数:36,代码来源:server.go
示例6: Backup
func (s *server) Backup(request *tabletmanagerdatapb.BackupRequest, stream tabletmanagerservicepb.TabletManager_BackupServer) error {
ctx := callinfo.GRPCCallInfo(stream.Context())
return s.agent.RPCWrapLockAction(ctx, actionnode.TabletActionBackup, request, nil, true, func() error {
// create a logger, send the result back to the caller
logger := logutil.NewChannelLogger(10)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logger {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying
// to send.
stream.Send(&tabletmanagerdatapb.BackupResponse{
Event: logutil.LoggerEventToProto(&e),
})
}
wg.Done()
}()
err := s.agent.Backup(ctx, int(request.Concurrency), logger)
close(logger)
wg.Wait()
return err
})
}
开发者ID:tjyang,项目名称:vitess,代码行数:28,代码来源:server.go
示例7: ExecuteVtworkerCommand
// ExecuteVtworkerCommand is part of the pb.VtworkerServer interface
func (s *VtworkerServer) ExecuteVtworkerCommand(args *pb.ExecuteVtworkerCommandRequest, stream pbs.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)
// create a logger, send the result back to the caller
logstream := logutil.NewChannelLogger(10)
logger := logutil.NewTeeLogger(logstream, logutil.NewMemoryLogger())
// send logs to the caller
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logstream {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying.
stream.Send(&pb.ExecuteVtworkerCommandResponse{
Event: &pbl.Event{
Time: &pbl.Time{
Seconds: e.Time.Unix(),
Nanoseconds: int32(e.Time.Nanosecond()),
},
Level: pbl.Level(e.Level),
File: e.File,
Line: int64(e.Line),
Value: e.Value,
},
})
}
wg.Done()
}()
// create the wrangler
wr := s.wi.CreateWrangler(logger)
// execute the command
if len(args.Args) >= 1 && args.Args[0] == "Reset" {
err = s.wi.Reset()
} else {
// Make sure we use the global "err" variable and do not redeclare it in this scope.
var worker worker.Worker
var done chan struct{}
worker, done, err = s.wi.RunCommand(args.Args, wr, false /*runFromCli*/)
if err == nil {
err = s.wi.WaitForCommand(worker, done)
}
}
// close the log channel, and wait for them all to be sent
close(logstream)
wg.Wait()
return err
}
开发者ID:Drooids,项目名称:vitess,代码行数:58,代码来源:server.go
示例8: 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.NewChannelLogger(10)
// 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())
// send logs to the caller
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logstream {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying.
stream.Send(&vtworkerdatapb.ExecuteVtworkerCommandResponse{
Event: e,
})
}
wg.Done()
}()
// create the wrangler
wr := s.wi.CreateWrangler(logger)
// execute the command
worker, done, err := s.wi.RunCommand(args.Args, wr, false /*runFromCli*/)
if err == nil && worker != nil && done != nil {
err = s.wi.WaitForCommand(worker, done)
}
// close the log channel, and wait for them all to be sent
close(logstream)
wg.Wait()
return err
}
开发者ID:littleyang,项目名称:vitess,代码行数:45,代码来源:server.go
示例9: MultiRestore
func (tm *TabletManager) MultiRestore(context *rpcproto.Context, args *actionnode.MultiRestoreArgs, sendReply func(interface{}) error) error {
return tm.agent.RpcWrapLockAction(context, actionnode.TABLET_ACTION_MULTI_RESTORE, args, nil, true, func() error {
// create a logger, send the result back to the caller
logger := logutil.NewChannelLogger(10)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logger {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying to send.
sendReply(&e)
}
wg.Done()
}()
err := tm.agent.MultiRestore(args, logger)
close(logger)
wg.Wait()
return err
})
}
开发者ID:miffa,项目名称:vitess,代码行数:23,代码来源:gorpc_server.go
示例10: ExecuteVtctlCommand
// ExecuteVtctlCommand is the server side method that will execute the query,
// and stream the results.
func (s *VtctlServer) ExecuteVtctlCommand(ctx context.Context, query *gorpcproto.ExecuteVtctlCommandArgs, sendReply func(interface{}) error) (err error) {
defer vtctl.HandlePanic(&err)
// create a logger, send the result back to the caller
logstream := logutil.NewChannelLogger(10)
logger := logutil.NewTeeLogger(logstream, logutil.NewConsoleLogger())
// send logs to the caller
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for e := range logstream {
// Note we don't interrupt the loop here, as
// we still need to flush and finish the
// command, even if the channel to the client
// has been broken. We'll just keep trying.
sendReply(&e)
}
wg.Done()
}()
// create the wrangler
wr := wrangler.New(logger, s.ts, tmclient.NewTabletManagerClient(), query.LockTimeout)
// FIXME(alainjobart) use a single context, copy the source info from it
ctx, cancel := context.WithTimeout(context.TODO(), query.ActionTimeout)
// execute the command
err = vtctl.RunCommand(ctx, wr, query.Args)
cancel()
// close the log channel, and wait for them all to be sent
close(logstream)
wg.Wait()
return err
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:38,代码来源:server.go
注:本文中的github.com/youtube/vitess/go/vt/logutil.NewChannelLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论