Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Yan Shtunder via Tarantool-patches <tarantool-patches@dev.tarantool.org>
Cc: v.shpilevoy@tarantool.org, Yan Shtunder <ya.shtunder@gmail.com>
Subject: Re: [Tarantool-patches] [PATCH v3] net.box: add predefined system events for pub/sub
Date: Sat, 12 Feb 2022 17:48:02 +0300	[thread overview]
Message-ID: <20220212144802.b5krz7sfgz5y3pak@esperanza> (raw)
In-Reply-To: <20220212011803.80185-1-ya.shtunder@gmail.com>

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

  reply	other threads:[~2022-02-12 14:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-12  1:18 Yan Shtunder via Tarantool-patches
2022-02-12 14:48 ` Vladimir Davydov via Tarantool-patches [this message]
2022-02-14 21:35 ` Vladislav Shpilevoy via Tarantool-patches
2022-02-15  7:36   ` Vladimir Davydov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220212144802.b5krz7sfgz5y3pak@esperanza \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --cc=vdavydov@tarantool.org \
    --cc=ya.shtunder@gmail.com \
    --subject='Re: [Tarantool-patches] [PATCH v3] net.box: add predefined system events for pub/sub' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox