Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0c758fa
Implemented Couchbase binary protocol support
giriraj-singh-couchbase Jul 30, 2025
aa034c7
added support for single connection type for couchbase
giriraj-singh-couchbase Jul 31, 2025
9d81669
removed unnecessary cout statements
giriraj-singh-couchbase Jul 31, 2025
7946cb4
added protocol code for helo packet
giriraj-singh-couchbase Jul 31, 2025
d2ca0d4
fixed vbucketID code for identification, fixed add and get functions
giriraj-singh-couchbase Jul 31, 2025
d1497c1
Added test cases for threaded get and add functions
giriraj-singh-couchbase Jul 31, 2025
aae6a3d
Added Error Handling code and made upsert and delete examples
giriraj-singh-couchbase Aug 6, 2025
95ba8c0
Merge branch 'apache:master' into couchbase_binary_protocol_brpc
giriraj-singh-couchbase Sep 10, 2025
2ff17ff
added makefile for example/couchbase_c++
giriraj-singh-couchbase Sep 10, 2025
10964aa
fixed bugs in couchbase header files
giriraj-singh-couchbase Sep 19, 2025
8bc4c59
Added License and formatted to google c++ norms
giriraj-singh-couchbase Sep 19, 2025
b38bb2d
fixed bugs, added support for collections and added couchbase_client.md
giriraj-singh-couchbase Sep 20, 2025
07d1b0c
fixed license issue
giriraj-singh-couchbase Sep 20, 2025
f8defb1
added custom logic for caching collectionIDs
giriraj-singh-couchbase Sep 30, 2025
6a8200d
added caching of collection manifests
giriraj-singh-couchbase Oct 1, 2025
db1afc1
Added example code for multithreaded demonstration
giriraj-singh-couchbase Oct 1, 2025
753e662
updated CMake
giriraj-singh-couchbase Oct 1, 2025
4bdb6a4
Abstracted CRUD operations
giriraj-singh-couchbase Oct 2, 2025
80713be
Added pipeline/batching support
giriraj-singh-couchbase Oct 2, 2025
e77e3cd
commented unused variables
giriraj-singh-couchbase Oct 2, 2025
792a004
Merge pull request #5 from apache/master
giriraj-singh-couchbase Oct 2, 2025
1ce8f28
Updated support for C++17
giriraj-singh-couchbase Oct 2, 2025
d229fc2
Merge branch 'couchbase_binary_protocol_brpc' of https://github.com/c…
giriraj-singh-couchbase Oct 2, 2025
f03e0f6
fixed some issue.
giriraj-singh-couchbase Oct 2, 2025
68b4a51
Using Mutex instead of shared lock to support c++11
giriraj-singh-couchbase Oct 2, 2025
464cf69
Formatted code to google c++ format
giriraj-singh-couchbase Oct 2, 2025
a66208e
Introduced local cache per-instance of CouchbaseOperations and added …
giriraj-singh-couchbase Oct 4, 2025
8384ad8
Delete MODULE.bazel.lock
giriraj-singh-couchbase Oct 4, 2025
2c21f49
Fixed bugs in local collection cache and collection refresh logic
giriraj-singh-couchbase Oct 5, 2025
510f5d8
remove recurring statements
giriraj-singh-couchbase Oct 5, 2025
844d536
Fixed bugs/repetitive calls to refreshing manifest on server
giriraj-singh-couchbase Oct 5, 2025
fe51d10
Formatted function/variable naming scheme and formatted code in c++ g…
giriraj-singh-couchbase Oct 5, 2025
5a55549
removed unnecessary code
giriraj-singh-couchbase Oct 5, 2025
0d8b7b2
updated comments
giriraj-singh-couchbase Oct 6, 2025
4d4d181
updated comments
giriraj-singh-couchbase Oct 6, 2025
80da22c
updated documentation
giriraj-singh-couchbase Oct 6, 2025
ec37f12
updated documentation
giriraj-singh-couchbase Oct 6, 2025
f469609
updated documentation
giriraj-singh-couchbase Oct 6, 2025
6988d33
updated documentation
giriraj-singh-couchbase Oct 6, 2025
2912a63
Updated documentation
giriraj-singh-couchbase Oct 6, 2025
2e13a7e
Updated documentation
giriraj-singh-couchbase Oct 6, 2025
592db28
Update documentation
giriraj-singh-couchbase Oct 6, 2025
ddf97c4
Added features and fixed bugs in multithreaded environment
giriraj-singh-couchbase Oct 16, 2025
442a3c3
Merge branch 'couchbase_binary_protocol_brpc' of https://github.com/c…
giriraj-singh-couchbase Oct 16, 2025
8cab3d1
Updated multithreaded and single threaded code.
giriraj-singh-couchbase Oct 16, 2025
1639f5d
updated documentation
giriraj-singh-couchbase Oct 17, 2025
e4242b9
removed commented code and updated readme to have links for cluster d…
giriraj-singh-couchbase Nov 5, 2025
90d5522
removed unused code.
giriraj-singh-couchbase Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ if(Protobuf_VERSION GREATER 4.21)
absl::variant
)
else()
use_cxx11()
# Use C++17 for shared_mutex support and modern features
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
find_package(Threads REQUIRED)

