From 6ab30ed3087761ce5c8415c4ce297906d3e37b48 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Thu, 14 Sep 2017 00:16:40 -0500 Subject: [PATCH] Update the client last usage timestamp --- pkg/client/client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index 27d7a8b..acea00b 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -5,6 +5,7 @@ import ( neturl "net/url" "reflect" "strings" + "time" _ "github.com/lib/pq" @@ -20,6 +21,7 @@ type Client struct { db *sqlx.DB tunnel *Tunnel serverVersion string + lastQueryTime time.Time History []history.Record `json:"history"` ConnectionString string `json:"connection_string"` } @@ -265,6 +267,11 @@ func (client *Client) ServerVersion() string { } func (client *Client) query(query string, args ...interface{}) (*Result, error) { + // Update the last usage time + defer func() { + client.lastQueryTime = time.Now().UTC() + }() + // We're going to force-set transaction mode on every query. // This is needed so that default mode could not be changed by user. if command.Opts.ReadOnly {