-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interceptors for threads (start, exit)
- Loading branch information
1 parent
5ce1f8c
commit 7418ab3
Showing
10 changed files
with
284 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <kafka/Project.h> | ||
|
||
#include <functional> | ||
|
||
|
||
namespace KAFKA_API { namespace clients { | ||
|
||
class Interceptors | ||
{ | ||
public: | ||
using ThreadStartCallback = std::function<void(const std::string&, const std::string&)>; | ||
using ThreadExitCallback = std::function<void(const std::string&, const std::string&)>; | ||
|
||
Interceptors& onThreadStart(ThreadStartCallback cb) { _valid = true; _threadStartCb = std::move(cb); return *this; } | ||
Interceptors& onThreadExit(ThreadExitCallback cb) { _valid = true; _threadExitCb = std::move(cb); return *this; } | ||
|
||
ThreadStartCallback onThreadStart() const { return _threadStartCb; } | ||
ThreadExitCallback onThreadExit() const { return _threadExitCb; } | ||
|
||
bool empty() const { return !_valid; } | ||
|
||
private: | ||
ThreadStartCallback _threadStartCb; | ||
ThreadExitCallback _threadExitCb; | ||
bool _valid = false; | ||
}; | ||
|
||
} } // end of KAFKA_API::clients | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.