From 91599d31a06f3aa65379ee321dc6b12b7677951f Mon Sep 17 00:00:00 2001 From: VivekPipaliya23 <147689085+VivekPipaliya23@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:51:23 +0530 Subject: [PATCH] feat: add reason parameter in disconnect events (#34) * feat: add reason parameter in disconnect events * fix : map required disconnect reason to events * fix : review revisions * fix : add empty line at the EOF. * fix : remove package import * refactor : move PUBLISH_AUTH_ERROR reason mapping to common function * add metrics for tracking different reasons * fix : update metric description * fix : remove duplicate reason mapping * fix : update reason mapping according to proto and add combination of reason code and name in metric * refactor : use macros for reason mapping * fix : test mqtt5_disconnect_sent - tcp_closed not found * fix : mqtt5 tcp closed and exit signal reason mapping --------- Co-authored-by: Vivek Pipaliya --- apps/vmq_diversity/src/vmq_diversity.app.src | 4 +- .../src/vmq_diversity_plugin.erl | 8 +- .../test/vmq_diversity_auth_cache_SUITE.erl | 3 +- .../test/vmq_diversity_plugin_SUITE.erl | 5 +- .../include/vmq_events_sidecar.hrl | 1 + .../src/vmq_events_sidecar.app.src | 4 +- .../src/vmq_events_sidecar_format.erl | 10 +- .../src/vmq_events_sidecar_plugin.erl | 16 +- .../test/events_sidecar_handler.erl | 4 +- .../test/vmq_events_sidecar_SUITE.erl | 4 +- .../test/vmq_events_sidecar_test.hrl | 1 + .../include/disconnect_reason_pb.hrl | 10 + apps/vmq_proto/include/on_client_gone_pb.hrl | 28 +- .../include/on_client_offline_pb.hrl | 28 +- apps/vmq_proto/proto/disconnect_reason.proto | 24 + apps/vmq_proto/proto/on_client_gone.proto | 4 +- apps/vmq_proto/proto/on_client_offline.proto | 4 +- apps/vmq_proto/src/disconnect_reason_pb.erl | 458 +++++++++++++++++ apps/vmq_proto/src/on_client_gone_pb.erl | 472 ++++++++++++++--- apps/vmq_proto/src/on_client_offline_pb.erl | 481 +++++++++++++++--- apps/vmq_server/src/vmq_metrics.erl | 56 +- apps/vmq_server/src/vmq_metrics.hrl | 19 + apps/vmq_server/src/vmq_mqtt5_fsm.erl | 4 + apps/vmq_server/src/vmq_mqtt_fsm.erl | 22 +- apps/vmq_server/src/vmq_mqtt_fsm_util.erl | 33 +- apps/vmq_server/src/vmq_mqtt_pre_init.erl | 4 +- apps/vmq_server/src/vmq_queue.erl | 27 +- apps/vmq_server/src/vmq_ranch.erl | 4 +- apps/vmq_server/src/vmq_server.hrl | 7 + apps/vmq_server/test/vmq_publish_SUITE.erl | 12 +- .../vmq_server/test/vmq_queue_hooks_SUITE.erl | 20 +- apps/vmq_webhooks/src/vmq_webhooks.app.src | 4 +- apps/vmq_webhooks/src/vmq_webhooks_plugin.erl | 12 +- apps/vmq_webhooks/test/vmq_webhooks_SUITE.erl | 4 +- apps/vmq_webhooks/test/vmq_webhooks_test.hrl | 1 + rebar.lock | 2 +- 36 files changed, 1548 insertions(+), 252 deletions(-) create mode 100644 apps/vmq_proto/include/disconnect_reason_pb.hrl create mode 100644 apps/vmq_proto/proto/disconnect_reason.proto create mode 100644 apps/vmq_proto/src/disconnect_reason_pb.erl diff --git a/apps/vmq_diversity/src/vmq_diversity.app.src b/apps/vmq_diversity/src/vmq_diversity.app.src index e57dda00c..daaab8a09 100644 --- a/apps/vmq_diversity/src/vmq_diversity.app.src +++ b/apps/vmq_diversity/src/vmq_diversity.app.src @@ -53,8 +53,8 @@ {vmq_diversity_plugin, on_offline_message, 5, []}, {vmq_diversity_plugin, on_client_wakeup, 1, []}, - {vmq_diversity_plugin, on_client_offline, 1, []}, - {vmq_diversity_plugin, on_client_gone, 1, []}, + {vmq_diversity_plugin, on_client_offline, 2, []}, + {vmq_diversity_plugin, on_client_gone, 2, []}, {vmq_diversity_plugin, on_session_expired, 1, []} ]}, {db_config, [ diff --git a/apps/vmq_diversity/src/vmq_diversity_plugin.erl b/apps/vmq_diversity/src/vmq_diversity_plugin.erl index 490bb9c0e..b36536ecf 100644 --- a/apps/vmq_diversity/src/vmq_diversity_plugin.erl +++ b/apps/vmq_diversity/src/vmq_diversity_plugin.erl @@ -51,8 +51,8 @@ on_deliver/6, on_offline_message/5, on_client_wakeup/1, - on_client_offline/1, - on_client_gone/1, + on_client_offline/2, + on_client_gone/2, on_session_expired/1, on_delivery_complete/6, auth_on_register_m5/6, @@ -624,7 +624,7 @@ on_client_wakeup(SubscriberId) -> {client_id, ClientId} ]). -on_client_offline(SubscriberId) -> +on_client_offline(SubscriberId, _) -> {MP, ClientId} = subscriber_id(SubscriberId), vmq_diversity_cache:clear_cache(MP, ClientId), all(on_client_offline, [ @@ -632,7 +632,7 @@ on_client_offline(SubscriberId) -> {client_id, ClientId} ]). -on_client_gone(SubscriberId) -> +on_client_gone(SubscriberId, _) -> {MP, ClientId} = subscriber_id(SubscriberId), vmq_diversity_cache:clear_cache(MP, ClientId), all(on_client_gone, [ diff --git a/apps/vmq_diversity/test/vmq_diversity_auth_cache_SUITE.erl b/apps/vmq_diversity/test/vmq_diversity_auth_cache_SUITE.erl index 7cf317114..255afef6d 100644 --- a/apps/vmq_diversity/test/vmq_diversity_auth_cache_SUITE.erl +++ b/apps/vmq_diversity/test/vmq_diversity_auth_cache_SUITE.erl @@ -141,7 +141,7 @@ auth_cache_cleanup_test(_) -> {subscribe, SubscribeAcls}] = vmq_diversity_cache:entries(<<"">>, <<"allowed-subscriber-id">>), 3 = length(PublishAcls), 3 = length(SubscribeAcls), - vmq_plugin:all(on_client_offline, [allowed_subscriber_id()]), + vmq_plugin:all(on_client_offline, [allowed_subscriber_id(), reason()]), [] = vmq_diversity_cache:entries(<<"">>, <<"allowed-subscriber-id">>). @@ -163,3 +163,4 @@ allowed_subscriber_id() -> username() -> <<"test-user">>. password() -> <<"test-password">>. payload() -> <<"hello world">>. +reason() -> normal_disconnect. diff --git a/apps/vmq_diversity/test/vmq_diversity_plugin_SUITE.erl b/apps/vmq_diversity/test/vmq_diversity_plugin_SUITE.erl index cb1ca4131..9b2b7e171 100644 --- a/apps/vmq_diversity/test/vmq_diversity_plugin_SUITE.erl +++ b/apps/vmq_diversity/test/vmq_diversity_plugin_SUITE.erl @@ -136,9 +136,9 @@ on_offline_message_test(_) -> on_client_wakeup_test(_) -> [next] = vmq_plugin:all(on_client_wakeup, [allowed_subscriber_id()]). on_client_offline_test(_) -> - [next] = vmq_plugin:all(on_client_offline, [allowed_subscriber_id()]). + [next] = vmq_plugin:all(on_client_offline, [allowed_subscriber_id(), reason()]). on_client_gone_test(_) -> - [next] = vmq_plugin:all(on_client_gone, [allowed_subscriber_id()]). + [next] = vmq_plugin:all(on_client_gone, [allowed_subscriber_id(), reason()]). on_session_expired_test(_) -> [next] = vmq_plugin:all(on_session_expired, [allowed_subscriber_id()]). @@ -312,3 +312,4 @@ payload() -> <<"hello world">>. subopts() -> #{rap => true, no_local => false}. +reason() -> normal_disconnect. diff --git a/apps/vmq_events_sidecar/include/vmq_events_sidecar.hrl b/apps/vmq_events_sidecar/include/vmq_events_sidecar.hrl index e8694a941..0ecaa165e 100644 --- a/apps/vmq_events_sidecar/include/vmq_events_sidecar.hrl +++ b/apps/vmq_events_sidecar/include/vmq_events_sidecar.hrl @@ -6,4 +6,5 @@ %% types -type event() :: {atom(), integer(), tuple()}. -type pool_size() :: pos_integer(). +-type reason() :: atom(). -endif. diff --git a/apps/vmq_events_sidecar/src/vmq_events_sidecar.app.src b/apps/vmq_events_sidecar/src/vmq_events_sidecar.app.src index 9b4c9ff87..c118eac08 100644 --- a/apps/vmq_events_sidecar/src/vmq_events_sidecar.app.src +++ b/apps/vmq_events_sidecar/src/vmq_events_sidecar.app.src @@ -23,10 +23,10 @@ {vmq_events_sidecar_plugin, on_deliver, 6, []}, {vmq_events_sidecar_plugin, on_offline_message, 5, []}, {vmq_events_sidecar_plugin, on_client_wakeup, 1, []}, - {vmq_events_sidecar_plugin, on_client_offline, 1, []}, + {vmq_events_sidecar_plugin, on_client_offline, 2, []}, {vmq_events_sidecar_plugin, on_session_expired, 1, []}, {vmq_events_sidecar_plugin, on_delivery_complete, 6, []}, - {vmq_events_sidecar_plugin, on_client_gone, 1, []} + {vmq_events_sidecar_plugin, on_client_gone, 2, []} ]} ]}, {modules, []}, diff --git a/apps/vmq_events_sidecar/src/vmq_events_sidecar_format.erl b/apps/vmq_events_sidecar/src/vmq_events_sidecar_format.erl index e4eb2c408..60a63e10e 100644 --- a/apps/vmq_events_sidecar/src/vmq_events_sidecar_format.erl +++ b/apps/vmq_events_sidecar/src/vmq_events_sidecar_format.erl @@ -132,22 +132,24 @@ encode({on_client_wakeup, Timestamp, {MP, ClientId}}) -> timestamp = convert_timestamp(Timestamp) }) ); -encode({on_client_offline, Timestamp, {MP, ClientId}}) -> +encode({on_client_offline, Timestamp, {MP, ClientId, Reason}}) -> encode_envelope( "OnClientOffline", on_client_offline_pb:encode_msg(#'eventssidecar.v1.OnClientOffline'{ client_id = ClientId, mountpoint = MP, - timestamp = convert_timestamp(Timestamp) + timestamp = convert_timestamp(Timestamp), + reason = Reason }) ); -encode({on_client_gone, Timestamp, {MP, ClientId}}) -> +encode({on_client_gone, Timestamp, {MP, ClientId, Reason}}) -> encode_envelope( "OnClientGone", on_client_gone_pb:encode_msg(#'eventssidecar.v1.OnClientGone'{ client_id = ClientId, mountpoint = MP, - timestamp = convert_timestamp(Timestamp) + timestamp = convert_timestamp(Timestamp), + reason = Reason }) ); encode({on_session_expired, Timestamp, {MP, ClientId}}) -> diff --git a/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl b/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl index cf89b92d8..f5291539d 100644 --- a/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl +++ b/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl @@ -26,8 +26,8 @@ on_deliver/6, on_offline_message/5, on_client_wakeup/1, - on_client_offline/1, - on_client_gone/1, + on_client_offline/2, + on_client_gone/2, on_session_expired/1, on_delivery_complete/6 ]). @@ -257,15 +257,15 @@ on_client_wakeup(SubscriberId) -> {MP, ClientId} = subscriber_id(SubscriberId), send_event({on_client_wakeup, {MP, ClientId}}). --spec on_client_offline(subscriber_id()) -> 'next'. -on_client_offline(SubscriberId) -> +-spec on_client_offline(subscriber_id(), reason()) -> 'next'. +on_client_offline(SubscriberId, Reason) -> {MP, ClientId} = subscriber_id(SubscriberId), - send_event({on_client_offline, {MP, ClientId}}). + send_event({on_client_offline, {MP, ClientId, Reason}}). --spec on_client_gone(subscriber_id()) -> 'next'. -on_client_gone(SubscriberId) -> +-spec on_client_gone(subscriber_id(), reason()) -> 'next'. +on_client_gone(SubscriberId, Reason) -> {MP, ClientId} = subscriber_id(SubscriberId), - send_event({on_client_gone, {MP, ClientId}}). + send_event({on_client_gone, {MP, ClientId, Reason}}). -spec on_session_expired(subscriber_id()) -> 'next'. on_session_expired(SubscriberId) -> diff --git a/apps/vmq_events_sidecar/test/events_sidecar_handler.erl b/apps/vmq_events_sidecar/test/events_sidecar_handler.erl index 8dbf060e5..294c74d1b 100644 --- a/apps/vmq_events_sidecar/test/events_sidecar_handler.erl +++ b/apps/vmq_events_sidecar/test/events_sidecar_handler.erl @@ -164,13 +164,13 @@ on_client_wakeup(#'eventssidecar.v1.OnClientWakeUp'{mountpoint = ?MOUNTPOINT_BIN on_client_offline(#'eventssidecar.v1.OnClientOffline'{mountpoint = ?MOUNTPOINT_BIN, - client_id = BinPid}) -> + client_id = BinPid, reason = ?REASON}) -> Pid = list_to_pid(binary_to_list(BinPid)), Pid ! on_client_offline_ok. on_client_gone(#'eventssidecar.v1.OnClientGone'{mountpoint = ?MOUNTPOINT_BIN, - client_id = BinPid}) -> + client_id = BinPid, reason = ?REASON}) -> Pid = list_to_pid(binary_to_list(BinPid)), Pid ! on_client_gone_ok. diff --git a/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl b/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl index 9b4a66100..a159ae9e7 100644 --- a/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl +++ b/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl @@ -136,14 +136,14 @@ on_client_wakeup_test(_) -> on_client_offline_test(_) -> enable_hook(on_client_offline), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_client_offline, [{?MOUNTPOINT, Self}]), + [ok] = vmq_plugin:all(on_client_offline, [{?MOUNTPOINT, Self}, ?REASON]), ok = exp_response(on_client_offline_ok), disable_hook(on_client_offline). on_client_gone_test(_) -> enable_hook(on_client_gone), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_client_gone, [{?MOUNTPOINT, Self}]), + [ok] = vmq_plugin:all(on_client_gone, [{?MOUNTPOINT, Self}, ?REASON]), ok = exp_response(on_client_gone_ok), disable_hook(on_client_gone). diff --git a/apps/vmq_events_sidecar/test/vmq_events_sidecar_test.hrl b/apps/vmq_events_sidecar/test/vmq_events_sidecar_test.hrl index d6a3335e4..cda1b7e7a 100644 --- a/apps/vmq_events_sidecar/test/vmq_events_sidecar_test.hrl +++ b/apps/vmq_events_sidecar/test/vmq_events_sidecar_test.hrl @@ -7,4 +7,5 @@ -define(MOUNTPOINT_BIN, <<"mountpoint">>). -define(TOPIC, <<"test/topic">>). -define(PAYLOAD, <<"hello world">>). +-define(REASON, 'REASON_NORMAL_DISCONNECT'). diff --git a/apps/vmq_proto/include/disconnect_reason_pb.hrl b/apps/vmq_proto/include/disconnect_reason_pb.hrl new file mode 100644 index 000000000..ec5ac1512 --- /dev/null +++ b/apps/vmq_proto/include/disconnect_reason_pb.hrl @@ -0,0 +1,10 @@ +%% -*- coding: utf-8 -*- +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.20.0 + +-ifndef(disconnect_reason_pb). +-define(disconnect_reason_pb, true). + +-define(disconnect_reason_pb_gpb_version, "4.20.0"). + +-endif. diff --git a/apps/vmq_proto/include/on_client_gone_pb.hrl b/apps/vmq_proto/include/on_client_gone_pb.hrl index 9e0bfc7a4..fd78b6bfd 100644 --- a/apps/vmq_proto/include/on_client_gone_pb.hrl +++ b/apps/vmq_proto/include/on_client_gone_pb.hrl @@ -1,11 +1,11 @@ %% -*- coding: utf-8 -*- %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.1 +%% Generated by gpb_compile version 4.20.0 -ifndef(on_client_gone_pb). -define(on_client_gone_pb, true). --define(on_client_gone_pb_gpb_version, "4.19.1"). +-define(on_client_gone_pb_gpb_version, "4.20.0"). -ifndef('EVENTSSIDECAR.V1.ONCLIENTGONE_PB_H'). -define('EVENTSSIDECAR.V1.ONCLIENTGONE_PB_H', true). @@ -16,7 +16,29 @@ % = 2, optional client_id = <<>> :: unicode:chardata() | undefined, % = 3, optional - mountpoint = <<>> :: unicode:chardata() | undefined + mountpoint = <<>> :: unicode:chardata() | undefined, + % = 4, optional, enum eventssidecar.v1.Reason + reason = 'REASON_UNSPECIFIED' :: + 'REASON_UNSPECIFIED' + | 'REASON_NOT_AUTHORIZED' + | 'REASON_NORMAL_DISCONNECT' + | 'REASON_SESSION_TAKEN_OVER' + | 'REASON_ADMINISTRATIVE_ACTION' + | 'REASON_DISCONNECT_KEEP_ALIVE' + | 'REASON_DISCONNECT_MIGRATION' + | 'REASON_BAD_AUTHENTICATION_METHOD' + | 'REASON_REMOTE_SESSION_TAKEN_OVER' + | 'REASON_MQTT_CLIENT_DISCONNECT' + | 'REASON_RECEIVE_MAX_EXCEEDED' + | 'REASON_PROTOCOL_ERROR' + | 'REASON_PUBLISH_AUTH_ERROR' + | 'REASON_INVALID_PUBREC_ERROR' + | 'REASON_INVALID_PUBCOMP_ERROR' + | 'REASON_UNEXPECTED_FRAME_TYPE' + | 'REASON_EXIT_SIGNAL_RECEIVED' + | 'REASON_TCP_CLOSED' + | integer() + | undefined } ). -endif. diff --git a/apps/vmq_proto/include/on_client_offline_pb.hrl b/apps/vmq_proto/include/on_client_offline_pb.hrl index aef0ec761..413777f02 100644 --- a/apps/vmq_proto/include/on_client_offline_pb.hrl +++ b/apps/vmq_proto/include/on_client_offline_pb.hrl @@ -1,11 +1,11 @@ %% -*- coding: utf-8 -*- %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.1 +%% Generated by gpb_compile version 4.20.0 -ifndef(on_client_offline_pb). -define(on_client_offline_pb, true). --define(on_client_offline_pb_gpb_version, "4.19.1"). +-define(on_client_offline_pb_gpb_version, "4.20.0"). -ifndef('EVENTSSIDECAR.V1.ONCLIENTOFFLINE_PB_H'). -define('EVENTSSIDECAR.V1.ONCLIENTOFFLINE_PB_H', true). @@ -16,7 +16,29 @@ % = 2, optional client_id = <<>> :: unicode:chardata() | undefined, % = 3, optional - mountpoint = <<>> :: unicode:chardata() | undefined + mountpoint = <<>> :: unicode:chardata() | undefined, + % = 4, optional, enum eventssidecar.v1.Reason + reason = 'REASON_UNSPECIFIED' :: + 'REASON_UNSPECIFIED' + | 'REASON_NOT_AUTHORIZED' + | 'REASON_NORMAL_DISCONNECT' + | 'REASON_SESSION_TAKEN_OVER' + | 'REASON_ADMINISTRATIVE_ACTION' + | 'REASON_DISCONNECT_KEEP_ALIVE' + | 'REASON_DISCONNECT_MIGRATION' + | 'REASON_BAD_AUTHENTICATION_METHOD' + | 'REASON_REMOTE_SESSION_TAKEN_OVER' + | 'REASON_MQTT_CLIENT_DISCONNECT' + | 'REASON_RECEIVE_MAX_EXCEEDED' + | 'REASON_PROTOCOL_ERROR' + | 'REASON_PUBLISH_AUTH_ERROR' + | 'REASON_INVALID_PUBREC_ERROR' + | 'REASON_INVALID_PUBCOMP_ERROR' + | 'REASON_UNEXPECTED_FRAME_TYPE' + | 'REASON_EXIT_SIGNAL_RECEIVED' + | 'REASON_TCP_CLOSED' + | integer() + | undefined } ). -endif. diff --git a/apps/vmq_proto/proto/disconnect_reason.proto b/apps/vmq_proto/proto/disconnect_reason.proto new file mode 100644 index 000000000..5af539295 --- /dev/null +++ b/apps/vmq_proto/proto/disconnect_reason.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package eventssidecar.v1; + +enum Reason { + REASON_UNSPECIFIED = 0; + REASON_NOT_AUTHORIZED = 1; + REASON_NORMAL_DISCONNECT = 2; + REASON_SESSION_TAKEN_OVER = 3; + REASON_ADMINISTRATIVE_ACTION = 4; + REASON_DISCONNECT_KEEP_ALIVE = 5; + REASON_DISCONNECT_MIGRATION = 6; + REASON_BAD_AUTHENTICATION_METHOD = 7; + REASON_REMOTE_SESSION_TAKEN_OVER = 8; + REASON_MQTT_CLIENT_DISCONNECT = 9; + REASON_RECEIVE_MAX_EXCEEDED = 10; + REASON_PROTOCOL_ERROR = 11; + REASON_PUBLISH_AUTH_ERROR = 12; + REASON_INVALID_PUBREC_ERROR = 13; + REASON_INVALID_PUBCOMP_ERROR = 14; + REASON_UNEXPECTED_FRAME_TYPE = 15; + REASON_EXIT_SIGNAL_RECEIVED = 16; + REASON_TCP_CLOSED = 17; +} diff --git a/apps/vmq_proto/proto/on_client_gone.proto b/apps/vmq_proto/proto/on_client_gone.proto index 73a190245..dda686cbe 100644 --- a/apps/vmq_proto/proto/on_client_gone.proto +++ b/apps/vmq_proto/proto/on_client_gone.proto @@ -1,8 +1,7 @@ syntax = "proto3"; import "google/protobuf/timestamp.proto"; - -option go_package = "source.golabs.io/courier/apis-go/eventssidecar/v1"; +import "disconnect_reason.proto"; package eventssidecar.v1; @@ -10,4 +9,5 @@ message OnClientGone { google.protobuf.Timestamp timestamp = 1; string client_id = 2; string mountpoint = 3; + eventssidecar.v1.Reason reason = 4; } diff --git a/apps/vmq_proto/proto/on_client_offline.proto b/apps/vmq_proto/proto/on_client_offline.proto index 6e637c7c8..26187ddb8 100644 --- a/apps/vmq_proto/proto/on_client_offline.proto +++ b/apps/vmq_proto/proto/on_client_offline.proto @@ -1,8 +1,7 @@ syntax = "proto3"; import "google/protobuf/timestamp.proto"; - -option go_package = "source.golabs.io/courier/apis-go/eventssidecar/v1"; +import "disconnect_reason.proto"; package eventssidecar.v1; @@ -10,4 +9,5 @@ message OnClientOffline { google.protobuf.Timestamp timestamp = 1; string client_id = 2; string mountpoint = 3; + eventssidecar.v1.Reason reason = 4; } diff --git a/apps/vmq_proto/src/disconnect_reason_pb.erl b/apps/vmq_proto/src/disconnect_reason_pb.erl new file mode 100644 index 000000000..ca36ef753 --- /dev/null +++ b/apps/vmq_proto/src/disconnect_reason_pb.erl @@ -0,0 +1,458 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.20.0 +%% Version source: file +-module(disconnect_reason_pb). + +-export([encode_msg/1, encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/2, merge_msgs/3, merge_msgs/4]). +-export([verify_msg/1, verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([ + 'enum_symbol_by_value_eventssidecar.v1.Reason'/1, + 'enum_value_by_symbol_eventssidecar.v1.Reason'/1 +]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + +-include("disconnect_reason_pb.hrl"). +-include("gpb.hrl"). + +%% enumerated types +-type 'eventssidecar.v1.Reason'() :: + 'REASON_UNSPECIFIED' + | 'REASON_NOT_AUTHORIZED' + | 'REASON_NORMAL_DISCONNECT' + | 'REASON_SESSION_TAKEN_OVER' + | 'REASON_ADMINISTRATIVE_ACTION' + | 'REASON_DISCONNECT_KEEP_ALIVE' + | 'REASON_DISCONNECT_MIGRATION' + | 'REASON_BAD_AUTHENTICATION_METHOD' + | 'REASON_REMOTE_SESSION_TAKEN_OVER' + | 'REASON_MQTT_CLIENT_DISCONNECT' + | 'REASON_RECEIVE_MAX_EXCEEDED' + | 'REASON_PROTOCOL_ERROR' + | 'REASON_PUBLISH_AUTH_ERROR' + | 'REASON_INVALID_PUBREC_ERROR' + | 'REASON_INVALID_PUBCOMP_ERROR' + | 'REASON_UNEXPECTED_FRAME_TYPE' + | 'REASON_EXIT_SIGNAL_RECEIVED' + | 'REASON_TCP_CLOSED'. +-export_type(['eventssidecar.v1.Reason'/0]). + +%% message types + +-export_type([]). +-type '$msg_name'() :: none(). +-type '$msg'() :: none(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-spec encode_msg(_) -> no_return(). +encode_msg(Msg) -> encode_msg(Msg, dummy_name, []). + +-spec encode_msg(_, _) -> no_return(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []); +encode_msg(Msg, Opts) when tuple_size(Msg) >= 1, is_list(Opts) -> + encode_msg(Msg, element(1, Msg), []). + +-spec encode_msg(_, _, _) -> no_return(). +encode_msg(_Msg, _MsgName, _Opts) -> erlang:error({gpb_error, no_messages}). + +-compile({nowarn_unused_function, e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function, e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function, e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function, e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function, e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function, e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function, e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function, e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function, e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function, e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function, e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function, e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function, e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = + case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> + Bin. + +-compile({nowarn_unused_function, e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function, e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +-spec decode_msg(binary(), atom()) -> no_return(). +decode_msg(Bin, _MsgName) when is_binary(Bin) -> erlang:error({gpb_error, no_messages}). + +-spec decode_msg(binary(), atom(), list()) -> no_return(). +decode_msg(Bin, _MsgName, _Opts) when is_binary(Bin) -> erlang:error({gpb_error, no_messages}). + +-spec merge_msgs(_, _) -> no_return(). +merge_msgs(Prev, New) -> merge_msgs(Prev, New, []). + +-spec merge_msgs(_, _, _) -> no_return(). +merge_msgs(_Prev, _New, _MsgNameOrOpts) -> erlang:error({gpb_error, no_messages}). + +merge_msgs(_Prev, _New, _MsgName, _Opts) -> erlang:error({gpb_error, no_messages}). + +-spec verify_msg(_) -> no_return(). +verify_msg(Msg) -> verify_msg(Msg, []). + +-spec verify_msg(_, _) -> no_return(). +verify_msg(Msg, _OptsOrMsgName) -> mk_type_error(not_a_known_message, Msg, []). + +-spec verify_msg(_, _, _) -> no_return(). +verify_msg(Msg, _MsgName, _Opts) -> mk_type_error(not_a_known_message, Msg, []). + +-compile({nowarn_unused_function, mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + +prettify_path([]) -> top_level. + +-compile({nowarn_unused_function, id/2}). +-compile({inline, id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function, v_ok/3}). +-compile({inline, v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function, m_overwrite/3}). +-compile({inline, m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function, cons/3}). +-compile({inline, cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function, lists_reverse/2}). +-compile({inline, lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function, 'erlang_++'/3}). +-compile({inline, 'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + +get_msg_defs() -> + [ + {{enum, 'eventssidecar.v1.Reason'}, [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]} + ]. + +get_msg_names() -> []. + +get_group_names() -> []. + +get_msg_or_group_names() -> []. + +get_enum_names() -> ['eventssidecar.v1.Reason']. + +-spec fetch_msg_def(_) -> no_return(). +fetch_msg_def(MsgName) -> erlang:error({no_such_msg, MsgName}). + +fetch_enum_def(EnumName) -> + case find_enum_def(EnumName) of + Es when is_list(Es) -> Es; + error -> erlang:error({no_such_enum, EnumName}) + end. + +find_msg_def(_) -> error. + +find_enum_def('eventssidecar.v1.Reason') -> + [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]; +find_enum_def(_) -> + error. + +enum_symbol_by_value('eventssidecar.v1.Reason', Value) -> + 'enum_symbol_by_value_eventssidecar.v1.Reason'(Value). + +enum_value_by_symbol('eventssidecar.v1.Reason', Sym) -> + 'enum_value_by_symbol_eventssidecar.v1.Reason'(Sym). + +'enum_symbol_by_value_eventssidecar.v1.Reason'(0) -> 'REASON_UNSPECIFIED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(1) -> 'REASON_NOT_AUTHORIZED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(2) -> 'REASON_NORMAL_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(3) -> 'REASON_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(4) -> 'REASON_ADMINISTRATIVE_ACTION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(5) -> 'REASON_DISCONNECT_KEEP_ALIVE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(6) -> 'REASON_DISCONNECT_MIGRATION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(7) -> 'REASON_BAD_AUTHENTICATION_METHOD'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(8) -> 'REASON_REMOTE_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(9) -> 'REASON_MQTT_CLIENT_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(10) -> 'REASON_RECEIVE_MAX_EXCEEDED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(11) -> 'REASON_PROTOCOL_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(12) -> 'REASON_PUBLISH_AUTH_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(13) -> 'REASON_INVALID_PUBREC_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(14) -> 'REASON_INVALID_PUBCOMP_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(15) -> 'REASON_UNEXPECTED_FRAME_TYPE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(16) -> 'REASON_EXIT_SIGNAL_RECEIVED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(17) -> 'REASON_TCP_CLOSED'. + +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNSPECIFIED') -> 0; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED') -> 1; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT') -> 2; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER') -> 3; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION') -> 4; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE') -> 5; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION') -> 6; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD') -> 7; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER') -> 8; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT') -> 9; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED') -> 10; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR') -> 11; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR') -> 12; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR') -> 13; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR') -> 14; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE') -> 15; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED') -> 16; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_TCP_CLOSED') -> 17. + +get_service_names() -> []. + +get_service_def(_) -> error. + +get_rpc_names(_) -> error. + +find_rpc_def(_, _) -> error. + +-spec fetch_rpc_def(_, _) -> no_return(). +fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +-spec fqbin_to_service_name(_) -> no_return(). +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +-spec service_name_to_fqbin(_) -> no_return(). +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +-spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +-spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + +-spec fqbin_to_msg_name(_) -> no_return(). +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + +-spec msg_name_to_fqbin(_) -> no_return(). +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + +fqbin_to_enum_name(<<"eventssidecar.v1.Reason">>) -> 'eventssidecar.v1.Reason'; +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + +enum_name_to_fqbin('eventssidecar.v1.Reason') -> <<"eventssidecar.v1.Reason">>; +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + +get_package_name() -> 'eventssidecar.v1'. + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + +source_basename() -> "disconnect_reason.proto". + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["disconnect_reason.proto"]. + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["disconnect_reason"]. + +get_msg_containment("disconnect_reason") -> []; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + +get_pkg_containment("disconnect_reason") -> 'eventssidecar.v1'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + +get_service_containment("disconnect_reason") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + +get_rpc_containment("disconnect_reason") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + +get_enum_containment("disconnect_reason") -> ['eventssidecar.v1.Reason']; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + +-spec get_proto_by_msg_name_as_fqbin(_) -> no_return(). +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + +-spec get_proto_by_service_name_as_fqbin(_) -> no_return(). +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + +get_proto_by_enum_name_as_fqbin(<<"eventssidecar.v1.Reason">>) -> "disconnect_reason"; +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + +get_protos_by_pkg_name_as_fqbin(<<"eventssidecar.v1">>) -> ["disconnect_reason"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + +gpb_version_as_string() -> + "4.20.0". + +gpb_version_as_list() -> + [4, 20, 0]. + +gpb_version_source() -> + "file". diff --git a/apps/vmq_proto/src/on_client_gone_pb.erl b/apps/vmq_proto/src/on_client_gone_pb.erl index 8df765b51..8a97a3022 100644 --- a/apps/vmq_proto/src/on_client_gone_pb.erl +++ b/apps/vmq_proto/src/on_client_gone_pb.erl @@ -1,7 +1,7 @@ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.1 +%% Generated by gpb_compile version 4.20.0 %% Version source: file -module(on_client_gone_pb). @@ -17,6 +17,10 @@ -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([ + 'enum_symbol_by_value_eventssidecar.v1.Reason'/1, + 'enum_value_by_symbol_eventssidecar.v1.Reason'/1 +]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). @@ -50,8 +54,26 @@ -include("gpb.hrl"). %% enumerated types - --export_type([]). +-type 'eventssidecar.v1.Reason'() :: + 'REASON_UNSPECIFIED' + | 'REASON_NOT_AUTHORIZED' + | 'REASON_NORMAL_DISCONNECT' + | 'REASON_SESSION_TAKEN_OVER' + | 'REASON_ADMINISTRATIVE_ACTION' + | 'REASON_DISCONNECT_KEEP_ALIVE' + | 'REASON_DISCONNECT_MIGRATION' + | 'REASON_BAD_AUTHENTICATION_METHOD' + | 'REASON_REMOTE_SESSION_TAKEN_OVER' + | 'REASON_MQTT_CLIENT_DISCONNECT' + | 'REASON_RECEIVE_MAX_EXCEEDED' + | 'REASON_PROTOCOL_ERROR' + | 'REASON_PUBLISH_AUTH_ERROR' + | 'REASON_INVALID_PUBREC_ERROR' + | 'REASON_INVALID_PUBCOMP_ERROR' + | 'REASON_UNEXPECTED_FRAME_TYPE' + | 'REASON_EXIT_SIGNAL_RECEIVED' + | 'REASON_TCP_CLOSED'. +-export_type(['eventssidecar.v1.Reason'/0]). %% message types -type 'eventssidecar.v1.OnClientGone'() :: #'eventssidecar.v1.OnClientGone'{}. @@ -89,7 +111,7 @@ encode_msg(Msg, MsgName, Opts) -> 'encode_msg_eventssidecar.v1.OnClientGone'(Msg, <<>>, TrUserData). 'encode_msg_eventssidecar.v1.OnClientGone'( - #'eventssidecar.v1.OnClientGone'{timestamp = F1, client_id = F2, mountpoint = F3}, + #'eventssidecar.v1.OnClientGone'{timestamp = F1, client_id = F2, mountpoint = F3, reason = F4}, Bin, TrUserData ) -> @@ -123,15 +145,28 @@ encode_msg(Msg, MsgName, Opts) -> end end end, + B3 = + if + F3 == undefined -> + B2; + true -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end + end, if - F3 == undefined -> - B2; + F4 == undefined -> + B3; true -> begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) + TrF4 = id(F4, TrUserData), + if + TrF4 =:= 'REASON_UNSPECIFIED'; TrF4 =:= 0 -> B3; + true -> 'e_enum_eventssidecar.v1.Reason'(TrF4, <>, TrUserData) end end end. @@ -173,6 +208,45 @@ encode_msg(Msg, MsgName, Opts) -> Bin2 = e_varint(byte_size(SubBin), Bin), <>. +'e_enum_eventssidecar.v1.Reason'('REASON_UNSPECIFIED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_TCP_CLOSED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'(V, Bin, _TrUserData) -> + e_varint(V, Bin). + -compile({nowarn_unused_function, e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). @@ -334,92 +408,109 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> id(undefined, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), + id('REASON_UNSPECIFIED', TrUserData), TrUserData ). 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - <<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientGone_timestamp'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - <<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientGone_client_id'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - <<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientGone_mountpoint'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); -'dfp_read_field_def_eventssidecar.v1.OnClientGone'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> - #'eventssidecar.v1.OnClientGone'{timestamp = F@_1, client_id = F@_2, mountpoint = F@_3}; -'dfp_read_field_def_eventssidecar.v1.OnClientGone'(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> +'dfp_read_field_def_eventssidecar.v1.OnClientGone'( + <<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData +) -> + 'd_field_eventssidecar.v1.OnClientGone_reason'( + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); +'dfp_read_field_def_eventssidecar.v1.OnClientGone'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> + #'eventssidecar.v1.OnClientGone'{ + timestamp = F@_1, client_id = F@_2, mountpoint = F@_3, reason = F@_4 + }; +'dfp_read_field_def_eventssidecar.v1.OnClientGone'( + Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData +) -> 'dg_read_field_def_eventssidecar.v1.OnClientGone'( - Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'dg_read_field_def_eventssidecar.v1.OnClientGone'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 32 - 7 -> 'dg_read_field_def_eventssidecar.v1.OnClientGone'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dg_read_field_def_eventssidecar.v1.OnClientGone'( - <<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> Key = X bsl N + Acc, case Key of 10 -> 'd_field_eventssidecar.v1.OnClientGone_timestamp'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); 18 -> 'd_field_eventssidecar.v1.OnClientGone_client_id'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); 26 -> 'd_field_eventssidecar.v1.OnClientGone_mountpoint'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData + ); + 32 -> + 'd_field_eventssidecar.v1.OnClientGone_reason'( + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); _ -> case Key band 7 of 0 -> 'skip_varint_eventssidecar.v1.OnClientGone'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 1 -> 'skip_64_eventssidecar.v1.OnClientGone'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 2 -> 'skip_length_delimited_eventssidecar.v1.OnClientGone'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 3 -> 'skip_group_eventssidecar.v1.OnClientGone'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 5 -> 'skip_32_eventssidecar.v1.OnClientGone'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ) end end; -'dg_read_field_def_eventssidecar.v1.OnClientGone'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> - #'eventssidecar.v1.OnClientGone'{timestamp = F@_1, client_id = F@_2, mountpoint = F@_3}. +'dg_read_field_def_eventssidecar.v1.OnClientGone'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> + #'eventssidecar.v1.OnClientGone'{ + timestamp = F@_1, client_id = F@_2, mountpoint = F@_3, reason = F@_4 + }. 'd_field_eventssidecar.v1.OnClientGone_timestamp'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientGone_timestamp'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientGone_timestamp'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -437,17 +528,18 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> end, F@_2, F@_3, + F@_4, TrUserData ). 'd_field_eventssidecar.v1.OnClientGone_client_id'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientGone_client_id'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientGone_client_id'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -456,17 +548,17 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> {id(Bytes2, TrUserData), Rest2} end, 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData + RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData ). 'd_field_eventssidecar.v1.OnClientGone_mountpoint'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientGone_mountpoint'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientGone_mountpoint'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -475,53 +567,78 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> {id(Bytes2, TrUserData), Rest2} end, 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData + RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData + ). + +'d_field_eventssidecar.v1.OnClientGone_reason'( + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData +) when N < 57 -> + 'd_field_eventssidecar.v1.OnClientGone_reason'( + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); +'d_field_eventssidecar.v1.OnClientGone_reason'( + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData +) -> + {NewFValue, RestF} = { + id( + 'd_enum_eventssidecar.v1.Reason'(begin + <> = <<(X bsl N + Acc):32/unsigned-native>>, + id(Res, TrUserData) + end), + TrUserData + ), + Rest + }, + 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( + RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData ). 'skip_varint_eventssidecar.v1.OnClientGone'( - <<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> - 'skip_varint_eventssidecar.v1.OnClientGone'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); + 'skip_varint_eventssidecar.v1.OnClientGone'( + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); 'skip_varint_eventssidecar.v1.OnClientGone'( - <<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_length_delimited_eventssidecar.v1.OnClientGone'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'skip_length_delimited_eventssidecar.v1.OnClientGone'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'skip_length_delimited_eventssidecar.v1.OnClientGone'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData + Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). -'skip_group_eventssidecar.v1.OnClientGone'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> +'skip_group_eventssidecar.v1.OnClientGone'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData + Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_32_eventssidecar.v1.OnClientGone'( - <<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_64_eventssidecar.v1.OnClientGone'( - <<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientGone'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'decode_msg_google.protobuf.Timestamp'(Bin, TrUserData) -> @@ -652,6 +769,26 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> 'skip_64_google.protobuf.Timestamp'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> 'dfp_read_field_def_google.protobuf.Timestamp'(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). +'d_enum_eventssidecar.v1.Reason'(0) -> 'REASON_UNSPECIFIED'; +'d_enum_eventssidecar.v1.Reason'(1) -> 'REASON_NOT_AUTHORIZED'; +'d_enum_eventssidecar.v1.Reason'(2) -> 'REASON_NORMAL_DISCONNECT'; +'d_enum_eventssidecar.v1.Reason'(3) -> 'REASON_SESSION_TAKEN_OVER'; +'d_enum_eventssidecar.v1.Reason'(4) -> 'REASON_ADMINISTRATIVE_ACTION'; +'d_enum_eventssidecar.v1.Reason'(5) -> 'REASON_DISCONNECT_KEEP_ALIVE'; +'d_enum_eventssidecar.v1.Reason'(6) -> 'REASON_DISCONNECT_MIGRATION'; +'d_enum_eventssidecar.v1.Reason'(7) -> 'REASON_BAD_AUTHENTICATION_METHOD'; +'d_enum_eventssidecar.v1.Reason'(8) -> 'REASON_REMOTE_SESSION_TAKEN_OVER'; +'d_enum_eventssidecar.v1.Reason'(9) -> 'REASON_MQTT_CLIENT_DISCONNECT'; +'d_enum_eventssidecar.v1.Reason'(10) -> 'REASON_RECEIVE_MAX_EXCEEDED'; +'d_enum_eventssidecar.v1.Reason'(11) -> 'REASON_PROTOCOL_ERROR'; +'d_enum_eventssidecar.v1.Reason'(12) -> 'REASON_PUBLISH_AUTH_ERROR'; +'d_enum_eventssidecar.v1.Reason'(13) -> 'REASON_INVALID_PUBREC_ERROR'; +'d_enum_eventssidecar.v1.Reason'(14) -> 'REASON_INVALID_PUBCOMP_ERROR'; +'d_enum_eventssidecar.v1.Reason'(15) -> 'REASON_UNEXPECTED_FRAME_TYPE'; +'d_enum_eventssidecar.v1.Reason'(16) -> 'REASON_EXIT_SIGNAL_RECEIVED'; +'d_enum_eventssidecar.v1.Reason'(17) -> 'REASON_TCP_CLOSED'; +'d_enum_eventssidecar.v1.Reason'(V) -> V. + read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, @@ -745,10 +882,16 @@ merge_msgs(Prev, New, MsgName, Opts) -> -compile({nowarn_unused_function, 'merge_msg_eventssidecar.v1.OnClientGone'/3}). 'merge_msg_eventssidecar.v1.OnClientGone'( #'eventssidecar.v1.OnClientGone'{ - timestamp = PFtimestamp, client_id = PFclient_id, mountpoint = PFmountpoint + timestamp = PFtimestamp, + client_id = PFclient_id, + mountpoint = PFmountpoint, + reason = PFreason }, #'eventssidecar.v1.OnClientGone'{ - timestamp = NFtimestamp, client_id = NFclient_id, mountpoint = NFmountpoint + timestamp = NFtimestamp, + client_id = NFclient_id, + mountpoint = NFmountpoint, + reason = NFreason }, TrUserData ) -> @@ -771,6 +914,11 @@ merge_msgs(Prev, New, MsgName, Opts) -> if NFmountpoint =:= undefined -> PFmountpoint; true -> NFmountpoint + end, + reason = + if + NFreason =:= undefined -> PFreason; + true -> NFreason end }. @@ -814,13 +962,13 @@ verify_msg(Msg, MsgName, Opts) -> -compile({nowarn_unused_function, 'v_msg_eventssidecar.v1.OnClientGone'/3}). -dialyzer({nowarn_function, 'v_msg_eventssidecar.v1.OnClientGone'/3}). 'v_msg_eventssidecar.v1.OnClientGone'( - #'eventssidecar.v1.OnClientGone'{timestamp = F1, client_id = F2, mountpoint = F3}, + #'eventssidecar.v1.OnClientGone'{timestamp = F1, client_id = F2, mountpoint = F3, reason = F4}, Path, TrUserData ) -> if F1 == undefined -> ok; - true -> 'v_msg_google.protobuf.Timestamp'(F1, [timestamp | Path], TrUserData) + true -> 'v_submsg_google.protobuf.Timestamp'(F1, [timestamp | Path], TrUserData) end, if F2 == undefined -> ok; @@ -830,10 +978,19 @@ verify_msg(Msg, MsgName, Opts) -> F3 == undefined -> ok; true -> v_type_string(F3, [mountpoint | Path], TrUserData) end, + if + F4 == undefined -> ok; + true -> 'v_enum_eventssidecar.v1.Reason'(F4, [reason | Path], TrUserData) + end, ok; 'v_msg_eventssidecar.v1.OnClientGone'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'eventssidecar.v1.OnClientGone'}, X, Path). +-compile({nowarn_unused_function, 'v_submsg_google.protobuf.Timestamp'/3}). +-dialyzer({nowarn_function, 'v_submsg_google.protobuf.Timestamp'/3}). +'v_submsg_google.protobuf.Timestamp'(Msg, Path, TrUserData) -> + 'v_msg_google.protobuf.Timestamp'(Msg, Path, TrUserData). + -compile({nowarn_unused_function, 'v_msg_google.protobuf.Timestamp'/3}). -dialyzer({nowarn_function, 'v_msg_google.protobuf.Timestamp'/3}). 'v_msg_google.protobuf.Timestamp'( @@ -851,9 +1008,54 @@ verify_msg(Msg, MsgName, Opts) -> 'v_msg_google.protobuf.Timestamp'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'google.protobuf.Timestamp'}, X, Path). +-compile({nowarn_unused_function, 'v_enum_eventssidecar.v1.Reason'/3}). +-dialyzer({nowarn_function, 'v_enum_eventssidecar.v1.Reason'/3}). +'v_enum_eventssidecar.v1.Reason'('REASON_UNSPECIFIED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_TCP_CLOSED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'(V, _Path, _TrUserData) when + -2147483648 =< V, V =< 2147483647, is_integer(V) +-> + ok; +'v_enum_eventssidecar.v1.Reason'(X, Path, _TrUserData) -> + mk_type_error({invalid_enum, 'eventssidecar.v1.Reason'}, X, Path). + -compile({nowarn_unused_function, v_type_int32/3}). -dialyzer({nowarn_function, v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, _Path, _TrUserData) when is_integer(N), -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> @@ -861,7 +1063,10 @@ v_type_int32(X, Path, _TrUserData) -> -compile({nowarn_unused_function, v_type_int64/3}). -dialyzer({nowarn_function, v_type_int64/3}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, _Path, _TrUserData) when + is_integer(N), -9223372036854775808 =< N, N =< 9223372036854775807 +-> + ok; v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); v_type_int64(X, Path, _TrUserData) -> @@ -917,6 +1122,26 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. get_msg_defs() -> [ + {{enum, 'eventssidecar.v1.Reason'}, [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]}, {{msg, 'eventssidecar.v1.OnClientGone'}, [ #field{ name = timestamp, @@ -941,6 +1166,14 @@ get_msg_defs() -> type = string, occurrence = optional, opts = [] + }, + #field{ + name = reason, + fnum = 4, + rnum = 5, + type = {enum, 'eventssidecar.v1.Reason'}, + occurrence = optional, + opts = [] } ]}, {{msg, 'google.protobuf.Timestamp'}, [ @@ -957,7 +1190,7 @@ get_group_names() -> []. get_msg_or_group_names() -> ['eventssidecar.v1.OnClientGone', 'google.protobuf.Timestamp']. -get_enum_names() -> []. +get_enum_names() -> ['eventssidecar.v1.Reason']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of @@ -965,8 +1198,11 @@ fetch_msg_def(MsgName) -> error -> erlang:error({no_such_msg, MsgName}) end. --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). +fetch_enum_def(EnumName) -> + case find_enum_def(EnumName) of + Es when is_list(Es) -> Es; + error -> erlang:error({no_such_enum, EnumName}) + end. find_msg_def('eventssidecar.v1.OnClientGone') -> [ @@ -983,6 +1219,14 @@ find_msg_def('eventssidecar.v1.OnClientGone') -> }, #field{ name = mountpoint, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = [] + }, + #field{ + name = reason, + fnum = 4, + rnum = 5, + type = {enum, 'eventssidecar.v1.Reason'}, + occurrence = optional, + opts = [] } ]; find_msg_def('google.protobuf.Timestamp') -> @@ -993,13 +1237,73 @@ find_msg_def('google.protobuf.Timestamp') -> find_msg_def(_) -> error. -find_enum_def(_) -> error. - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). +find_enum_def('eventssidecar.v1.Reason') -> + [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]; +find_enum_def(_) -> + error. --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). +enum_symbol_by_value('eventssidecar.v1.Reason', Value) -> + 'enum_symbol_by_value_eventssidecar.v1.Reason'(Value). + +enum_value_by_symbol('eventssidecar.v1.Reason', Sym) -> + 'enum_value_by_symbol_eventssidecar.v1.Reason'(Sym). + +'enum_symbol_by_value_eventssidecar.v1.Reason'(0) -> 'REASON_UNSPECIFIED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(1) -> 'REASON_NOT_AUTHORIZED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(2) -> 'REASON_NORMAL_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(3) -> 'REASON_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(4) -> 'REASON_ADMINISTRATIVE_ACTION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(5) -> 'REASON_DISCONNECT_KEEP_ALIVE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(6) -> 'REASON_DISCONNECT_MIGRATION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(7) -> 'REASON_BAD_AUTHENTICATION_METHOD'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(8) -> 'REASON_REMOTE_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(9) -> 'REASON_MQTT_CLIENT_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(10) -> 'REASON_RECEIVE_MAX_EXCEEDED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(11) -> 'REASON_PROTOCOL_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(12) -> 'REASON_PUBLISH_AUTH_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(13) -> 'REASON_INVALID_PUBREC_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(14) -> 'REASON_INVALID_PUBCOMP_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(15) -> 'REASON_UNEXPECTED_FRAME_TYPE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(16) -> 'REASON_EXIT_SIGNAL_RECEIVED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(17) -> 'REASON_TCP_CLOSED'. + +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNSPECIFIED') -> 0; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED') -> 1; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT') -> 2; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER') -> 3; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION') -> 4; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE') -> 5; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION') -> 6; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD') -> 7; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER') -> 8; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT') -> 9; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED') -> 10; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR') -> 11; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR') -> 12; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR') -> 13; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR') -> 14; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE') -> 15; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED') -> 16; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_TCP_CLOSED') -> 17. get_service_names() -> []. @@ -1042,10 +1346,10 @@ msg_name_to_fqbin('eventssidecar.v1.OnClientGone') -> <<"eventssidecar.v1.OnClie msg_name_to_fqbin('google.protobuf.Timestamp') -> <<"google.protobuf.Timestamp">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). --spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(<<"eventssidecar.v1.Reason">>) -> 'eventssidecar.v1.Reason'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). --spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin('eventssidecar.v1.Reason') -> <<"eventssidecar.v1.Reason">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'eventssidecar.v1'. @@ -1061,33 +1365,39 @@ source_basename() -> "on_client_gone.proto". %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension -get_all_source_basenames() -> ["on_client_gone.proto", "timestamp.proto"]. +get_all_source_basenames() -> + ["on_client_gone.proto", "timestamp.proto", "disconnect_reason.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. -get_all_proto_names() -> ["on_client_gone", "timestamp"]. +get_all_proto_names() -> ["on_client_gone", "timestamp", "disconnect_reason"]. get_msg_containment("on_client_gone") -> ['eventssidecar.v1.OnClientGone']; get_msg_containment("timestamp") -> ['google.protobuf.Timestamp']; +get_msg_containment("disconnect_reason") -> []; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("on_client_gone") -> 'eventssidecar.v1'; get_pkg_containment("timestamp") -> 'google.protobuf'; +get_pkg_containment("disconnect_reason") -> 'eventssidecar.v1'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("on_client_gone") -> []; get_service_containment("timestamp") -> []; +get_service_containment("disconnect_reason") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("on_client_gone") -> []; get_rpc_containment("timestamp") -> []; +get_rpc_containment("disconnect_reason") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("on_client_gone") -> []; get_enum_containment("timestamp") -> []; +get_enum_containment("disconnect_reason") -> ['eventssidecar.v1.Reason']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; @@ -1097,18 +1407,18 @@ get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(<<"eventssidecar.v1.Reason">>) -> "disconnect_reason"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -get_protos_by_pkg_name_as_fqbin(<<"eventssidecar.v1">>) -> ["on_client_gone"]; +get_protos_by_pkg_name_as_fqbin(<<"eventssidecar.v1">>) -> ["disconnect_reason", "on_client_gone"]; get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["timestamp"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.19.1". + "4.20.0". gpb_version_as_list() -> - [4, 19, 1]. + [4, 20, 0]. gpb_version_source() -> "file". diff --git a/apps/vmq_proto/src/on_client_offline_pb.erl b/apps/vmq_proto/src/on_client_offline_pb.erl index 574ac4251..91ed81a0a 100644 --- a/apps/vmq_proto/src/on_client_offline_pb.erl +++ b/apps/vmq_proto/src/on_client_offline_pb.erl @@ -1,7 +1,7 @@ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.1 +%% Generated by gpb_compile version 4.20.0 %% Version source: file -module(on_client_offline_pb). @@ -17,6 +17,10 @@ -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([ + 'enum_symbol_by_value_eventssidecar.v1.Reason'/1, + 'enum_value_by_symbol_eventssidecar.v1.Reason'/1 +]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). @@ -50,8 +54,26 @@ -include("gpb.hrl"). %% enumerated types - --export_type([]). +-type 'eventssidecar.v1.Reason'() :: + 'REASON_UNSPECIFIED' + | 'REASON_NOT_AUTHORIZED' + | 'REASON_NORMAL_DISCONNECT' + | 'REASON_SESSION_TAKEN_OVER' + | 'REASON_ADMINISTRATIVE_ACTION' + | 'REASON_DISCONNECT_KEEP_ALIVE' + | 'REASON_DISCONNECT_MIGRATION' + | 'REASON_BAD_AUTHENTICATION_METHOD' + | 'REASON_REMOTE_SESSION_TAKEN_OVER' + | 'REASON_MQTT_CLIENT_DISCONNECT' + | 'REASON_RECEIVE_MAX_EXCEEDED' + | 'REASON_PROTOCOL_ERROR' + | 'REASON_PUBLISH_AUTH_ERROR' + | 'REASON_INVALID_PUBREC_ERROR' + | 'REASON_INVALID_PUBCOMP_ERROR' + | 'REASON_UNEXPECTED_FRAME_TYPE' + | 'REASON_EXIT_SIGNAL_RECEIVED' + | 'REASON_TCP_CLOSED'. +-export_type(['eventssidecar.v1.Reason'/0]). %% message types -type 'eventssidecar.v1.OnClientOffline'() :: #'eventssidecar.v1.OnClientOffline'{}. @@ -89,7 +111,9 @@ encode_msg(Msg, MsgName, Opts) -> 'encode_msg_eventssidecar.v1.OnClientOffline'(Msg, <<>>, TrUserData). 'encode_msg_eventssidecar.v1.OnClientOffline'( - #'eventssidecar.v1.OnClientOffline'{timestamp = F1, client_id = F2, mountpoint = F3}, + #'eventssidecar.v1.OnClientOffline'{ + timestamp = F1, client_id = F2, mountpoint = F3, reason = F4 + }, Bin, TrUserData ) -> @@ -123,15 +147,28 @@ encode_msg(Msg, MsgName, Opts) -> end end end, + B3 = + if + F3 == undefined -> + B2; + true -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end + end, if - F3 == undefined -> - B2; + F4 == undefined -> + B3; true -> begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) + TrF4 = id(F4, TrUserData), + if + TrF4 =:= 'REASON_UNSPECIFIED'; TrF4 =:= 0 -> B3; + true -> 'e_enum_eventssidecar.v1.Reason'(TrF4, <>, TrUserData) end end end. @@ -173,6 +210,45 @@ encode_msg(Msg, MsgName, Opts) -> Bin2 = e_varint(byte_size(SubBin), Bin), <>. +'e_enum_eventssidecar.v1.Reason'('REASON_UNSPECIFIED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'('REASON_TCP_CLOSED', Bin, _TrUserData) -> + <>; +'e_enum_eventssidecar.v1.Reason'(V, Bin, _TrUserData) -> + e_varint(V, Bin). + -compile({nowarn_unused_function, e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). @@ -334,94 +410,109 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> id(undefined, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), + id('REASON_UNSPECIFIED', TrUserData), TrUserData ). 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - <<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientOffline_timestamp'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - <<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientOffline_client_id'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - <<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'd_field_eventssidecar.v1.OnClientOffline_mountpoint'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); -'dfp_read_field_def_eventssidecar.v1.OnClientOffline'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> - #'eventssidecar.v1.OnClientOffline'{timestamp = F@_1, client_id = F@_2, mountpoint = F@_3}; 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData +) -> + 'd_field_eventssidecar.v1.OnClientOffline_reason'( + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); +'dfp_read_field_def_eventssidecar.v1.OnClientOffline'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> + #'eventssidecar.v1.OnClientOffline'{ + timestamp = F@_1, client_id = F@_2, mountpoint = F@_3, reason = F@_4 + }; +'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( + Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dg_read_field_def_eventssidecar.v1.OnClientOffline'( - Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'dg_read_field_def_eventssidecar.v1.OnClientOffline'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 32 - 7 -> 'dg_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'dg_read_field_def_eventssidecar.v1.OnClientOffline'( - <<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> Key = X bsl N + Acc, case Key of 10 -> 'd_field_eventssidecar.v1.OnClientOffline_timestamp'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); 18 -> 'd_field_eventssidecar.v1.OnClientOffline_client_id'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); 26 -> 'd_field_eventssidecar.v1.OnClientOffline_mountpoint'( - Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData + ); + 32 -> + 'd_field_eventssidecar.v1.OnClientOffline_reason'( + Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData ); _ -> case Key band 7 of 0 -> 'skip_varint_eventssidecar.v1.OnClientOffline'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 1 -> 'skip_64_eventssidecar.v1.OnClientOffline'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 2 -> 'skip_length_delimited_eventssidecar.v1.OnClientOffline'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 3 -> 'skip_group_eventssidecar.v1.OnClientOffline'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ); 5 -> 'skip_32_eventssidecar.v1.OnClientOffline'( - Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData + Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData ) end end; -'dg_read_field_def_eventssidecar.v1.OnClientOffline'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> - #'eventssidecar.v1.OnClientOffline'{timestamp = F@_1, client_id = F@_2, mountpoint = F@_3}. +'dg_read_field_def_eventssidecar.v1.OnClientOffline'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> + #'eventssidecar.v1.OnClientOffline'{ + timestamp = F@_1, client_id = F@_2, mountpoint = F@_3, reason = F@_4 + }. 'd_field_eventssidecar.v1.OnClientOffline_timestamp'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientOffline_timestamp'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientOffline_timestamp'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -439,17 +530,18 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> end, F@_2, F@_3, + F@_4, TrUserData ). 'd_field_eventssidecar.v1.OnClientOffline_client_id'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientOffline_client_id'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientOffline_client_id'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -458,17 +550,17 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> {id(Bytes2, TrUserData), Rest2} end, 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData + RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData ). 'd_field_eventssidecar.v1.OnClientOffline_mountpoint'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'd_field_eventssidecar.v1.OnClientOffline_mountpoint'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'd_field_eventssidecar.v1.OnClientOffline_mountpoint'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData ) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, @@ -477,53 +569,78 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> {id(Bytes2, TrUserData), Rest2} end, 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData + RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData + ). + +'d_field_eventssidecar.v1.OnClientOffline_reason'( + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData +) when N < 57 -> + 'd_field_eventssidecar.v1.OnClientOffline_reason'( + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); +'d_field_eventssidecar.v1.OnClientOffline_reason'( + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData +) -> + {NewFValue, RestF} = { + id( + 'd_enum_eventssidecar.v1.Reason'(begin + <> = <<(X bsl N + Acc):32/unsigned-native>>, + id(Res, TrUserData) + end), + TrUserData + ), + Rest + }, + 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( + RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData ). 'skip_varint_eventssidecar.v1.OnClientOffline'( - <<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> - 'skip_varint_eventssidecar.v1.OnClientOffline'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); + 'skip_varint_eventssidecar.v1.OnClientOffline'( + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData + ); 'skip_varint_eventssidecar.v1.OnClientOffline'( - <<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_length_delimited_eventssidecar.v1.OnClientOffline'( - <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) when N < 57 -> 'skip_length_delimited_eventssidecar.v1.OnClientOffline'( - Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData + Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ); 'skip_length_delimited_eventssidecar.v1.OnClientOffline'( - <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData + <<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData + Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). -'skip_group_eventssidecar.v1.OnClientOffline'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> +'skip_group_eventssidecar.v1.OnClientOffline'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData + Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_32_eventssidecar.v1.OnClientOffline'( - <<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'skip_64_eventssidecar.v1.OnClientOffline'( - <<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + <<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ) -> 'dfp_read_field_def_eventssidecar.v1.OnClientOffline'( - Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData + Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData ). 'decode_msg_google.protobuf.Timestamp'(Bin, TrUserData) -> @@ -654,6 +771,26 @@ decode_msg_2_doit('google.protobuf.Timestamp', Bin, TrUserData) -> 'skip_64_google.protobuf.Timestamp'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> 'dfp_read_field_def_google.protobuf.Timestamp'(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). +'d_enum_eventssidecar.v1.Reason'(0) -> 'REASON_UNSPECIFIED'; +'d_enum_eventssidecar.v1.Reason'(1) -> 'REASON_NOT_AUTHORIZED'; +'d_enum_eventssidecar.v1.Reason'(2) -> 'REASON_NORMAL_DISCONNECT'; +'d_enum_eventssidecar.v1.Reason'(3) -> 'REASON_SESSION_TAKEN_OVER'; +'d_enum_eventssidecar.v1.Reason'(4) -> 'REASON_ADMINISTRATIVE_ACTION'; +'d_enum_eventssidecar.v1.Reason'(5) -> 'REASON_DISCONNECT_KEEP_ALIVE'; +'d_enum_eventssidecar.v1.Reason'(6) -> 'REASON_DISCONNECT_MIGRATION'; +'d_enum_eventssidecar.v1.Reason'(7) -> 'REASON_BAD_AUTHENTICATION_METHOD'; +'d_enum_eventssidecar.v1.Reason'(8) -> 'REASON_REMOTE_SESSION_TAKEN_OVER'; +'d_enum_eventssidecar.v1.Reason'(9) -> 'REASON_MQTT_CLIENT_DISCONNECT'; +'d_enum_eventssidecar.v1.Reason'(10) -> 'REASON_RECEIVE_MAX_EXCEEDED'; +'d_enum_eventssidecar.v1.Reason'(11) -> 'REASON_PROTOCOL_ERROR'; +'d_enum_eventssidecar.v1.Reason'(12) -> 'REASON_PUBLISH_AUTH_ERROR'; +'d_enum_eventssidecar.v1.Reason'(13) -> 'REASON_INVALID_PUBREC_ERROR'; +'d_enum_eventssidecar.v1.Reason'(14) -> 'REASON_INVALID_PUBCOMP_ERROR'; +'d_enum_eventssidecar.v1.Reason'(15) -> 'REASON_UNEXPECTED_FRAME_TYPE'; +'d_enum_eventssidecar.v1.Reason'(16) -> 'REASON_EXIT_SIGNAL_RECEIVED'; +'d_enum_eventssidecar.v1.Reason'(17) -> 'REASON_TCP_CLOSED'; +'d_enum_eventssidecar.v1.Reason'(V) -> V. + read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, @@ -747,10 +884,16 @@ merge_msgs(Prev, New, MsgName, Opts) -> -compile({nowarn_unused_function, 'merge_msg_eventssidecar.v1.OnClientOffline'/3}). 'merge_msg_eventssidecar.v1.OnClientOffline'( #'eventssidecar.v1.OnClientOffline'{ - timestamp = PFtimestamp, client_id = PFclient_id, mountpoint = PFmountpoint + timestamp = PFtimestamp, + client_id = PFclient_id, + mountpoint = PFmountpoint, + reason = PFreason }, #'eventssidecar.v1.OnClientOffline'{ - timestamp = NFtimestamp, client_id = NFclient_id, mountpoint = NFmountpoint + timestamp = NFtimestamp, + client_id = NFclient_id, + mountpoint = NFmountpoint, + reason = NFreason }, TrUserData ) -> @@ -773,6 +916,11 @@ merge_msgs(Prev, New, MsgName, Opts) -> if NFmountpoint =:= undefined -> PFmountpoint; true -> NFmountpoint + end, + reason = + if + NFreason =:= undefined -> PFreason; + true -> NFreason end }. @@ -816,13 +964,15 @@ verify_msg(Msg, MsgName, Opts) -> -compile({nowarn_unused_function, 'v_msg_eventssidecar.v1.OnClientOffline'/3}). -dialyzer({nowarn_function, 'v_msg_eventssidecar.v1.OnClientOffline'/3}). 'v_msg_eventssidecar.v1.OnClientOffline'( - #'eventssidecar.v1.OnClientOffline'{timestamp = F1, client_id = F2, mountpoint = F3}, + #'eventssidecar.v1.OnClientOffline'{ + timestamp = F1, client_id = F2, mountpoint = F3, reason = F4 + }, Path, TrUserData ) -> if F1 == undefined -> ok; - true -> 'v_msg_google.protobuf.Timestamp'(F1, [timestamp | Path], TrUserData) + true -> 'v_submsg_google.protobuf.Timestamp'(F1, [timestamp | Path], TrUserData) end, if F2 == undefined -> ok; @@ -832,10 +982,19 @@ verify_msg(Msg, MsgName, Opts) -> F3 == undefined -> ok; true -> v_type_string(F3, [mountpoint | Path], TrUserData) end, + if + F4 == undefined -> ok; + true -> 'v_enum_eventssidecar.v1.Reason'(F4, [reason | Path], TrUserData) + end, ok; 'v_msg_eventssidecar.v1.OnClientOffline'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'eventssidecar.v1.OnClientOffline'}, X, Path). +-compile({nowarn_unused_function, 'v_submsg_google.protobuf.Timestamp'/3}). +-dialyzer({nowarn_function, 'v_submsg_google.protobuf.Timestamp'/3}). +'v_submsg_google.protobuf.Timestamp'(Msg, Path, TrUserData) -> + 'v_msg_google.protobuf.Timestamp'(Msg, Path, TrUserData). + -compile({nowarn_unused_function, 'v_msg_google.protobuf.Timestamp'/3}). -dialyzer({nowarn_function, 'v_msg_google.protobuf.Timestamp'/3}). 'v_msg_google.protobuf.Timestamp'( @@ -853,9 +1012,54 @@ verify_msg(Msg, MsgName, Opts) -> 'v_msg_google.protobuf.Timestamp'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'google.protobuf.Timestamp'}, X, Path). +-compile({nowarn_unused_function, 'v_enum_eventssidecar.v1.Reason'/3}). +-dialyzer({nowarn_function, 'v_enum_eventssidecar.v1.Reason'/3}). +'v_enum_eventssidecar.v1.Reason'('REASON_UNSPECIFIED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'('REASON_TCP_CLOSED', _Path, _TrUserData) -> + ok; +'v_enum_eventssidecar.v1.Reason'(V, _Path, _TrUserData) when + -2147483648 =< V, V =< 2147483647, is_integer(V) +-> + ok; +'v_enum_eventssidecar.v1.Reason'(X, Path, _TrUserData) -> + mk_type_error({invalid_enum, 'eventssidecar.v1.Reason'}, X, Path). + -compile({nowarn_unused_function, v_type_int32/3}). -dialyzer({nowarn_function, v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, _Path, _TrUserData) when is_integer(N), -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> @@ -863,7 +1067,10 @@ v_type_int32(X, Path, _TrUserData) -> -compile({nowarn_unused_function, v_type_int64/3}). -dialyzer({nowarn_function, v_type_int64/3}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, _Path, _TrUserData) when + is_integer(N), -9223372036854775808 =< N, N =< 9223372036854775807 +-> + ok; v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); v_type_int64(X, Path, _TrUserData) -> @@ -919,6 +1126,26 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. get_msg_defs() -> [ + {{enum, 'eventssidecar.v1.Reason'}, [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]}, {{msg, 'eventssidecar.v1.OnClientOffline'}, [ #field{ name = timestamp, @@ -943,6 +1170,14 @@ get_msg_defs() -> type = string, occurrence = optional, opts = [] + }, + #field{ + name = reason, + fnum = 4, + rnum = 5, + type = {enum, 'eventssidecar.v1.Reason'}, + occurrence = optional, + opts = [] } ]}, {{msg, 'google.protobuf.Timestamp'}, [ @@ -959,7 +1194,7 @@ get_group_names() -> []. get_msg_or_group_names() -> ['eventssidecar.v1.OnClientOffline', 'google.protobuf.Timestamp']. -get_enum_names() -> []. +get_enum_names() -> ['eventssidecar.v1.Reason']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of @@ -967,8 +1202,11 @@ fetch_msg_def(MsgName) -> error -> erlang:error({no_such_msg, MsgName}) end. --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). +fetch_enum_def(EnumName) -> + case find_enum_def(EnumName) of + Es when is_list(Es) -> Es; + error -> erlang:error({no_such_enum, EnumName}) + end. find_msg_def('eventssidecar.v1.OnClientOffline') -> [ @@ -985,6 +1223,14 @@ find_msg_def('eventssidecar.v1.OnClientOffline') -> }, #field{ name = mountpoint, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = [] + }, + #field{ + name = reason, + fnum = 4, + rnum = 5, + type = {enum, 'eventssidecar.v1.Reason'}, + occurrence = optional, + opts = [] } ]; find_msg_def('google.protobuf.Timestamp') -> @@ -995,13 +1241,73 @@ find_msg_def('google.protobuf.Timestamp') -> find_msg_def(_) -> error. -find_enum_def(_) -> error. - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). +find_enum_def('eventssidecar.v1.Reason') -> + [ + {'REASON_UNSPECIFIED', 0}, + {'REASON_NOT_AUTHORIZED', 1}, + {'REASON_NORMAL_DISCONNECT', 2}, + {'REASON_SESSION_TAKEN_OVER', 3}, + {'REASON_ADMINISTRATIVE_ACTION', 4}, + {'REASON_DISCONNECT_KEEP_ALIVE', 5}, + {'REASON_DISCONNECT_MIGRATION', 6}, + {'REASON_BAD_AUTHENTICATION_METHOD', 7}, + {'REASON_REMOTE_SESSION_TAKEN_OVER', 8}, + {'REASON_MQTT_CLIENT_DISCONNECT', 9}, + {'REASON_RECEIVE_MAX_EXCEEDED', 10}, + {'REASON_PROTOCOL_ERROR', 11}, + {'REASON_PUBLISH_AUTH_ERROR', 12}, + {'REASON_INVALID_PUBREC_ERROR', 13}, + {'REASON_INVALID_PUBCOMP_ERROR', 14}, + {'REASON_UNEXPECTED_FRAME_TYPE', 15}, + {'REASON_EXIT_SIGNAL_RECEIVED', 16}, + {'REASON_TCP_CLOSED', 17} + ]; +find_enum_def(_) -> + error. --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). +enum_symbol_by_value('eventssidecar.v1.Reason', Value) -> + 'enum_symbol_by_value_eventssidecar.v1.Reason'(Value). + +enum_value_by_symbol('eventssidecar.v1.Reason', Sym) -> + 'enum_value_by_symbol_eventssidecar.v1.Reason'(Sym). + +'enum_symbol_by_value_eventssidecar.v1.Reason'(0) -> 'REASON_UNSPECIFIED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(1) -> 'REASON_NOT_AUTHORIZED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(2) -> 'REASON_NORMAL_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(3) -> 'REASON_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(4) -> 'REASON_ADMINISTRATIVE_ACTION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(5) -> 'REASON_DISCONNECT_KEEP_ALIVE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(6) -> 'REASON_DISCONNECT_MIGRATION'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(7) -> 'REASON_BAD_AUTHENTICATION_METHOD'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(8) -> 'REASON_REMOTE_SESSION_TAKEN_OVER'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(9) -> 'REASON_MQTT_CLIENT_DISCONNECT'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(10) -> 'REASON_RECEIVE_MAX_EXCEEDED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(11) -> 'REASON_PROTOCOL_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(12) -> 'REASON_PUBLISH_AUTH_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(13) -> 'REASON_INVALID_PUBREC_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(14) -> 'REASON_INVALID_PUBCOMP_ERROR'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(15) -> 'REASON_UNEXPECTED_FRAME_TYPE'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(16) -> 'REASON_EXIT_SIGNAL_RECEIVED'; +'enum_symbol_by_value_eventssidecar.v1.Reason'(17) -> 'REASON_TCP_CLOSED'. + +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNSPECIFIED') -> 0; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NOT_AUTHORIZED') -> 1; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_NORMAL_DISCONNECT') -> 2; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_SESSION_TAKEN_OVER') -> 3; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_ADMINISTRATIVE_ACTION') -> 4; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_KEEP_ALIVE') -> 5; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_DISCONNECT_MIGRATION') -> 6; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_BAD_AUTHENTICATION_METHOD') -> 7; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_REMOTE_SESSION_TAKEN_OVER') -> 8; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_MQTT_CLIENT_DISCONNECT') -> 9; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_RECEIVE_MAX_EXCEEDED') -> 10; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PROTOCOL_ERROR') -> 11; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_PUBLISH_AUTH_ERROR') -> 12; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBREC_ERROR') -> 13; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_INVALID_PUBCOMP_ERROR') -> 14; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_UNEXPECTED_FRAME_TYPE') -> 15; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_EXIT_SIGNAL_RECEIVED') -> 16; +'enum_value_by_symbol_eventssidecar.v1.Reason'('REASON_TCP_CLOSED') -> 17. get_service_names() -> []. @@ -1044,10 +1350,10 @@ msg_name_to_fqbin('eventssidecar.v1.OnClientOffline') -> <<"eventssidecar.v1.OnC msg_name_to_fqbin('google.protobuf.Timestamp') -> <<"google.protobuf.Timestamp">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). --spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(<<"eventssidecar.v1.Reason">>) -> 'eventssidecar.v1.Reason'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). --spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin('eventssidecar.v1.Reason') -> <<"eventssidecar.v1.Reason">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'eventssidecar.v1'. @@ -1063,33 +1369,39 @@ source_basename() -> "on_client_offline.proto". %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension -get_all_source_basenames() -> ["on_client_offline.proto", "timestamp.proto"]. +get_all_source_basenames() -> + ["on_client_offline.proto", "timestamp.proto", "disconnect_reason.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. -get_all_proto_names() -> ["on_client_offline", "timestamp"]. +get_all_proto_names() -> ["on_client_offline", "timestamp", "disconnect_reason"]. get_msg_containment("on_client_offline") -> ['eventssidecar.v1.OnClientOffline']; get_msg_containment("timestamp") -> ['google.protobuf.Timestamp']; +get_msg_containment("disconnect_reason") -> []; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("on_client_offline") -> 'eventssidecar.v1'; get_pkg_containment("timestamp") -> 'google.protobuf'; +get_pkg_containment("disconnect_reason") -> 'eventssidecar.v1'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("on_client_offline") -> []; get_service_containment("timestamp") -> []; +get_service_containment("disconnect_reason") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("on_client_offline") -> []; get_rpc_containment("timestamp") -> []; +get_rpc_containment("disconnect_reason") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("on_client_offline") -> []; get_enum_containment("timestamp") -> []; +get_enum_containment("disconnect_reason") -> ['eventssidecar.v1.Reason']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; @@ -1099,18 +1411,21 @@ get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(<<"eventssidecar.v1.Reason">>) -> "disconnect_reason"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -get_protos_by_pkg_name_as_fqbin(<<"eventssidecar.v1">>) -> ["on_client_offline"]; -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["timestamp"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). +get_protos_by_pkg_name_as_fqbin(<<"eventssidecar.v1">>) -> + ["disconnect_reason", "on_client_offline"]; +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> + ["timestamp"]; +get_protos_by_pkg_name_as_fqbin(E) -> + error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.19.1". + "4.20.0". gpb_version_as_list() -> - [4, 19, 1]. + [4, 20, 0]. gpb_version_source() -> "file". diff --git a/apps/vmq_server/src/vmq_metrics.erl b/apps/vmq_server/src/vmq_metrics.erl index 0f5ff8fdc..8a231c419 100644 --- a/apps/vmq_server/src/vmq_metrics.erl +++ b/apps/vmq_server/src/vmq_metrics.erl @@ -890,7 +890,8 @@ internal_defs() -> mqtt5_auth_received_def(), sidecar_events_def(), redis_def(), - msg_store_ops_def() + msg_store_ops_def(), + mqtt_disconnect_def() ], [] ). @@ -1818,6 +1819,39 @@ rcn_to_str(RNC) -> %% TODO: replace this with a real textual representation atom_to_list(RNC). +mqtt_disconnect_def() -> + RCNs = + [ + ?REASON_NOT_AUTHORIZED, + ?REASON_NORMAL_DISCONNECT, + ?REASON_SESSION_TAKEN_OVER, + ?REASON_ADMINISTRATIVE_ACTION, + ?REASON_DISCONNECT_KEEP_ALIVE, + ?REASON_DISCONNECT_MIGRATION, + ?REASON_BAD_AUTHENTICATION_METHOD, + ?REASON_REMOTE_SESSION_TAKEN_OVER, + ?REASON_MQTT_CLIENT_DISCONNECT, + ?REASON_RECEIVE_MAX_EXCEEDED, + ?REASON_PROTOCOL_ERROR, + ?REASON_PUBLISH_AUTH_ERROR, + ?REASON_INVALID_PUBREC_ERROR, + ?REASON_INVALID_PUBCOMP_ERROR, + ?REASON_UNEXPECTED_FRAME_TYPE, + ?REASON_EXIT_SIGNAL_RECEIVED, + ?REASON_TCP_CLOSED, + ?REASON_UNSPECIFIED + ], + [ + m( + counter, + [{mqtt_version, "4"}, {reason_code, rcn_to_str(RCN)}], + {?MQTT_DISONNECT, RCN}, + ?MQTT_DISONNECT, + <<"The number of client disconnects seperated by reason codes.">> + ) + || RCN <- RCNs + ]. + mqtt5_disconnect_recv_def() -> RCNs = [ @@ -2809,7 +2843,25 @@ met2idx({?REDIS_CMD_ERROR, ?FUNCTION_LOAD, ?REAP_SUBSCRIBERS}) -> 338; met2idx({?REDIS_CMD, ?SCARD, ?ENSURE_NO_LOCAL_CLIENT}) -> 339; met2idx({?REDIS_CMD_ERROR, ?SCARD, ?ENSURE_NO_LOCAL_CLIENT}) -> 340; met2idx({?REDIS_CMD_MISS, ?SCARD, ?ENSURE_NO_LOCAL_CLIENT}) -> 341; -met2idx(msg_enqueue_subscriber_not_found) -> 342. +met2idx(msg_enqueue_subscriber_not_found) -> 342; +met2idx({?MQTT_DISONNECT, ?REASON_NOT_AUTHORIZED}) -> 343; +met2idx({?MQTT_DISONNECT, ?REASON_NORMAL_DISCONNECT}) -> 344; +met2idx({?MQTT_DISONNECT, ?REASON_SESSION_TAKEN_OVER}) -> 345; +met2idx({?MQTT_DISONNECT, ?REASON_ADMINISTRATIVE_ACTION}) -> 346; +met2idx({?MQTT_DISONNECT, ?REASON_DISCONNECT_KEEP_ALIVE}) -> 347; +met2idx({?MQTT_DISONNECT, ?REASON_DISCONNECT_MIGRATION}) -> 348; +met2idx({?MQTT_DISONNECT, ?REASON_BAD_AUTHENTICATION_METHOD}) -> 349; +met2idx({?MQTT_DISONNECT, ?REASON_REMOTE_SESSION_TAKEN_OVER}) -> 350; +met2idx({?MQTT_DISONNECT, ?REASON_MQTT_CLIENT_DISCONNECT}) -> 351; +met2idx({?MQTT_DISONNECT, ?REASON_RECEIVE_MAX_EXCEEDED}) -> 352; +met2idx({?MQTT_DISONNECT, ?REASON_PROTOCOL_ERROR}) -> 353; +met2idx({?MQTT_DISONNECT, ?REASON_PUBLISH_AUTH_ERROR}) -> 354; +met2idx({?MQTT_DISONNECT, ?REASON_INVALID_PUBREC_ERROR}) -> 355; +met2idx({?MQTT_DISONNECT, ?REASON_INVALID_PUBCOMP_ERROR}) -> 356; +met2idx({?MQTT_DISONNECT, ?REASON_UNEXPECTED_FRAME_TYPE}) -> 357; +met2idx({?MQTT_DISONNECT, ?REASON_EXIT_SIGNAL_RECEIVED}) -> 358; +met2idx({?MQTT_DISONNECT, ?REASON_TCP_CLOSED}) -> 359; +met2idx({?MQTT_DISONNECT, ?REASON_UNSPECIFIED}) -> 360. -ifdef(TEST). clear_stored_rates() -> diff --git a/apps/vmq_server/src/vmq_metrics.hrl b/apps/vmq_server/src/vmq_metrics.hrl index 6fb60533c..34821ff2c 100644 --- a/apps/vmq_server/src/vmq_metrics.hrl +++ b/apps/vmq_server/src/vmq_metrics.hrl @@ -137,3 +137,22 @@ -define(RETRY, false). -define(QOS1_NON_RETRY_DROPPED, qos1_non_retry_dropped). -define(QOS1_NON_PERSISTENCE_DROPPED, qos1_non_persistence_dropped). +-define(MQTT_DISONNECT, mqtt_disconnect). +-define(REASON_NOT_AUTHORIZED, 'REASON_NOT_AUTHORIZED'). +-define(REASON_NORMAL_DISCONNECT, 'REASON_NORMAL_DISCONNECT'). +-define(REASON_SESSION_TAKEN_OVER, 'REASON_SESSION_TAKEN_OVER'). +-define(REASON_ADMINISTRATIVE_ACTION, 'REASON_ADMINISTRATIVE_ACTION'). +-define(REASON_DISCONNECT_KEEP_ALIVE, 'REASON_DISCONNECT_KEEP_ALIVE'). +-define(REASON_DISCONNECT_MIGRATION, 'REASON_DISCONNECT_MIGRATION'). +-define(REASON_BAD_AUTHENTICATION_METHOD, 'REASON_BAD_AUTHENTICATION_METHOD'). +-define(REASON_REMOTE_SESSION_TAKEN_OVER, 'REASON_REMOTE_SESSION_TAKEN_OVER'). +-define(REASON_MQTT_CLIENT_DISCONNECT, 'REASON_MQTT_CLIENT_DISCONNECT'). +-define(REASON_RECEIVE_MAX_EXCEEDED, 'REASON_RECEIVE_MAX_EXCEEDED'). +-define(REASON_PROTOCOL_ERROR, 'REASON_PROTOCOL_ERROR'). +-define(REASON_PUBLISH_AUTH_ERROR, 'REASON_PUBLISH_AUTH_ERROR'). +-define(REASON_INVALID_PUBREC_ERROR, 'REASON_INVALID_PUBREC_ERROR'). +-define(REASON_INVALID_PUBCOMP_ERROR, 'REASON_INVALID_PUBCOMP_ERROR'). +-define(REASON_UNEXPECTED_FRAME_TYPE, 'REASON_UNEXPECTED_FRAME_TYPE'). +-define(REASON_EXIT_SIGNAL_RECEIVED, 'REASON_EXIT_SIGNAL_RECEIVED'). +-define(REASON_TCP_CLOSED, 'REASON_TCP_CLOSED'). +-define(REASON_UNSPECIFIED, 'REASON_UNSPECIFIED'). diff --git a/apps/vmq_server/src/vmq_mqtt5_fsm.erl b/apps/vmq_server/src/vmq_mqtt5_fsm.erl index 733f21c7e..7e11a0820 100644 --- a/apps/vmq_server/src/vmq_mqtt5_fsm.erl +++ b/apps/vmq_server/src/vmq_mqtt5_fsm.erl @@ -904,6 +904,10 @@ terminate( %% MQTT errors and as such we don't tell the client %% about them, we just drop the connection. []; + ?EXIT_SIGNAL_RECEIVED -> + [gen_disconnect(?NORMAL_DISCONNECT, Props)]; + ?TCP_CLOSED -> + [gen_disconnect(?NORMAL_DISCONNECT, Props)]; _ -> [gen_disconnect(Reason, Props)] end, diff --git a/apps/vmq_server/src/vmq_mqtt_fsm.erl b/apps/vmq_server/src/vmq_mqtt_fsm.erl index f86ea3e64..ec34de541 100644 --- a/apps/vmq_server/src/vmq_mqtt_fsm.erl +++ b/apps/vmq_server/src/vmq_mqtt_fsm.erl @@ -265,7 +265,7 @@ connected( end, case Ret of {error, not_allowed} -> - terminate(publish_not_authorized_3_1_1, State); + terminate(?PUBLISH_AUTH_ERROR, State); Out when is_list(Out) -> case do_throttle(#{}, State) of false -> @@ -372,7 +372,7 @@ connected(#mqtt_pubrec{message_id = MessageId}, State) -> not_found -> lager:debug("stopped connected session, due to unknown qos2 pubrec ~p", [MessageId]), _ = vmq_metrics:incr_mqtt_error_invalid_pubrec(), - terminate(normal, State) + terminate(?INVALID_PUBREC_ERROR, State) end; connected(#mqtt_pubrel{message_id = MessageId}, State) -> #state{waiting_acks = WAcks} = State, @@ -406,7 +406,7 @@ connected(#mqtt_pubcomp{message_id = MessageId}, State) -> not_found -> lager:debug("stopped connected session, due to qos2 pubrel missing ~p", [MessageId]), _ = vmq_metrics:incr_mqtt_error_invalid_pubcomp(), - terminate(normal, State) + terminate(?INVALID_PUBCOMP_ERROR, State) end; connected( #mqtt_subscribe{message_id = MessageId, topics = Topics}, @@ -485,7 +485,7 @@ connected(#mqtt_pingreq{}, State) -> {State, [Frame]}; connected(#mqtt_disconnect{}, State) -> _ = vmq_metrics:incr_mqtt_disconnect_received(), - terminate(mqtt_client_disconnect, State); + terminate(?CLIENT_DISCONNECT, State); connected( retry, #state{ @@ -515,7 +515,7 @@ connected( SubscriberId, UserName ]), _ = vmq_metrics:incr(?MQTT4_CLIENT_KEEPALIVE_EXPIRED), - terminate(normal, State); + terminate(?DISCONNECT_KEEP_ALIVE, State); false -> set_keepalive_check_timer(KeepAlive), {State, []} @@ -556,17 +556,25 @@ queue_down_terminate(shutdown, State) -> queue_down_terminate(Reason, #state{queue_pid = QPid} = State) -> terminate({error, {queue_down, QPid, Reason}}, State). -terminate(Reason, #state{clean_session = CleanSession} = State) -> +terminate(Reason, #state{clean_session = CleanSession, queue_pid = QueuePid} = State) -> _ = case CleanSession of true -> ok; false -> handle_waiting_acks_and_msgs(State) end, + + NewReason = + case Reason of + {error, unexpected_message, _} -> ?UNEXPECTED_FRAME_TYPE; + _ -> Reason + end, %% TODO: the counter update is missing the last will message maybe_publish_last_will(State, Reason), + ProtoReason = vmq_mqtt_fsm_util:terminate_proto_reason(NewReason), + _ = vmq_metrics:incr({?MQTT_DISONNECT, ProtoReason}), + vmq_queue:set_last_disconnect_reason(QueuePid, ProtoReason), {stop, terminate_reason(Reason), []}. -terminate_reason(publish_not_authorized_3_1_1) -> normal; terminate_reason(Reason) -> vmq_mqtt_fsm_util:terminate_reason(Reason). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/apps/vmq_server/src/vmq_mqtt_fsm_util.erl b/apps/vmq_server/src/vmq_mqtt_fsm_util.erl index 98f6c57f6..4277f119a 100644 --- a/apps/vmq_server/src/vmq_mqtt_fsm_util.erl +++ b/apps/vmq_server/src/vmq_mqtt_fsm_util.erl @@ -14,6 +14,7 @@ -module(vmq_mqtt_fsm_util). -include("vmq_server.hrl"). +-include("vmq_metrics.hrl"). -include_lib("vmq_commons/include/vmq_types.hrl"). -export([ @@ -23,7 +24,8 @@ plugin_receive_loop/2, to_vmq_subtopics/2, peertoa/1, - terminate_reason/1 + terminate_reason/1, + terminate_proto_reason/1 ]). -define(TO_SESSION, to_session_fsm). @@ -143,4 +145,33 @@ terminate_reason(?DISCONNECT_MIGRATION) -> normal; terminate_reason(?NORMAL_DISCONNECT) -> normal; terminate_reason(?SESSION_TAKEN_OVER) -> normal; terminate_reason(?REMOTE_SESSION_TAKEN_OVER) -> normal; +terminate_reason(?INVALID_PUBREC_ERROR) -> normal; +terminate_reason(?INVALID_PUBCOMP_ERROR) -> normal; +terminate_reason(?TCP_CLOSED) -> normal; +terminate_reason(?EXIT_SIGNAL_RECEIVED) -> normal; +terminate_reason(?PUBLISH_AUTH_ERROR) -> normal; terminate_reason(Reason) -> Reason. + +-spec terminate_proto_reason(any()) -> any(). +terminate_proto_reason(Reason) -> + case Reason of + ?NOT_AUTHORIZED -> ?REASON_NOT_AUTHORIZED; + ?NORMAL_DISCONNECT -> ?REASON_NORMAL_DISCONNECT; + ?SESSION_TAKEN_OVER -> ?REASON_SESSION_TAKEN_OVER; + ?ADMINISTRATIVE_ACTION -> ?REASON_ADMINISTRATIVE_ACTION; + ?DISCONNECT_KEEP_ALIVE -> ?REASON_DISCONNECT_KEEP_ALIVE; + ?DISCONNECT_MIGRATION -> ?REASON_DISCONNECT_MIGRATION; + ?BAD_AUTHENTICATION_METHOD -> ?REASON_BAD_AUTHENTICATION_METHOD; + ?REMOTE_SESSION_TAKEN_OVER -> ?REASON_REMOTE_SESSION_TAKEN_OVER; + ?CLIENT_DISCONNECT -> ?REASON_MQTT_CLIENT_DISCONNECT; + ?RECEIVE_MAX_EXCEEDED -> ?REASON_RECEIVE_MAX_EXCEEDED; + ?PROTOCOL_ERROR -> ?REASON_PROTOCOL_ERROR; + ?PUBLISH_AUTH_ERROR -> ?REASON_PUBLISH_AUTH_ERROR; + ?INVALID_PUBREC_ERROR -> ?REASON_INVALID_PUBREC_ERROR; + ?INVALID_PUBCOMP_ERROR -> ?REASON_INVALID_PUBCOMP_ERROR; + ?UNEXPECTED_FRAME_TYPE -> ?REASON_UNEXPECTED_FRAME_TYPE; + ?EXIT_SIGNAL_RECEIVED -> ?REASON_EXIT_SIGNAL_RECEIVED; + ?TCP_CLOSED -> ?REASON_TCP_CLOSED; + ?NORMAL -> ?REASON_NORMAL_DISCONNECT; + _ -> ?REASON_UNSPECIFIED + end. diff --git a/apps/vmq_server/src/vmq_mqtt_pre_init.erl b/apps/vmq_server/src/vmq_mqtt_pre_init.erl index d8f6c2ff3..048762107 100644 --- a/apps/vmq_server/src/vmq_mqtt_pre_init.erl +++ b/apps/vmq_server/src/vmq_mqtt_pre_init.erl @@ -166,9 +166,9 @@ get_protocol_info(<<0:8, 6:8, "MQIsdp", _:8, _/binary>>) -> get_protocol_info(_) -> more. --spec msg_in('close_timeout' | 'disconnect' | {'disconnect', 'normal_disconnect'}, _) -> +-spec msg_in('close_timeout' | 'disconnect' | {'disconnect', _}, _) -> 'ignore' | {'stop', 'normal', []}. -msg_in({disconnect, ?NORMAL_DISCONNECT}, _FsmState0) -> +msg_in({disconnect, _}, _FsmState0) -> {stop, normal, []}; msg_in(disconnect, _FsmState0) -> ignore; diff --git a/apps/vmq_server/src/vmq_queue.erl b/apps/vmq_server/src/vmq_queue.erl index 26444446d..5dcb2dee4 100644 --- a/apps/vmq_server/src/vmq_queue.erl +++ b/apps/vmq_server/src/vmq_queue.erl @@ -56,7 +56,8 @@ force_disconnect/2, force_disconnect/3, set_delayed_will/3, - init_offline_queue/1 + init_offline_queue/1, + set_last_disconnect_reason/2 ]). -export([ @@ -111,7 +112,8 @@ | undefined, delayed_will_timer :: reference() | undefined, started_at :: vmq_time:timestamp(), - initial_msg_id = 1 :: msg_id() + initial_msg_id = 1 :: msg_id(), + last_disconnect_reason :: atom() | undefined }). -type state() :: #state{}. @@ -160,6 +162,9 @@ set_opts(Queue, Opts) when is_pid(Queue) -> get_opts(Queue) when is_pid(Queue) -> save_sync_send_all_state_event(Queue, get_opts). +set_last_disconnect_reason(Queue, Reason) when is_pid(Queue) -> + gen_fsm:sync_send_all_state_event(Queue, {set_last_disconnect_reason, Reason}, infinity). + force_disconnect(Queue, Reason) when is_pid(Queue) -> force_disconnect(Queue, Reason, false). force_disconnect(Queue, Reason, DoCleanup) when is_pid(Queue) and is_boolean(DoCleanup) -> @@ -691,6 +696,8 @@ handle_sync_event( end; handle_sync_event({set_delayed_will, Fun, Delay}, _From, StateName, State) -> {reply, ok, StateName, State#state{delayed_will = {Delay, Fun}}}; +handle_sync_event({set_last_disconnect_reason, Reason}, _From, StateName, State) -> + {reply, ok, StateName, State#state{last_disconnect_reason = Reason}}; handle_sync_event(Event, _From, _StateName, State) -> {stop, {error, {unknown_sync_event, Event}}, State}. @@ -869,7 +876,7 @@ del_session(SessionPid, #state{id = SId, sessions = Sessions} = State) -> handle_session_down( SessionPid, StateName, - #state{id = SId, waiting_call = WaitingCall} = State + #state{id = SId, waiting_call = WaitingCall, last_disconnect_reason = Reason} = State ) -> {NewState, DeletedSession} = del_session(SessionPid, State), case {maps:size(NewState#state.sessions), StateName, WaitingCall} of @@ -881,9 +888,9 @@ handle_session_down( gen_fsm:reply(From, {ok, RetOpts}), case DeletedSession#session.cleanup_on_disconnect of true -> - _ = vmq_plugin:all(on_client_gone, [SId]); + _ = vmq_plugin:all(on_client_gone, [SId, Reason]); false -> - _ = vmq_plugin:all(on_client_offline, [SId]) + _ = vmq_plugin:all(on_client_offline, [SId, Reason]) end, {next_state, state_change({'DOWN', add_session}, wait_for_offline, online), add_session_(NewSessionPid, Opts, NewState#state{waiting_call = undefined})}; @@ -895,7 +902,7 @@ handle_session_down( vmq_plugin:all(on_topic_unsubscribed, [SId, all_topics]), vmq_reg:delete_subscriptions(SId), vmq_message_store:delete(SId), - _ = vmq_plugin:all(on_client_gone, [SId]), + _ = vmq_plugin:all(on_client_gone, [SId, Reason]), gen_fsm:reply(From, ok), {stop, normal, NewState}; {0, wait_for_offline, {migrate, _, _}} -> @@ -903,7 +910,7 @@ handle_session_down( %% ... but we've a migrate request waiting %% go into drain state gen_fsm:send_event(self(), drain_start), - _ = vmq_plugin:all(on_client_offline, [SId]), + _ = vmq_plugin:all(on_client_offline, [SId, Reason]), {next_state, state_change({'DOWN', migrate}, wait_for_offline, drain), NewState}; {0, wait_for_offline, {{cleanup, _Reason}, From}} -> %% Forcefully cleaned up, we have to cleanup remaining offline messages @@ -913,7 +920,7 @@ handle_session_down( vmq_message_store:delete(SId), _ = vmq_metrics:incr_queue_unhandled(queue:len(Q)), gen_fsm:reply(From, ok), - _ = vmq_plugin:all(on_client_gone, [SId]), + _ = vmq_plugin:all(on_client_gone, [SId, Reason]), {stop, normal, NewState}; {0, wait_for_offline, {{terminate, _Reason}, From}} -> %% Terminate queue process due to remote sub @@ -928,13 +935,13 @@ handle_session_down( vmq_plugin:all(on_topic_unsubscribed, [SId, all_topics]), vmq_reg:delete_subscriptions(SId), vmq_message_store:delete(SId), - _ = vmq_plugin:all(on_client_gone, [SId]), + _ = vmq_plugin:all(on_client_gone, [SId, Reason]), {stop, normal, NewState}; {0, OldStateName, _} -> %% last session gone %% ... we've to stay around and store the messages %% inside the offline queue - _ = vmq_plugin:all(on_client_offline, [SId]), + _ = vmq_plugin:all(on_client_offline, [SId, Reason]), {next_state, state_change('DOWN', OldStateName, offline), maybe_set_last_will_timer( maybe_set_expiry_timer(NewState#state{ diff --git a/apps/vmq_server/src/vmq_ranch.erl b/apps/vmq_server/src/vmq_ranch.erl index 715432763..21bec2e3e 100644 --- a/apps/vmq_server/src/vmq_ranch.erl +++ b/apps/vmq_server/src/vmq_ranch.erl @@ -259,7 +259,7 @@ handle_message({Proto, _, Data}, #st{proto_tag = {Proto, _, _}, fsm_mod = FsmMod end; handle_message({ProtoClosed, _}, #st{proto_tag = {_, ProtoClosed, _}, fsm_mod = FsmMod} = State) -> %% we regard a tcp_closed as 'normal' - _ = FsmMod:msg_in({disconnect, ?NORMAL_DISCONNECT}, State#st.fsm_state), + _ = FsmMod:msg_in({disconnect, ?TCP_CLOSED}, State#st.fsm_state), {exit, normal, State}; handle_message({ProtoErr, _, Error}, #st{proto_tag = {_, _, ProtoErr}} = State) -> _ = vmq_metrics:incr_socket_error(), @@ -288,7 +288,7 @@ handle_message(restart_work, #st{throttled = true} = State) -> handle_message({Proto, Socket, <<>>}, State#st{throttled = false}); handle_message({'EXIT', _Parent, Reason}, #st{fsm_state = FsmState0, fsm_mod = FsmMod} = State) -> %% TODO: this should probably not be a normal disconnect... - _ = FsmMod:msg_in({disconnect, ?NORMAL_DISCONNECT}, FsmState0), + _ = FsmMod:msg_in({disconnect, ?EXIT_SIGNAL_RECEIVED}, FsmState0), {exit, Reason, State}; handle_message({system, From, Request}, #st{parent = Parent} = State) -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], State); diff --git a/apps/vmq_server/src/vmq_server.hrl b/apps/vmq_server/src/vmq_server.hrl index 1b61c6b91..b5263d327 100644 --- a/apps/vmq_server/src/vmq_server.hrl +++ b/apps/vmq_server/src/vmq_server.hrl @@ -86,4 +86,11 @@ -define(CONSUMER, "consumer"). -define(REMOTE_SESSION_TAKEN_OVER, remote_session_taken_over). +-define(INVALID_PUBREC_ERROR, invalid_pubrec_error). +-define(INVALID_PUBCOMP_ERROR, invalid_pubcomp_error). +-define(PUBLISH_AUTH_ERROR, publish_not_authorized_3_1_1). +-define(TCP_CLOSED, tcp_closed). +-define(EXIT_SIGNAL_RECEIVED, exit_signal_received). +-define(UNEXPECTED_FRAME_TYPE, unexpected_frame_type). +-define(NORMAL, normal). -endif. diff --git a/apps/vmq_server/test/vmq_publish_SUITE.erl b/apps/vmq_server/test/vmq_publish_SUITE.erl index 409f25a5f..8b4470e82 100644 --- a/apps/vmq_server/test/vmq_publish_SUITE.erl +++ b/apps/vmq_server/test/vmq_publish_SUITE.erl @@ -1493,8 +1493,8 @@ hook_on_message_drop(_, Promise, max_packet_size_exceeded) -> hook_on_message_drop({"", <<"message-expiry-sub">>}, _, expired) -> ok. -hook_on_client_offline(SubscriberId) -> - ?CLIENT_OFFLINE_EVENT_SRV ! {on_client_offline, SubscriberId}. +hook_on_client_offline(SubscriberId, Reason) -> + ?CLIENT_OFFLINE_EVENT_SRV ! {on_client_offline, SubscriberId, Reason}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Helper @@ -1599,7 +1599,7 @@ wait_for_offline_event(ClientId, Timeout) -> ClientId end, receive - {on_client_offline, {"", ClientIdBin}} -> + {on_client_offline, {"", ClientIdBin}, _} -> ok after Timeout -> throw(client_not_offline) @@ -1607,12 +1607,12 @@ wait_for_offline_event(ClientId, Timeout) -> start_client_offline_events(Cfg) -> ok = vmq_plugin_mgr:enable_module_plugin( - on_client_offline, ?MODULE, hook_on_client_offline, 1 + on_client_offline, ?MODULE, hook_on_client_offline, 2 ), TestPid = self(), F = fun(Fun) -> receive - {on_client_offline, _} = E -> + {on_client_offline, _, _} = E -> TestPid ! E, Fun(Fun); {stop, Ref} -> @@ -1626,7 +1626,7 @@ start_client_offline_events(Cfg) -> stop_client_offline_events(Cfg) -> ok = vmq_plugin_mgr:disable_module_plugin( - on_client_offline, ?MODULE, hook_on_client_offline, 1 + on_client_offline, ?MODULE, hook_on_client_offline, 2 ), Pid = proplists:get_value(?CLIENT_OFFLINE_EVENT_SRV, Cfg), Ref = make_ref(), diff --git a/apps/vmq_server/test/vmq_queue_hooks_SUITE.erl b/apps/vmq_server/test/vmq_queue_hooks_SUITE.erl index 2949c0cbb..cd61070ed 100644 --- a/apps/vmq_server/test/vmq_queue_hooks_SUITE.erl +++ b/apps/vmq_server/test/vmq_queue_hooks_SUITE.erl @@ -17,8 +17,8 @@ -export([hook_auth_on_subscribe/3, hook_auth_on_publish/6, - hook_on_client_gone/1, - hook_on_client_offline/1, + hook_on_client_gone/2, + hook_on_client_offline/2, hook_on_client_wakeup/1, hook_on_session_expired/1, hook_on_offline_message/5, @@ -178,14 +178,14 @@ hook_on_client_wakeup({"", <<"queue-client">>}) -> hook_on_client_wakeup(_) -> ok. -hook_on_client_gone({"", <<"queue-client">>}) -> +hook_on_client_gone({"", <<"queue-client">>}, _) -> ets:insert(?MODULE, {on_client_gone, true}); -hook_on_client_gone(_) -> +hook_on_client_gone(_, _) -> ok. -hook_on_client_offline({"", <<"queue-client">>}) -> +hook_on_client_offline({"", <<"queue-client">>}, _) -> ets:insert(?MODULE, {on_client_offline, true}); -hook_on_client_offline(_) -> +hook_on_client_offline(_, _) -> ok. hook_on_session_expired({"", <<"queue-client">>}) -> @@ -222,9 +222,9 @@ disable_on_publish() -> enable_queue_hooks() -> vmq_plugin_mgr:enable_module_plugin( - on_client_gone, ?MODULE, hook_on_client_gone, 1), + on_client_gone, ?MODULE, hook_on_client_gone, 2), vmq_plugin_mgr:enable_module_plugin( - on_client_offline, ?MODULE, hook_on_client_offline, 1), + on_client_offline, ?MODULE, hook_on_client_offline, 2), vmq_plugin_mgr:enable_module_plugin( on_client_wakeup, ?MODULE, hook_on_client_wakeup, 1), vmq_plugin_mgr:enable_module_plugin( @@ -236,9 +236,9 @@ enable_queue_hooks() -> disable_queue_hooks() -> vmq_plugin_mgr:disable_module_plugin( - on_client_gone, ?MODULE, hook_on_client_gone, 1), + on_client_gone, ?MODULE, hook_on_client_gone, 2), vmq_plugin_mgr:disable_module_plugin( - on_client_offline, ?MODULE, hook_on_client_offline, 1), + on_client_offline, ?MODULE, hook_on_client_offline, 2), vmq_plugin_mgr:disable_module_plugin( on_client_wakeup, ?MODULE, hook_on_client_wakeup, 1), vmq_plugin_mgr:disable_module_plugin( diff --git a/apps/vmq_webhooks/src/vmq_webhooks.app.src b/apps/vmq_webhooks/src/vmq_webhooks.app.src index ecb397ed2..eff40edec 100644 --- a/apps/vmq_webhooks/src/vmq_webhooks.app.src +++ b/apps/vmq_webhooks/src/vmq_webhooks.app.src @@ -41,10 +41,10 @@ {vmq_webhooks_plugin, on_offline_message, 5, []}, {vmq_webhooks_plugin, on_client_wakeup, 1, []}, - {vmq_webhooks_plugin, on_client_offline, 1, []}, + {vmq_webhooks_plugin, on_client_offline, 2, []}, {vmq_webhooks_plugin, on_session_expired, 1, []}, {vmq_webhooks_plugin, on_delivery_complete, 6, []}, - {vmq_webhooks_plugin, on_client_gone, 1, []} + {vmq_webhooks_plugin, on_client_gone, 2, []} ]} ]}, {modules, []}, diff --git a/apps/vmq_webhooks/src/vmq_webhooks_plugin.erl b/apps/vmq_webhooks/src/vmq_webhooks_plugin.erl index fa7e4a459..685a036d2 100644 --- a/apps/vmq_webhooks/src/vmq_webhooks_plugin.erl +++ b/apps/vmq_webhooks/src/vmq_webhooks_plugin.erl @@ -52,8 +52,8 @@ on_deliver/6, on_offline_message/5, on_client_wakeup/1, - on_client_offline/1, - on_client_gone/1, + on_client_offline/2, + on_client_gone/2, on_session_expired/1, on_delivery_complete/6, @@ -561,16 +561,16 @@ on_client_wakeup(SubscriberId) -> {client_id, ClientId} ]). --spec on_client_offline(subscriber_id()) -> 'next'. -on_client_offline(SubscriberId) -> +-spec on_client_offline(subscriber_id(), _) -> 'next'. +on_client_offline(SubscriberId, _) -> {MP, ClientId} = subscriber_id(SubscriberId), all(on_client_offline, [ {mountpoint, MP}, {client_id, ClientId} ]). --spec on_client_gone(subscriber_id()) -> 'next'. -on_client_gone(SubscriberId) -> +-spec on_client_gone(subscriber_id(), _) -> 'next'. +on_client_gone(SubscriberId, _) -> {MP, ClientId} = subscriber_id(SubscriberId), all(on_client_gone, [ {mountpoint, MP}, diff --git a/apps/vmq_webhooks/test/vmq_webhooks_SUITE.erl b/apps/vmq_webhooks/test/vmq_webhooks_SUITE.erl index ab03e16c0..e870e689b 100644 --- a/apps/vmq_webhooks/test/vmq_webhooks_SUITE.erl +++ b/apps/vmq_webhooks/test/vmq_webhooks_SUITE.erl @@ -455,14 +455,14 @@ on_client_wakeup_test(_) -> on_client_offline_test(_) -> register_hook(on_client_offline, ?ENDPOINT), Self = pid_to_bin(self()), - [next] = vmq_plugin:all(on_client_offline, [{?MOUNTPOINT, Self}]), + [next] = vmq_plugin:all(on_client_offline, [{?MOUNTPOINT, Self}, ?REASON]), ok = exp_response(on_client_offline_ok), deregister_hook(on_client_offline, ?ENDPOINT). on_client_gone_test(_) -> register_hook(on_client_gone, ?ENDPOINT), Self = pid_to_bin(self()), - [next] = vmq_plugin:all(on_client_gone, [{?MOUNTPOINT, Self}]), + [next] = vmq_plugin:all(on_client_gone, [{?MOUNTPOINT, Self}, ?REASON]), ok = exp_response(on_client_gone_ok), deregister_hook(on_client_gone, ?ENDPOINT). diff --git a/apps/vmq_webhooks/test/vmq_webhooks_test.hrl b/apps/vmq_webhooks/test/vmq_webhooks_test.hrl index 485380556..2c9a99f6a 100644 --- a/apps/vmq_webhooks/test/vmq_webhooks_test.hrl +++ b/apps/vmq_webhooks/test/vmq_webhooks_test.hrl @@ -18,4 +18,5 @@ -define(PASSWORD, <<"test-password">>). -define(TOPIC, <<"test/topic">>). -define(PAYLOAD, <<"hello world">>). +-define(REASON, normal_disconnect). diff --git a/rebar.lock b/rebar.lock index 9368a6b96..27705a72e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -119,7 +119,7 @@ {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},1}, {<<"vernemq_dev">>, {git,"https://github.com/gojekfarm/vernemq_dev.git", - {ref,"e3b332f6d9183503900c59544d2af140400ffefe"}}, + {ref,"56eff34a0b030bfbc2cfbc7eba3897f11eccdb19"}}, 0}]}. [ {pkg_hash,[