func NewStorageUnit(
	sucs []Storage,
	conntype, addr string,
	extra ...interface{}) (*StorageUnit, error) {

	su := StorageUnit{
		ConnType: conntype,
		Addr:     addr,
		conns:    make([]Storage, 0, len(sucs)),
		cmdCh:    make(chan *CommandBundle),
		closeCh:  make(chan chan error),
	}

	for _, suc := range sucs {
		if err := suc.Connect(su.cmdCh, conntype, addr, extra...); err == nil {
			su.conns = append(su.conns, suc)
		} else {
			su.internalClose()
			return nil, err
		}
	}

	go su.spin()
	return &su, nil
}
// NewStorageUnit takes in a slice of zero'd Storages, a connection
// type/address, and any extra info which will be passed back to the Connect
// function of each Storage. If any of the calls to Connect result in an
// error all the previous Storages will be Close'd and that error will
// be returned.
NewStorageUnit takes in a slice of zero'd Storages, a connection
type/address, and any extra info which will be passed back to the Connect
function of each Storage. If any of the calls to Connect result in an
error all the previous Storages will be Close'd and that error will
be returned.
// NewStorageUnit takes in a slice of zero ' d Storages a connection // type / address and any extra info which will be passed back to the Connect // function of each Storage . If any of the calls to Connect result in an // error all the previous Storages will be Close ' d and that error will // be returned .
func NewStorageUnit(
	sucs []Storage,
	conntype, addr string,
	extra ...interface{}) (*StorageUnit, error) {
	su := StorageUnit{
		ConnType: conntype,
		Addr:     addr,
		conns:    make([]Storage, 0, len(sucs)),
		cmdCh:    make(chan *CommandBundle),
		closeCh:  make(chan chan error),
	}
	for _, suc := range sucs {
		if err := suc.Connect(su.cmdCh, conntype, addr, extra...); err == nil {
			su.conns = append(su.conns, suc)
		} else {
			su.internalClose()
			return nil, err
		}
	}
	go su.spin()
	return &su, nil
}
func NewStorageUnit ( sucs [ ] Storage , conntype , addr string , extra ... interface { } ) ( * StorageUnit , error ) { su := StorageUnit { ConnType : conntype , Addr : addr , conns : make ( [ ] Storage , 0 , len ( sucs ) ) , cmdCh : make ( chan * CommandBundle ) , closeCh : make ( chan chan error ) , } for _ , suc := range sucs { if err := suc . Connect ( su . cmdCh , conntype , addr , extra ... ) ; err == nil { su . conns = append ( su . conns , suc ) } else { su . internalClose ( ) return nil , err } } go su . spin ( ) return & su , nil }
NewStorageUnit takes in a slice of zero'd Storages, a connection
type/address, and any extra info which will be passed back to the Connect
function of each Storage.
NewStorageUnit takes in a slice of zero ' d Storages a connection type / address and any extra info which will be passed back to the Connect function of each Storage .