55
66namespace DominionEnterprises \Mongo ;
77
8+ use MongoDB \BSON \UTCDateTime ;
9+
810/**
911 * Abstraction of mongo db collection as priority queue.
1012 *
@@ -155,7 +157,7 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
155157 $ pollDurationInMillis = 0 ;
156158 }
157159
158- $ completeQuery = ['earliestGet ' => ['$lte ' => new \ MongoDB \ BSON \ UTCDateTime ((int )(microtime (true ) * 1000 ))]];
160+ $ completeQuery = ['earliestGet ' => ['$lte ' => new UTCDateTime ((int )(microtime (true ) * 1000 ))]];
159161 foreach ($ query as $ key => $ value ) {
160162 if (!is_string ($ key )) {
161163 throw new \InvalidArgumentException ('key in $query was not a string ' );
@@ -172,7 +174,7 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
172174
173175 $ resetTimestamp = min (max (0 , $ resetTimestamp * 1000 ), self ::MONGO_INT32_MAX );
174176
175- $ update = ['$set ' => ['earliestGet ' => new \ MongoDB \ BSON \ UTCDateTime ($ resetTimestamp )]];
177+ $ update = ['$set ' => ['earliestGet ' => new UTCDateTime ($ resetTimestamp )]];
176178 $ options = ['sort ' => ['priority ' => 1 , 'created ' => 1 ]];
177179
178180 //ints overflow to floats, should be fine
@@ -231,7 +233,7 @@ public function count(array $query, $running = null)
231233
232234 if ($ running === true || $ running === false ) {
233235 $ key = $ running ? '$gt ' : '$lte ' ;
234- $ totalQuery ['earliestGet ' ] = [$ key => new \ MongoDB \ BSON \ UTCDateTime ((int )(microtime (true ) * 1000 ))];
236+ $ totalQuery ['earliestGet ' ] = [$ key => new UTCDateTime ((int )(microtime (true ) * 1000 ))];
235237 }
236238
237239 foreach ($ query as $ key => $ value ) {
@@ -318,11 +320,11 @@ public function ackSend(array $message, array $payload, $earliestGet = 0, $prior
318320
319321 $ toSet = [
320322 'payload ' => $ payload ,
321- 'earliestGet ' => new \ MongoDB \ BSON \ UTCDateTime ($ earliestGet ),
323+ 'earliestGet ' => new UTCDateTime ($ earliestGet ),
322324 'priority ' => $ priority ,
323325 ];
324326 if ($ newTimestamp ) {
325- $ toSet ['created ' ] = new \ MongoDB \ BSON \ UTCDateTime ((int )(microtime (true ) * 1000 ));
327+ $ toSet ['created ' ] = new UTCDateTime ((int )(microtime (true ) * 1000 ));
326328 }
327329
328330 //using upsert because if no documents found then the doc was removed (SHOULD ONLY HAPPEN BY SOMEONE MANUALLY)
@@ -385,9 +387,9 @@ public function send(array $payload, $earliestGet = 0, $priority = 0.0)
385387
386388 $ message = [
387389 'payload ' => $ payload ,
388- 'earliestGet ' => new \ MongoDB \ BSON \ UTCDateTime ($ earliestGet ),
390+ 'earliestGet ' => new UTCDateTime ($ earliestGet ),
389391 'priority ' => $ priority ,
390- 'created ' => new \ MongoDB \ BSON \ UTCDateTime ((int )(microtime (true ) * 1000 )),
392+ 'created ' => new UTCDateTime ((int )(microtime (true ) * 1000 )),
391393 ];
392394
393395 $ this ->collection ->insertOne ($ message );
0 commit comments