ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_entity.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_REPOSITORY_SESSION_ENTITY_HPP
21#define ORES_IAM_REPOSITORY_SESSION_ENTITY_HPP
22
23#include <string>
24#include <cstdint>
25#include <optional>
26#include "sqlgen/Timestamp.hpp"
27#include "sqlgen/PrimaryKey.hpp"
28
29namespace ores::iam::repository {
30
38 constexpr static const char* schema = "production";
39 constexpr static const char* tablename = "iam_sessions_tbl";
40
44 sqlgen::PrimaryKey<std::string> id;
45
49 std::string account_id;
50
56 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> start_time;
57
65 std::string end_time;
66
70 std::string client_ip;
71
75 std::string client_identifier;
76
81
86
90 std::int64_t bytes_sent = 0;
91
95 std::int64_t bytes_received = 0;
96
100 std::string country_code;
101
105 std::string protocol = "binary";
106};
107
108std::ostream& operator<<(std::ostream& s, const session_entity& v);
109
114 constexpr static const char* schema = "production";
115 constexpr static const char* tablename = "iam_session_stats_tbl";
116
117 std::string day;
118 std::string account_id;
119 std::int64_t session_count = 0;
120 double avg_duration_seconds = 0.0;
121 std::int64_t total_bytes_sent = 0;
122 std::int64_t total_bytes_received = 0;
123};
124
125std::ostream& operator<<(std::ostream& s, const session_statistics_entity& v);
126
127}
128
129#endif
Database persistence layer for IAM domain types.
Definition account_entity.hpp:27
Represents a session record in the database.
Definition session_entity.hpp:37
std::string client_identifier
Client application identifier from handshake.
Definition session_entity.hpp:75
std::string client_ip
Client IP address (IPv4 or IPv6).
Definition session_entity.hpp:70
sqlgen::PrimaryKey< std::string > id
Session UUID - part of composite primary key.
Definition session_entity.hpp:44
sqlgen::PrimaryKey< sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> > start_time
Session start timestamp - part of composite primary key.
Definition session_entity.hpp:56
std::int64_t bytes_sent
Total bytes sent to client.
Definition session_entity.hpp:90
std::string account_id
Foreign key to accounts table.
Definition session_entity.hpp:49
std::int64_t bytes_received
Total bytes received from client.
Definition session_entity.hpp:95
int client_version_major
Client protocol version major number.
Definition session_entity.hpp:80
std::string protocol
Protocol used for this session (binary or http).
Definition session_entity.hpp:105
std::string country_code
ISO 3166-1 alpha-2 country code.
Definition session_entity.hpp:100
int client_version_minor
Client protocol version minor number.
Definition session_entity.hpp:85
std::string end_time
Session end timestamp. Empty string if session is active.
Definition session_entity.hpp:65
Entity for session statistics from continuous aggregates.
Definition session_entity.hpp:113