From 800c293d5951d21fa29db1ede3aca3a02c6d2814 Mon Sep 17 00:00:00 2001 From: Pugma Date: Sat, 13 Jan 2024 23:55:34 +0900 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E7=A8=BF=E5=8F=96=E5=BE=97=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E3=81=8C100=E4=BB=B6=E3=82=92=E8=B6=85=E3=81=88?= =?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AEoffset=E3=81=AE=E5=A2=97=E5=88=86?= =?UTF-8?q?=E3=82=921=E2=86=92100=E3=81=AB=20/=20`processer`=E2=86=92`proc?= =?UTF-8?q?essor`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/traqmessage/collect.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/traqmessage/collect.go b/server/traqmessage/collect.go index bac16e6..036357c 100644 --- a/server/traqmessage/collect.go +++ b/server/traqmessage/collect.go @@ -13,12 +13,12 @@ import ( ) type MessagePoller struct { - processer *messageProcesser + processor *messageProcessor } func NewMessagePoller() *MessagePoller { return &MessagePoller{ - processer: &messageProcesser{ + processor: &messageProcessor{ queue: make(chan *[]traq.Message), }, } @@ -26,7 +26,7 @@ func NewMessagePoller() *MessagePoller { // go routineの中で呼ぶこと func (m *MessagePoller) Run() { - go m.processer.run() + go m.processor.run() pollingInterval := time.Minute * 3 @@ -40,7 +40,7 @@ func (m *MessagePoller) Run() { now := time.Now() var collectedMessageCount int64 - for i := 0; ; i++ { + for i := 0; ; i += 100 { messages, err := collectMessages(lastCheckpoint, now, i) if err != nil { slog.Error(fmt.Sprintf("Failled to polling messages: %v", err)) @@ -51,7 +51,7 @@ func (m *MessagePoller) Run() { collectedMessageCount += messages.TotalHits // 取得したメッセージを使っての処理の呼び出し - m.processer.enqueue(&messages.Hits) + m.processor.enqueue(&messages.Hits) if messages.TotalHits < 100 { break @@ -66,12 +66,12 @@ func (m *MessagePoller) Run() { } // 通知メッセージの検索と通知処理のjobを処理する -type messageProcesser struct { +type messageProcessor struct { queue chan *[]traq.Message } // go routineの中で呼ぶ -func (m *messageProcesser) run() { +func (m *messageProcessor) run() { for { select { case messages := <-m.queue: @@ -80,11 +80,11 @@ func (m *messageProcesser) run() { } } -func (m *messageProcesser) enqueue(messages *[]traq.Message) { +func (m *messageProcessor) enqueue(messages *[]traq.Message) { m.queue <- messages } -func (m *messageProcesser) process(messages []traq.Message) { +func (m *messageProcessor) process(messages []traq.Message) { messageList, err := ConvertMessageHits(messages) if err != nil { slog.Error(fmt.Sprintf("Failled to convert messages: %v", err))