func (cs *clientServer) createPublishHealthRequests() ([]*ecstcs.PublishHealthRequest, error) {
	metadata, taskHealthMetrics, err := cs.statsEngine.GetTaskHealthMetrics()
	if err != nil {
		return nil, err
	}

	if metadata == nil || taskHealthMetrics == nil {
		seelog.Debug("No container health metrics to report")
		return nil, nil
	}

	var requests []*ecstcs.PublishHealthRequest
	var taskHealths []*ecstcs.TaskHealth
	numOfTasks := len(taskHealthMetrics)
	for i, taskHealth := range taskHealthMetrics {
		taskHealths = append(taskHealths, taskHealth)
		// create a request if the number of task reaches the maximum page size
		if (i+1)%tasksInHealthMessage == 0 {
			requestMetadata := copyHealthMetadata(metadata, (i+1) == numOfTasks)
			requestTaskHealth := copyTaskHealthMetrics(taskHealths)
			request := ecstcs.NewPublishHealthMetricsRequest(requestMetadata, requestTaskHealth)
			requests = append(requests, request)
			taskHealths = taskHealths[:0]
		}
	}

	// Put the rest of the metrics in another request
	if len(taskHealths) != 0 {
		requestMetadata := copyHealthMetadata(metadata, true)
		requests = append(requests, ecstcs.NewPublishHealthMetricsRequest(requestMetadata, taskHealths))
	}

	return requests, nil
}
func (cs *clientServer) createPublishHealthRequests() ([]*ecstcs.PublishHealthRequest, error) {
	metadata, taskHealthMetrics, err := cs.statsEngine.GetTaskHealthMetrics()
	if err != nil {
		return nil, err
	}

	if metadata == nil || taskHealthMetrics == nil {
		seelog.Debug("No container health metrics to report")
		return nil, nil
	}

	var requests []*ecstcs.PublishHealthRequest
	var taskHealths []*ecstcs.TaskHealth
	numOfTasks := len(taskHealthMetrics)
	for i, taskHealth := range taskHealthMetrics {
		taskHealths = append(taskHealths, taskHealth)
		
		if (i+1)%tasksInHealthMessage == 0 {
			requestMetadata := copyHealthMetadata(metadata, (i+1) == numOfTasks)
			requestTaskHealth := copyTaskHealthMetrics(taskHealths)
			request := ecstcs.NewPublishHealthMetricsRequest(requestMetadata, requestTaskHealth)
			requests = append(requests, request)
			taskHealths = taskHealths[:0]
		}
	}

	
	if len(taskHealths) != 0 {
		requestMetadata := copyHealthMetadata(metadata, true)
		requests = append(requests, ecstcs.NewPublishHealthMetricsRequest(requestMetadata, taskHealths))
	}

	return requests, nil
}
func ( cs * clientServer ) createPublishHealthRequests ( ) ( [ ] * ecstcs . PublishHealthRequest , error ) { metadata , taskHealthMetrics , err := cs . statsEngine . GetTaskHealthMetrics ( ) if err != nil { return nil , err } if metadata == nil || taskHealthMetrics == nil { seelog . Debug ( " " ) return nil , nil } var requests [ ] * ecstcs . PublishHealthRequest var taskHealths [ ] * ecstcs . TaskHealth numOfTasks := len ( taskHealthMetrics ) for i , taskHealth := range taskHealthMetrics { taskHealths = append ( taskHealths , taskHealth ) // create a request if the number of task reaches the maximum page size if ( i + 1 ) % tasksInHealthMessage == 0 { requestMetadata := copyHealthMetadata ( metadata , ( i + 1 ) == numOfTasks ) requestTaskHealth := copyTaskHealthMetrics ( taskHealths ) request := ecstcs . NewPublishHealthMetricsRequest ( requestMetadata , requestTaskHealth ) requests = append ( requests , request ) taskHealths = taskHealths [ : 0 ] } } // Put the rest of the metrics in another request if len ( taskHealths ) != 0 { requestMetadata := copyHealthMetadata ( metadata , true ) requests = append ( requests , ecstcs . NewPublishHealthMetricsRequest ( requestMetadata , taskHealths ) ) } return requests , nil }
// createPublishHealthRequests creates the requests to publish container health
createPublishHealthRequests creates the requests to publish container health