From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 35E16469710 for ; Fri, 20 Nov 2020 02:43:07 +0300 (MSK) From: Vladislav Shpilevoy References: <0f6505cf411bd9e7e11f42b5b6a8526b6b291ce1.1605570907.git.v.shpilevoy@tarantool.org> <697d34e7-c630-37b7-de39-21865b69bb33@tarantool.org> Message-ID: <370679d3-a6ab-95ad-68eb-c90867ba958a@tarantool.org> Date: Fri, 20 Nov 2020 00:43:05 +0100 MIME-Version: 1.0 In-Reply-To: <697d34e7-c630-37b7-de39-21865b69bb33@tarantool.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [Tarantool-patches] [PATCH 08/12] raft: introduce vtab for disk and network List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com Thanks for the review! >>   @@ -598,8 +553,7 @@ raft_worker_handle_broadcast(struct raft *raft) >>           assert(raft->vote == raft->self); >>           req.vclock = raft->vclock; >>       } >> -    replicaset_foreach(replica) >> -        relay_push_raft(replica->relay, &req); >> +    raft->vtab->broadcast(raft, &req); > > > I'd introduce helpers, like raft_write() and raft_broadcast(), > to hide raft->vtab->... calls. Up to you, though. Introduced raft_write and raft_broadcast. ==================== diff --git a/src/box/raftlib.c b/src/box/raftlib.c index cc9139a5b..2f5e90f21 100644 --- a/src/box/raftlib.c +++ b/src/box/raftlib.c @@ -62,6 +62,20 @@ raft_state_str(uint32_t state) return "invalid (x)"; }; +/** Shortcut for vtab 'broadcast' method. */ +static inline void +raft_broadcast(struct raft *raft, const struct raft_request *req) +{ + raft->vtab->broadcast(raft, req); +} + +/** Shortcut for vtab 'write' method. */ +static inline void +raft_write(struct raft *raft, const struct raft_request *req) +{ + raft->vtab->write(raft, req); +} + /** * Check if Raft is completely synced with disk. Meaning all its critical values * are in WAL. Only in that state the node can become a leader or a candidate. @@ -523,7 +537,7 @@ end_dump: * is a leader now, after the node is restarted, there will be * another leader elected by that time likely. */ - raft->vtab->write(raft, &req); + raft_write(raft, &req); say_info("RAFT: persisted state %s", raft_request_to_string(&req)); @@ -553,7 +567,7 @@ raft_worker_handle_broadcast(struct raft *raft) assert(raft->vote == raft->self); req.vclock = raft->vclock; } - raft->vtab->broadcast(raft, &req); + raft_broadcast(raft, &req); trigger_run(&raft->on_update, raft); raft->is_broadcast_scheduled = false; }