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

    }
}