-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aleksandr Ivanov <[email protected]>
- Loading branch information
1 parent
d9224b5
commit a98f3b0
Showing
10 changed files
with
382 additions
and
75 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
56 changes: 56 additions & 0 deletions
56
src/applications/bmqstoragetool/m_bmqstoragetool_filters.cpp
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,56 @@ | ||
// Copyright 2014-2023 Bloomberg Finance L.P. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed 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. | ||
|
||
// m_bmqstoragetool_filters.cpp -*-C++-*- | ||
|
||
#include <m_bmqstoragetool_filters.h> | ||
|
||
namespace BloombergLP { | ||
namespace m_bmqstoragetool { | ||
|
||
// ===================== | ||
// class Filters | ||
// ===================== | ||
|
||
Filters::Filters(const bsl::vector<bsl::string>& queueHexKeys, | ||
const bsl::vector<bsl::string>& queueURIS, | ||
bslma::Allocator* allocator) | ||
: d_queueKeys(allocator) | ||
{ | ||
if (!queueHexKeys.empty()) { | ||
for (auto& key : queueHexKeys) { | ||
d_queueKeys.push_back( | ||
mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), | ||
key.c_str())); | ||
} | ||
} | ||
} | ||
|
||
bool Filters::apply(const mqbs::MessageRecord& record) | ||
{ | ||
if (!d_queueKeys.empty()) | ||
// Match by queueKey | ||
if (auto it = bsl::find(d_queueKeys.begin(), | ||
d_queueKeys.end(), | ||
record.queueKey()); | ||
it == d_queueKeys.end()) { | ||
// Not matched | ||
return false; // RETURN | ||
} | ||
return true; | ||
} | ||
|
||
} // close package namespace | ||
} // close enterprise namespace |
51 changes: 51 additions & 0 deletions
51
src/applications/bmqstoragetool/m_bmqstoragetool_filters.h
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,51 @@ | ||
// Copyright 2014-2023 Bloomberg Finance L.P. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed 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. | ||
|
||
// m_bmqstoragetool_filters.h -*-C++-*- | ||
#ifndef INCLUDED_M_BMQSTORAGETOOL_FILTERS | ||
#define INCLUDED_M_BMQSTORAGETOOL_FILTERS | ||
|
||
#include <m_bmqstoragetool_parameters.h> | ||
|
||
// MQB | ||
#include <mqbu_storagekey.h> | ||
|
||
namespace BloombergLP { | ||
namespace m_bmqstoragetool { | ||
|
||
// ===================== | ||
// class Filters | ||
// ===================== | ||
|
||
class Filters { | ||
private: | ||
// DATA | ||
bsl::vector<mqbu::StorageKey> d_queueKeys; | ||
|
||
public: | ||
// CREATORS | ||
explicit Filters(const bsl::vector<bsl::string>& queueHexKeys, | ||
const bsl::vector<bsl::string>& queueURIS, | ||
bslma::Allocator* allocator); | ||
|
||
// MANIPULATORS | ||
bool apply(const mqbs::MessageRecord& record); | ||
// Apply filters and return true if filter matched, false otherwise. | ||
}; | ||
|
||
} // close package namespace | ||
} // close enterprise namespace | ||
|
||
#endif |
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.