File tree Expand file tree Collapse file tree 5 files changed +21
-10
lines changed
Expand file tree Collapse file tree 5 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ Configure `/etc/readyset_proxysql_scheduler.cnf` as follow:
4646* ` proxysql_port ` - (Required) - ProxySQL admin port
4747* ` readyset_user ` - (Required) - Readyset application user
4848* ` readyset_password ` - (Required) - Readyset application password
49+ * ` readyset_database ` - (Optional) - Readyset application database
4950* ` source_hostgroup ` - (Required) - Hostgroup running your Read workload
5051* ` readyset_hostgroup ` - (Required) - Hostgroup where Readyset is configure
5152* ` warmup_time_s ` - (Optional) - Time in seconds to mirror a query supported before redirecting the query to Readyset (Default ` 0 ` - no mirror)
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ pub struct Config {
7777 pub proxysql_port : u16 ,
7878 pub readyset_user : String ,
7979 pub readyset_password : String ,
80+ pub readyset_database : Option < String > ,
8081 pub source_hostgroup : u16 ,
8182 pub readyset_hostgroup : u16 ,
8283 #[ serde( default ) ]
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ impl ProxySQL {
5353 config. proxysql_port ,
5454 & config. proxysql_user ,
5555 & config. proxysql_password ,
56+ None ,
5657 ) {
5758 Ok ( conn) => conn,
5859 Err ( err) => panic ! ( "Failed to create ProxySQL connection: {err}" ) ,
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ impl Readyset {
116116 port,
117117 & config. readyset_user ,
118118 & config. readyset_password ,
119+ config. readyset_database . as_deref ( ) ,
119120 ) {
120121 Ok ( conn) => conn,
121122 Err ( err) => {
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ impl SQLConnection {
3535 port : u16 ,
3636 user : & str ,
3737 pass : & str ,
38+ database : Option < & str > ,
3839 ) -> Result < Self > {
3940 Ok ( match database_type {
4041 DatabaseType :: MySQL => Self :: MySQL ( Conn :: new (
@@ -43,25 +44,31 @@ impl SQLConnection {
4344 . tcp_port ( port)
4445 . user ( Some ( user) )
4546 . pass ( Some ( pass) )
47+ . db_name ( database)
4648 . prefer_socket ( false )
4749 . read_timeout ( Some ( TIMEOUT ) )
4850 . write_timeout ( Some ( TIMEOUT ) )
4951 . tcp_connect_timeout ( Some ( TIMEOUT ) ) ,
5052 ) ?) ,
51- DatabaseType :: PostgreSQL => Self :: PostgreSQL (
52- Config :: new ( )
53- . host ( hostname)
54- . port ( port)
55- . user ( user)
56- . password ( pass)
57- . connect_timeout ( TIMEOUT )
58- . tcp_user_timeout ( TIMEOUT )
59- . connect ( MakeTlsConnector :: new (
53+ DatabaseType :: PostgreSQL => {
54+ let mut config = Config :: new ( ) ;
55+ config. host ( hostname) ;
56+ config. port ( port) ;
57+ config. user ( user) ;
58+ config. password ( pass) ;
59+ if let Some ( database) = database {
60+ config. dbname ( database) ;
61+ }
62+ config. connect_timeout ( TIMEOUT ) ;
63+ config. tcp_user_timeout ( TIMEOUT ) ;
64+ Self :: PostgreSQL (
65+ config. connect ( MakeTlsConnector :: new (
6066 TlsConnector :: builder ( )
6167 . danger_accept_invalid_certs ( true )
6268 . build ( ) ?,
6369 ) ) ?,
64- ) ,
70+ )
71+ }
6572 } )
6673 }
6774
You can’t perform that action at this time.
0 commit comments