Expand Down
1,009 changes: 1,009 additions & 0 deletions docs/en/couchbase_example.md

Large diffs are not rendered by default.

130 changes: 130 additions & 0 deletions example/couchbase_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 2.8.10)
project(couchbase_c++ C CXX)

option(LINK_SO "Whether examples are linked dynamically" OFF)

execute_process(
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)

set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})

include(FindThreads)
include(FindProtobuf)
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
# include PROTO_HEADER
include_directories(${CMAKE_CURRENT_BINARY_DIR})

# Search for libthrift* by best effort. If it is not found and brpc is
# compiled with thrift protocol enabled, a link error would be reported.
find_library(THRIFT_LIB NAMES thrift)
if (NOT THRIFT_LIB)
set(THRIFT_LIB "")
endif()

find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(LINK_SO)
find_library(BRPC_LIB NAMES brpc)
else()
find_library(BRPC_LIB NAMES libbrpc.a brpc)
endif()
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
message(FATAL_ERROR "Fail to find brpc")
endif()
include_directories(${BRPC_INCLUDE_PATH})

find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h)
find_library(GFLAGS_LIBRARY NAMES gflags libgflags)
if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
message(FATAL_ERROR "Fail to find gflags")
endif()
include_directories(${GFLAGS_INCLUDE_PATH})

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME)
set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
endif()
endif()

set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")

if(CMAKE_VERSION VERSION_LESS "3.1.3")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
find_library(LEVELDB_LIB NAMES leveldb)
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message(FATAL_ERROR "Fail to find leveldb")
endif()
include_directories(${LEVELDB_INCLUDE_PATH})

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OPENSSL_ROOT_DIR
"/usr/local/opt/openssl" # Homebrew installed OpenSSL
)
endif()

find_package(OpenSSL)
include_directories(${OPENSSL_INCLUDE_DIR})

set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY}
${PROTOBUF_LIBRARIES}
${LEVELDB_LIB}
${OPENSSL_CRYPTO_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${THRIFT_LIB}
dl
)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DYNAMIC_LIB ${DYNAMIC_LIB}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
"-Wl,-U,__Z13GetStackTracePPvii"
"-Wl,-U,_mallctl"
"-Wl,-U,_malloc_stats_print"
)
endif()

add_executable(couchbase_client couchbase_client.cpp)

target_link_libraries(couchbase_client ${BRPC_LIB} ${DYNAMIC_LIB})
82 changes: 82 additions & 0 deletions example/couchbase_c++/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk
CXXFLAGS+=$(CPPFLAGS) -std=c++17 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer
HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS))
LIBPATHS = $(addprefix -L, $(LIBS))
COMMA=,
SOPATHS=$(addprefix -Wl$(COMMA)-rpath$(COMMA), $(LIBS))

# Define targets and their sources
TARGETS = couchbase_client multithreaded_couchbase_client
COUCHBASE_CLIENT_OBJS = couchbase_client.o
MULTITHREADED_CLIENT_OBJS = multithreaded_couchbase_client.o
ALL_OBJS = $(COUCHBASE_CLIENT_OBJS) $(MULTITHREADED_CLIENT_OBJS)

ifeq ($(SYSTEM),Darwin)
ifneq ("$(LINK_SO)", "")
STATIC_LINKINGS += -lbrpc
else
# *.a must be explicitly specified in clang
STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a
endif
LINK_OPTIONS_SO = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
LINK_OPTIONS = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
else ifeq ($(SYSTEM),Linux)
STATIC_LINKINGS += -lbrpc
LINK_OPTIONS_SO = -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
LINK_OPTIONS = -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
endif

.PHONY: all clean couchbase_client multithreaded_couchbase_client help

# Default target builds both clients
all: $(TARGETS)

clean:
@echo "> Cleaning"
rm -rf $(TARGETS) $(ALL_OBJS)

# Build rules for individual targets
couchbase_client: $(COUCHBASE_CLIENT_OBJS)
@echo "> Linking $@"
ifneq ("$(LINK_SO)", "")
$(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
else
$(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
endif

multithreaded_couchbase_client: $(MULTITHREADED_CLIENT_OBJS)
@echo "> Linking $@"
ifneq ("$(LINK_SO)", "")
$(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
else
$(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
endif

# Compilation rules
couchbase_client.o: couchbase_client.cpp
@echo "> Compiling $@"
$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@

multithreaded_couchbase_client.o: multithreaded_couchbase_client.cpp
@echo "> Compiling $@"
$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
Loading
Loading