func (s *Service) Start(config *Config) bool {
	if config == nil {
		panic("missing config")
	}
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if s.started {
		return false
	}
	s.started = true
	s.config = config
	s.backoff = &backoff.Backoff{
		Min:    s.MinReconnectDelay,
		Max:    s.MaxReconnectDelay,
		Factor: 2,
	}
	s.futureStore.Protect(true)
	s.tomb = new(tomb.Tomb)
	s.tomb.Go(s.supervisor)
	return true
}
Start will start the service with the specified configuration. From now on
the service will automatically reconnect on any error until Stop is called.
It returns false if the service was already started.
package client
import (
	"fmt"
	"sort"
	"sync"
	"time"
	"github.com/256dpi/gomqtt/client/future"
	"github.com/256dpi/gomqtt/packet"
	"github.com/256dpi/gomqtt/session"
	"github.com/256dpi/gomqtt/topic"
	"github.com/jpillora/backoff"
	"gopkg.in/tomb.v2"
)
type command struct {
	publish       bool
	subscribe     bool
	unsubscribe   bool
	future        *future.Future
	message       *packet.Message
	subscriptions []packet.Subscription
	topics        []string
}
type Service struct {
	Session Session
	OnlineCallback func(resumed bool)
	MessageCallback func(*packet.Message) error
	ErrorCallback func(error)
	OfflineCallback func()
	Logger func(msg string)
	MinReconnectDelay time.Duration
	MaxReconnectDelay time.Duration
	ConnectTimeout time.Duration
	DisconnectTimeout time.Duration
	ResubscribeTimeout time.Duration
	ResubscribeAllSubscriptions bool
	QueueTimeout time.Duration
	config        *Config
	started       bool
	backoff       *backoff.Backoff
	subscriptions *topic.Tree
	commandQueue  chan *command
	futureStore   *future.Store
	mutex         sync.Mutex
	tomb          *tomb.Tomb
}
func NewService(queueSize ...int) *Service {
	var qs = 100
	if len(queueSize) > 0 {
		qs = queueSize[0]
	}
	return &Service{
		Session:                     session.NewMemorySession(),
		MinReconnectDelay:           50 * time.Millisecond,
		MaxReconnectDelay:           10 * time.Second,
		ConnectTimeout:              5 * time.Second,
		DisconnectTimeout:           10 * time.Second,
		ResubscribeTimeout:          5 * time.Second,
		QueueTimeout:                10 * time.Second,
		ResubscribeAllSubscriptions: true,
		subscriptions:               topic.NewStandardTree(),
		commandQueue:                make(chan *command, qs),
		futureStore:                 future.NewStore(),
	}
}