// Backup is part of the tmclient.TabletManagerClient interface func (client *Client) Backup(ctx context.Context, tablet *topo.TabletInfo, concurrency int) (<-chan *logutil.LoggerEvent, tmclient.ErrFunc, error) { cc, c, err := client.dial(ctx, tablet) if err != nil { return nil, nil, err } logstream := make(chan *logutil.LoggerEvent, 10) stream, err := c.Backup(ctx, &pb.BackupRequest{ Concurrency: int64(concurrency), }) if err != nil { cc.Close() return nil, nil, err } var finalErr error go func() { for { br, err := stream.Recv() if err != nil { if err != io.EOF { finalErr = err } close(logstream) return } logstream <- logutil.ProtoToLoggerEvent(br.Event) } }() return logstream, func() error { cc.Close() return finalErr }, nil }
// ExecuteVtctlCommand is part of the VtctlClient interface func (client *gRPCVtctlClient) ExecuteVtctlCommand(ctx context.Context, args []string, actionTimeout, lockTimeout time.Duration) (<-chan *logutil.LoggerEvent, vtctlclient.ErrFunc, error) { query := &pb.ExecuteVtctlCommandRequest{ Args: args, ActionTimeout: int64(actionTimeout.Nanoseconds()), LockTimeout: int64(lockTimeout.Nanoseconds()), } stream, err := client.c.ExecuteVtctlCommand(ctx, query) if err != nil { return nil, nil, err } results := make(chan *logutil.LoggerEvent, 1) var finalError error go func() { for { le, err := stream.Recv() if err != nil { if err != io.EOF { finalError = err } close(results) return } results <- logutil.ProtoToLoggerEvent(le.Event) } }() return results, func() error { return finalError }, nil }