-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make it possible to build tests in STUB_ONLY mode
- Loading branch information
1 parent
a29756e
commit d8d187c
Showing
8 changed files
with
146 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright 2018-2024 Project Tsurugi. | ||
* | ||
* 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <functional> | ||
#include <memory> | ||
#include <type_traits> | ||
|
||
namespace tateyama::framework { | ||
|
||
class environment; | ||
|
||
/** | ||
* @brief base class for tateyama components whose life-cycle is managed by the framework | ||
*/ | ||
class component { | ||
public: | ||
/** | ||
* @brief type to identify components | ||
* @details the id must be unique among each categories of components (e.g. resource, service) | ||
* Users custom module should use one larger than `max_system_reserved_id`. | ||
*/ | ||
using id_type = std::uint32_t; | ||
|
||
/** | ||
* @brief maximum id reserved for built-in system resources/services | ||
*/ | ||
static constexpr id_type max_system_reserved_id = 255; | ||
|
||
/** | ||
* @brief construct new object | ||
*/ | ||
component() = default; | ||
|
||
component(component const& other) = delete; | ||
component& operator=(component const& other) = delete; | ||
component(component&& other) noexcept = delete; | ||
component& operator=(component&& other) noexcept = delete; | ||
|
||
/** | ||
* @brief setup the component (the state will be `ready`) | ||
* @return true when setup completed successfully | ||
* @return false otherwise | ||
*/ | ||
virtual bool setup(environment&) = 0; | ||
|
||
/** | ||
* @brief start the component (the state will be `activated`) | ||
* @return true when start completed successfully | ||
* @return false otherwise | ||
*/ | ||
virtual bool start(environment&) = 0; | ||
|
||
/** | ||
* @brief shutdown the component (the state will be `deactivated`) | ||
* @return true when shutdown completed successfully, or component is already deactivated | ||
* @return false otherwise | ||
* @note shutdown is an idempotent operation, meaning second call to the already deactivated component should be | ||
* simply ignored and return true. | ||
*/ | ||
virtual bool shutdown(environment&) = 0; | ||
|
||
/** | ||
* @brief destruct the object (the state will be `disposed`) | ||
*/ | ||
virtual ~component() = default; | ||
|
||
/** | ||
* @brief list the section names in the config. file that this component is affected | ||
* @return the list of section name | ||
*/ | ||
// TODO implement to validate config file | ||
//virtual std::vector<std::string> configuration_sections() = 0; | ||
|
||
/** | ||
* @brief fetch human readable label of this component (not necessarily unique) | ||
* @return the label for this component | ||
*/ | ||
[[nodiscard]] virtual std::string_view label() const noexcept = 0; | ||
}; | ||
|
||
} | ||
|
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,45 @@ | ||
/* | ||
* Copyright 2018-2023 Project Tsurugi. | ||
* | ||
* 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <tateyama/framework/component.h> | ||
|
||
namespace tateyama::framework { | ||
|
||
// resource | ||
constexpr inline component::id_type resource_id_task_scheduler = 0; | ||
constexpr inline component::id_type resource_id_transactional_kvs = 1; | ||
constexpr inline component::id_type resource_id_sql = 2; | ||
constexpr inline component::id_type resource_id_datastore = 3; | ||
constexpr inline component::id_type resource_id_session = 4; | ||
constexpr inline component::id_type resource_id_status = 5; | ||
//constexpr inline component::id_type resource_id_mutex = 6; | ||
constexpr inline component::id_type resource_id_diagnostic = 7; | ||
constexpr inline component::id_type resource_id_remote_kvs = 8; | ||
constexpr inline component::id_type resource_id_metrics = 9; | ||
|
||
// service | ||
constexpr inline component::id_type service_id_routing = 0; | ||
constexpr inline component::id_type service_id_endpoint_broker = 1; | ||
constexpr inline component::id_type service_id_datastore = 2; | ||
constexpr inline component::id_type service_id_sql = 3; | ||
constexpr inline component::id_type service_id_fdw = 4; | ||
constexpr inline component::id_type service_id_remote_kvs = 5; | ||
constexpr inline component::id_type service_id_debug = 6; | ||
constexpr inline component::id_type service_id_session = 7; | ||
constexpr inline component::id_type service_id_metrics = 8; | ||
|
||
} |
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