func NewWorkSpace(ctx context.Context, nsm *nsmServer, name string, restore bool) (*Workspace, error) {
	span := spanhelper.FromContext(ctx, fmt.Sprintf("Workspace:%v", name))
	defer span.Finish()
	span.Logger().Infof("Creating new workspace: %s", name)
	w := &Workspace{
		locationProvider: nsm.locationProvider,
		name:             name,
		state:            NEW,
		localRegistry:    nsm.localRegistry,
		ctx:              span.Context(),
	}
	defer w.cleanup()  
	span.LogValue("restore", restore)
	if !restore {
		if err := w.clearContents(span.Context()); err != nil {
			return nil, err
		}
	}
	span.Logger().Infof("Creating new directory: %s", w.NsmDirectory())
	if err := os.MkdirAll(w.NsmDirectory(), os.ModePerm); err != nil {
		span.Logger().Errorf("can't create folder: %s, error: %v", w.NsmDirectory(), err)
		return nil, err
	}
	socket := w.NsmServerSocket()
	span.Logger().Infof("Creating new listener on: %s", socket)
	listener, err := NewCustomListener(socket)
	if err != nil {
		span.LogError(err)
		return nil, err
	}
	w.listener = listener
	registerWorkspaceServices(span, w, nsm)
	w.state = RUNNING
	go func() {
		defer w.Close()
		err = w.grpcServer.Serve(w.listener)
		if err != nil {
			span.Logger().Errorf("Failed to server workspace %+v: %s", w, err)
			return
		}
	}()
	conn, err := tools.DialUnix(socket)
	if err != nil {
		span.Logger().Errorf("failure to communicate with the socket %s with error: %+v", socket, err)
		return nil, err
	}
	_ = conn.Close()
	span.Logger().Infof("grpcserver for workspace %+v is operational", w)
	span.Logger().Infof("Created new workspace: %+v", w)
	return w, nil
}
NewWorkSpace - constructs a new workspace.
package nsmd
import (
	"context"
	"fmt"
	"net"
	"os"
	"sync"
	"time"
	connectionMonitor "github.com/networkservicemesh/networkservicemesh/sdk/monitor/connectionmonitor"
	"google.golang.org/grpc"
	"github.com/networkservicemesh/networkservicemesh/pkg/tools/spanhelper"
	"github.com/networkservicemesh/networkservicemesh/controlplane/api/connection"
	"github.com/networkservicemesh/networkservicemesh/controlplane/api/networkservice"
	unified "github.com/networkservicemesh/networkservicemesh/controlplane/api/networkservice"
	"github.com/networkservicemesh/networkservicemesh/controlplane/api/registry"
	"github.com/networkservicemesh/networkservicemesh/controlplane/pkg/nseregistry"
	"github.com/networkservicemesh/networkservicemesh/controlplane/pkg/serviceregistry"
	"github.com/networkservicemesh/networkservicemesh/pkg/tools"
)
type WorkspaceState int
const (
	NEW WorkspaceState = iota + 1
	RUNNING
	CLOSED
)
type Workspace struct {
	name                    string
	listener                net.Listener
	registryServer          NSERegistryServer
	networkServiceServer    networkservice.NetworkServiceServer
	monitorConnectionServer connectionMonitor.MonitorServer
	grpcServer              *grpc.Server
	sync.Mutex
	state            WorkspaceState
	locationProvider serviceregistry.WorkspaceLocationProvider
	localRegistry    *nseregistry.NSERegistry
	ctx              context.Context
	discoveryServer  registry.NetworkServiceDiscoveryServer
}