Skip to content

Commit

Permalink
Merge pull request #238 from vmarmol/inotify
Browse files Browse the repository at this point in the history
Use inotify to watch for new containers.
  • Loading branch information
rjnagal committed Sep 18, 2014
2 parents 9eab388 + 100170b commit 7c59947
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 250 deletions.
15 changes: 15 additions & 0 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ const (

type ListType int

// SubcontainerEvent types.
const (
SUBCONTAINER_ADD = iota
SUBCONTAINER_DELETE
)

type SubcontainerEvent struct {
// The type of event that occurred.
EventType int

// The full container name of the container where the event occurred.
Name string
}

// Interface for container operation handlers.
type ContainerHandler interface {
ContainerReference() (info.ContainerReference, error)
Expand All @@ -32,4 +46,5 @@ type ContainerHandler interface {
ListContainers(listType ListType) ([]info.ContainerReference, error)
ListThreads(listType ListType) ([]int, error)
ListProcesses(listType ListType) ([]int, error)
WatchSubcontainers(events chan SubcontainerEvent) error
}
4 changes: 4 additions & 0 deletions container/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,7 @@ func (self *dockerContainerHandler) ListProcesses(listType container.ListType) (
}
return fs.GetPids(c)
}

func (self *dockerContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
return fmt.Errorf("watch is unimplemented in the Docker container driver")
}
93 changes: 0 additions & 93 deletions container/filter.go

This file was deleted.

127 changes: 0 additions & 127 deletions container/filter_test.go

This file was deleted.

5 changes: 5 additions & 0 deletions container/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func (self *MockContainerHandler) ListProcesses(listType ListType) ([]int, error
return args.Get(0).([]int), args.Error(1)
}

func (self *MockContainerHandler) WatchSubcontainers(events chan SubcontainerEvent) error {
args := self.Called(events)
return args.Error(0)
}

type FactoryForMockContainerHandler struct {
Name string
PrepareContainerHandlerFunc func(name string, handler *MockContainerHandler)
Expand Down
Loading

0 comments on commit 7c59947

Please sign in to comment.