Skip to content

Conversation

@jeffschoner-stripe
Copy link
Contributor

Adds a method to Temporal::Workflow::Context and Temporal::Testing::LocalWorkflowContext for determining if a replay is occurring. This makes it possible to write a replay-aware custom logger or metrics emitter for other logging libraries besides the built-in Ruby logger. Specs for LocalWorkflowContext are extended to cover this new method and a new specs file is added for testing Workflow::Context.

end

def replay?
@state_manager.replay?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@state_manager.replay?
state_manager.replay?

nil
)
end
describe '#replay' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe '#replay' do
describe '#replay?' do

nil,
nil
)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing newline before describe

@robholland
Copy link
Contributor

My only slight concern would be that people might think they can safely use replay? for flow control. I understand your use case though and I'm not sure how else we'd satisfy it.

@jeffschoner-stripe
Copy link
Contributor Author

After doing some more digging, I think we can get what we need without this change

  • Inject our logger during configuration via Temporal.configure { |config| config.logger = foo } because its API is a superset of the logger gem's API
  • Wrap this logger by formatting the messages within an adapter. This appears to be doable with a relatively small amount of code for our use case
  • For metrics, there are already adapters and a null metrics object that should be able to allow for a switch-out pattern, but we'll have to figure out the details when addressing metrics

christopherb-stripe pushed a commit to christopherb-stripe/temporal-ruby that referenced this pull request Jan 19, 2022
…nal-with-start

Update method signature in temporal test fixture
@jeffschoner-stripe jeffschoner-stripe deleted the replay-flag branch October 26, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants