<commit_before>package rethinkdb

import (
	"fmt"
	"strings"
	"time"

	"github.com/Sirupsen/logrus"
	"gopkg.in/dancannon/gorethink.v2"
)

// Wait for 60 seconds maximum on Wait() calls for rethink
var timeoutOpt = gorethink.WaitOpts{Timeout: time.Minute.Seconds()}

func makeDB(session *gorethink.Session, name string) error {
	_, err := gorethink.DBCreate(name).RunWrite(session)
	if err != nil {
		if strings.Contains(err.Error(), "already exists") {
			return nil
		}
	}
	return err
}

// Table holds the configuration for setting up a RethinkDB table
type Table struct {
	Name       string
	PrimaryKey interface{}
	// Keys are the index names. If len(value) is 0, it is a simple index
	// on the field matching the key. Otherwise, it is a compound index
	// on the list of fields in the corrensponding slice value.
	SecondaryIndexes map[string][]string
	Config           map[string]string
}<commit_msg>Explicitly wait for all replicas to be ready on bootstrapping.  While this should be the rethinkdb default, I was running into errors sometimes after bootstrapping - the signer and servers sometimes can't connect after bootstrapping.<commit_after>package rethinkdb

import (
	"fmt"
	"strings"
	"time"

	"github.com/Sirupsen/logrus"
	"gopkg.in/dancannon/gorethink.v2"
)

// Wait for 60 seconds maximum on Wait() calls for rethink
var timeoutOpt = gorethink.WaitOpts{WaitFor: "all_replicas_ready", Timeout: time.Minute.Seconds()}

func makeDB(session *gorethink.Session, name string) error {
	_, err := gorethink.DBCreate(name).RunWrite(session)
	if err != nil {
		if strings.Contains(err.Error(), "already exists") {
			return nil
		}
	}
	return err
}

// Table holds the configuration for setting up a RethinkDB table
type Table struct {
	Name       string
	PrimaryKey interface{}
	// Keys are the index names. If len(value) is 0, it is a simple index
	// on the field matching the key. Otherwise, it is a compound index
	// on the list of fields in the corrensponding slice value.
	SecondaryIndexes map[string][]string
	Config           map[string]string
}
{'fraction_non_alphanumeric': 0.09258361609306835, 'fraction_numerical': 0.003877847794474067, 'mean_word_length': 3.949640287769784, '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': '4488217', 'n_tokens_mistral': 670, 'n_tokens_neox': 650, 'n_words': 231}