rabbitmq-server/deps/rabbitmq_stream_common/include/rabbit_stream.hrl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

156 lines
4.2 KiB
Erlang
Raw Permalink Normal View History

%% The contents of this file are subject to the Mozilla Public 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 https://www.mozilla.org/en-US/MPL/2.0/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and
%% limitations under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is Pivotal Software, Inc.
%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
%%
2021-02-26 18:48:45 +08:00
-define(COMMAND_DECLARE_PUBLISHER, 1).
-define(COMMAND_PUBLISH, 2).
-define(COMMAND_PUBLISH_CONFIRM, 3).
-define(COMMAND_PUBLISH_ERROR, 4).
-define(COMMAND_QUERY_PUBLISHER_SEQUENCE, 5).
-define(COMMAND_DELETE_PUBLISHER, 6).
-define(COMMAND_SUBSCRIBE, 7).
-define(COMMAND_DELIVER, 8).
-define(COMMAND_CREDIT, 9).
-define(COMMAND_STORE_OFFSET, 10).
2021-02-26 18:48:45 +08:00
-define(COMMAND_QUERY_OFFSET, 11).
-define(COMMAND_UNSUBSCRIBE, 12).
-define(COMMAND_CREATE_STREAM, 13).
-define(COMMAND_DELETE_STREAM, 14).
-define(COMMAND_METADATA, 15).
-define(COMMAND_METADATA_UPDATE, 16).
-define(COMMAND_PEER_PROPERTIES, 17).
-define(COMMAND_SASL_HANDSHAKE, 18).
-define(COMMAND_SASL_AUTHENTICATE, 19).
-define(COMMAND_TUNE, 20).
-define(COMMAND_OPEN, 21).
-define(COMMAND_CLOSE, 22).
-define(COMMAND_HEARTBEAT, 23).
-define(COMMAND_ROUTE, 24).
-define(COMMAND_PARTITIONS, 25).
-define(COMMAND_CONSUMER_UPDATE, 26).
-define(COMMAND_EXCHANGE_COMMAND_VERSIONS, 27).
-define(COMMAND_STREAM_STATS, 28).
-define(COMMAND_CREATE_SUPER_STREAM, 29).
-define(COMMAND_DELETE_SUPER_STREAM, 30).
2020-03-25 17:08:10 +08:00
-define(REQUEST, 0).
-define(RESPONSE, 1).
2021-02-26 18:48:45 +08:00
-define(VERSION_1, 1).
-define(VERSION_2, 2).
2020-03-25 17:08:10 +08:00
2021-02-26 18:48:45 +08:00
-define(RESPONSE_CODE_OK, 1).
-define(RESPONSE_CODE_STREAM_DOES_NOT_EXIST, 2).
-define(RESPONSE_CODE_SUBSCRIPTION_ID_ALREADY_EXISTS, 3).
-define(RESPONSE_CODE_SUBSCRIPTION_ID_DOES_NOT_EXIST, 4).
-define(RESPONSE_CODE_STREAM_ALREADY_EXISTS, 5).
-define(RESPONSE_CODE_STREAM_NOT_AVAILABLE, 6).
-define(RESPONSE_SASL_MECHANISM_NOT_SUPPORTED, 7).
-define(RESPONSE_AUTHENTICATION_FAILURE, 8).
-define(RESPONSE_SASL_ERROR, 9).
-define(RESPONSE_SASL_CHALLENGE, 10).
-define(RESPONSE_SASL_AUTHENTICATION_FAILURE_LOOPBACK, 11).
-define(RESPONSE_VHOST_ACCESS_FAILURE, 12).
-define(RESPONSE_CODE_UNKNOWN_FRAME, 13).
-define(RESPONSE_CODE_FRAME_TOO_LARGE, 14).
-define(RESPONSE_CODE_INTERNAL_ERROR, 15).
-define(RESPONSE_CODE_ACCESS_REFUSED, 16).
-define(RESPONSE_CODE_PRECONDITION_FAILED, 17).
-define(RESPONSE_CODE_PUBLISHER_DOES_NOT_EXIST, 18).
-define(RESPONSE_CODE_NO_OFFSET, 19).
-define(RESPONSE_SASL_CANNOT_CHANGE_MECHANISM, 20).
-define(RESPONSE_SASL_CANNOT_CHANGE_USERNAME, 21).
2020-03-27 00:52:54 +08:00
-define(OFFSET_TYPE_NONE, 0).
2021-02-26 18:48:45 +08:00
-define(OFFSET_TYPE_FIRST, 1).
-define(OFFSET_TYPE_LAST, 2).
-define(OFFSET_TYPE_NEXT, 3).
-define(OFFSET_TYPE_OFFSET, 4).
-define(OFFSET_TYPE_TIMESTAMP, 5).
2020-03-27 00:52:54 +08:00
-define(DEFAULT_INITIAL_CREDITS, 50000).
-define(DEFAULT_CREDITS_REQUIRED_FOR_UNBLOCKING, 12500).
2020-10-12 22:05:34 +08:00
-define(DEFAULT_FRAME_MAX, 1048576). %% 1 MiB
-define(DEFAULT_HEARTBEAT, 60). %% 60 seconds
Global counters per protocol + protocol AND queue_type This way we can show how many messages were received via a certain protocol (stream is the second real protocol besides the default amqp091 one), as well as by queue type, which is something that many asked for a really long time. The most important aspect is that we can also see them by protocol AND queue_type, which becomes very important for Streams, which have different rules from regular queues (e.g. for example, consuming messages is non-destructive, and deep queue backlogs - think billions of messages - are normal). Alerting and consumer scaling due to deep backlogs will now work correctly, as we can distinguish between regular queues & streams. This has gone through a few cycles, with @mkuratczyk & @dcorbacho covering most of the ground. @dcorbacho had most of this in https://github.com/rabbitmq/rabbitmq-server/pull/3045, but the main branch went through a few changes in the meantime. Rather than resolving all the conflicts, and then making the necessary changes, we (@gerhard + @kjnilsson) took all learnings and started re-applying a lot of the existing code from #3045. We are confident in this approach and would like to see it through. We continued working on this with @dumbbell, and the most important changes are captured in https://github.com/rabbitmq/seshat/pull/1. We expose these global counters in rabbitmq_prometheus via a new collector. We don't want to keep modifying the existing collector, which grew really complex in parts, especially since we introduced aggregation, but start with a new namespace, `rabbitmq_global_`, and continue building on top of it. The idea is to build in parallel, and slowly transition to the new metrics, because semantically the changes are too big since streams, and we have been discussing protocol-specific metrics with @kjnilsson, which makes me think that this approach is least disruptive and... simple. While at this, we removed redundant empty return value handling in the channel. The function called no longer returns this. Also removed all DONE / TODO & other comments - we'll handle them when the time comes, no need to leave TODO reminders. Pairs @kjnilsson @dcorbacho @dumbbell (this is multiple commits squashed into one) Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2021-05-21 00:16:17 +08:00
-define(STREAM_QUEUE_TYPE, rabbit_stream_queue).
-define(INFO_ITEMS,
[conn_name,
pid,
node,
port,
peer_port,
host,
peer_cert_issuer,
peer_cert_subject,
peer_cert_validity,
peer_host,
user,
vhost,
subscriptions,
ssl,
ssl_cipher,
ssl_hash,
ssl_key_exchange,
ssl_protocol,
connection_state,
auth_mechanism,
heartbeat,
frame_max,
client_properties,
connected_at
]).
2021-01-19 18:31:39 +08:00
-define(CONSUMER_INFO_ITEMS, [
connection_pid,
node,
2021-01-19 18:31:39 +08:00
subscription_id,
stream,
messages_consumed,
offset,
offset_lag,
credits,
active,
activity_status,
properties
2021-01-19 18:31:39 +08:00
]).
2021-01-19 21:49:30 +08:00
-define(PUBLISHER_INFO_ITEMS, [
connection_pid,
node,
2021-01-19 21:49:30 +08:00
publisher_id,
stream,
2021-01-19 21:49:30 +08:00
reference,
messages_published,
messages_confirmed,
messages_errored
]).
-define(CONSUMER_GROUP_INFO_ITEMS, [
stream,
reference,
partition_index,
consumers
]).
-define(GROUP_CONSUMER_INFO_ITEMS, [
subscription_id,
connection_name,
state
]).
-define(STREAMS_GUIDE_URL, <<"https://rabbitmq.com/docs/streams">>).