Skip to content

Commit

Permalink
Added a timer interface (#387)
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <[email protected]>
  • Loading branch information
yashrsharma44 authored Jan 28, 2021
1 parent 468f615 commit 3ff779b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions interceptors/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ import (

type GRPCType string

// Timer is a helper interface to time functions.
// Useful for interceptors to record the total
// time elapsed since completion of a call.
type Timer interface {
ObserveDuration() time.Duration
}

// zeroTimer.
type zeroTimer struct {
}

func (zeroTimer) ObserveDuration() time.Duration {
return 0
}

var EmptyTimer = &zeroTimer{}

const (
Unary GRPCType = "unary"
ClientStream GRPCType = "client_stream"
Expand Down

0 comments on commit 3ff779b

Please sign in to comment.