func NewQueue(name string, state *tasks.Queue, onTaskDone func(task *Task)) (*Queue, *tasks.Queue) {
	setInitialQueueState(state)
	queue := &Queue{
		name:                   name,
		state:                  state,
		fire:                   make(chan *Task),
		work:                   make(chan *Task),
		ts:                     make(map[string]*Task),
		onTaskDone:             onTaskDone,
		tokenBucket:            make(chan bool, state.GetRateLimits().GetMaxBurstSize()),
		maxDispatchesPerSecond: state.GetRateLimits().GetMaxDispatchesPerSecond(),
		cancelTokenGenerator:   make(chan bool, 1),
		cancelDispatcher:       make(chan bool, 1),
		cancelWorkers:          make(chan bool, 1),
	}
	for i := 0; i < int(state.GetRateLimits().GetMaxBurstSize()); i++ {
		queue.tokenBucket <- true
	}
	return queue, state
}
NewQueue creates a new task queue
package main
import (
	"log"
	"sync"
	"time"
	"github.com/golang/protobuf/proto"
	pduration "github.com/golang/protobuf/ptypes/duration"
	tasks "google.golang.org/genproto/googleapis/cloud/tasks/v2"
)
type Queue struct {
	name string
	state *tasks.Queue
	fire chan *Task
	work chan *Task
	ts map[string]*Task
	tsMux sync.Mutex
	tokenBucket chan bool
	maxDispatchesPerSecond float64
	cancelTokenGenerator chan bool
	cancelDispatcher chan bool
	cancelWorkers chan bool
	cancelled bool
	paused bool
	onTaskDone func(task *Task)
}