func (c *conn) Extend(ctx context.Context, id string) error {
	return c.client.Extend(ctx, c.opts.project, c.opts.topic, id, 600)
}
Extend extends the deadline for a task.
package gcp
import (
	"context"
	"errors"
	"io/ioutil"
	"log"
	"sync"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/google"
	"github.com/cncd/queue"
	"github.com/cncd/queue/gcp/internal"
)
type subscription struct {
	done  chan bool
	error error
}
type conn struct {
	sync.Mutex
	opts   *Options
	client *internal.Client
	subs   map[string]*subscription
}
func New(opts ...Option) (queue.Queue, error) {
	conn := new(conn)
	conn.subs = map[string]*subscription{}
	conn.opts = new(Options)
	conn.opts.topic = "queue"
	conn.opts.subscription = "default"
	for _, opt := range opts {
		opt(conn.opts)
	}
	jsonToken, err := ioutil.ReadFile(conn.opts.tokenpath)
	if err != nil {
		return nil, err
	}
	jwt, err := google.JWTConfigFromJSON(jsonToken, "https://www.googleapis.com/auth/pubsub")
	if err != nil {
		return nil, err
	}
	src := jwt.TokenSource(oauth2.NoContext)
	cli := oauth2.NewClient(oauth2.NoContext, src)
	conn.client = internal.NewClient(cli)
	go conn.pollWait()
	return conn, nil
}
func (c *conn) Push(ctx context.Context, task *queue.Task) error {
	message := internal.Message{
		MessageID:  task.ID,
		Attributes: task.Labels,
		Data:       task.Data,
	}
	_, err := c.client.Publish(ctx, c.opts.project, c.opts.topic, message)
	if err != nil {
		return err
	}
	return nil
}
func (c *conn) Poll(ctx context.Context, f queue.Filter) (*queue.Task, error) {
	message, err := c.poll(ctx)
	if err != nil {
		return nil, err
	}
	task := new(queue.Task)
	task.ID = message.MessageID
	task.Data = message.Data
	task.Labels = message.Attributes
	return task, nil
}