-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: message ack sync changes improvements (#43)
* feat: message ack performance improvements
- Loading branch information
1 parent
b895a6c
commit ef219b6
Showing
6 changed files
with
62 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package websocket | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/odpf/raccoon/metrics" | ||
"github.com/odpf/raccoon/serialization" | ||
"github.com/odpf/raccoon/services/rest/websocket/connection" | ||
) | ||
|
||
var AckChan = make(chan AckInfo) | ||
|
||
type AckInfo struct { | ||
MessageType int | ||
RequestGuid string | ||
Err error | ||
Conn connection.Conn | ||
serializer serialization.SerializeFunc | ||
TimeConsumed time.Time | ||
AckTimeConsumed time.Time | ||
} | ||
|
||
func AckHandler(ch <-chan AckInfo) { | ||
for c := range ch { | ||
ackTim := time.Since(c.AckTimeConsumed) | ||
metrics.Timing("ack_event_rtt_ms", ackTim.Milliseconds(), "") | ||
|
||
tim := time.Since(c.TimeConsumed) | ||
if c.Err != nil { | ||
metrics.Timing("event_rtt_ms", tim.Milliseconds(), "") | ||
writeFailedResponse(c.Conn, c.serializer, c.MessageType, c.RequestGuid, c.Err) | ||
continue | ||
} | ||
|
||
metrics.Timing("event_rtt_ms", tim.Milliseconds(), "") | ||
writeSuccessResponse(c.Conn, c.serializer, c.MessageType, c.RequestGuid) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters