harshitydv1 opened a new pull request, #5803:
URL: https://github.com/apache/couchdb/pull/5803

   This PR implements a new `/{db}/_config` API endpoint that provides a 
unified, extensible interface for database-specific configuration settings, as 
requested in issue #5685.
   
   ## Overview
   
   The implementation follows the pattern of the server-level `/_config` API 
and consolidates existing per-database configuration endpoints (`_revs_limit`, 
`_purged_infos_limit`, `_auto_purge`) into a cohesive structure while 
maintaining full backward compatibility.
   
   ## Changes Made
   
   ### Modified Files
   
   1. **`src/chttpd/src/chttpd_httpd_handlers.erl`** (1 line added)
      - Registered handler for `_config` endpoint
   
   2. **`src/chttpd/src/chttpd_db.erl`** (~220 lines added)
      - Added export for `handle_db_config_req/2`
      - Implemented main handler function with routing for GET, PUT, DELETE 
operations
      - Added comprehensive helper functions for configuration management
   
   ### API Endpoints
   
   #### GET `/{db}/_config`
   Returns all configuration sections and their values.
   
   **Example Response:**
   ```json
   {
     "revs": {"limit": 1000},
     "purges": {"limit": 1000},
     "auto_purge": {"deleted_document_ttl": null},
     "compaction": {"generations": 0}
   }
   ```
   
   #### GET `/{db}/_config/{section}`
   Returns all keys in a specific section.
   
   **Example:** `GET /mydb/_config/revs`
   ```json
   {"limit": 1000}
   ```
   
   #### GET `/{db}/_config/{section}/{key}`
   Returns a specific configuration value.
   
   **Example:** `GET /mydb/_config/revs/limit` → `1000`
   
   #### PUT `/{db}/_config/{section}/{key}`
   Updates a configuration value and returns the old value.
   
   **Example:** `PUT /mydb/_config/revs/limit` with body `2000` → returns `1000`
   
   #### DELETE `/{db}/_config/{section}/{key}`
   Resets a configuration value to its default and returns the old value.
   
   ## Supported Configuration Sections
   
   ### 1. `revs` Section
   - **Key:** `limit` (integer, default: 1000)
   - **Description:** Maximum number of document revisions to track
   - **Replaces:** `/{db}/_revs_limit` (still supported for backward 
compatibility)
   
   ### 2. `purges` Section
   - **Key:** `limit` (positive integer, default: 1000)
   - **Description:** Maximum number of purge requests to store
   - **Replaces:** `/{db}/_purged_infos_limit` (still supported for backward 
compatibility)
   
   ### 3. `auto_purge` Section
   - **Key:** `deleted_document_ttl` (string, default: null)
   - **Description:** Time-to-live for deleted documents before auto-purge 
(e.g., "30d", "7d")
   - **Replaces:** `/{db}/_auto_purge` (still supported for backward 
compatibility)
   
   ### 4. `compaction` Section
   - **Key:** `generations` (integer, default: 0)
   - **Description:** Generational compaction setting (reserved for future use)
   - **Status:** Not yet implemented (returns error on PUT/DELETE)
   
   ## Backward Compatibility
   
   ✅ All existing endpoints continue to work:
   - `/{db}/_revs_limit` 
   - `/{db}/_purged_infos_limit`
   - `/{db}/_auto_purge`
   
   The new `_config` API internally uses the same fabric layer functions, 
ensuring consistency.
   
   ## Implementation Details
   
   - Follows existing CouchDB patterns and conventions
   - Comprehensive input validation for all config keys
   - Proper HTTP status codes and error messages
   - Extensible design for adding new configuration options
   
   Fixes #5685<!-- Thank you for your contribution!
   
        Please file this form by replacing the Markdown comments
        with your text. If a section needs no action - remove it.
   
        Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
        of code collaboration. Positive feedback is represented +1 from 
committers
        and negative is a -1. The -1 also means veto, and needs to be addressed
        to proceed. Once there are no objections, the PR can be merged by a
        CouchDB committer.
   
        See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
   
   ## Overview
   
   <!-- Please give a short brief for the pull request,
        what problem it solves or how it makes things better. -->
   
   ## Testing recommendations
   
   <!-- Describe how we can test your changes.
        Does it provide any behaviour that the end users
        could notice? -->
   
   ## Related Issues or Pull Requests
   
   <!-- If your changes affect multiple components in different
        repositories please put links to those issues or pull requests here.  
-->
   
   ## Checklist
   
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in 
`rel/overlay/etc/default.ini`
   - [ ] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected 
branches
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to