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

SetOnActivityHeartbeatListener on TestActivityEnvironment #771

Merged
merged 2 commits into from
Apr 13, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Apr 11, 2022

What was changed

Added SetOnActivityHeartbeatListener on TestActivityEnvironment same as TestWorkflowEnvironment

Why?

Need to be able to mock heartbeat calls to server

Checklist

  1. Closes Add TestActivityEnvironment.SetOnActivityHeartbeatListener #768

Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the added value of this callback over using activity interceptors?

@cretz
Copy link
Member Author

cretz commented Apr 11, 2022

What's the added value of this callback over using activity interceptors?

This is for the testing framework. We already have it for TestWorkflowEnvironment so it's just inconsistent not to have it for TestActivityEnvironment. That we could replace many of our mocks/callbacks with interceptors I think is a different discussion.

@bergundy
Copy link
Member

What's the added value of this callback over using activity interceptors?

This is for the testing framework. We already have it for TestWorkflowEnvironment so it's just inconsistent not to have it for TestActivityEnvironment. That we could replace many of our mocks/callbacks with interceptors I think is a different discussion.

Sure, just with interceptors you wouldn't have to add the comment below which of course will come as a surprise to many users.
I'd at least add a sentence stating that interceptors can be used to track each heartbeat call.

// Note: Due to internal caching by the activity system, this may not get called
// for every heartbeat recorded. This is only called when the heartbeat would be
// sent to the server (periodic batch and at the end only on failure).

@cretz
Copy link
Member Author

cretz commented Apr 11, 2022

@bergundy - Added the comment. Agreed the behavior is confusing, but it is already in use that way.

@cretz cretz merged commit d10ca68 into temporalio:master Apr 13, 2022
@cretz cretz deleted the no-activity-heartbeat branch April 13, 2022 13:39
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.

Add TestActivityEnvironment.SetOnActivityHeartbeatListener
2 participants