From b4c69bb7058ebe216dde8a15ff51f66ac00e6d87 Mon Sep 17 00:00:00 2001 From: a <a@tuxpa.in> Date: Mon, 14 Nov 2022 17:49:11 -0600 Subject: [PATCH] remove timer --- handler.go | 5 +++-- timer.go | 23 ----------------------- 2 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 timer.go diff --git a/handler.go b/handler.go index 9a30262..3937b2f 100644 --- a/handler.go +++ b/handler.go @@ -24,6 +24,7 @@ import ( "reflect" "strings" "sync" + "time" "tuxpa.in/a/zlog" ) @@ -200,7 +201,7 @@ func (h *handler) startCallProc(fn func(*callProc)) { // handleImmediate executes non-call messages. It returns false if the message is a // call or requires a reply. func (h *handler) handleImmediate(msg *jsonrpcMessage) bool { - start := NewTimer() + start := time.Now() switch { case msg.isNotification(): if strings.HasSuffix(msg.Method, notificationMethodSuffix) { @@ -210,7 +211,7 @@ func (h *handler) handleImmediate(msg *jsonrpcMessage) bool { return false case msg.isResponse(): h.handleResponse(msg) - h.log.Trace().Str("reqid", string(msg.ID.RawMessage())).Dur("duration", start.Since(start)).Msg("Handled RPC response") + h.log.Trace().Str("reqid", string(msg.ID.RawMessage())).Dur("duration", time.Since(start)).Msg("Handled RPC response") return true default: return false diff --git a/timer.go b/timer.go deleted file mode 100644 index 689d955..0000000 --- a/timer.go +++ /dev/null @@ -1,23 +0,0 @@ -package jrpc - -import ( - "time" -) - -type Timer struct { - s time.Time -} - -func NewTimer() *Timer { - return &Timer{ - s: time.Now(), - } -} - -func (t *Timer) Since(...any) time.Duration { - return time.Since(t.s) -} - -func (t *Timer) Until() time.Duration { - return time.Until(t.s) -} -- GitLab