From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Ilya Kosarev <i.kosarev@tarantool.org> Cc: tarantool-patches@freelists.org, georgy@tarantool.org, i.kosarev@corp.mail.ru Subject: Re: [PATCH v4] iproto: report active connections number Date: Thu, 28 Feb 2019 12:01:50 +0300 [thread overview] Message-ID: <20190228090150.c5tyy5htr4bp36us@esperanza> (raw) In-Reply-To: <20190227143757.30000-1-i.kosarev@tarantool.org> On Wed, Feb 27, 2019 at 05:37:57PM +0300, Ilya Kosarev wrote: > Now there is new member in box.stat.net() called "CONNECTIONS" > which is a number of active iproto connections. Please see a few nitpicking comments below. > > Closes #3905 > --- > https://github.com/tarantool/tarantool/tree/i.kosarev/gh-3905-report-connections-number > https://github.com/tarantool/tarantool/issues/3905 > > Changes in v4: > - CONNECTIONS counter doesn't have extra lua tables inside anymore > - refactoring > > src/box/iproto.cc | 6 ++++++ > src/box/iproto.h | 6 ++++++ > src/box/lua/stat.c | 11 +++++++++++ > test/box/stat_net.result | 37 +++++++++++++++++++++++++++++++++++++ > test/box/stat_net.test.lua | 13 +++++++++++++ > 5 files changed, 73 insertions(+) > > diff --git a/src/box/iproto.cc b/src/box/iproto.cc > index 863eb4f06..d6dafe155 100644 > --- a/src/box/iproto.cc > +++ b/src/box/iproto.cc > @@ -2121,6 +2121,12 @@ iproto_mem_used(void) > return slab_cache_used(&net_cord.slabc) + slab_cache_used(&net_slabc); > } > > +size_t > +iproto_connections_n(void) We don't typically use _n in variable names. Please rename to iproto_connection_count() Note, no 's' after 'connection'. > +{ > + return mempool_count(&iproto_connection_pool); > +} > + > void > iproto_reset_stat(void) > { > diff --git a/src/box/iproto.h b/src/box/iproto.h > index 8f3607ffc..0d53d13ed 100644 > --- a/src/box/iproto.h > +++ b/src/box/iproto.h > @@ -62,6 +62,12 @@ extern unsigned iproto_readahead; > size_t > iproto_mem_used(void); > > +/** > + * Return number of active iproto connections /** * Return the number of active iproto connections. */ Note the article and the dot at the end of the comment. Kostja's fussy about comments purity :-) > + */ > +size_t > +iproto_connections_n(void); > + > /** > * Reset network statistics. > */ > diff --git a/src/box/lua/stat.c b/src/box/lua/stat.c > index 3fce81f61..f8b9b581e 100644 > --- a/src/box/lua/stat.c > +++ b/src/box/lua/stat.c > @@ -52,6 +52,8 @@ extern struct rmean *rmean_error; > extern struct rmean *rmean_net; > extern struct rmean *rmean_tx_wal_bus; > > +static const char *conn_n_name = "CONNECTIONS"; > + I don't think there's any point in introducing a variable for this rather than simply using the string literal directly. There are only a couple places where we need it, and we aren't going to change those. > static void > fill_stat_item(struct lua_State *L, int rps, int64_t total) > { > @@ -140,6 +142,10 @@ static int > lbox_stat_net_index(struct lua_State *L) > { > luaL_checkstring(L, -1); > + if (strcmp(conn_n_name, lua_tostring(L, -1)) == 0) { > + lua_pushnumber(L, iproto_connections_n()); > + return 1; > + } > return rmean_foreach(rmean_net, seek_stat_item, L); > } > > @@ -148,6 +154,11 @@ lbox_stat_net_call(struct lua_State *L) > { > lua_newtable(L); > rmean_foreach(rmean_net, set_stat_item, L); > + > + lua_pushstring(L, conn_n_name); > + lua_pushnumber(L, iproto_connections_n()); > + lua_settable(L, -3); > + > return 1; > }
next prev parent reply other threads:[~2019-02-28 9:01 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-27 14:37 Ilya Kosarev 2019-02-28 9:01 ` Vladimir Davydov [this message] 2019-02-28 10:28 ` [tarantool-patches] " Konstantin Osipov
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=20190228090150.c5tyy5htr4bp36us@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=georgy@tarantool.org \ --cc=i.kosarev@corp.mail.ru \ --cc=i.kosarev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v4] iproto: report active connections number' \ /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