ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_handler.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_IAM_MESSAGING_SESSION_HANDLER_HPP
21#define ORES_IAM_MESSAGING_SESSION_HANDLER_HPP
22
23#include "ores.logging/make_logger.hpp"
24#include "ores.nats/domain/message.hpp"
25#include "ores.nats/service/client.hpp"
26#include "ores.database/domain/context.hpp"
27#include "ores.security/jwt/jwt_authenticator.hpp"
28#include "ores.service/messaging/handler_helpers.hpp"
29#include "ores.iam.api/messaging/session_protocol.hpp"
30#include "ores.iam.api/messaging/session_samples_protocol.hpp"
31
32namespace ores::iam::messaging {
33
34namespace {
35
36inline auto& session_handler_lg() {
37 static auto instance = ores::logging::make_logger(
38 "ores.iam.messaging.session_handler");
39 return instance;
40}
41
42} // namespace
43
44using ores::service::messaging::reply;
45using ores::service::messaging::decode;
46
47class session_handler {
48public:
49 session_handler(ores::nats::service::client& nats,
52 : nats_(nats), ctx_(std::move(ctx)), signer_(std::move(signer)) {}
53
54 void list(ores::nats::message msg) {
55 using namespace ores::logging;
56 BOOST_LOG_SEV(session_handler_lg(), debug)
57 << "Handling " << msg.subject;
58 BOOST_LOG_SEV(session_handler_lg(), debug)
59 << "Completed " << msg.subject;
60 reply(nats_, msg, list_sessions_response{});
61 }
62
63 void active(ores::nats::message msg) {
64 using namespace ores::logging;
65 BOOST_LOG_SEV(session_handler_lg(), debug)
66 << "Handling " << msg.subject;
67 BOOST_LOG_SEV(session_handler_lg(), debug)
68 << "Completed " << msg.subject;
69 reply(nats_, msg, get_active_sessions_response{});
70 }
71
72 void samples(ores::nats::message msg) {
73 using namespace ores::logging;
74 BOOST_LOG_SEV(session_handler_lg(), debug)
75 << "Handling " << msg.subject;
76 BOOST_LOG_SEV(session_handler_lg(), debug)
77 << "Completed " << msg.subject;
78 reply(nats_, msg, get_session_samples_response{});
79 }
80
81private:
85};
86
87} // namespace ores::iam::messaging
88#endif
STL namespace.
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
A received NATS message.
Definition message.hpp:40
std::string subject
The subject the message was published to.
Definition message.hpp:44
NATS client: connection, pub/sub, request/reply, and JetStream.
Definition client.hpp:73
JWT authentication primitive.
Definition jwt_authenticator.hpp:45