ORE Studio 0.0.4
Loading...
Searching...
No Matches
jetstream_admin.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_NATS_SERVICE_JETSTREAM_ADMIN_HPP
21#define ORES_NATS_SERVICE_JETSTREAM_ADMIN_HPP
22
23#include <cstdint>
24#include <string>
25#include <string_view>
26#include <vector>
27#include "ores.nats/domain/consumer_info.hpp"
28#include "ores.nats/domain/stream_info.hpp"
29#include "ores.nats/domain/stream_message.hpp"
30
31namespace ores::nats::service {
32
54public:
60 explicit jetstream_admin(void* js_ctx) noexcept;
61
62 // -------------------------------------------------------------------------
63 // Streams
64 // -------------------------------------------------------------------------
65
69 [[nodiscard]] std::vector<domain::stream_info> list_streams();
70
74 [[nodiscard]] domain::stream_info get_stream(std::string_view name);
75
80 void purge_stream(std::string_view name);
81
82 // -------------------------------------------------------------------------
83 // Consumers
84 // -------------------------------------------------------------------------
85
89 [[nodiscard]] std::vector<domain::consumer_info>
90 list_consumers(std::string_view stream_name);
91
92 // -------------------------------------------------------------------------
93 // Messages
94 // -------------------------------------------------------------------------
95
99 [[nodiscard]] domain::stream_message
100 peek_message(std::string_view stream_name, std::uint64_t sequence);
101
105 [[nodiscard]] domain::stream_message
106 peek_last_message(std::string_view stream_name,
107 std::string_view subject);
108
114 void delete_message(std::string_view stream_name, std::uint64_t sequence);
115
122 void publish(std::string_view subject, std::string_view payload);
123
124private:
125 void* js_ctx_; // opaque jsCtx*; not owned
126};
127
128}
129
130#endif
Metadata for a JetStream stream.
Definition stream_info.hpp:36
A message stored in a JetStream stream.
Definition stream_message.hpp:38
JetStream management API.
Definition jetstream_admin.hpp:53
void delete_message(std::string_view stream_name, std::uint64_t sequence)
Delete a message by sequence number.
Definition jetstream_admin.cpp:242
void purge_stream(std::string_view name)
Purge all messages from a stream (non-destructive to the stream itself — consumers and configuration ...
Definition jetstream_admin.cpp:136
domain::stream_info get_stream(std::string_view name)
Get metadata for a single stream by name.
Definition jetstream_admin.cpp:119
std::vector< domain::stream_info > list_streams()
List all streams on the connected NATS server.
Definition jetstream_admin.cpp:98
std::vector< domain::consumer_info > list_consumers(std::string_view stream_name)
List all consumers for a stream.
Definition jetstream_admin.cpp:153
domain::stream_message peek_message(std::string_view stream_name, std::uint64_t sequence)
Peek at a message by sequence number (non-destructive).
Definition jetstream_admin.cpp:180
domain::stream_message peek_last_message(std::string_view stream_name, std::string_view subject)
Peek at the last message published to a subject (non-destructive).
Definition jetstream_admin.cpp:210
void publish(std::string_view subject, std::string_view payload)
Publish a message to a JetStream subject.
Definition jetstream_admin.cpp:255