github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/core/ledger/util/couchdb/config.go (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package couchdb 18 19 import ( 20 "time" 21 22 "github.com/spf13/viper" 23 ) 24 25 // CouchDBDef contains parameters 26 type CouchDBDef struct { 27 URL string 28 Username string 29 Password string 30 MaxRetries int 31 MaxRetriesOnStartup int 32 RequestTimeout time.Duration 33 } 34 35 //GetCouchDBDefinition exposes the useCouchDB variable 36 func GetCouchDBDefinition() *CouchDBDef { 37 38 couchDBAddress := viper.GetString("ledger.state.couchDBConfig.couchDBAddress") 39 username := viper.GetString("ledger.state.couchDBConfig.username") 40 password := viper.GetString("ledger.state.couchDBConfig.password") 41 maxRetries := viper.GetInt("ledger.state.couchDBConfig.maxRetries") 42 maxRetriesOnStartup := viper.GetInt("ledger.state.couchDBConfig.maxRetriesOnStartup") 43 requestTimeout := viper.GetDuration("ledger.state.couchDBConfig.requestTimeout") 44 45 return &CouchDBDef{couchDBAddress, username, password, maxRetries, maxRetriesOnStartup, requestTimeout} 46 }