func NewService(factory ServiceFactory) (srv *Service, err error) {
	defer func() {
		if r := recover(); r != nil {
			if ex, ok := r.(error); ok {
				err = ex
			} else {
				err = services.ErrFactoryPanic
			}
		}
	}()
	transport, err := factory()
	if err != nil {
		return nil, err
	}
	srv = &Service{
		transport:  transport,
		executor:   newExecutor(transport),
		dispatcher: newDispatcher(transport),
		closedCh:   make(chan struct{}),
	}
	go func() {
		<-srv.executor.terminated()
		<-srv.dispatcher.terminated()
		close(srv.closedCh)
	}()
	go func() {
		select {
		case err := <-srv.transport.ErrorChan():
			srv.err = err
			srv.Close()
		case <-srv.Closed():
			return
		}
	}()
	return srv, nil
}
NewService uses factory to construct a Transport instance that is then used
for creating the Service instance itself.

factory can panic without any worries, it just makes NewService return an
error, so some if-errs can be saved.
package rpc
import (
	"errors"
	"github.com/meeko/go-meeko/meeko/services"
	log "github.com/cihub/seelog"
)
const (
	CmdRegister int = iota
	CmdUnregister
	CmdCall
	CmdInterrupt
	CmdSignalProgress
	CmdSendStreamFrame
	CmdReply
	CmdClose
)
type Service struct {
	transport Transport
	*executor
	*dispatcher
	closedCh chan struct{}
}
type ServiceFactory func() (Transport, error)