Skip to content

Commit 58accd6

Browse files
committed
Request: Use pointer receiver for all functions
1 parent 978e4fb commit 58accd6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nrpc.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,19 @@ type Request struct {
288288
}
289289

290290
// Elapsed duration since request was started
291-
func (r Request) Elapsed() time.Duration {
291+
func (r *Request) Elapsed() time.Duration {
292292
return time.Since(r.CreatedAt)
293293
}
294294

295295
// Run the handler and capture any error. Returns the response or the error
296296
// that should be returned to the caller
297-
func (r Request) Run() (msg proto.Message, replyError *Error) {
297+
func (r *Request) Run() (msg proto.Message, replyError *Error) {
298298
r.StartedAt = time.Now()
299299
ctx := r.Context
300300
if r.StreamedReply() {
301301
ctx = r.StreamContext
302302
}
303-
ctx = context.WithValue(ctx, RequestContextKey, &r)
303+
ctx = context.WithValue(ctx, RequestContextKey, r)
304304
msg, replyError = CaptureErrors(
305305
func() (proto.Message, error) {
306306
return r.Handler(ctx)
@@ -381,7 +381,7 @@ func (r *Request) setupStreamedReply() {
381381
}
382382

383383
// StreamedReply returns true if the request reply is streamed
384-
func (r Request) StreamedReply() bool {
384+
func (r *Request) StreamedReply() bool {
385385
return r.isStreamedReply
386386
}
387387

0 commit comments

Comments
 (0)