This commit is contained in:
aozhiwei 2023-06-18 14:26:30 +08:00
parent 4210cf3813
commit 924ae0c500
2 changed files with 10 additions and 3 deletions

View File

@ -464,8 +464,13 @@ void App::UnInitLog()
bool App::ParseOpt()
{
int ch = 0;
while ((ch = getopt(argc, argv, "i:t:r:f:n:")) != -1) {
while ((ch = getopt(argc, argv, "z:i:t:r:f:n:")) != -1) {
switch (ch) {
case 'z':
{
zone_id = a8::XValue(optarg);
}
break;
case 'n':
{
node_id = a8::XValue(optarg);
@ -493,12 +498,13 @@ bool App::ParseOpt()
break;
}
}
return instance_id > 0 && node_id > 0;
return zone_id > 0 && instance_id > 0 && node_id > 0;
}
std::string App::NewUuid()
{
return a8::XValue(uuid.Generate()).GetString();
std::string id = a8::Format("%d%d", {zone_id, uuid.Generate()});
return id;
}
bool App::HasFlag(int flag)

View File

@ -62,6 +62,7 @@ public:
a8::uuid::SnowFlake uuid;
public:
int zone_id = 0;
int instance_id = 0;
int node_id = 0;
bool is_test_mode = false;