From ae6d066255b6c77ee5985892163452e98469903f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Thu, 21 May 2020 14:03:57 +0200 Subject: [PATCH] Add NewSession function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MichaƂ Matczuk --- session.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/session.go b/session.go index 6262a2b..66e86da 100644 --- a/session.go +++ b/session.go @@ -22,8 +22,19 @@ type Session struct { Mapper *reflectx.Mapper } +// NewSession wraps existing gocql.session. +func NewSession(session *gocql.Session) Session { + return Session{ + Session: session, + Mapper: DefaultMapper, + } +} + // WrapSession should be called on CreateSession() gocql function to convert // the created session to gocqlx.Session. +// +// Example: +// session, err := gocqlx.WrapSession(cluster.CreateSession()) func WrapSession(session *gocql.Session, err error) (Session, error) { return Session{ Session: session,