Skip to content

Commit

Permalink
Add support for couchdb connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
eledra89 committed Aug 1, 2019
1 parent 10108eb commit 1445958
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions util/dbHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ type CouchDBHandler struct {
CouchDatabase *couchdb.CouchDatabase
}

// NewCouchDBHandler returns a new CouchDBHandler and setup database for testing
func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) {
// NewCouchDBHandlerWithConnection returns a new CouchDBHandler and setup database for testing
func NewCouchDBHandlerWithConnection(dbName string, isDrop bool, connectionString string) (*CouchDBHandler, error) {
handler := new(CouchDBHandler)

//Create a couchdb instance
couchDBInstance, er := couchdb.CreateCouchInstance(DefaultBaseURL, "", "", 3, 10, time.Second*30, true, &disabled.Provider{})
couchDBInstance, er := couchdb.CreateCouchInstance(connectionString, "", "", 3, 10, time.Second*30, true, &disabled.Provider{})
if er != nil {
return nil, er
}
Expand All @@ -42,6 +42,11 @@ func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) {
return handler, nil
}

// NewCouchDBHandler returns a new CouchDBHandler and setup database for testing
func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) {
return NewCouchDBHandlerWithConnection(dbName, isDrop, DefaultBaseURL)
}

// SaveDocument stores a value in couchDB
func (handler *CouchDBHandler) SaveDocument(key string, value []byte) (string, error) {
// unmarshal the value param
Expand Down

0 comments on commit 1445958

Please sign in to comment.