Add NewSession function

Signed-off-by: Michał Matczuk <michal@scylladb.com>
This commit is contained in:
Michał Matczuk
2020-05-21 14:03:57 +02:00
parent a721151829
commit ae6d066255

View File

@@ -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,