@@ -54,8 +54,8 @@ pub type Config {
5454 /// (default: False) By default, pgo will return a n-tuple, in the order of the query.
5555 /// By setting `rows_as_map` to `True`, the result will be `Dict`.
5656 rows_as_map : Bool ,
57- /// (default: 5000): Default time to wait before the query is considered timeout.
58- /// Timeout can be edited per query.
57+ /// (default: 5000): Default time in milliseconds to wait before the query
58+ /// is considered timeout. Timeout can be edited per query.
5959 default_timeout : Int ,
6060 )
6161}
@@ -164,6 +164,9 @@ pub fn rows_as_map(config: Config, rows_as_map: Bool) -> Config {
164164 Config ( .. config , rows_as_map : )
165165}
166166
167+ /// By default, pog have a default value of 5000ms as timeout.
168+ /// By setting `default_timeout`, every queries will now use that timeout.
169+ /// `default_timeout` should be set as milliseconds.
167170pub fn default_timeout ( config : Config , default_timeout : Int ) -> Config {
168171 Config ( .. config , default_timeout : )
169172}
@@ -400,6 +403,8 @@ pub fn parameter(query: Query(t1), parameter: Value) -> Query(t1) {
400403 Query ( .. query , parameters : [ parameter , .. query . parameters ] )
401404}
402405
406+ /// Use a custom timeout for the query. This timeout will take precedence over
407+ /// the default connection timeout.
403408pub fn timeout ( query : Query ( t1) , timeout : Int ) -> Query ( t1) {
404409 Query ( .. query , timeout : Some ( timeout ) )
405410}
0 commit comments