-
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.
* Feat: append entries * Feat: logger, executor * Add scripts
- Loading branch information
Showing
20 changed files
with
267 additions
and
112 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
tmp | ||
log |
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
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,38 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'optparse' | ||
require 'byraft' | ||
|
||
banner = <<-BANNER | ||
Request AppendLog to byraft application | ||
Usage: client <address> <command> [options] | ||
-h --help Print help | ||
Option: | ||
BANNER | ||
OptionParser.new do |parser| | ||
parser.banner = banner | ||
parser.on("-h", "--help") do | ||
puts banner | ||
exit | ||
end | ||
end.parse! | ||
|
||
if ARGV.size < 2 | ||
puts banner | ||
exit | ||
end | ||
|
||
address, command = ARGV[0], ARGV[1] | ||
client = Byraft::GRPC::Stub.new(address, :this_channel_is_insecure) | ||
begin | ||
res = client.append_log(Byraft::GRPC::AppendLogRequest.new(command: command)) | ||
if res.success | ||
puts "Success." | ||
elsif res.leader_id.empty? || res.leader_address.empty? | ||
puts "Failed to request: No leader available" | ||
else | ||
puts "Retry to leader Node##{res.leader_id}: #{res.leader_address}" | ||
end | ||
rescue GRPC::Unavailable => e | ||
puts "Failed to request: #{e}" | ||
end |
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
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.