remote_local.go 1.0 KB

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