Drop the AGPL license in favor of a source-available license. See the blog post [1] for details. [1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
37 lines
923 B
C++
37 lines
923 B
C++
/*
|
|
* Copyright 2020-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#include "utils/assert.hh"
|
|
#include <cassert>
|
|
#include <chrono>
|
|
#include <utility>
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include "generation-number.hh"
|
|
|
|
namespace gms {
|
|
|
|
generation_type get_generation_number() {
|
|
using namespace std::chrono;
|
|
auto now = high_resolution_clock::now().time_since_epoch();
|
|
int generation_number = duration_cast<seconds>(now).count();
|
|
auto ret = generation_type(generation_number);
|
|
// Make sure the clock didn't overflow the 32 bits value
|
|
SCYLLA_ASSERT(ret.value() == generation_number);
|
|
return ret;
|
|
}
|
|
|
|
void validate_gossip_generation(int64_t generation_number) {
|
|
if (!std::in_range<gms::generation_type::value_type>(generation_number)) {
|
|
throw std::out_of_range(fmt::format("gossip generation {} is out of range", generation_number));
|
|
}
|
|
}
|
|
|
|
}
|