Skip to content

Commit b5fd9b8

Browse files
authored
[4.0.0] High availability, sentinel, design improvement (cpp-redis#101) (cpp-redis#109)
* High availability, sentinel, design improvement (cpp-redis#101) * Added sentiel and high availability(HA) versions of client and subscriber which will handle connect/reconnection automatically to redis server. * Merged changes * clang format * bump tacopie * unix compilation. will need some time to code review and port windows changes to unix. * clean unecessary changes. merge future_client into redis_client to make interface cleaner. rename redis_ prefix to classes * merge ha_client into client, refactore architecture. * merge ha_subscriber into subscriber * try_commit instead of commit in disconnection flow * doxygen * tacopie link & documentation & compilation fix * fix reconnection process * fix unit tests * clean code sentinel & make it consistent (avoid regression for example with callbacks execution) * ability to change number of io service workers at runtime * ha redis client example * doxygen doc * switch ZADD score param from map to multimap cpp-redis#107 * update CHANGELOG.md for 4.0.0 release * bump tacopie * [4.0.0] update README
1 parent c44677f commit b5fd9b8

File tree

569 files changed

+72709
-4151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

569 files changed

+72709
-4151
lines changed

.doxygen

Lines changed: 2473 additions & 0 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ language: cpp
33
compiler:
44
- clang
55
- gcc
6-
7-
cache: ccache
6+
7+
cache: ccache
88

99
os:
1010
- linux
@@ -35,4 +35,3 @@ install:
3535
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then (redis-server&); fi
3636

3737
script: mkdir build && cd build && cmake .. -DBUILD_TESTS=true -DBUILD_EXAMPLES=true && make && ./bin/cpp_redis_tests
38-

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Changelog
22

3+
## [v4.0.0](https://github.com/Cylix/cpp_redis/releases/tag/4.0.0)
4+
### Tag
5+
`4.0.0`.
6+
### Date
7+
September 20th, 2017
8+
### Changes
9+
* ZADD score param changed from map to multimap to allow multiple elements with same score
10+
* connection_callback (replacement of disconnection_callback). Called for any steps of connection process (attempt, success, failure, reconnection, drop, ...)
11+
### Additions
12+
* Sentinel support
13+
* Automatic reconnection if requested
14+
* Connection timeout
15+
* Ability to set number of io workers if you are working with tacopie
16+
* `redis_client` renamed into `client`
17+
* `redis_subscriber` renamed into `subscriber`
18+
* commands that failed to be sent (client not connected or disconnected) get their callback called with an error reply `connection failure`. This ensure that now all callbacks are always called
19+
* if reconnection process is enabled and succeed, failed commands are resent
20+
* if you send command and commit while client is not connected, it will now dismiss the commands and call their callback with an error, or resend them if reconnection is enabled. This is a change compared to the existing behavior that simply kept the commands in the buffer.
21+
* doxygen documentation
22+
### Removals
23+
* future_client: all functions have been merge into the redis_client
24+
* disconnection_callback: it is now replaced by the connection callback
25+
26+
This is a major release with lots of breaking changes.
27+
It aims to enable high availability configuration as well as improved consistency with an enhanced design.
28+
29+
If you are upgrading please consider the following breaking changes:
30+
* `redis_client` is now `client` and `redis_subscriber` is now `subscriber`
31+
* `future_client` has been removed, but it is actually merged into `client`. Simply switch from `future_client` to `client` and you will have the same behavior
32+
* `disconnection_callback` has been removed and replaced by a `connection_callback`. If you are looking for exact same behavior, you will have to check if the state param is equal to `dropped`.
33+
* commands callbacks are always called. In case of failure, an error reply is passed in.
34+
35+
Any other changes should not be breaking changes but you might be interested into the added features.
36+
37+
38+
339
## [v3.5.4](https://github.com/Cylix/cpp_redis/releases/tag/3.5.4)
440
### Tag
541
`3.5.4`.

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ include_directories(${CPP_REDIS_INCLUDES} ${DEPS_INCLUDES})
9292
###
9393
# sources
9494
###
95-
set(SRC_DIRS "sources" "sources/network" "sources/builders" "includes/cpp_redis" "includes/cpp_redis/builders" "includes/cpp_redis/network")
95+
set(SRC_DIRS "sources"
96+
"sources/builders"
97+
"sources/core"
98+
"sources/misc"
99+
"sources/network"
100+
"includes/cpp_redis"
101+
"includes/cpp_redis/builders"
102+
"includes/cpp_redis/core"
103+
"includes/cpp_redis/misc"
104+
"includes/cpp_redis/network")
105+
96106
foreach(dir ${SRC_DIRS})
97107
# get directory sources and headers
98108
file(GLOB s_${dir} "${dir}/*.cpp")
@@ -138,11 +148,12 @@ ELSE ()
138148
target_link_libraries(${PROJECT} pthread)
139149
ENDIF (WIN32)
140150

141-
if(TACOPIE_LIBRARY)
151+
if (TACOPIE_LIBRARY)
142152
target_link_libraries(${PROJECT} ${TACOPIE_LIBRARY})
143153
else()
144154
target_link_libraries(${PROJECT} tacopie)
145-
endif()
155+
endif(TACOPIE_LIBRARY)
156+
146157

147158
# __CPP_REDIS_READ_SIZE
148159
IF (READ_SIZE)

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ cmake .. -DCMAKE_BUILD_TYPE=Release
1919
make
2020
# Run tests and examples
2121
./bin/cpp_redis_tests
22-
./bin/redis_subscriber
23-
./bin/redis_client
22+
./bin/subscriber
23+
./bin/client
2424
```
2525

2626
## 5. Code your changes

README.md

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,36 @@
33
</p>
44

55
# cpp_redis [![Build Status](https://travis-ci.org/Cylix/cpp_redis.svg?branch=master)](https://travis-ci.org/Cylix/cpp_redis)
6-
`cpp_redis` is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.
6+
`cpp_redis` is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations, pipelining, sentinels and high availability.
77

88
## Requirement
99
`cpp_redis` has **no dependency**. Its only requirement is `C++11`.
1010

11+
It comes with no network module, so you are free to configure your own, or to use the default one ([tacopie](https://github.com/cylix/tacopie))
12+
1113
## Example
12-
### cpp_redis::redis_client
14+
### cpp_redis::client
1315
```cpp
14-
cpp_redis::redis_client client;
16+
cpp_redis::client client;
1517

1618
client.connect();
1719

1820
client.set("hello", "42");
1921
client.get("hello", [](cpp_redis::reply& reply) {
2022
std::cout << reply << std::endl;
2123
});
24+
//! also support std::future
25+
//! std::future<cpp_redis::reply> get_reply = client.get("hello");
2226

2327
client.sync_commit();
24-
# or client.commit(); for synchronous call
28+
//! or client.commit(); for synchronous call
2529
```
26-
`cpp_redis::redis_client` [full documentation](https://github.com/Cylix/cpp_redis/wiki/Redis-Client) and [detailed example](https://github.com/Cylix/cpp_redis/wiki/Examples#redis-client).
30+
`cpp_redis::client` [full documentation](https://github.com/Cylix/cpp_redis/wiki/Redis-Client) and [detailed example](https://github.com/Cylix/cpp_redis/wiki/Examples#redis-client).
2731
More about [cpp_redis::reply](https://github.com/Cylix/cpp_redis/wiki/Replies).
2832

29-
### cpp_redis::redis_subscriber
33+
### cpp_redis::subscriber
3034
```cpp
31-
cpp_redis::redis_subscriber sub;
35+
cpp_redis::subscriber sub;
3236

3337
sub.connect();
3438

@@ -40,45 +44,24 @@ sub.psubscribe("*", [](const std::string& chan, const std::string& msg) {
4044
});
4145

4246
sub.sync_commit();
43-
# or sub.commit(); for synchronous call
44-
```
45-
`cpp_redis::redis_subscriber` [full documentation](https://github.com/Cylix/cpp_redis/wiki/Redis-Subscriber) and [detailed example](https://github.com/Cylix/cpp_redis/wiki/Examples#redis-subscriber).
46-
47-
### cpp_redis::future_client
48-
```cpp
49-
cpp_redis::future_client client;
50-
51-
client.connect();
52-
53-
auto set = client.set("hello", "42");
54-
auto decrby = client.decrby("hello", 12);
55-
auto get = client.get("hello");
56-
57-
client.sync_commit();
58-
# or client.commit(); for synchronous call
59-
60-
std::cout << "set 'hello' 42: " << set.get() << std::endl;
61-
std::cout << "After 'hello' decrement by 12: " << decrby.get() << std::endl;
62-
std::cout << "get 'hello': " << get.get() << std::endl;
47+
//! or sub.commit(); for synchronous call
6348
```
64-
`cpp_redis::future_client` [full documentation](https://github.com/Cylix/cpp_redis/wiki/Future-Client) and [detailed example](https://github.com/Cylix/cpp_redis/wiki/Examples#future-client).
49+
`cpp_redis::subscriber` [full documentation](https://github.com/Cylix/cpp_redis/wiki/Redis-Subscriber) and [detailed example](https://github.com/Cylix/cpp_redis/wiki/Examples#redis-subscriber).
6550

6651
## Wiki
6752
A [Wiki](https://github.com/Cylix/cpp_redis/wiki) is available and provides full documentation for the library as well as [installation explanations](https://github.com/Cylix/cpp_redis/wiki/Installation).
6853

54+
# Doxygen
55+
A [Doxygen documentation](https://cylix.github.io/cpp_redis/html/index.html) is available and provides full API documentation for the library.
56+
6957
## License
7058
`cpp_redis` is under [MIT License](LICENSE).
7159

7260
## Contributing
7361
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
7462

7563
## Special Thanks
76-
77-
* [Frank Pagliughi](https://github.com/fpagliughi) for adding support of futures to the library
78-
* [Mike Moening](https://github.com/MikesAracade) for his unexpected and incredible great work aiming to port cpp_redis on Windows!
79-
* [Tobias Gustafsson](https://github.com/tobbe303) for contributing and reporting issues
80-
* Alexis Vasseur for reporting me issues and spending time helping me debugging
81-
* Pawel Lopko for reporting me issues
64+
[Mike Moening](https://github.com/MikesAracade) for his unexpected and incredible great work aiming to port cpp_redis on Windows, provides sentinel support and high availability support!
8265

8366
## Author
8467
[Simon Ninon](http://simon-ninon.fr)

0 commit comments

Comments
 (0)