-
Notifications
You must be signed in to change notification settings - Fork 100
MINIFICPP-2764 Controller Service CPP API #2152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f36998f
MINIFICPP-2764 Controller Service CPP API
martinzink d40b59e
rebase fix
martinzink 0bb815e
useProcessorClassDescription -> useProcessorClassDefinition
martinzink a396029
add explanatory comments to ControllerServiceImpl.h
martinzink ee86904
notifyStop -> disable in CPP API aswell
martinzink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
extension-framework/cpp-extension-lib/include/api/core/ControllerServiceContext.h
This file contains hidden or 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,41 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <expected> | ||
|
|
||
| #include "minifi-c.h" | ||
| #include "minifi-cpp/core/PropertyDefinition.h" | ||
|
|
||
| namespace org::apache::nifi::minifi::api::core { | ||
|
|
||
| class ControllerServiceContext { | ||
| public: | ||
| explicit ControllerServiceContext(MinifiControllerServiceContext* impl) : impl_(impl) {} | ||
|
|
||
| [[nodiscard]] std::expected<std::string, std::error_code> getProperty(std::string_view name) const; | ||
| [[nodiscard]] std::expected<std::string, std::error_code> getProperty(const minifi::core::PropertyReference& property_reference) const { | ||
| return getProperty(property_reference.name); | ||
| } | ||
|
|
||
| private: | ||
| MinifiControllerServiceContext* impl_; | ||
| }; | ||
|
|
||
| } // namespace org::apache::nifi::minifi::api::core |
63 changes: 63 additions & 0 deletions
63
extension-framework/cpp-extension-lib/include/api/core/ControllerServiceImpl.h
This file contains hidden or 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,63 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "ControllerServiceContext.h" | ||
| #include "minifi-cpp/core/ControllerServiceMetadata.h" | ||
| #include "minifi-cpp/utils/Id.h" | ||
| #include "utils/SmallString.h" | ||
|
|
||
| namespace org::apache::nifi::minifi::api { | ||
|
|
||
| class Connection; | ||
|
|
||
| namespace core { | ||
|
|
||
| /// Helper class that makes implementing the stable API easier | ||
| /// It is used in conjunction with useControllerServiceClassDefinition | ||
| class ControllerServiceImpl { | ||
|
szaszm marked this conversation as resolved.
|
||
| public: | ||
| explicit ControllerServiceImpl(minifi::core::ControllerServiceMetadata metadata); | ||
|
|
||
| ControllerServiceImpl(const ControllerServiceImpl&) = delete; | ||
| ControllerServiceImpl(ControllerServiceImpl&&) = delete; | ||
| ControllerServiceImpl& operator=(const ControllerServiceImpl&) = delete; | ||
| ControllerServiceImpl& operator=(ControllerServiceImpl&&) = delete; | ||
|
|
||
| virtual ~ControllerServiceImpl(); | ||
|
|
||
| MinifiStatus enable(ControllerServiceContext&); | ||
| void disable(); | ||
|
|
||
| [[nodiscard]] std::string getName() const; | ||
| [[nodiscard]] minifi::utils::Identifier getUUID() const; | ||
| [[nodiscard]] minifi::utils::SmallString<36> getUUIDStr() const; | ||
|
|
||
| protected: | ||
| virtual MinifiStatus enableImpl(api::core::ControllerServiceContext&) = 0; | ||
| virtual void disableImpl() {} | ||
|
|
||
| minifi::core::ControllerServiceMetadata metadata_; | ||
|
|
||
| std::shared_ptr<minifi::core::logging::Logger> logger_; | ||
| }; | ||
|
|
||
| } // namespace core | ||
| } // namespace org::apache::nifi::minifi::api | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
40 changes: 40 additions & 0 deletions
40
extension-framework/cpp-extension-lib/src/core/ControllerServiceContext.cpp
This file contains hidden or 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,40 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "api/core/ControllerServiceContext.h" | ||
| #include "api/utils/minifi-c-utils.h" | ||
|
|
||
| namespace org::apache::nifi::minifi::api::core { | ||
|
|
||
| std::expected<std::string, std::error_code> ControllerServiceContext::getProperty(const std::string_view name) const { | ||
| std::optional<std::string> value = std::nullopt; | ||
| const MinifiStatus status = MinifiControllerServiceContextGetProperty(impl_, utils::toStringView(name), | ||
| [] (void* data, const MinifiStringView result) { | ||
| (*static_cast<std::optional<std::string>*>(data)) = std::string(result.data, result.length); | ||
| }, &value); | ||
|
|
||
| if (status != MINIFI_STATUS_SUCCESS) { | ||
| return std::unexpected{utils::make_error_code(status)}; | ||
| } | ||
|
|
||
| if (!value) { | ||
| return std::unexpected{utils::make_error_code(MINIFI_STATUS_UNKNOWN_ERROR)}; | ||
| } | ||
| return value.value(); | ||
| } | ||
|
|
||
| } // namespace org::apache::nifi::minifi::api::core |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.