48 lines
853 B
C++
48 lines
853 B
C++
//
|
|
// Created by Kirill Zhukov on 20.04.2025.
|
|
//
|
|
|
|
#ifndef COMMAND_H
|
|
#define COMMAND_H
|
|
|
|
#include <cstdint>
|
|
#include <atomic>
|
|
#include <cstring>
|
|
#include "utils/hash/Hash128.h"
|
|
|
|
namespace usub::core
|
|
{
|
|
enum class OperationType : uint8_t
|
|
{
|
|
PUT = 0,
|
|
DELETE = 1,
|
|
FIND = 2,
|
|
UNKNOWN = 0xFF
|
|
};
|
|
|
|
struct Command
|
|
{
|
|
Command();
|
|
|
|
Command(const Command& other);
|
|
|
|
Command& operator=(const Command& other);
|
|
|
|
void serialize(std::ostream& out) const;
|
|
|
|
static Command deserialize(std::istream& in);
|
|
|
|
std::atomic<uint8_t> ready;
|
|
OperationType op;
|
|
utils::Hash128 key;
|
|
uint32_t value_size;
|
|
char value[1024];
|
|
|
|
std::atomic<uint8_t> response_ready;
|
|
uint32_t response_size;
|
|
char response[1024];
|
|
};
|
|
}
|
|
|
|
#endif // COMMAND_H
|