Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ACS heartbeat message handling #3724

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

danehlim
Copy link
Contributor

@danehlim danehlim commented May 30, 2023

Summary

Refactor ACS heartbeat message handling and update other associated code.

Implementation details

  1. Remove RegisterResponder method from wsclient.RequestResponder interface as it is unnecessary and will not be required for any future responders (see this comment thread for more details)
    • ecs-agent/wsclient/client.go
      • Remove RegisterResponder method and associated comments
    • ecs-agent/wsclient/mock/client.go
      • Regenerate mocks after removal performed above
  2. Refactor ACS heartbeat message handling and move to ecs-agent/
    • agent/acs/handler/heartbeat_handler.go -> ecs-agent/acs/session/heartbeat_responder.go
      • Define heartbeatResponder struct and refactor existing code, such that heartbeatResponder struct implements the wsclient.RequestResponder interface
      • Use github.com/aws/amazon-ecs-agent/ecs-agent/logger instead of github.com/cihub/seelog for logging
    • agent/acs/handler/heartbeat_handler_test.go -> ecs-agent/acs/session/heartbeat_responder_test.go
      • Update tests accordingly based off of above changes
  3. Update other associated files
    • agent/acs/handler/acs_handler.go
      • Initialize heartbeat responder and add its HandlerFunc function as a request handler to the ACS client, such that heartbeat responder dictates what to do in response to receiving heartbeat messages from ACS
        • Eventually, each ACS message type will have its own responder (which implements the wsclient.RequestResponder interface) that dictates what to do in response to ACS messages of that specific type
    • ecs-agent/logger/field/constants.go
      • Add new MessageID constant to logger constants, since we expect this to be commonly used in logging as we continue to refactor handling of other ACS messages in future pull requests

Testing

Unit, integration, and functional tests.

Description for the changelog

Refactor ACS heartbeat message handling

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@danehlim danehlim marked this pull request as ready for review May 30, 2023 19:36
@danehlim danehlim requested a review from a team as a code owner May 30, 2023 19:36
@danehlim danehlim force-pushed the ecs-agent-heartbeat-acs branch 2 times, most recently from 9c5c61b to c4b68dd Compare May 30, 2023 22:00
ohsoo
ohsoo previously approved these changes May 30, 2023
ohsoo
ohsoo previously approved these changes May 30, 2023
fierlion
fierlion previously approved these changes Jun 1, 2023
ecs-agent/acs/session/heartbeat_responder.go Show resolved Hide resolved
@danehlim danehlim dismissed stale reviews from fierlion and ohsoo via ca688bf June 6, 2023 20:50
@danehlim danehlim requested a review from fierlion June 6, 2023 23:12
@danehlim danehlim merged commit 64e4ef6 into aws:dev Jun 7, 2023
@prateekchaudhry prateekchaudhry mentioned this pull request Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants