Added support to connect and perform CRUD operations with couchbase #3138
Added support to connect and perform CRUD operations with couchbase #3138wwbmmm merged 57 commits intoapache:masterfrom
Conversation
Merging from source
…ouchbaselabs/cb_brpc into couchbase_binary_protocol_brpc t :wq
…functionality to handle server side manifest updates.
Unnecessary file
Added an example where a single instance is being shared across the threads when operating on single bucket.
updated the documentation on thread safe operations and fixed small small discrepancies.
…ownload certificate
Added support to connect and perform CRUD operations with couchbase
There was a problem hiding this comment.
Pull Request Overview
This pull request adds comprehensive support for Couchbase Binary Protocol to bRPC, enabling communication with Couchbase Server clusters using the native binary protocol. The implementation provides both high-level and low-level APIs for key-value operations with support for collections, pipelining, SSL/TLS, and multithreading.
Key Changes:
- Complete Couchbase Binary Protocol implementation with request/response parsing and serialization
- High-level
CouchbaseOperationsAPI with simple CRUD operations and pipeline support - SSL/TLS support for secure connections to Couchbase Capella (cloud)
- Collection-scoped operations with automatic manifest caching and refresh
- Multithreading support with both shared and separate instance patterns
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/brpc/proto_base.proto | Adds base message types for Couchbase request/response |
| src/brpc/policy/couchbase_protocol.h | Defines protocol structures, enums, and function declarations for Couchbase Binary Protocol |
| src/brpc/policy/couchbase_protocol.cpp | Implements message parsing, serialization, and protocol handling |
| src/brpc/couchbase.h | Defines high-level CouchbaseOperations API with request/response classes and manifest management |
| src/brpc/couchbase.cpp | Implements CRUD operations, authentication, collection management, and pipeline functionality |
| src/brpc/options.proto | Adds PROTOCOL_COUCHBASE enum value for protocol registration |
| src/brpc/global.cpp | Registers Couchbase protocol with bRPC framework |
| example/couchbase_c++/couchbase_client.cpp | Single-threaded example demonstrating all features |
| example/couchbase_c++/multithreaded_couchbase_client.cpp | Multithreaded example with shared and separate instance patterns |
| example/couchbase_c++/Makefile | Build configuration for examples |
| example/couchbase_c++/CMakeLists.txt | CMake build configuration for examples |
| docs/en/couchbase_example.md | Comprehensive documentation with usage patterns and examples |
| CMakeLists.txt | Updates C++ standard to C++17 for modern features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@giriraj-singh-couchbase Thank you for your contribution! This is quite a complicated job. Your code looks very good! I have add some comments. |
|
A small advice: you can add an unit test for the couchbase protocol, just base on the code in |
Traditional bRPC coding approach doesn't uses high level functions but provides more control to the user fixed formatting issues. fixed the bug in couchbase.cpp where logic to check the cache is empty was inverted
|
Hi @wwbmmm, I have added the unit test cases, traditional approach example and updated the documentation regarding it. |
Most look good, can you remove the |
Removed. |
|
LGTM |
Can you re-run the checks? |
I have fixed the unittest in this PR: #3153 . You can merge this PR and then re-run the checks. |
|
Hi @wwbmmm & @chenBright, can I get further feedback on this PR? |
This pull request introduces Couchbase Binary Protocol support to bRPC, enabling communication with Couchbase Server and Capella deployments. It adds a new protocol handler, request/response builders, comprehensive example clients, performance benchmarking tools, and detailed documentation. The changes are grouped below by theme:
Couchbase Binary Protocol Integration
Protocol Layer (
src/brpc/policy/):couchbase_protocol.handcouchbase_protocol.cppimplementing the complete binary protocol framing, parsing, with support for all standard Couchbase commands (GET, SET, ADD, REPLACE, DELETE, etc.)High-Level API (
src/brpc/):Implemented
CouchbaseOperationsclass insrc/brpc/couchbase.handsrc/brpc/couchbase.cpp(~3,500 lines), providing simplified APIs for:authenticate()andauthenticateSSL()for both non-SSL and SSL connections (required for Couchbase Capella)selectBucket()for bucket selectionget(),upsert(),add(),replace(),append(),prepend(),delete_()withResultstruct for clean error handlingbeginPipeline(),pipelineRequest(),executePipeline(),clearPipeline()for batching multiple operations in a single network call.Implemented
CouchbaseRequestandCouchbaseResponseclasses (inherit fromNonreflectableMessage) providing low-level request construction and response parsingImplemented
CouchbaseManifestManagersingleton for thread-safe collection manifest management with automatic caching and refreshExample Clients
Basic Client (
example/couchbase_c++/couchbase_client.cpp- 462 lines):Multithreaded Client (
example/couchbase_c++/multithreaded_couchbase_client.cpp- 375 lines):CouchbaseOperationsinstance (same bucket, shared connection)CouchbaseOperationsinstances (different buckets, isolated connections)Documentation
Comprehensive Guide (
docs/en/couchbase_example.md):Key Features
Resultstruct with success flag, error messages, status codes, and valuesWhat problem does this PR solve?
Added native support to interact with Couchbase servers using the binary protocol, enabling efficient CRUD operations, SSL/TLS encrypted connections and collection management.
Side effects:
Performance effects: None
Breaking backward compatibility: NO
Check List: