// QueryStatus query worker's sub tasks' status. If relay enabled, also return source status.
QueryStatus query worker's sub tasks' status. If relay enabled, also return source status.
// QueryStatus query worker ' s sub tasks ' status . If relay enabled also return source status .
func (w *SourceWorker) QueryStatus(ctx context.Context, name string) ([]*pb.SubTaskStatus, *pb.RelayStatus, error) {
	w.RLock()
	defer w.RUnlock()
	if w.closed.Load() {
		w.l.Warn("querying status from a closed worker")
		return nil, nil, nil
	}
	var (
		sourceStatus *binlog.SourceStatus
		relayStatus  *pb.RelayStatus
	)
	if err := w.updateSourceStatus(ctx); err != nil {
		if terror.ErrNoMasterStatus.Equal(err) {
			w.l.Warn("This source's bin_log is OFF, so it only supports full_mode.", zap.String("sourceID", w.cfg.SourceID), zap.Error(err))
			return nil, nil, nil
		}
		w.l.Error("failed to update source status", zap.Error(err))
	} else {
		sourceStatus = w.sourceStatus.Load().(*binlog.SourceStatus)
	}
	subtaskStatus := w.Status(name, sourceStatus)
	if w.relayEnabled.Load() {
		relayStatus = w.relayHolder.Status(sourceStatus)
	}
	return subtaskStatus, relayStatus, nil
}
func ( w * SourceWorker ) QueryStatus ( ctx context . Context , name string ) ( [ ] * pb . SubTaskStatus , * pb . RelayStatus , error ) { w . RLock ( ) defer w . RUnlock ( ) if w . closed . Load ( ) { w . l . Warn ( " " ) return nil , nil , nil } var ( sourceStatus * binlog . SourceStatus relayStatus * pb . RelayStatus ) if err := w . updateSourceStatus ( ctx ) ; err != nil { if terror . ErrNoMasterStatus . Equal ( err ) { w . l . Warn ( " " , zap . String ( " " , w . cfg . SourceID ) , zap . Error ( err ) ) return nil , nil , nil } w . l . Error ( " " , zap . Error ( err ) ) } else { sourceStatus = w . sourceStatus . Load ( ) . ( * binlog . SourceStatus ) } subtaskStatus := w . Status ( name , sourceStatus ) if w . relayEnabled . Load ( ) { relayStatus = w . relayHolder . Status ( sourceStatus ) } return subtaskStatus , relayStatus , nil }
QueryStatus query worker's sub tasks' status.
QueryStatus query worker ' s sub tasks ' status .