2020-10-29 07:07:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
|
|
|
#include <atomic>
|
|
|
|
#include <common/types.h>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
/** Allows to count number of simultaneously happening error codes.
|
|
|
|
* See also Exception.cpp for incrementing part.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
/// ErrorCode identifier (index in array).
|
2021-03-08 19:05:51 +00:00
|
|
|
using ErrorCode = int;
|
|
|
|
using Value = size_t;
|
2020-10-29 07:07:42 +00:00
|
|
|
|
|
|
|
/// Get name of error_code by identifier.
|
|
|
|
/// Returns statically allocated string.
|
2020-10-29 18:08:09 +00:00
|
|
|
std::string_view getName(ErrorCode error_code);
|
2020-10-29 07:07:42 +00:00
|
|
|
|
|
|
|
/// ErrorCode identifier -> current value of error_code.
|
2021-03-08 19:05:51 +00:00
|
|
|
struct ValuePair
|
|
|
|
{
|
|
|
|
std::atomic<Value> local;
|
|
|
|
std::atomic<Value> remote;
|
|
|
|
};
|
|
|
|
extern ValuePair values[];
|
2020-10-29 07:07:42 +00:00
|
|
|
|
|
|
|
/// Get index just after last error_code identifier.
|
|
|
|
ErrorCode end();
|
|
|
|
|
|
|
|
/// Add value for specified error_code.
|
2021-03-08 19:05:51 +00:00
|
|
|
void increment(ErrorCode error_code, bool remote);
|
2020-10-29 07:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|