github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/libcontainerd/remote_local.go (about)

     1  // +build windows
     2  
     3  package libcontainerd
     4  
     5  import (
     6  	"sync"
     7  
     8  	"github.com/sirupsen/logrus"
     9  )
    10  
    11  type remote struct {
    12  	sync.RWMutex
    13  
    14  	logger  *logrus.Entry
    15  	clients []*client
    16  
    17  	// Options
    18  	rootDir  string
    19  	stateDir string
    20  }
    21  
    22  // New creates a fresh instance of libcontainerd remote.
    23  func New(rootDir, stateDir string, options ...RemoteOption) (Remote, error) {
    24  	return &remote{
    25  		logger:   logrus.WithField("module", "libcontainerd"),
    26  		rootDir:  rootDir,
    27  		stateDir: stateDir,
    28  	}, nil
    29  }
    30  
    31  type client struct {
    32  	sync.Mutex
    33  
    34  	rootDir    string
    35  	stateDir   string
    36  	backend    Backend
    37  	logger     *logrus.Entry
    38  	eventQ     queue
    39  	containers map[string]*container
    40  }
    41  
    42  func (r *remote) NewClient(ns string, b Backend) (Client, error) {
    43  	c := &client{
    44  		rootDir:    r.rootDir,
    45  		stateDir:   r.stateDir,
    46  		backend:    b,
    47  		logger:     r.logger.WithField("namespace", ns),
    48  		containers: make(map[string]*container),
    49  	}
    50  	r.Lock()
    51  	r.clients = append(r.clients, c)
    52  	r.Unlock()
    53  
    54  	return c, nil
    55  }
    56  
    57  func (r *remote) Cleanup() {
    58  	// Nothing to do
    59  }