feat: add builder patterns to request structs#40
Merged
joshrotenberg merged 2 commits intomainfrom Aug 28, 2025
Merged
Conversation
- Add typed-builder v0.20 dependency to both redis-cloud and redis-enterprise - Implement builders for high-priority request structs: redis-cloud: - CreateDatabaseRequest, UpdateDatabaseRequest - CreateSubscriptionRequest, UpdateSubscriptionRequest - CloudProviderConfig, CloudRegionConfig - CreateBackupRequest, CreatePeeringRequest redis-enterprise: - CreateUserRequest, UpdateUserRequest - CreateRoleRequest with BdbRole - CreateCrdbRequest with CreateCrdbInstance - Builder benefits: - No more manual Some() wrapping for optional fields - No more .to_string() calls with setter(into) - strip_option allows natural API (no Option in setter) - Default values for optional fields - Compile-time validation - Update example to showcase cleaner builder API - Add comprehensive examples in doc comments Resolves #38
Complete 100% builder pattern coverage across both libraries! redis-cloud (already complete): - All 6 request structs have TypedBuilder redis-enterprise (now complete): - All 18 request structs now have TypedBuilder - Migrated CreateDatabaseRequest from custom builder to TypedBuilder - Added builders to all HIGH, MEDIUM, and LOW priority structs Structs updated in this commit: - CreateDatabaseRequest (migrated from custom builder) - BootstrapRequest with nested ClusterBootstrapInfo - CreateMigrationRequest with MigrationEndpoint - DebugInfoRequest (all optional fields) - CreateScheduledJobRequest - CreateLdapMappingRequest - CreateSuffixRequest - CreateRedisAclRequest - CreateCrdbTaskRequest - DiagnosticRequest - ServiceConfigRequest - NodeActionRequest - LicenseUpdateRequest - ModuleConfig (helper struct) Achievement: 100% builder pattern coverage! - redis-cloud: 6/6 structs ✅ - redis-enterprise: 18/18 structs ✅ Resolves #38 Closes #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
🎉 100% COMPLETE - This PR now implements builder patterns for ALL request structs across both
redis-cloudandredis-enterpriselibraries!Achievement Unlocked: 100% Coverage! 🏆
Final Status
Changes Made
🏗️ Complete Builder Pattern Implementation
redis-cloud crate (6 structs):
CreateDatabaseRequest/UpdateDatabaseRequestCreateSubscriptionRequest/UpdateSubscriptionRequestCloudProviderConfig/CloudRegionConfigCreateBackupRequestCreatePeeringRequestredis-enterprise crate (18 structs):
HIGH Priority:
CreateDatabaseRequest(migrated from custom builder to TypedBuilder)BootstrapRequestCreateMigrationRequestDebugInfoRequestMEDIUM Priority:
CreateUserRequest/UpdateUserRequestCreateRoleRequestwithBdbRoleCreateCrdbRequestwithCreateCrdbInstanceCreateScheduledJobRequestCreateLdapMappingRequestCreateSuffixRequestCreateRedisAclRequestCreateCrdbTaskRequestDiagnosticRequestLOW Priority:
ServiceConfigRequestNodeActionRequestLicenseUpdateRequest🎯 Developer Experience Improvements
Before (verbose and error-prone):
After (clean and ergonomic):
🚀 Key Benefits
Some()wrapping -strip_optionattribute handles this automatically.to_string()calls -setter(into)converts &str to StringTesting
Implementation Details
Used
typed-builderv0.20 with consistent patterns:#[builder(setter(into))]for String fields#[builder(default, setter(into, strip_option))]for Option#[builder(default, setter(strip_option))]for other OptionWhat This Means
Every single request struct in both Redis libraries now has an ergonomic builder pattern! This makes the Redis APIs significantly more pleasant to use and maintains consistency across the entire codebase.
Closes #38
Closes #41