Skip to content

Conversation

@joshrotenberg
Copy link
Collaborator

Summary

This PR implements the --wait flag for Cloud database operations that return task IDs, allowing users to wait for operations to complete without having to manually run separate task commands.

Fixes #175 (partially - database commands only in this PR)

Background

Many Cloud API operations are asynchronous and return task IDs. Previously, users had to:

  1. Run the operation (e.g., create database)
  2. Note the returned task ID
  3. Run redisctl cloud task wait <task-id> separately

This enhancement streamlines the workflow by allowing operations to optionally wait for completion.

What's Changed

Core Infrastructure

  • ✅ Created async_utils module with shared utilities for handling async operations
  • ✅ Added AsyncOperationArgs struct for --wait, --wait-timeout, and --wait-interval flags
  • ✅ Implemented handle_async_response() to optionally wait for task completion with progress indicators
  • ✅ Reused existing task wait logic from task.rs

Database Commands Updated

  • cloud database create - Creating databases
  • cloud database update - Updating database configuration
  • cloud database delete - Deleting databases
  • cloud database backup - Triggering manual backups
  • cloud database import - Importing data

Usage Examples

Without --wait (existing behavior)

$ redisctl cloud database create --subscription 123 --data @config.json
Database created successfully
Task ID: abc-123
To wait for completion, run: redisctl cloud task wait abc-123

With --wait (new behavior)

$ redisctl cloud database create --subscription 123 --data @config.json --wait
⠙ Task abc-123: processing [00:00:12]
✓ Task abc-123: completed [00:00:45]
Database created successfully

Custom timeout and interval

$ redisctl cloud database delete 123:456 --wait --wait-timeout 600 --wait-interval 10

Testing

  • Compiles successfully
  • Help text shows new flags correctly
  • Manual testing with real Cloud API (needs API credentials)
  • Integration tests (future PR)

Future Work

This PR implements the foundation with database commands. Follow-up PRs will add --wait support to:

  • Subscription operations (create, update, delete)
  • Fixed database operations
  • Fixed subscription operations
  • ACL operations (rules, roles, users)
  • User operations (delete)
  • Cloud provider account operations
  • Connectivity operations (VPC, PSC, TGW)

Breaking Changes

None - this is purely additive functionality. All existing commands work exactly as before when --wait is not specified.

- Add AsyncOperationArgs struct for --wait, --wait-timeout, and --wait-interval flags
- Create async_utils module with shared utilities for handling async operations
- Implement handle_async_response() to optionally wait for task completion
- Update database commands (create, update, delete, backup, import) with --wait support
- Reuse existing task wait logic with progress indicators

When --wait is specified, commands will automatically poll for task completion
instead of requiring users to manually run 'redisctl cloud task wait <id>'.

Part of #175
Combine nested if statements using && operator to satisfy clippy's
collapsible_if lint rule.
@joshrotenberg joshrotenberg merged commit a356198 into main Sep 7, 2025
9 checks passed
@joshrotenberg joshrotenberg deleted the feat/cloud-wait-flag branch September 7, 2025 02:55
joshrotenberg added a commit that referenced this pull request Sep 7, 2025
- Add AsyncOperationArgs to Create, Update, and Delete subscription commands
- Update command handlers to pass async_ops parameter through
- Modify subscription_impl functions to use handle_async_response()
- Reuse async_utils module from #191 for consistent behavior

All three subscription operations now support --wait, --wait-timeout,
and --wait-interval flags for synchronous operation completion.

Fixes #192
Part of #175
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.

feat: add --wait flag to async Cloud operations that return task IDs

2 participants