Skip to content

Commit

Permalink
Add NewSession function
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Matczuk <michal@scylladb.com>
  • Loading branch information
mmatczuk committed May 21, 2020
1 parent a721151 commit ae6d066
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ae6d066

Please sign in to comment.