Skip to content

Commit 7c59947

Browse files
committed
Merge pull request #238 from vmarmol/inotify
Use inotify to watch for new containers.
2 parents 9eab388 + 100170b commit 7c59947

File tree

7 files changed

+247
-250
lines changed

7 files changed

+247
-250
lines changed

container/container.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ const (
2424

2525
type ListType int
2626

27+
// SubcontainerEvent types.
28+
const (
29+
SUBCONTAINER_ADD = iota
30+
SUBCONTAINER_DELETE
31+
)
32+
33+
type SubcontainerEvent struct {
34+
// The type of event that occurred.
35+
EventType int
36+
37+
// The full container name of the container where the event occurred.
38+
Name string
39+
}
40+
2741
// Interface for container operation handlers.
2842
type ContainerHandler interface {
2943
ContainerReference() (info.ContainerReference, error)
@@ -32,4 +46,5 @@ type ContainerHandler interface {
3246
ListContainers(listType ListType) ([]info.ContainerReference, error)
3347
ListThreads(listType ListType) ([]int, error)
3448
ListProcesses(listType ListType) ([]int, error)
49+
WatchSubcontainers(events chan SubcontainerEvent) error
3550
}

container/docker/handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,7 @@ func (self *dockerContainerHandler) ListProcesses(listType container.ListType) (
262262
}
263263
return fs.GetPids(c)
264264
}
265+
266+
func (self *dockerContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
267+
return fmt.Errorf("watch is unimplemented in the Docker container driver")
268+
}

container/filter.go

Lines changed: 0 additions & 93 deletions
This file was deleted.

container/filter_test.go

Lines changed: 0 additions & 127 deletions
This file was deleted.

container/mock.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func (self *MockContainerHandler) ListProcesses(listType ListType) ([]int, error
6969
return args.Get(0).([]int), args.Error(1)
7070
}
7171

72+
func (self *MockContainerHandler) WatchSubcontainers(events chan SubcontainerEvent) error {
73+
args := self.Called(events)
74+
return args.Error(0)
75+
}
76+
7277
type FactoryForMockContainerHandler struct {
7378
Name string
7479
PrepareContainerHandlerFunc func(name string, handler *MockContainerHandler)

0 commit comments

Comments
 (0)