Files
Giriraj Singh d2ea819af0 Added support to connect and perform CRUD operations with couchbase (#3138)
* Implemented Couchbase binary protocol support

* added support for single connection type for couchbase

* removed unnecessary cout statements

* added protocol code for helo packet

* fixed vbucketID code for identification, fixed add and get functions

* Added test cases for threaded get and add functions

* Added Error Handling code and made upsert and delete examples

* added makefile for example/couchbase_c++

* fixed bugs in couchbase header files

* Added License and formatted to google c++ norms

* fixed bugs, added support for collections and added couchbase_client.md

* fixed license issue

* added custom logic for caching collectionIDs

* added caching of collection manifests

* Added example code for multithreaded demonstration

* updated CMake

* Abstracted CRUD operations

* Added pipeline/batching support

* commented unused variables

* Updated support for C++17

* fixed some issue.

* Using Mutex instead of shared lock to support c++11

* Formatted code to google c++ format

* Introduced local cache per-instance of CouchbaseOperations and added functionality to handle server side manifest updates.

* Delete MODULE.bazel.lock

Unnecessary file

* Fixed bugs in local collection cache and collection refresh logic

* remove recurring statements

* Fixed bugs/repetitive calls to refreshing manifest on server

* Formatted function/variable naming scheme and formatted code in c++ google format

* removed unnecessary code

* updated comments

* updated comments

* updated documentation

* updated documentation

* updated documentation

* updated documentation

* Updated documentation

* Updated documentation

* Update documentation

* Added features and fixed bugs in multithreaded environment

Using connection_groups to differentiate between connections across CouchbaseOperations instances to different buckets.

Renamed CollectionManifestTracker class to CollectionManifestManager and all the related functionality inside it as before refreshing method was outside this class

Added two different authenticate method authenticate(not secure) and authenticateSSL(secure)

* Updated multithreaded and single threaded code.

Added an example where a single instance is being shared across the threads when operating on single bucket.

* updated documentation

updated the documentation on thread safe operations and fixed small small discrepancies.

* removed commented code and updated readme to have links for cluster download certificate

* removed unused code.

* Added traditional bRPC coding approach

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

* updated couchbase_example.md

* added unit test cases

* removed using namespace std from couchbase.h

* restored original CMakeLists.txt
2025-11-25 16:56:37 +08:00

95 lines
3.3 KiB
Makefile

# 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 traditional_brpc_couchbase_client
COUCHBASE_CLIENT_OBJS = couchbase_client.o
MULTITHREADED_CLIENT_OBJS = multithreaded_couchbase_client.o
TRADITIONAL_CLIENT_OBJS = traditional_brpc_couchbase_client.o
ALL_OBJS = $(COUCHBASE_CLIENT_OBJS) $(MULTITHREADED_CLIENT_OBJS) $(TRADITIONAL_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
traditional_brpc_couchbase_client: $(TRADITIONAL_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 $@
traditional_brpc_couchbase_client.o: traditional_brpc_couchbase_client.cpp
@echo "> Compiling $@"
$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@