-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1459869
commit f15e00f
Showing
9 changed files
with
393 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <nlohmann/json.hpp> | ||
#include "impl/Logger.hpp" | ||
#include "impl/Transport.hpp" | ||
|
||
using namespace std::literals; | ||
|
||
namespace dlsm { | ||
|
||
class Node { | ||
public: | ||
|
||
using Transport = dlsm::Transport<dlsm::ZMQ>; | ||
|
||
const nlohmann::json config_; | ||
dlsm::Logger log_; | ||
Transport transport_; | ||
Transport::Pub pub_; | ||
Transport::Sub sub_; | ||
Transport::Poller poller_; | ||
|
||
Node(nlohmann::json config) | ||
: config_(std::move(config)) | ||
, log_{config_.value("log","debug:stdout:")} | ||
, transport_{config_.value("transport","io_threads=1")} | ||
, pub_{transport_.pub(config_.at("commands").get<std::string>())} | ||
, sub_{transport_.sub(config_.at("commands").get<std::string>())} | ||
, poller_{transport_.poller()} | ||
{ | ||
LOG_INFO("Started config {}", config_.dump(4)); | ||
} | ||
Node(std::filesystem::path config) : Node{nlohmann::json::parse(std::ifstream{config.string()})} {} | ||
|
||
void send() { | ||
auto tosend = "1234"s; | ||
pub_.send(tosend); | ||
} | ||
|
||
void recv() { | ||
auto torecv = "000011111111"s; | ||
sub_.recv(torecv); | ||
|
||
LOG_INFO("Started recv {}", torecv); | ||
} | ||
}; | ||
|
||
} // namespace dlsm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.