Skip to content

Add Timer sample for monthly subscription - #112

Open
sachinsharma3191 wants to merge 1 commit into
temporalio:mainfrom
sachinsharma3191:sample/18-timer
Open

Add Timer sample for monthly subscription#112
sachinsharma3191 wants to merge 1 commit into
temporalio:mainfrom
sachinsharma3191:sample/18-timer

Conversation

@sachinsharma3191

Copy link
Copy Markdown

Summary

  • Adds a Timer sample implementing a monthly subscription workflow with cancellation handling (closes Sample request: Timer #18)
  • Uses Temporalio::Workflow.sleep for 30-day intervals and Temporalio::Workflow.execute_activity to charge the user
  • Handles Temporalio::Error::CanceledError for graceful workflow cancellation
  • Follows the .NET Timer sample reference pattern

Files

  • timer/subscription_workflow.rb — Subscription workflow with sleep loop and cancellation
  • timer/my_activities.rb — Simple Charge activity
  • timer/worker.rb — Worker registering workflow and activity
  • timer/starter.rb — Starts the subscription workflow
  • timer/README.md — Usage instructions
  • test/timer/subscription_workflow_test.rb — Time-skipping test verifying charge and cancellation
  • README.md — Added timer to the samples list

Test plan

  • Rubocop passes with no offenses
  • Time-skipping test passes (1 run, 2 assertions, 0 failures)

Implements issue temporalio#18 — a Timer sample matching the .NET reference.
Uses Temporalio::Workflow.sleep for 30-day intervals, charges via
an activity, and handles CanceledError for graceful cleanup.
Includes a time-skipping test.
@sachinsharma3191
sachinsharma3191 requested a review from a team as a code owner August 12, 2026 05:47
@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Sample request: Timer

2 participants