[Tarantool-patches] [PATCH 14/20] net.box: rename netbox_{prepare, encode}_request to {begin, end}
Vladimir Davydov
vdavydov at tarantool.org
Fri Jul 23 14:07:24 MSK 2021
netbox_encode_request is a confusing name - the function doesn't encode
a request, it just writes the actual request size to the fix header.
Let's rename the two functions to netbox_begin_request and
netbox_end_request to emphasize that they are used to start and finish
request encoding.
Another reason to do that now is that in the following patches we will
be moving the request table implementation from Lua to C so having a
"request" in the function names would be confusing.
---
src/box/lua/net_box.c | 52 +++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c
index 12d82738a050..122d69e9219e 100644
--- a/src/box/lua/net_box.c
+++ b/src/box/lua/net_box.c
@@ -77,10 +77,10 @@ enum netbox_method {
};
static inline size_t
-netbox_prepare_request(struct mpstream *stream, uint64_t sync,
- enum iproto_type type)
+netbox_begin_encode(struct mpstream *stream, uint64_t sync,
+ enum iproto_type type)
{
- /* Remember initial size of ibuf (see netbox_encode_request()) */
+ /* Remember initial size of ibuf (see netbox_end_encode()) */
struct ibuf *ibuf = (struct ibuf *) stream->ctx;
size_t used = ibuf_used(ibuf);
@@ -103,7 +103,7 @@ netbox_prepare_request(struct mpstream *stream, uint64_t sync,
}
static inline void
-netbox_encode_request(struct mpstream *stream, size_t initial_size)
+netbox_end_encode(struct mpstream *stream, size_t initial_size)
{
mpstream_flush(stream);
@@ -135,8 +135,8 @@ netbox_encode_ping(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_PING);
- netbox_encode_request(&stream, svp);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_PING);
+ netbox_end_encode(&stream, svp);
}
static int
@@ -152,7 +152,7 @@ netbox_encode_auth(lua_State *L)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_AUTH);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_AUTH);
size_t user_len;
const char *user = lua_tolstring(L, 3, &user_len);
@@ -176,7 +176,7 @@ netbox_encode_auth(lua_State *L)
mpstream_encode_strn(&stream, scramble, SCRAMBLE_SIZE);
}
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
return 0;
}
@@ -188,7 +188,7 @@ netbox_encode_call_impl(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync,
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, type);
+ size_t svp = netbox_begin_encode(&stream, sync, type);
mpstream_encode_map(&stream, 2);
@@ -202,7 +202,7 @@ netbox_encode_call_impl(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync,
mpstream_encode_uint(&stream, IPROTO_TUPLE);
luamp_encode_tuple(L, cfg, &stream, idx + 1);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -224,7 +224,7 @@ netbox_encode_eval(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_EVAL);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_EVAL);
mpstream_encode_map(&stream, 2);
@@ -238,7 +238,7 @@ netbox_encode_eval(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_TUPLE);
luamp_encode_tuple(L, cfg, &stream, idx + 1);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -248,7 +248,7 @@ netbox_encode_select(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_SELECT);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_SELECT);
mpstream_encode_map(&stream, 6);
@@ -282,7 +282,7 @@ netbox_encode_select(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_KEY);
luamp_convert_key(L, cfg, &stream, idx + 5);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -293,7 +293,7 @@ netbox_encode_insert_or_replace(lua_State *L, int idx, struct ibuf *ibuf,
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, type);
+ size_t svp = netbox_begin_encode(&stream, sync, type);
mpstream_encode_map(&stream, 2);
@@ -306,7 +306,7 @@ netbox_encode_insert_or_replace(lua_State *L, int idx, struct ibuf *ibuf,
mpstream_encode_uint(&stream, IPROTO_TUPLE);
luamp_encode_tuple(L, cfg, &stream, idx + 1);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -328,7 +328,7 @@ netbox_encode_delete(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_DELETE);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_DELETE);
mpstream_encode_map(&stream, 3);
@@ -346,7 +346,7 @@ netbox_encode_delete(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_KEY);
luamp_convert_key(L, cfg, &stream, idx + 2);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -356,7 +356,7 @@ netbox_encode_update(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_UPDATE);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_UPDATE);
mpstream_encode_map(&stream, 5);
@@ -382,7 +382,7 @@ netbox_encode_update(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_TUPLE);
luamp_encode_tuple(L, cfg, &stream, idx + 3);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -392,7 +392,7 @@ netbox_encode_upsert(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_UPSERT);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_UPSERT);
mpstream_encode_map(&stream, 4);
@@ -413,7 +413,7 @@ netbox_encode_upsert(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_OPS);
luamp_encode_tuple(L, cfg, &stream, idx + 2);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static int
@@ -631,7 +631,7 @@ netbox_encode_execute(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_EXECUTE);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_EXECUTE);
mpstream_encode_map(&stream, 3);
@@ -652,7 +652,7 @@ netbox_encode_execute(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_uint(&stream, IPROTO_OPTIONS);
luamp_encode_tuple(L, cfg, &stream, idx + 2);
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
@@ -662,7 +662,7 @@ netbox_encode_prepare(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
struct mpstream stream;
mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb,
luamp_error, L);
- size_t svp = netbox_prepare_request(&stream, sync, IPROTO_PREPARE);
+ size_t svp = netbox_begin_encode(&stream, sync, IPROTO_PREPARE);
mpstream_encode_map(&stream, 1);
@@ -677,7 +677,7 @@ netbox_encode_prepare(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync)
mpstream_encode_strn(&stream, query, len);
};
- netbox_encode_request(&stream, svp);
+ netbox_end_encode(&stream, svp);
}
static void
--
2.25.1
More information about the Tarantool-patches
mailing list