Register the broker wait before the first poll (closes #157)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
GET /api/v1/messages read the client output queue and only then registered with the broker. Notify wakes only the channels registered at that moment, so a message queued between the empty read and the registration waited out the whole long-poll timeout. The handler now registers first and removes its channel on every exit path; the IRC relay loop registers before each drain in the same way. The handlers read the queue through a function field that defaults to Database.PollMessages, so tests can act just after a read: one checks that a message queued there comes back at once, others that no wait channel stays registered however a request ends. Model: opus-5-5
This commit was merged in pull request #174.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sneak.berlin/go/neoirc/internal/db"
|
||||
)
|
||||
|
||||
// SetPollMessages makes HandleGetMessages read the client
|
||||
// output queue with poll in place of Database.PollMessages.
|
||||
func (hdlr *Handlers) SetPollMessages(
|
||||
poll func(
|
||||
ctx context.Context,
|
||||
clientID, afterQueueID int64,
|
||||
limit int,
|
||||
) ([]db.IRCMessage, int64, error),
|
||||
) {
|
||||
hdlr.pollMessages = poll
|
||||
}
|
||||
Reference in New Issue
Block a user