@@ -56,8 +56,9 @@ type MobyWatcher struct {
5656 packer engineclient.RucksackPacker // optional Rucksack packer for app-specific container information.
5757}
5858
59- // Make sure that the EngineClient interface is fully implemented.
59+ // Make sure that the EngineClient and Preflighter interfaces are fully implemented.
6060var _ (engineclient.EngineClient ) = (* MobyWatcher )(nil )
61+ var _ (engineclient.Preflighter ) = (* MobyWatcher )(nil )
6162
6263// NewMobyWatcher returns a new MobyWatcher using the specified Docker engine
6364// client; typically, you would want to use this lower-level constructor only in
@@ -129,12 +130,17 @@ func (mw *MobyWatcher) Close() {
129130 mw .moby .Close ()
130131}
131132
132- // List all the currently alive and kicking containers, but do not list any
133- // containers without any processes.
134- func (mw * MobyWatcher ) List (ctx context.Context ) ([]* whalewatcher.Container , error ) {
133+ // Allow an engine client to do some final pre-flight operations that might
134+ // require talking to a particular engine and thus should be controlled by a
135+ // context.
136+ func (mw * MobyWatcher ) Preflight (ctx context.Context ) {
135137 // https://github.com/moby/moby/pull/42379
136138 mw .moby .NegotiateAPIVersion (ctx )
139+ }
137140
141+ // List all the currently alive and kicking containers, but do not list any
142+ // containers without any processes.
143+ func (mw * MobyWatcher ) List (ctx context.Context ) ([]* whalewatcher.Container , error ) {
138144 // Scan the currently available containers and take only the alive into
139145 // further consideration. This is a potentially lengthy operation, as we
140146 // need to inspect each potential candidate individually due to the way the
@@ -192,9 +198,6 @@ func (mw *MobyWatcher) Inspect(ctx context.Context, nameorid string) (*whalewatc
192198// in the lifecycle of containers getting born (=alive, as opposed to, say,
193199// "conceived") and die.
194200func (mw * MobyWatcher ) LifecycleEvents (ctx context.Context ) (<- chan engineclient.ContainerEvent , <- chan error ) {
195- // https://github.com/moby/moby/pull/42379
196- mw .moby .NegotiateAPIVersion (ctx )
197-
198201 cntreventstream := make (chan engineclient.ContainerEvent )
199202 cntrerrstream := make (chan error , 1 )
200203
0 commit comments