@@ -50,6 +50,9 @@ pub struct Opt {
50
50
/// Should we wait for a debugger before executing any JS?
51
51
#[ structopt( long) ]
52
52
inspect_brk : bool ,
53
+ /// size of database connection pool.
54
+ #[ structopt( short, long, default_value = "1000" ) ]
55
+ nr_connections : usize ,
53
56
/// How many executor threads to create
54
57
#[ structopt( short, long, default_value = "1" ) ]
55
58
executor_threads : usize ,
@@ -113,6 +116,7 @@ pub struct SharedState {
113
116
data_db : DbConnection ,
114
117
metadata_db : DbConnection ,
115
118
materialize : ModulesDirectory ,
119
+ nr_connections : usize ,
116
120
}
117
121
118
122
impl SharedState {
@@ -136,7 +140,8 @@ impl SharedTasks {
136
140
async fn run ( state : SharedState , mut cmd : ExecutorChannel ) -> Result < ( ) > {
137
141
init_deno ( & state. materialize . path ( ) , state. inspect_brk ) . await ?;
138
142
139
- let meta = Rc :: new ( MetaService :: local_connection ( & state. metadata_db ) . await ?) ;
143
+ let meta =
144
+ Rc :: new ( MetaService :: local_connection ( & state. metadata_db , state. nr_connections ) . await ?) ;
140
145
let ts = meta. load_type_system ( ) . await ?;
141
146
142
147
let routes = meta. load_endpoints ( ) . await ?;
@@ -148,7 +153,8 @@ async fn run(state: SharedState, mut cmd: ExecutorChannel) -> Result<()> {
148
153
Ok ( Type :: Object ( t) ) => t,
149
154
_ => anyhow:: bail!( "Internal error: type {} not found" , OAUTHUSER_TYPE_NAME ) ,
150
155
} ;
151
- let query_engine = Arc :: new ( QueryEngine :: local_connection ( & state. data_db ) . await ?) ;
156
+ let query_engine =
157
+ Arc :: new ( QueryEngine :: local_connection ( & state. data_db , state. nr_connections ) . await ?) ;
152
158
let mut transaction = query_engine. start_transaction ( ) . await ?;
153
159
query_engine
154
160
. create_table ( & mut transaction, & oauth_user_type)
@@ -239,11 +245,11 @@ pub async fn run_shared_state(
239
245
let file = format ! ( "{}/chisel.ts" , materialize. path( ) . display( ) ) ;
240
246
fs:: write ( file, include_bytes ! ( "../../api/src/chisel.ts" ) ) . await ?;
241
247
242
- let meta_conn = DbConnection :: connect ( & opt. metadata_db_uri ) . await ?;
243
- let data_db = DbConnection :: connect ( & opt. data_db_uri ) . await ?;
248
+ let meta_conn = DbConnection :: connect ( & opt. metadata_db_uri , opt . nr_connections ) . await ?;
249
+ let data_db = DbConnection :: connect ( & opt. data_db_uri , opt . nr_connections ) . await ?;
244
250
245
- let meta = MetaService :: local_connection ( & meta_conn) . await ?;
246
- let query_engine = QueryEngine :: local_connection ( & data_db) . await ?;
251
+ let meta = MetaService :: local_connection ( & meta_conn, opt . nr_connections ) . await ?;
252
+ let query_engine = QueryEngine :: local_connection ( & data_db, opt . nr_connections ) . await ?;
247
253
248
254
meta. create_schema ( ) . await ?;
249
255
@@ -383,6 +389,7 @@ pub async fn run_shared_state(
383
389
data_db,
384
390
metadata_db : meta_conn,
385
391
materialize : materialize. clone ( ) ,
392
+ nr_connections : opt. nr_connections ,
386
393
} ;
387
394
388
395
let tasks = SharedTasks { rpc_task, sig_task } ;
0 commit comments