Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2023 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #ifndef FIREBOLT_RIALTO_SERVER_I_CONTROL_SERVER_INTERNAL_H_
21 : #define FIREBOLT_RIALTO_SERVER_I_CONTROL_SERVER_INTERNAL_H_
22 :
23 : /**
24 : * @file IControlServerInternal.h
25 : *
26 : * The definition of the IControlServerInternal interface.
27 : *
28 : * This interface defines the server internal API of Rialto for controlling rialto clients.
29 : */
30 :
31 : #include "IControl.h"
32 : #include "IControlClientServerInternal.h"
33 : #include "IHeartbeatHandler.h"
34 : #include <memory>
35 :
36 : namespace firebolt::rialto::server
37 : {
38 : class IControlServerInternal;
39 : class IControlServerInternalFactory : public IControlFactory
40 : {
41 : public:
42 10 : IControlServerInternalFactory() = default;
43 10 : ~IControlServerInternalFactory() override = default;
44 :
45 : /**
46 : * @brief Create a IControlServerInternalFactory instance.
47 : *
48 : * @retval the factory instance or null on error.
49 : */
50 : static std::shared_ptr<IControlServerInternalFactory> createFactory();
51 :
52 : /**
53 : * @brief IControlServerInternal factory method, returns a concrete implementation of IControlServerInternal
54 : *
55 : * @param[in] id : Control id
56 : * @param[in] client : Client object for callbacks
57 : *
58 : * @retval the new IControlServerInternal instance or null on error.
59 : */
60 : virtual std::shared_ptr<IControlServerInternal>
61 : createControlServerInternal(int id, const std::shared_ptr<IControlClientServerInternal> &client) const = 0;
62 : };
63 :
64 : class IControlServerInternal : public IControl
65 : {
66 : public:
67 20 : IControlServerInternal() = default;
68 20 : virtual ~IControlServerInternal() = default;
69 :
70 : /**
71 : * @brief Informs connected rialto client about rialto server state change
72 : *
73 : * @param[in] state: The new application state.
74 : */
75 : virtual void setApplicationState(const ApplicationState &state) = 0;
76 :
77 : /**
78 : * @brief Acknowledgement of a received ping request
79 : *
80 : * @param[in] id : id received in ping notification
81 : */
82 : virtual void ack(int32_t id) = 0;
83 :
84 : /**
85 : * @brief Ping notification for checking system health
86 : * The client should perform any health checks then respond with
87 : * a call to ack(id) if system healthy
88 : *
89 : * @param[in] heartbeatHandler : Handler of current heartbeat request
90 : */
91 : virtual void ping(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) = 0;
92 : };
93 : } // namespace firebolt::rialto::server
94 :
95 : #endif // FIREBOLT_RIALTO_SERVER_I_CONTROL_SERVER_INTERNAL_H_
|