agent/stats/engine.go
func (engine *DockerStatsEngine) MustInit(ctx context.Context, taskEngine ecsengine.TaskEngine, cluster string, containerInstanceArn string) error {
	derivedCtx, cancel := context.WithCancel(ctx)
	engine.stopEngine = cancel

	engine.ctx = derivedCtx
	// TODO ensure that this is done only once per engine object
	seelog.Info("Initializing stats engine")
	engine.cluster = cluster
	engine.containerInstanceArn = containerInstanceArn

	var err error
	engine.resolver, err = newDockerContainerMetadataResolver(taskEngine)
	if err != nil {
		return err
	}

	// Subscribe to the container change event stream
	err = engine.containerChangeEventStream.Subscribe(containerChangeHandler, engine.handleDockerEvents)
	if err != nil {
		return fmt.Errorf("Failed to subscribe to container change event stream, err %v", err)
	}

	err = engine.synchronizeState()
	if err != nil {
		seelog.Warnf("Synchronize the container state failed, err: %v", err)
	}

	go engine.waitToStop()
	return nil
}
func (engine *DockerStatsEngine) MustInit(ctx context.Context, taskEngine ecsengine.TaskEngine, cluster string, containerInstanceArn string) error {
	derivedCtx, cancel := context.WithCancel(ctx)
	engine.stopEngine = cancel

	engine.ctx = derivedCtx
	// TODO ensure that this is done only once per engine object
	seelog.Info("Initializing stats engine")
	engine.cluster = cluster
	engine.containerInstanceArn = containerInstanceArn

	var err error
	engine.resolver, err = newDockerContainerMetadataResolver(taskEngine)
	if err != nil {
		return err
	}

	// Subscribe to the container change event stream
	err = engine.containerChangeEventStream.Subscribe(containerChangeHandler, engine.handleDockerEvents)
	if err != nil {
		return fmt.Errorf("Failed to subscribe to container change event stream, err %v", err)
	}

	err = engine.synchronizeState()
	if err != nil {
		seelog.Warnf("Synchronize the container state failed, err: %v", err)
	}

	go engine.waitToStop()
	return nil
}
func ( engine * DockerStatsEngine ) MustInit ( ctx context . Context , taskEngine ecsengine . TaskEngine , cluster string , containerInstanceArn string ) error { derivedCtx , cancel := context . WithCancel ( ctx ) engine . stopEngine = cancel engine . ctx = derivedCtx // TODO ensure that this is done only once per engine object seelog . Info ( " " ) engine . cluster = cluster engine . containerInstanceArn = containerInstanceArn var err error engine . resolver , err = newDockerContainerMetadataResolver ( taskEngine ) if err != nil { return err } // Subscribe to the container change event stream err = engine . containerChangeEventStream . Subscribe ( containerChangeHandler , engine . handleDockerEvents ) if err != nil { return fmt . Errorf ( " " , err ) } err = engine . synchronizeState ( ) if err != nil { seelog . Warnf ( " " , err ) } go engine . waitToStop ( ) return nil }
// MustInit initializes fields of the DockerStatsEngine object.
MustInit initializes fields of the DockerStatsEngine object .