aboutsummaryrefslogtreecommitdiff
path: root/conn_pool.go
diff options
context:
space:
mode:
Diffstat (limited to 'conn_pool.go')
-rw-r--r--conn_pool.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/conn_pool.go b/conn_pool.go
index 1ccc879..69281af 100644
--- a/conn_pool.go
+++ b/conn_pool.go
@@ -21,10 +21,18 @@ func generateToken() (string, error) {
var ErrSessionExpired = errors.New("session expired")
type Session struct {
+ locker sync.Mutex
imapConn *imapclient.Client
username, password string
}
+func (s *Session) Do(f func(*imapclient.Client) error) error {
+ s.locker.Lock()
+ defer s.locker.Unlock()
+
+ return f(s.imapConn)
+}
+
// TODO: expiration timer
type ConnPool struct {
locker sync.Mutex