func NewManager(
	chunkSize int64,
	loadAhead,
	checkThreads int,
	loadThreads int,
	client *drive.Client,
	maxChunks int) (*Manager, error) {
	if chunkSize < 4096 {
		return nil, fmt.Errorf("Chunk size must not be < 4096")
	}
	if chunkSize%1024 != 0 {
		return nil, fmt.Errorf("Chunk size must be divideable by 1024")
	}
	if maxChunks < 2 || maxChunks < loadAhead {
		return nil, fmt.Errorf("max-chunks must be greater than 2 and bigger than the load ahead value")
	}
	storage := NewStorage(chunkSize, maxChunks)
	downloader, err := NewDownloader(loadThreads, client, storage, chunkSize)
	if nil != err {
		return nil, err
	}
	manager := Manager{
		ChunkSize:  chunkSize,
		LoadAhead:  loadAhead,
		downloader: downloader,
		storage:    storage,
		queue:      make(chan *QueueEntry, 100),
	}
	if err := manager.storage.Clear(); nil != err {
		return nil, err
	}
	for i := 0; i < checkThreads; i++ {
		go manager.thread()
	}
	return &manager, nil
}
NewManager creates a new chunk manager
package chunk
import (
	"fmt"
	"github.com/plexdrive/plexdrive/drive"
)
type Manager struct {
	ChunkSize  int64
	LoadAhead  int
	downloader *Downloader
	storage    *Storage
	queue      chan *QueueEntry
}
type QueueEntry struct {
	request  *Request
	response chan Response
}
type Request struct {
	id             string
	object         *drive.APIObject
	offsetStart    int64
	offsetEnd      int64
	chunkOffset    int64
	chunkOffsetEnd int64
	sequence       int
	preload        bool
}
type Response struct {
	Sequence int
	Error    error
	Bytes    []byte
}