Skip to content

Conversation

@jeffschoner-stripe
Copy link
Contributor

@jeffschoner-stripe jeffschoner-stripe commented Nov 18, 2021

  • Exposes memo to a running workflow through workflow.metadata.memo
  • Adds options to specify a memo when starting or scheduling a workflow
  • Some additional refactoring of mapping between proto and JSON maps for memos which is also applied to existing headers that have the same structure

Testing

  • There are new and updated unit specs, including changes to fabricators
  • The integration test for MetadataWorkflow now also checks for memo round-tripping

@antstorm
Copy link
Contributor

This should now be rebaseable

@jeffschoner-stripe
Copy link
Contributor Author

@antstorm This has been rebased, cleaned up, and is ready for final review

def serialize_memo(memo)
return unless memo

Temporal::Api::Common::V1::Memo.new(fields: object.memo)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we need to call to_payload_map here to properly serialise it. Also we should use the local memo variable, not object.memo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll see if I can cover this in some tests, and clean up the mixed instance/local variable pattern I blindly copied from headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should now be fixed for all memos. I'll do the same for headers in a separate PR.

def serialize_memo(memo)
return unless memo

Temporal::Api::Common::V1::Memo.new(fields: object.memo)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here ^

def serialize_headers(headers)
return unless headers

Temporal::Api::Common::V1::Header.new(fields: object.headers)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This is probably out of scope for this PR, but this also needs to have to_payload_map call

class Workflow
class ExecutionInfo < Struct.new(:workflow, :workflow_id, :run_id, :start_time, :close_time, :status, :history_length, keyword_init: true)
class ExecutionInfo < Struct.new(:workflow, :workflow_id, :run_id, :start_time, :close_time, :status, :history_length, :memo, keyword_init: true)
extend Concerns::Payloads
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be required within this file

@jeffschoner-stripe
Copy link
Contributor Author

@antstorm I believe I've addressed the latest round of feedback regarding memos.

I have the changes to improve headers on another branch ready to be rebased onto this PR once it's merged too. The change I'll be making to headers will be a breaking one in that callers will need to pass a plain hash of header key/value pairs rather than constructing the generated proto that's required today. This should be much more ergonomic but will benefit from a dedicated PR that calls out the impact of that change.

retry_policy: execution_options.retry_policy,
headers: execution_options.headers
headers: execution_options.headers,
memo: execution_options.memo,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also new in this latest iteration. The ensures the memo is copied in a continue-as-new.

class LoopWorkflow < Temporal::Workflow
def execute(count)
def execute(count, assert_memo)
assert_memo.each do |memo_key, memo_value|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how you feel about this approach. Essentially, I need the workflow to check its own memo value on each iteration continues to match what was passed to the first iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up scrapping this, having it return count and memo, and instead created a dedicated integration test for continue-as-new behavior. This also uncovered that memo was not being automatically copied to the next iteration as well, which is the behavior in Java and Go SDKs.

@jeffschoner-stripe
Copy link
Contributor Author

Made a few more changes to how the integration tests are structured, and copying memos to the next iteration of a continue-as-new workflow by default.

Copy link
Contributor

@antstorm antstorm left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@antstorm antstorm merged commit 7d63692 into coinbase:master Nov 28, 2021
@jeffschoner-stripe jeffschoner-stripe deleted the memos branch November 29, 2021 07:05
gvieira pushed a commit to clearbit/temporal-ruby that referenced this pull request Dec 21, 2021
* Pass config to the error handler instead of using the global config

* Fix example tests

* Make the config property in the workflow context publicly readable

* [Fix] Retryer GRPC error lookup (coinbase#109)

* Fix issue with GRPC error lookup in Retryer

* Rename spec file for retryer to contain _spec

* [Feature] Add id and domain to workflow context's metadata (coinbase#110)

* Start syncing id and domain on workflow context metadata

* Fixed tests

Co-authored-by: DeRauk Gibble <derauk.gibble@coinbase.com>

* Explicit docker-compose project name (coinbase#114)

* Add YARD documentation for Temporal::Client (coinbase#113)

* Add YARD documentation for Temporal::Client

* Add yard gem

* Fix @option tag

* Typo fix

* Add signal arguments to start_workflow (support for signal_with_start) (coinbase#112)

* Add signal arguments to start_workflow (to support signal_with_start)

* Move signal arguments to the options hash

* PR feedback

* Fix merge error

* Extend #wait_for to take multiple futures and a condition block (coinbase#111)

* Differentiate TARGET_WILDCARD and WILDCARD, allow comparison with EventTarget objects (coinbase#118)

* Turn off schedule_to_start activity timeout by default (coinbase#119)

* Separate options from keyword args in #start_workflow (coinbase#117)

* Separate options from keyword args in #start_workflow

* fixup! Separate options from keyword args in #start_workflow

* Surface additional workflow metadata on workflow context (coinbase#120)

* Refactor metadata generation

* Make task queue available on workflow metadata, add example test

* Expose workflow start time metadata

* Add memos (coinbase#121)

* Add describe_namespace (coinbase#122)

* Add describe_namespace

* Feedback

* Improve header serialization and propagation (coinbase#124)

* [Fix] Non-started activity cancellation (coinbase#125)

* Fix event target map entry for ACTIVITY_CANCELED event

* Fix cancellation of a non-started activity

* fixup! Fix event target map entry for ACTIVITY_CANCELED event

Co-authored-by: DeRauk Gibble <derauk.gibble@coinbase.com>
Co-authored-by: DeRauk Gibble <derauk@gmail.com>
Co-authored-by: Anthony Dmitriyev <antstorm@gmail.com>
Co-authored-by: nagl-stripe <86737162+nagl-stripe@users.noreply.github.com>
Co-authored-by: jeffschoner-stripe <63118764+jeffschoner-stripe@users.noreply.github.com>
Co-authored-by: Drew Hoskins <37816070+drewhoskins-stripe@users.noreply.github.com>
calum-stripe pushed a commit to calum-stripe/temporal-ruby that referenced this pull request Mar 28, 2023
…oner-search-attributes

APIs for adding, listing, and removing custom search attributes
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