From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 7E8F56E454; Sat, 12 Feb 2022 17:48:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7E8F56E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1644677284; bh=j4iep+GcnmSHqPkYUsDZugpXXhn1eGSEos4jCpB5hmM=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pOfLUc+xA0A05Qpz9pvhc5J3bRLGMqU7hX5SRCnTPtQXhKOsg956GcVY1Cs+uZFzV iUljJcImslf1RFeaH7fftsqZzANOYHehM/teFkR3P38WJzWiLNP1Gy8BorUsGv54Zo alwRzfJixiLrGXx1T3PsSEBcHpJu9bz2S4Iype94= Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 11ADC6E454 for ; Sat, 12 Feb 2022 17:48:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 11ADC6E454 Received: by smtp51.i.mail.ru with esmtpa (envelope-from ) id 1nItgx-0008J4-Cz; Sat, 12 Feb 2022 17:48:03 +0300 Date: Sat, 12 Feb 2022 17:48:02 +0300 To: Yan Shtunder via Tarantool-patches Cc: v.shpilevoy@tarantool.org, Yan Shtunder Message-ID: <20220212144802.b5krz7sfgz5y3pak@esperanza> References: <20220212011803.80185-1-ya.shtunder@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220212011803.80185-1-ya.shtunder@gmail.com> X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD94A599DE53EADEE5705EB66965380F0CDB4C116533E9EB873182A05F538085040F292E53BCB55E7848D9AD44B8A0DDE892AFD39A64A8C4898F55DD2E36820E852 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7370F4F695FFFC24BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379CBE0668FF2CDAD68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D287997BD70377E113D5C00538426EF0117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE437C869540D2AB0F86750DBF4DC650F2D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE32A336C65186350919735652A29929C6CC4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637630B8AA1820BAD00731C566533BA786AA5CC5B56E945C8DA X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A57B29A83F181104FC58556A1357E2A69605208077CE496328D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75D33992D797C36249410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343D1F112031EF3D6250A1F88EB45C599FDE76462BA559B65576D185B0ECEEE178509CCB1691CE70F51D7E09C32AA3244C1B11611148741C3C5EF5B09D7C15268C8580396430872480927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0jP+VWF3k0dO/jjwZT57CA== X-Mailru-Sender: 0D4E4D77B0FF454AF6D9FBD60507A85271E0F8A880F75CE8E19AB33262403A128CBF93FA4102E581F6B1EBADD65A9BC308F7CA0949898EDC8EBA24583C5741300927C8791E7949AC0F27244EEAA5B9A50D4ABDE8C577C2ED X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3] net.box: add predefined system events for pub/sub X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladimir Davydov via Tarantool-patches Reply-To: Vladimir Davydov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Sat, Feb 12, 2022 at 04:18:03AM +0300, Yan Shtunder via Tarantool-patches wrote: > Adding predefined system events: box.status, box.id, box.election > and box.schema. > > Closes #6260 > > NO_CHANGELOG=test stuff > NO_DOC=testing stuff This change definitely needs both a changelog and a doc request. > --- > Issue: https://github.com/tarantool/tarantool/issues/6260 > Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-6260-events-v3 I recommend to create a pull request from your own GitHub fork instead of pushing to a dev branch and sending patches to the mailing list, because dev branches in the main repo are likely to be banned soon and the mailing list is probably going to be shut down (or left for LuaJIT patches only). > diff --git a/src/box/box.cc b/src/box/box.cc > index 6a33203df..d72bd3dad 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -3933,3 +3943,82 @@ box_reset_stat(void) > engine_reset_stat(); > space_foreach(box_reset_space_stat, NULL); > } > + > +void > +box_broadcast_id(void) > +{ > + char buf[1024]; > + char *w = buf; > + > + struct replica *replica = replica_by_uuid(&INSTANCE_UUID); > + uint32_t id = (replica == NULL) ? 0 : replica->id; > + > + w = mp_encode_map(w, 3); > + w = mp_encode_str0(w, "id"); > + w = mp_encode_uint(w, id); > + w = mp_encode_str0(w, "instance_uuid"); > + w = mp_encode_uuid(w, &INSTANCE_UUID); > + w = mp_encode_str0(w, "replicaset_uuid"); > + w = mp_encode_uuid(w, &REPLICASET_UUID); > + > + box_broadcast("box.id", strlen("box.id"), buf, w); You can use box_broadcast_fmt instead. AFAIU events added in this patch are not triggered from hot paths so it should be fine performance-wise. https://github.com/tarantool/tarantool/blob/17f08c821ea44531a2f4882653527b672d8e447f/src/box/watcher.h#L254-L260