aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/message_status_counter.h
blob: e8ba2fdd31de1d6985603dd2374a83cd5ca86e9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include "message_status.h"

#include <library/cpp/messagebus/monitoring/mon_proto.pb.h>

#include <util/generic/string.h>

#include <array>

namespace NBus {
    namespace NPrivate {
        struct TMessageStatusCounter {
            static TMessageStatusRecord::EMessageStatus MessageStatusToProtobuf(EMessageStatus status) {
                return (TMessageStatusRecord::EMessageStatus)status;
            }

            std::array<unsigned, MESSAGE_STATUS_COUNT> Counts;

            unsigned& operator[](EMessageStatus index) {
                return Counts[index];
            }
            const unsigned& operator[](EMessageStatus index) const {
                return Counts[index];
            }

            TMessageStatusCounter();

            TMessageStatusCounter& operator+=(const TMessageStatusCounter&);

            TString PrintToString() const;
            void FillErrorsProtobuf(TConnectionStatusMonRecord*) const;
        };

    }
}