support set max-time on cursor
This commit is contained in:
parent
efc440a8f9
commit
ba29a45cc6
1 changed files with 8 additions and 0 deletions
|
|
@ -43,6 +43,7 @@
|
|||
[monger.conversion :refer :all]
|
||||
[monger.operators :refer :all])
|
||||
(:import [com.mongodb DB DBCollection DBObject DBCursor ReadPreference]
|
||||
[java.util.concurrent TimeUnit]
|
||||
java.util.List))
|
||||
|
||||
|
||||
|
|
@ -96,6 +97,7 @@
|
|||
snapshot
|
||||
read-preference
|
||||
keywordize-fields
|
||||
max-time
|
||||
options]
|
||||
:or { limit 0 batch-size 256 skip 0 } }]
|
||||
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
||||
|
|
@ -109,6 +111,8 @@
|
|||
(.hint cursor (to-db-object hint)))
|
||||
(when read-preference
|
||||
(.setReadPreference cursor read-preference))
|
||||
(when max-time
|
||||
(.maxTime cursor max-time TimeUnit/MILLISECONDS))
|
||||
(when options
|
||||
(add-options cursor options))
|
||||
(map (fn [x] (from-db-object x keywordize-fields))
|
||||
|
|
@ -154,6 +158,10 @@
|
|||
[m ^ReadPreference rp]
|
||||
(merge m { :read-preference rp }))
|
||||
|
||||
(defn max-time
|
||||
[m ^long max-time]
|
||||
(merge m { :max-time max-time }))
|
||||
|
||||
(defn options
|
||||
[m opts]
|
||||
(merge m { :options opts }))
|
||||
|
|
|
|||
Loading…
Reference in a new issue