refactor: rename id_generator to snowflake

This commit is contained in:
luwenpeng
2024-08-16 11:02:19 +08:00
parent 6fbce43afc
commit f4d437d58b
23 changed files with 177 additions and 177 deletions

View File

@@ -10,6 +10,6 @@ target_include_directories(session_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(session_manager PUBLIC ${CMAKE_SOURCE_DIR}/src/utils)
target_link_libraries(session_manager timeout id_generator duplicated_packet_filter evicted_session_filter log tcp_reassembly)
target_link_libraries(session_manager timeout snowflake duplicated_packet_filter evicted_session_filter log tcp_reassembly)
add_subdirectory(test)

View File

@@ -8,7 +8,7 @@
#include "udp_utils.h"
#include "packet_layer.h"
#include "packet_utils.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_def.h"
#include "session_utils.h"
#include "session_pool.h"
@@ -539,7 +539,7 @@ static void session_update(struct session_manager *mgr, struct session *sess, en
{
if (session_get_current_state(sess) == SESSION_STATE_INIT)
{
session_set_id(sess, id_generator_alloc(mgr->now_ms / 1000));
session_set_id(sess, snowflake_id_generate(mgr->now_ms / 1000));
session_set_tuple6(sess, key);
session_set_tuple_direction(sess, dir);

View File

@@ -3,7 +3,7 @@
#include "tuple.h"
#include "packet_def.h"
#include "packet_parse.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "tcp_reassembly.h"
@@ -421,11 +421,11 @@ TEST(CASE, TCP_FAST_OPEN)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -6,7 +6,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -555,11 +555,11 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -6,7 +6,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -776,11 +776,11 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -5,7 +5,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -445,11 +445,11 @@ TEST(TCP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING_TO_CLOSED, TEST)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -5,7 +5,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -232,11 +232,11 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -6,7 +6,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -773,11 +773,11 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_FIN)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -5,7 +5,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -157,11 +157,11 @@ TEST(UDP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING, TEST)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -5,7 +5,7 @@
#include "packet_def.h"
#include "packet_parse.h"
#include "packet_layer.h"
#include "id_generator.h"
#include "snowflake.h"
#include "session_utils.h"
#include "session_manager.h"
#include "test_packets.h"
@@ -212,11 +212,11 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_S2C)
int main(int argc, char **argv)
{
struct id_generator_options opt = {
.snowflake_worker_id_base = 1,
.snowflake_worker_id_offset = 2,
struct snowflake_options opt = {
.snowflake_base = 1,
.snowflake_offset = 2,
};
id_generator_init(&opt);
snowflake_id_init(&opt);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}