Skip to content

Commit

Permalink
TQueue: now more than MAX_QUEUE_EVENTS events in each queue
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a8553f02f631fd34ef1451044c3ad7e27ee7d3dd
  • Loading branch information
arseny30 committed Aug 7, 2019
1 parent 8226c9a commit 3976bbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tddb/td/db/TQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ class TQueueImpl : public TQueue {
q.events.push(std::move(raw_event));
}

EventId push(QueueId queue_id, string data, double expire_at, EventId new_id = EventId()) override {
Result<EventId> push(QueueId queue_id, string data, double expire_at, EventId new_id = EventId()) override {
auto &q = queues_[queue_id];
if (q.events.size() >= MAX_QUEUE_EVENTS) {
return Status::Error("Queue is full");
}
EventId event_id;
while (true) {
if (q.tail_id.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion tddb/td/db/TQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TQueue {

virtual void do_push(QueueId queue_id, RawEvent &&raw_event) = 0;

virtual EventId push(QueueId queue_id, string data, double expire_at, EventId new_id = EventId()) = 0;
virtual Result<EventId> push(QueueId queue_id, string data, double expire_at, EventId new_id = EventId()) = 0;

virtual EventId get_head(QueueId queue_id) const = 0;
virtual EventId get_tail(QueueId queue_id) const = 0;
Expand Down
6 changes: 3 additions & 3 deletions test/tqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class TestTQueue {

TQueue::EventId push(TQueue::QueueId queue_id, string data, double expire_at,
TQueue::EventId new_id = TQueue::EventId()) {
auto a_id = baseline_->push(queue_id, data, expire_at, new_id);
auto b_id = memory_->push(queue_id, data, expire_at, new_id);
auto c_id = binlog_->push(queue_id, data, expire_at, new_id);
auto a_id = baseline_->push(queue_id, data, expire_at, new_id).move_as_ok();
auto b_id = memory_->push(queue_id, data, expire_at, new_id).move_as_ok();
auto c_id = binlog_->push(queue_id, data, expire_at, new_id).move_as_ok();
ASSERT_EQ(a_id, b_id);
ASSERT_EQ(a_id, c_id);
return a_id;
Expand Down

0 comments on commit 3976bbb

Please sign in to comment.