Files
scylladb/test/lib/error_injection.hh
Avi Kivity 0ae22a09d4 LICENSE: Update to version 1.1
Updated terms of non-commercial use (must be a never-customer).
2026-04-12 19:46:33 +03:00

31 lines
714 B
C++

/*
* Copyright (C) 2025-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
*/
#pragma once
#include "utils/error_injection.hh"
// Injects the error for the duration of the scope on all shards.
// Runs in seastar thread.
class scoped_error_injection {
std::string_view _name;
public:
// Add other overloads as needed
explicit scoped_error_injection(std::string_view name) : _name(name) {
smp::invoke_on_all([this] {
utils::get_local_injector().enable(_name);
}).get();
}
~scoped_error_injection() {
smp::invoke_on_all([this] {
utils::get_local_injector().disable(_name);
}).get();
}
};