Skip to content

[task]: attempt to improve debugging info for AnyWorkflowAction #194

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

Merged
merged 4 commits into from
Mar 17, 2023

Conversation

jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Mar 14, 2023

Description

this change adds introspection capabilities for what i believe is the final type-eraser that lacks them – AnyWorkflowAction. changes include:

  • adds a public base property on AnyWorkflowAction to expose the underlying action as an Any value
  • adds an internal utility type, ClosureAction, for closure-based AnyWorkflowActions. the intent is to provide the possibility of improved telemetry information when logging such actions.
  • adds a new public property isClosureBased on AnyWorkflowAction to differentiate instances that forward to an underlying wrapped action vs those whose implementations are defined by a closure.

Checklist

  • Unit Tests
  • UI Tests
  • Snapshot Tests (iOS only)
  • I have made corresponding changes to the documentation

fileID: StaticString = #fileID,
line: UInt = #line
) {
let closureAction = ClosureAction<WorkflowType>(
Copy link
Member

Choose a reason for hiding this comment

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

could we expose a way for consumers who receive AnyWorkflowAction to know if this is wrapping a closure vs. a real action? could maybe make ClosureAction public to achieve that

let action: AnyWorkflowAction<SomeWorkflow> = ...

if action.base is ClosureAction<SomeWorkflow> {

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah we can do that. do you think full access to the underlying type is needed? or would a flag suffice?

Copy link
Member

Choose a reason for hiding this comment

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

In general my default is "provide more access" but I know as the SDK author its the opposite for you :p for now I suppose a flag would work

@jamieQ jamieQ marked this pull request as ready for review March 16, 2023 19:37
@jamieQ jamieQ requested a review from a team as a code owner March 16, 2023 19:37
@jamieQ jamieQ changed the title [wip]: attempt to improve debugging info for AnyWorkflowAction [task]: attempt to improve debugging info for AnyWorkflowAction Mar 16, 2023
/// defined via a closure.
struct ClosureAction<WorkflowType: Workflow>: WorkflowAction {
private let _apply: (inout WorkflowType.State) -> WorkflowType.Output?
let fileID: StaticString
Copy link
Member

Choose a reason for hiding this comment

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

nice touch!

@jamieQ jamieQ merged commit d6189b1 into main Mar 17, 2023
@jamieQ jamieQ deleted the jquadri/anyaction-introspection branch March 17, 2023 19:21
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.

3 participants