aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/message_status_counter.h
blob: 18a1afd1b7825744afcca2335640f96e9d1557f4 (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;
        };
 
    }
}