Skip to content

Issue 47 - Added functions and changes for CouchDB support #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ const (
Bolt = "bolt"
InMemory = "inmemory"
Mongo = "mongo"
Couch = "couch"
)

// HashStrings uses FNV-1a (Fowler/Noll/Vo) fast and well dispersed hash functions
Expand Down
37 changes: 31 additions & 6 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ type Config struct {
// MongoUsername specifies the username of the mongo database
MongoUsername string `env:"MONGO_USERNAME"`

// MongoPassword specifies the username of the mongo database
// MongoPassword specifies the password of the mongo database
MongoPassword string `env:"MONGO_PASSWORD"`

// MongoUseSSL specifies whether or not to use SSL connection with mongo
Expand All @@ -278,6 +278,31 @@ type Config struct {
// MongoSessionCacheSize specifies the number of MongoDB session copies to use
MongoSessionCacheSize int `env:"MONGO_SESSION_CACHE_SIZE"`

// CouchAddress specifies address of the couch database
CouchAddress string `env:"COUCH_ADDRESS"`

// CouchDbName specifies the name of the database to use
CouchDbName string `env:"COUCH_DB_NAME"`

// CouchUsername specifies the username of the couch database
CouchUsername string `env:"COUCH_USERNAME"`

// CouchPassword specifies the password of the couch database
CouchPassword string `env:"COUCH_PASSWORD"`

// CouchUseSSL specifies whether or not to use SSL connection with couch
CouchUseSSL bool `env:"COUCH_USE_SSL"`

// CouchCACertificate specifies the CA certificate that was used to sign the server certificate
// used by the CouchDB server. This value can either be the CA certificate itself or the path of a
// file containing the CA certificate. If it is a path of a file, then it is relative to the
// PersistenceRootPath configuration property if it doesn't start with a slash (/).
CouchCACertificate string `env:"COUCH_CA_CERTIFICATE"`

// CouchAllowInvalidCertificates specifies that the couch driver will not attempt to validate the server certificates.
// Please only set this for development purposes! It makes using TLS pointless and is never the right answer.
CouchAllowInvalidCertificates bool `env:"COUCH_ALLOW_INVALID_CERTIFICATES"`

// DatabaseConnectTimeout specifies that the timeout in seconds of database connection attempts on startup
// The default value is 300
DatabaseConnectTimeout int `env:"DATABASE_CONNECT_TIMEOUT"`
Expand All @@ -290,7 +315,7 @@ type Config struct {
ObjectActivationInterval int16 `env:"OBJECT_ACTIVATION_INTERVAL"`

// StorageProvider specifies the type of the storage to be used by this node.
// For the CSS the options are 'mongo' (the default), and 'bolt'
// For the CSS the options are 'mongo' (the default), 'couch' and 'bolt'
// For the ESS the options are 'inmemory' (the default), and 'bolt'
StorageProvider string `env:"STORAGE_PROVIDER"`

Expand Down Expand Up @@ -612,7 +637,7 @@ func ValidateConfig() error {
case ParallelMQTTLarge:
case "":
default:
return &configError{"Invalid MQTTParallelMode, please specify any off: 'none', 'small', 'medium', 'large', or leave as empty string"}
return &configError{"Invalid MQTTParallelMode, please specify any of: 'none', 'small', 'medium', 'large', or leave as empty string"}
}

if Configuration.MaxInflightChunks < 1 {
Expand All @@ -626,14 +651,14 @@ func ValidateConfig() error {
if Configuration.NodeType == CSS {
if Configuration.StorageProvider == "" {
Configuration.StorageProvider = Mongo
} else if Configuration.StorageProvider != Mongo && Configuration.StorageProvider != Bolt {
return &configError{"Invalid StorageProvider, for CSS please specify any off: 'mongo', 'bolt', or leave as empty string"}
} else if Configuration.StorageProvider != Mongo && Configuration.StorageProvider != Bolt && Configuration.StorageProvider != Couch {
return &configError{"Invalid StorageProvider, for CSS please specify any of: 'mongo', 'bolt', 'couch' or leave as empty string"}
}
} else {
if Configuration.StorageProvider == "" {
Configuration.StorageProvider = InMemory
} else if Configuration.StorageProvider != InMemory && Configuration.StorageProvider != Bolt {
return &configError{"Invalid StorageProvider, for ESS please specify any off: 'inmemory', 'bolt', or leave as empty string"}
return &configError{"Invalid StorageProvider, for ESS please specify any of: 'inmemory', 'bolt', or leave as empty string"}
}
}
if len(Configuration.ObjectsDataPath) > 0 {
Expand Down
2 changes: 2 additions & 0 deletions core/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func Start(swaggerFile string, registerHandlers bool) common.SyncServiceError {
var cssStore storage.Storage
if common.Configuration.StorageProvider == common.Mongo {
cssStore = &storage.MongoStorage{}
} else if common.Configuration.StorageProvider == common.Couch {
cssStore = &storage.CouchStorage{}
} else {
cssStore = &storage.BoltStorage{}
}
Expand Down
Loading