2016-06-14 16:54:23 +00:00
|
|
|
package natpmp
|
|
|
|
|
2021-06-16 20:19:45 +00:00
|
|
|
import "time"
|
|
|
|
|
2016-06-14 16:54:23 +00:00
|
|
|
type callObserver interface {
|
|
|
|
observeCall(msg []byte, result []byte, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// A caller that records the RPC call.
|
|
|
|
type recorder struct {
|
|
|
|
child caller
|
|
|
|
observer callObserver
|
|
|
|
}
|
|
|
|
|
2021-06-16 20:19:45 +00:00
|
|
|
func (n *recorder) call(msg []byte, timeout time.Duration) (result []byte, err error) {
|
|
|
|
result, err = n.child.call(msg, timeout)
|
2016-06-14 16:54:23 +00:00
|
|
|
n.observer.observeCall(msg, result, err)
|
|
|
|
return
|
|
|
|
}
|