Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support setting raft server init options and raft callback in raft_launcher::init() #147

Merged
merged 3 commits into from
Oct 21, 2020

Conversation

sheepgrass
Copy link
Contributor

support setting raft server init options and raft callback in raft_launcher::init()

Copy link
Contributor

@greensky00 greensky00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sheepgrass , some minor comments.

@@ -45,7 +47,9 @@ public:
ptr<logger> lg,
int port_number,
const asio_service::options& asio_options,
const raft_params& params);
const raft_params& params,
const raft_server::init_options opt = raft_server::init_options(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use reference?

const raft_server::init_options& opt = raft_server::init_options()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

Actually, I was just copied from your unit test case :p

void initServer(raft_params* given_params = nullptr,
const raft_server::init_options opt =
raft_server::init_options(),
cb_func::func_type raft_callback = nullptr)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch, it also needs to be fixed. Thanks :)

src/launcher.cxx Outdated
const raft_params& params_given)
const raft_params& params_given,
const raft_server::init_options opt,
cb_func::func_type raft_callback)
Copy link
Contributor

@greensky00 greensky00 Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the previous PR, I'd like to suggest you to move cb_func::func_type raft_callback inside raft_server::init_options like this:

struct init_options {
    // ...

    bool skip_initial_election_timeout_;
    
    cb_func::func_type raft_callback_;
};

and invoke ctx->set_cb_func(...) inside the constructor of raft_server. Then launcher doesn't need to call set_cb_func, thus we can get benefit for both launcher and raft_server. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I didn't notice you mentioned about moving it to raft_server constructor. I will make the change.

Actually, for this change, I am also taken reference to your unit test case:

ctx = new context( sMgr, sm, listener, myLog,
rpcCliFactory, scheduler, params );
if (raft_callback) {
ctx->set_cb_func(raft_callback);
}
raftServer = cs_new<raft_server>(ctx, opt);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants