Skip to content

Commit

Permalink
Remove CLI code; further refactoring of commands and models
Browse files Browse the repository at this point in the history
  • Loading branch information
0xg0nz0 committed Feb 18, 2024
1 parent ddceec5 commit f97c141
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 179 deletions.
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
endif()

# set up library dependencies
find_package(argh CONFIG REQUIRED)
find_package(benchmark CONFIG REQUIRED)
find_package(cpptoml CONFIG REQUIRED)
find_package(libuv CONFIG REQUIRED)
Expand All @@ -27,20 +26,6 @@ add_library(
target_compile_features(iggy PRIVATE cxx_std_17)
target_include_directories(iggy PRIVATE ${unofficial-sodium_DIR}/../../include)

add_executable(
iggy_cmd

examples/cli/cli.cc
examples/cli/iggy_cmd.cc
)
target_include_directories(iggy_cmd PRIVATE ${argh_INCLUDE_DIR})
target_link_libraries(
iggy_cmd

iggy
unofficial-sodium::sodium
)

if (BUILD_TESTS)
add_subdirectory(tests)
endif()
Expand Down
6 changes: 0 additions & 6 deletions examples/cli/cli.cc

This file was deleted.

38 changes: 0 additions & 38 deletions examples/cli/cli.h

This file was deleted.

24 changes: 0 additions & 24 deletions examples/cli/iggy_cmd.cc

This file was deleted.

4 changes: 2 additions & 2 deletions sdk/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void iggy::client::Client::ping() {
ping_process.wait(reproc::milliseconds(5000));
}

iggy::model::Stats iggy::client::Client::getStats() {
iggy::model::system::Stats iggy::client::Client::getStats() {
// temporary! need to send GetStats command to server then use WireFormat to read the response
return iggy::model::Stats();
return iggy::model::system::Stats();
}
2 changes: 1 addition & 1 deletion sdk/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Client {
/**
* @brief Get the Iggy server's performance statistics.
*/
iggy::model::Stats getStats();
iggy::model::system::Stats getStats();
};
}; // namespace client
}; // namespace iggy
108 changes: 45 additions & 63 deletions sdk/command.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include <string>
#include <vector>
#include "model.h"
#include "types.h"

namespace iggy {

/**
* @namespace command
* @brief All supported commands in the Iggy protocol.
*
*
* Serialization-agnostic Command classes that you can send via an @ref iggy::client::Client.
*/
namespace command {
Expand All @@ -18,39 +18,6 @@ class Command {
virtual ~Command() = default;
};

/**
* @namespace shared
* @brief Shared types used across multiple Commands.
*/
namespace shared {
enum ConsumerKind { CONSUMER = 1, CONSUMER_GROUP = 2 };

class Consumer {
private:
ConsumerKind kind;
uint32_t id;
public:
Consumer(ConsumerKind kind, uint32_t id);
ConsumerKind getKind();
uint32_t getId();
};

enum IdKind { NUMERIC = 1, STRING = 2 };

class Identifier {
private:
IdKind kind;
uint8_t length;
std::vector<unsigned char> value;
};

class PolledMessages {};

class Message {};

class ConsumerOffsetInfo {};
} // namespace shared

/**
* @namespace stream
* @brief Commands related to managing Iggy streams.
Expand Down Expand Up @@ -87,35 +54,51 @@ class DeletePartitions : Command {};
*/
namespace message {
enum PollingKind { OFFSET = 1, TIMESTAMP = 2, FIRST = 3, LAST = 4, NEXT = 5 };
class PollingStrategy {
private:
PollingKind kind;
uint64_t value;
public:
PollingStrategy(PollingKind kind, uint64_t value)
: kind(kind)
, value(value) {}
PollingKind getKind() const { return kind; }
uint64_t getValue() const { return value; }
};

class PollingStrategy {};
class PolledMessages {};

enum PartitioningKind { BALANCED = 1, PARITION_ID = 2, MESSAGES_KEY = 3 };
class PollMessages : Command {
private:
iggy::model::shared::Consumer consumer;
iggy::model::shared::Identifier streamId;
iggy::model::shared::Identifier topicId;
uint32_t partitionId;
PollingStrategy strategy;
uint32_t count;
bool autoCommit;

typedef std::string HeaderKey;

enum HeaderKind {
RAW = 1,
STRING = 2,
BOOL = 3,
INT8 = 4,
INT16 = 5,
INT32 = 6,
INT64 = 7,
INT128 = 8,
UINT8 = 9,
UINT16 = 10,
UINT32 = 11,
UINT64 = 12,
UINT128 = 13,
FLOAT32 = 14,
FLOAT64 = 15
public:
PollMessages(iggy::model::shared::Consumer consumer, iggy::model::shared::Identifier streamId,
iggy::model::shared::Identifier topicId, uint32_t partitionId, PollingStrategy strategy,
uint32_t count, bool autoCommit)
: consumer(consumer)
, streamId(streamId)
, topicId(topicId)
, partitionId(partitionId)
, strategy(strategy)
, count(count)
, autoCommit(autoCommit) {}

iggy::model::shared::Consumer getConsumer() const { return consumer; }
iggy::model::shared::Identifier getStreamId() const { return streamId; }
iggy::model::shared::Identifier getTopicId() const { return topicId; }
uint32_t getPartitionId() const { return partitionId; }
PollingStrategy getStrategy() const { return strategy; }
uint32_t getCount() const { return count; }
bool getAutoCommit() const { return autoCommit; }
};

class HeaderValue {};

class Message {};
enum PartitioningKind { BALANCED = 1, PARITION_ID = 2, MESSAGES_KEY = 3 };
class Partitioning {};
class SendMessages : Command {};

} // namespace message
Expand Down Expand Up @@ -143,8 +126,7 @@ class LeaveConsumerGroup : Command {};
} // namespace consumergroup

/**
* @namespace system
* @brief Commands related to global system status.
* @brief Commands related to global system state.
*/
namespace system {
class Ping : Command {};
Expand Down
Loading

0 comments on commit f97c141

Please sign in to comment.