<commit_before>package db

import (
	r "github.com/dancannon/gorethink"
	"github.com/materials-commons/config"
)

// RSession creates a new RethinkDB session.
func RSession() (*r.Session, error) {
	return r.Connect(
		r.ConnectOpts{
			Address:  config.GetString("MCDB_CONNECTION"),
			Database: config.GetString("MCDB_NAME"),
		})
}
<commit_msg>Add additional ways to get a rethinkdb session. Add methods that will panic if a session cannot be allocated.<commit_after>package db

import (
	r "github.com/dancannon/gorethink"
	"github.com/materials-commons/config"
)

// RSession creates a new RethinkDB session.
func RSession() (*r.Session, error) {
	return r.Connect(
		r.ConnectOpts{
			Address:  config.GetString("MCDB_CONNECTION"),
			Database: config.GetString("MCDB_NAME"),
		})
}

// RSessionMust creates a new RethinkDB session and panics if it cannot
// allocate it.
func RSessionMust() *r.Session {
	session, err := RSession()
	if err != nil {
		panic("Couldn't get new rethinkdb session")
	}
	return session
}

// RSessionUsing createa new RethinkDB session using the passed in parameters
func RSessionUsing(address, db string) (*r.Session, error) {
	return r.Connect(
		r.ConnectOpts{
			Address:  address,
			Database: db,
		})
}

// RSessionUsingMust creates a new RethinkDB session and panics if it cannot
// allocate it.
func RSessionUsingMust(address, db string) *r.Session {
	session, err := RSessionUsing(address, db)
	if err != nil {
		panic("Couldn't get new rethinkdb session")
	}
	return session
}

{'fraction_non_alphanumeric': 0.11300919842312747, 'fraction_numerical': 0.0, 'mean_word_length': 4.269896193771626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6494811', 'n_tokens_mistral': 518, 'n_tokens_neox': 504, 'n_words': 151}