func (handler *attachENIHandler) handleSingleMessage(message *ecsacs.AttachTaskNetworkInterfacesMessage) error {
	receivedAt := time.Now()
	// Validate fields in the message
	if err := validateAttachTaskNetworkInterfacesMessage(message); err != nil {
		return errors.Wrapf(err,
			"attach eni message handler: error validating AttachTaskNetworkInterface message received from ECS")
	}

	// Send ACK
	go func(clusterArn *string, containerInstanceArn *string, messageID *string) {
		if err := handler.acsClient.MakeRequest(&ecsacs.AckRequest{
			Cluster:           clusterArn,
			ContainerInstance: containerInstanceArn,
			MessageId:         messageID,
		}); err != nil {
			seelog.Warnf("Failed to ack request with messageId: %s, error: %v", aws.StringValue(messageID), err)
		}
	}(message.ClusterArn, message.ContainerInstanceArn, message.MessageId)

	// Check if this is a duplicate message
	mac := aws.StringValue(message.ElasticNetworkInterfaces[0].MacAddress)
	if eniAttachment, ok := handler.state.ENIByMac(mac); ok {
		seelog.Infof("Duplicate ENI attachment message for ENI with MAC address: %s", mac)
		eniAckTimeoutHandler := ackTimeoutHandler{mac: mac, state: handler.state}
		return eniAttachment.StartTimer(eniAckTimeoutHandler.handle)
	}
	if err := handler.addENIAttachmentToState(message, receivedAt); err != nil {
		return errors.Wrapf(err, "attach eni message handler: unable to add eni attachment to engine state")
	}
	if err := handler.saver.Save(); err != nil {
		return errors.Wrapf(err, "attach eni message handler: unable to save agent state")
	}
	return nil
}
func (handler *attachENIHandler) handleSingleMessage(message *ecsacs.AttachTaskNetworkInterfacesMessage) error {
	receivedAt := time.Now()
	
	if err := validateAttachTaskNetworkInterfacesMessage(message); err != nil {
		return errors.Wrapf(err,
			"attach eni message handler: error validating AttachTaskNetworkInterface message received from ECS")
	}

	
	go func(clusterArn *string, containerInstanceArn *string, messageID *string) {
		if err := handler.acsClient.MakeRequest(&ecsacs.AckRequest{
			Cluster:           clusterArn,
			ContainerInstance: containerInstanceArn,
			MessageId:         messageID,
		}); err != nil {
			seelog.Warnf("Failed to ack request with messageId: %s, error: %v", aws.StringValue(messageID), err)
		}
	}(message.ClusterArn, message.ContainerInstanceArn, message.MessageId)

	
	mac := aws.StringValue(message.ElasticNetworkInterfaces[0].MacAddress)
	if eniAttachment, ok := handler.state.ENIByMac(mac); ok {
		seelog.Infof("Duplicate ENI attachment message for ENI with MAC address: %s", mac)
		eniAckTimeoutHandler := ackTimeoutHandler{mac: mac, state: handler.state}
		return eniAttachment.StartTimer(eniAckTimeoutHandler.handle)
	}
	if err := handler.addENIAttachmentToState(message, receivedAt); err != nil {
		return errors.Wrapf(err, "attach eni message handler: unable to add eni attachment to engine state")
	}
	if err := handler.saver.Save(); err != nil {
		return errors.Wrapf(err, "attach eni message handler: unable to save agent state")
	}
	return nil
}
func ( handler * attachENIHandler ) handleSingleMessage ( message * ecsacs . AttachTaskNetworkInterfacesMessage ) error { receivedAt := time . Now ( ) // Validate fields in the message if err := validateAttachTaskNetworkInterfacesMessage ( message ) ; err != nil { return errors . Wrapf ( err , " " ) } // Send ACK go func ( clusterArn * string , containerInstanceArn * string , messageID * string ) { if err := handler . acsClient . MakeRequest ( & ecsacs . AckRequest { Cluster : clusterArn , ContainerInstance : containerInstanceArn , MessageId : messageID , } ) ; err != nil { seelog . Warnf ( " " , aws . StringValue ( messageID ) , err ) } } ( message . ClusterArn , message . ContainerInstanceArn , message . MessageId ) // Check if this is a duplicate message mac := aws . StringValue ( message . ElasticNetworkInterfaces [ 0 ] . MacAddress ) if eniAttachment , ok := handler . state . ENIByMac ( mac ) ; ok { seelog . Infof ( " " , mac ) eniAckTimeoutHandler := ackTimeoutHandler { mac : mac , state : handler . state } return eniAttachment . StartTimer ( eniAckTimeoutHandler . handle ) } if err := handler . addENIAttachmentToState ( message , receivedAt ) ; err != nil { return errors . Wrapf ( err , " " ) } if err := handler . saver . Save ( ) ; err != nil { return errors . Wrapf ( err , " " ) } return nil }
// handleSingleMessage acks the message received
handleSingleMessage acks the message received