Implement feature flags system for subscriptions with bulk operations#5262
Implement feature flags system for subscriptions with bulk operations#5262
Conversation
… Service Co-authored-by: premun <[email protected]>
- Replace 5 example feature flags with single `enable-rebase-strategy` flag for codeflow conflict resolution - Update all tests to use the new flag appropriately - Update CLI example to use the new flag - Maintain all existing functionality while focusing on the specific use case Co-authored-by: premun <[email protected]>
I've replaced all the example feature flags with a single The changes include:
Commit: e4cf109 |
premun
left a comment
There was a problem hiding this comment.
@copilot the PCS.Cli project cannot use the Redis wrapper class directly. It needs to use the ProductConstructionClient class like the rest of the Cli project does.
I have added the feature flag support to the PCS client class in the last commit.
… direct Redis access Co-authored-by: premun <[email protected]>
Updated the PCS CLI to use the Key changes:
The CLI builds successfully and all feature flag commands are available with the correct options ( Commit: 68e43ae |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive feature flags system for the Product Construction Service (PCS), enabling subscription-specific feature toggles through a Redis-backed storage system with full CLI and API integration.
Key changes:
- Added predefined feature flags registry with rebase strategy flag and type-safe validation
- Implemented Redis-backed feature flag service with expiration support and comprehensive CRUD operations
- Created REST API endpoints for complete feature flag management in the v2020_02_20 API version
Reviewed Changes
Copilot reviewed 18 out of 27 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/ProductConstructionService.Cli/Program.cs | Registers new feature flag CLI command types |
| tools/ProductConstructionService.Cli/Options/*.cs | Defines CLI options for all 5 feature flag operations (set, get, remove, list, available) |
| tools/ProductConstructionService.Cli/Operations/*.cs | Implements CLI operations using ProductConstructionService API client |
| test/ProductConstructionService.Api.Tests/FeatureFlagsController20200220Tests.cs | Comprehensive unit tests covering API controller functionality |
| src/ProductConstructionService/ProductConstructionService.Common/ProductConstructionServiceExtension.cs | Registers feature flag service in dependency injection container |
| src/ProductConstructionService/ProductConstructionService.Common/IFeatureFlagService.cs | Service interface defining feature flag operations |
| src/ProductConstructionService/ProductConstructionService.Common/FeatureFlags.cs | Static registry of available feature flags with validation |
| src/ProductConstructionService/ProductConstructionService.Common/FeatureFlagService.cs | Redis-backed implementation of feature flag service |
| src/ProductConstructionService/ProductConstructionService.Common/FeatureFlagModels.cs | Data models for feature flag requests and responses |
| src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/FeatureFlagsController.cs | REST API controller implementing complete feature flag management |
Co-authored-by: Copilot <[email protected]>
…is TTL to never expire Co-authored-by: premun <[email protected]>
|
@copilot switch to using |
…e ILogger in CLI Co-authored-by: premun <[email protected]>
Switched all feature flag commands in the PCS CLI project to use |
This PR implements a complete feature flags system for the Product Construction Service (PCS) that enables subscription-specific feature toggles, gradual rollouts, and A/B testing capabilities with administrative bulk operations.
🎯 Key Features
Core Infrastructure
FeatureFlagsclass with rebase strategy flag and metadataIRedisCacheFactoryIFeatureFlagClientwith compile-time validation and per-request cachingFeatureFlagValuewith only essential fields (SubscriptionId, FlagName, Value, CreatedAt)REST API Endpoints
Added
FeatureFlagsControllerin the v2020_02_20 API with full CRUD operations:POST /api/feature-flags- Set feature flags with optional expiryGET /api/feature-flags/{subscriptionId}- Get all flags for a subscriptionGET /api/feature-flags/{subscriptionId}/{flagName}- Get specific flagDELETE /api/feature-flags/{subscriptionId}/{flagName}- Remove flagGET /api/feature-flags- Admin endpoint to list all flagsGET /api/feature-flags/available- List available flags with metadataGET /api/feature-flags/by-flag/{flagName}- List all subscriptions with a specific flagDELETE /api/feature-flags/by-flag/{flagName}- Remove flag from all subscriptions (admin)CLI Integration
Integrated 7 new commands into the existing PCS CLI tool using the
ProductConstructionServiceApiclient:🏗️ Technical Implementation
Simplified Feature Flag Model
FeatureFlagValue(SubscriptionId, FlagName, Value, CreatedAt)ExpiryandUpdatedAtfields from the modelExpiryDaysparameter in API allows custom expiration when neededBulk Operations
Added two new service methods for administrative operations:
GetSubscriptionsWithFlagAsync()- Find all subscriptions with a specific flag using Redis patternFeatureFlags_*:{flagName}RemoveFlagFromAllSubscriptionsAsync()- Remove a flag from all subscriptions and return count of removed flagsRedis Key Structure
Uses consistent key pattern:
FeatureFlags_{subscriptionId}:{flagName}with automatic expiration cleanup handled by Redis TTL.CLI Architecture
The CLI commands use the generated
ProductConstructionServiceApiclient and follow established patterns:PcsStatusOptionsfor consistent authentication--isCi,--pcsUri) instead of direct Redis access_client.FeatureFlags.*methods to interact with the APIILoggerinstead ofConsole.WriteLinefollowing PCS CLI patternsService Integration
The
IFeatureFlagClientis designed for easy integration into existing PCS components:Available Feature Flag
enable-rebase-strategy- Enables rebase strategy for codeflow conflict resolution instead of merge🧪 Testing
Added comprehensive unit tests (17 tests) covering:
🔄 Integration with Existing Systems
IRedisCacheFactory)ProductConstructionServiceApiclient and Azure authentication📝 Recent Updates
Successboolean fromRemoveFlagFromAllResponse- HTTP status codes indicate success/failureRemoveFlagFromAllSubscriptionsAsyncnow properly propagates exceptions instead of silently continuingILoggerfollowing established PCS patternsThis implementation provides a robust foundation for enabling rebase strategy in codeflow conflict resolution on a per-subscription basis, with administrative capabilities for bulk flag management across all subscriptions. The streamlined model reduces complexity while maintaining full functionality.
Fixes #5261.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.