-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert worker to use json instead of protobuf
This was complicated by the difficulty in reading from stdin since it's populated asynchronously from a file while the worker is running. Fixes #516
- Loading branch information
Showing
9 changed files
with
79 additions
and
147 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,50 @@ | ||
#include <nlohmann/json.hpp> | ||
|
||
class WorkRequest { | ||
public: | ||
WorkRequest(std::int64_t request_id, const std::vector<std::string> &args) : | ||
request_id_(request_id), arguments_(args) {}; | ||
|
||
const std::vector<std::string> arguments() const { | ||
return arguments_; | ||
}; | ||
|
||
const int64_t request_id() const { | ||
return request_id_; | ||
} | ||
|
||
private: | ||
int64_t request_id_; | ||
std::vector<std::string> arguments_; | ||
}; | ||
|
||
class WorkResponse { | ||
public: | ||
WorkResponse() {}; | ||
|
||
nlohmann::json to_json() { | ||
return nlohmann::json{ | ||
{"exitCode", this->exit_code_}, | ||
{"output", this->output_}, | ||
{"requestId", this->request_id_}, | ||
}; | ||
} | ||
|
||
void set_exit_code(int exit_code) { | ||
exit_code_ = exit_code; | ||
} | ||
|
||
void set_output(std::string output) { | ||
output_ = output; | ||
} | ||
|
||
void set_request_id(int64_t request_id) { | ||
request_id_ = request_id; | ||
} | ||
|
||
private: | ||
int exit_code_; | ||
std::string output_; | ||
std::int64_t request_id_; | ||
}; | ||
|
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