Skip to content

Instantly share code, notes, and snippets.

@emaxerrno
Created July 23, 2016 23:18
Show Gist options
  • Select an option

  • Save emaxerrno/45badd32d12f5d55f876f74ccb03fed4 to your computer and use it in GitHub Desktop.

Select an option

Save emaxerrno/45badd32d12f5d55f876f74ccb03fed4 to your computer and use it in GitHub Desktop.
raft.h
// Generated by the smf_gen.
// Any local changes WILL BE LOST.
// source: /home/agallego/workspace/smurf/src/flatbuffers/raft
#pragma once
#ifndef SMF_RAFT__INCLUDED
#define SMF_RAFT__INCLUDED
#include "raft_generated.h"
#include <experimental/optional>
#include <rpc/rpc_service.h>
#include <rpc/rpc_client.h>
#include <rpc/rpc_recv_typed_context.h>
#include <log.h>
namespace smf {
namespace fbs {
namespace raft {
class raft_api: public smf::rpc_service {
public:
virtual const char *service_name() const override final {
return "raft_api";
}
virtual uint32_t service_id() const override final {
return 3041114740;
}
virtual std::vector<smf::rpc_service_method_handle> methods() override final {
using h = smf::rpc_service_method_handle;
std::vector<h> handles;
handles.emplace_back(
"configuration_update", 3352363828,
[this](smf::rpc_recv_context c) -> future<smf::rpc_envelope> {
return configuration_update(smf::rpc_recv_typed_context<Configuration>(std::move(c)));
});
handles.emplace_back(
"vote", 1001591086,
[this](smf::rpc_recv_context c) -> future<smf::rpc_envelope> {
return vote(smf::rpc_recv_typed_context<VoteRequest>(std::move(c)));
});
handles.emplace_back(
"append_entries", 3863279681,
[this](smf::rpc_recv_context c) -> future<smf::rpc_envelope> {
return append_entries(smf::rpc_recv_typed_context<AppendEntriesRequest>(std::move(c)));
});
handles.emplace_back(
"install_snapshot", 2242216522,
[this](smf::rpc_recv_context c) -> future<smf::rpc_envelope> {
return install_snapshot(smf::rpc_recv_typed_context<InstallSnapshotRequest>(std::move(c)));
});
return handles;
}
virtual future<smf::rpc_envelope>
configuration_update(smf::rpc_recv_typed_context<Configuration> &&rec) {
// Output type: Void
smf::rpc_envelope e(nullptr);
// Helpful for clients to set the status.
// Typically follows HTTP style. Not imposed by smf whatsoever.
e.set_status(501); // Not implemented
return make_ready_future<smf::rpc_envelope>(std::move(e));
}
virtual future<smf::rpc_envelope>
vote(smf::rpc_recv_typed_context<VoteRequest> &&rec) {
// Output type: VoteReply
smf::rpc_envelope e(nullptr);
// Helpful for clients to set the status.
// Typically follows HTTP style. Not imposed by smf whatsoever.
e.set_status(501); // Not implemented
return make_ready_future<smf::rpc_envelope>(std::move(e));
}
virtual future<smf::rpc_envelope>
append_entries(smf::rpc_recv_typed_context<AppendEntriesRequest> &&rec) {
// Output type: AppendEntriesReply
smf::rpc_envelope e(nullptr);
// Helpful for clients to set the status.
// Typically follows HTTP style. Not imposed by smf whatsoever.
e.set_status(501); // Not implemented
return make_ready_future<smf::rpc_envelope>(std::move(e));
}
virtual future<smf::rpc_envelope>
install_snapshot(smf::rpc_recv_typed_context<InstallSnapshotRequest> &&rec) {
// Output type: InstallSnapshotReply
smf::rpc_envelope e(nullptr);
// Helpful for clients to set the status.
// Typically follows HTTP style. Not imposed by smf whatsoever.
e.set_status(501); // Not implemented
return make_ready_future<smf::rpc_envelope>(std::move(e));
}
}; // end of service: raft_api
class raft_api_client: public smf::rpc_client {
public:
raft_api_client(ipv4_addr server_addr)
:smf::rpc_client(std::move(server_addr)) {}
future<smf::rpc_recv_typed_context<Void>>
configuration_update_send(smf::rpc_envelope req) {
// RequestID: 3041114740 ^ 3352363828
// ServiceID: 3041114740 == crc32("raft_api")
// MethodID: 3352363828 == crc32("configuration_update_send")
req.set_request_id(3041114740, 3352363828);
return send<Void>(req.to_temp_buf(),false);
}
future<smf::rpc_recv_typed_context<VoteReply>>
vote_send(smf::rpc_envelope req) {
// RequestID: 3041114740 ^ 1001591086
// ServiceID: 3041114740 == crc32("raft_api")
// MethodID: 1001591086 == crc32("vote_send")
req.set_request_id(3041114740, 1001591086);
return send<VoteReply>(req.to_temp_buf(),false);
}
future<smf::rpc_recv_typed_context<AppendEntriesReply>>
append_entries_send(smf::rpc_envelope req) {
// RequestID: 3041114740 ^ 3863279681
// ServiceID: 3041114740 == crc32("raft_api")
// MethodID: 3863279681 == crc32("append_entries_send")
req.set_request_id(3041114740, 3863279681);
return send<AppendEntriesReply>(req.to_temp_buf(),false);
}
future<smf::rpc_recv_typed_context<InstallSnapshotReply>>
install_snapshot_send(smf::rpc_envelope req) {
// RequestID: 3041114740 ^ 2242216522
// ServiceID: 3041114740 == crc32("raft_api")
// MethodID: 2242216522 == crc32("install_snapshot_send")
req.set_request_id(3041114740, 2242216522);
return send<InstallSnapshotReply>(req.to_temp_buf(),false);
}
}; // end of rpc client: raft_api_client
} // namespace raft
} // namespace fbs
} // namespace smf
#endif // SMF_RAFT__INCLUDED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment