Fix from_id check in TQueue.
GitOrigin-RevId: ad52ed5183780b806dcd994bb1a33e67ba508635
This commit is contained in:
parent
e04232559a
commit
dfd01bf87b
@ -186,11 +186,7 @@ class TQueueImpl : public TQueue {
|
||||
if (it == queues_.end()) {
|
||||
return EventId();
|
||||
}
|
||||
auto &q = it->second;
|
||||
if (q.events.empty()) {
|
||||
return q.tail_id;
|
||||
}
|
||||
return q.events.begin()->first;
|
||||
return get_queue_head(it->second);
|
||||
}
|
||||
|
||||
EventId get_tail(QueueId queue_id) const override {
|
||||
@ -227,7 +223,7 @@ class TQueueImpl : public TQueue {
|
||||
if (from_id.value() > q.tail_id.value() + 10) {
|
||||
return Status::Error("Specified from_id is in the future");
|
||||
}
|
||||
if (from_id.value() < q.tail_id.value() - static_cast<int32>(MAX_QUEUE_EVENTS) * 2) {
|
||||
if (from_id.value() < get_queue_head(q).value() - MAX_QUEUE_EVENTS) {
|
||||
return Status::Error("Specified from_id is in the past");
|
||||
}
|
||||
|
||||
@ -267,7 +263,7 @@ class TQueueImpl : public TQueue {
|
||||
return deleted_events;
|
||||
}
|
||||
|
||||
size_t get_size(QueueId queue_id) override {
|
||||
size_t get_size(QueueId queue_id) const override {
|
||||
auto it = queues_.find(queue_id);
|
||||
if (it == queues_.end()) {
|
||||
return 0;
|
||||
@ -294,7 +290,14 @@ class TQueueImpl : public TQueue {
|
||||
std::set<std::pair<int32, QueueId>> queue_gc_at_;
|
||||
unique_ptr<StorageCallback> callback_;
|
||||
|
||||
static size_t get_size(Queue &q) {
|
||||
static EventId get_queue_head(const Queue &q) {
|
||||
if (q.events.empty()) {
|
||||
return q.tail_id;
|
||||
}
|
||||
return q.events.begin()->first;
|
||||
}
|
||||
|
||||
static size_t get_size(const Queue &q) {
|
||||
if (q.events.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class TQueue {
|
||||
virtual Result<size_t> get(QueueId queue_id, EventId from_id, bool forget_previous, int32 unix_time_now,
|
||||
MutableSpan<Event> &result_events) = 0;
|
||||
|
||||
virtual size_t get_size(QueueId queue_id) = 0;
|
||||
virtual size_t get_size(QueueId queue_id) const = 0;
|
||||
|
||||
virtual int64 run_gc(int32 unix_time_now) = 0;
|
||||
virtual void close(Promise<> promise) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user