func (c *ParserContext) Invalid() bool {
	return c.DbCh == nil && c.StringObjectCh == nil && c.ListMetadataCh == nil && c.ListDataCh == nil && c.SetMetadataCh == nil && c.SetDataCh == nil && c.HashMetadataCh == nil && c.HashDataCh == nil && c.SortedSetMetadataCh == nil && c.SortedSetEntriesCh == nil
}
Invalid returns true if the context is invalid (all channels are nil), false otherwise.
This is needed to actually terminate parsing if you use a for-select loop
package rdbtools
import (
	"encoding/binary"
	"errors"
	"io"
	"math"
	"strconv"
)
type Parser interface {
	Parse(r io.Reader) (err error)
}
type parser struct {
	ctx     ParserContext
	r       io.Reader
	scratch [4]byte
}
const (
	RedisRdbVersion = 6
)
var (
	errNoMoreDatabases               = errors.New("errNoMoreDatabases")
	errNoMoreKeyValuePair            = errors.New("errNoMoreKeyValuePair")
	ErrInvalidMagicString            = errors.New("invalid magic string")
	ErrInvalidRDBVersionNumber       = errors.New("invalid RDB version number")
	ErrInvalidChecksum               = errors.New("invalid checksum")
	ErrUnexpectedEncodedLength       = errors.New("unexpected encoded length")
	ErrUnknownValueType              = errors.New("unknown value type")
	ErrUnknownLengthEncoding         = errors.New("unknown length encoding")
	ErrUnexpectedPrevLengthEntryByte = errors.New("unexpected prev length entry byte")
)
type ParserContext struct {
	DbCh                chan int
	StringObjectCh      chan StringObject
	ListMetadataCh      chan ListMetadata
	ListDataCh          chan interface{}
	SetMetadataCh       chan SetMetadata
	SetDataCh           chan interface{}
	HashMetadataCh      chan HashMetadata
	HashDataCh          chan HashEntry
	SortedSetMetadataCh chan SortedSetMetadata
	SortedSetEntriesCh  chan SortedSetEntry
	endOfFileCh         chan struct{}
}
func (c *ParserContext) closeChannels() {
	if c.DbCh != nil {
		close(c.DbCh)
	}
	if c.StringObjectCh != nil {
		close(c.StringObjectCh)
	}
	if c.ListMetadataCh != nil {
		close(c.ListMetadataCh)
	}
	if c.ListDataCh != nil {
		close(c.ListDataCh)
	}
	if c.SetMetadataCh != nil {
		close(c.SetMetadataCh)
	}
	if c.SetDataCh != nil {
		close(c.SetDataCh)
	}
	if c.HashMetadataCh != nil {
		close(c.HashMetadataCh)
	}
	if c.HashDataCh != nil {
		close(c.HashDataCh)
	}
	if c.SortedSetMetadataCh != nil {
		close(c.SortedSetMetadataCh)
	}
	if c.SortedSetEntriesCh != nil {
		close(c.SortedSetEntriesCh)
	}
	close(c.endOfFileCh)
}