Skip to content

Commit ca4efc6

Browse files
committed
pg/Config: new struct
1 parent 9f63780 commit ca4efc6

File tree

8 files changed

+13
-11
lines changed

8 files changed

+13
-11
lines changed

libcommon

src/Config.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ WorkshopConfigParser::Partition::ParseLine(FileLineParser &line)
140140
const char *word = line.ExpectWord();
141141

142142
if (StringIsEqual(word, "database")) {
143-
config.database = line.ExpectValueAndEnd();
143+
config.database.connect = line.ExpectValueAndEnd();
144144
} else if (StringIsEqual(word, "database_schema")) {
145-
config.database_schema = line.ExpectValueAndEnd();
145+
config.database.schema = line.ExpectValueAndEnd();
146146
} else if (StringIsEqual(word, "translation_server")) {
147147
config.translation_socket.SetLocal(line.ExpectValueAndEnd());
148148
} else if (StringIsEqual(word, "tag")) {
@@ -190,9 +190,9 @@ WorkshopConfigParser::CronPartition::ParseLine(FileLineParser &line)
190190
const char *word = line.ExpectWord();
191191

192192
if (StringIsEqual(word, "database")) {
193-
config.database = line.ExpectValueAndEnd();
193+
config.database.connect = line.ExpectValueAndEnd();
194194
} else if (StringIsEqual(word, "database_schema")) {
195-
config.database_schema = line.ExpectValueAndEnd();
195+
config.database.schema = line.ExpectValueAndEnd();
196196
} else if (StringIsEqual(word, "translation_server")) {
197197
config.translation_socket.SetLocal(line.ExpectValueAndEnd());
198198
} else if (StringIsEqual(word, "qmqp_server")) {

src/cron/Config.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
void
1010
CronPartitionConfig::Check() const
1111
{
12-
if (database.empty())
12+
if (database.connect.empty())
1313
throw std::runtime_error("Missing 'database' setting");
1414

1515
if (!translation_socket.IsDefined())

src/cron/Config.hxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#pragma once
66

7+
#include "pg/Config.hxx"
78
#include "event/Chrono.hxx"
89
#include "net/AllocatedSocketAddress.hxx"
910
#include "net/LocalSocketAddress.hxx"
@@ -22,7 +23,7 @@ struct CronPartitionConfig {
2223
*/
2324
std::string tag;
2425

25-
std::string database, database_schema;
26+
Pg::Config database;
2627

2728
LocalSocketAddress translation_socket;
2829

src/cron/Partition.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CronPartition::CronPartition(EventLoop &event_loop,
2525
? CreateConnectDatagramSocket(config.pond_server)
2626
: UniqueSocketDescriptor()),
2727
queue(logger, event_loop, root_config.node_name.c_str(),
28-
config.database.c_str(), config.database_schema.c_str(),
28+
config.database.connect.c_str(), config.database.schema.c_str(),
2929
[this](CronJob &&job){ OnJob(std::move(job)); }),
3030
workplace(_spawn_service,
3131
email_service, config.use_qrelay, config.default_email_sender,

src/workshop/Config.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
void
1010
WorkshopPartitionConfig::Check() const
1111
{
12-
if (database.empty())
12+
if (database.connect.empty())
1313
throw std::runtime_error("Missing 'database' setting");
1414
}

src/workshop/Config.hxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#pragma once
66

7+
#include "pg/Config.hxx"
78
#include "net/LocalSocketAddress.hxx"
89

910
#include <string>
@@ -14,7 +15,7 @@ struct WorkshopPartitionConfig {
1415
*/
1516
std::string name;
1617

17-
std::string database, database_schema;
18+
Pg::Config database;
1819

1920
LocalSocketAddress translation_socket;
2021

src/workshop/Partition.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WorkshopPartition::WorkshopPartition(Instance &_instance,
2828
BIND_THIS_METHOD(OnRateLimitTimer)),
2929
reap_timer(instance.GetEventLoop(), BIND_THIS_METHOD(OnReapTimer)),
3030
queue(logger, instance.GetEventLoop(), root_config.node_name.c_str(),
31-
config.database.c_str(), config.database_schema.c_str(),
31+
config.database.connect.c_str(), config.database.schema.c_str(),
3232
*this),
3333
workplace(_spawn_service, *this, logger,
3434
root_config.node_name.c_str(),

0 commit comments

Comments
 (0)