IServerSPtr ServersManager::createServer(IConnectionSettingsBaseSPtr settings) { if (!settings) { NOTREACHED(); return IServerSPtr(); } connectionTypes conT = settings->type(); IServer* server = nullptr; #ifdef BUILD_WITH_REDIS if (conT == REDIS) { server = new redis::RedisServer(settings); } #endif #ifdef BUILD_WITH_MEMCACHED if (conT == MEMCACHED) { server = new memcached::MemcachedServer(settings); } #endif #ifdef BUILD_WITH_SSDB if (conT == SSDB) { server = new ssdb::SsdbServer(settings); } #endif #ifdef BUILD_WITH_LEVELDB if (conT == LEVELDB) { server = new leveldb::LeveldbServer(settings); } #endif #ifdef BUILD_WITH_ROCKSDB if (conT == ROCKSDB) { server = new rocksdb::RocksdbServer(settings); } #endif #ifdef BUILD_WITH_UNQLITE if (conT == UNQLITE) { server = new unqlite::UnqliteServer(settings); } #endif #ifdef BUILD_WITH_LMDB if (conT == LMDB) { server = new lmdb::LmdbServer(settings); } #endif if (!server) { NOTREACHED(); return IServerSPtr(); } IServerSPtr sh(server); servers_.push_back(sh); return sh; }
common::Error ServersManager::discoveryConnection(IConnectionSettingsBaseSPtr connection, std::vector<ServerDiscoveryInfoSPtr>* inf) { if (!connection || !inf) { return common::make_error_value("Invalid input argument", common::ErrorValue::E_ERROR); } connectionTypes type = connection->type(); #ifdef BUILD_WITH_REDIS if (type == REDIS) { return fastonosql::redis::discoveryConnection(dynamic_cast<redis::RedisConnectionSettings*>(connection.get()), inf); } #endif #ifdef BUILD_WITH_MEMCACHED if (type == MEMCACHED) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif #ifdef BUILD_WITH_SSDB if (type == SSDB) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif #ifdef BUILD_WITH_LEVELDB if (type == LEVELDB) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif #ifdef BUILD_WITH_ROCKSDB if (type == ROCKSDB) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif #ifdef BUILD_WITH_UNQLITE if (type == UNQLITE) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif #ifdef BUILD_WITH_LMDB if (type == LMDB) { return common::make_error_value("Not supported setting type", common::ErrorValue::E_ERROR); } #endif return common::make_error_value("Invalid setting type", common::ErrorValue::E_ERROR); }
common::Error ServersManager::testConnection(IConnectionSettingsBaseSPtr connection) { if (!connection) { NOTREACHED(); return common::make_error_value("Invalid input argument", common::ErrorValue::E_ERROR); } connectionTypes type = connection->type(); #ifdef BUILD_WITH_REDIS if (type == REDIS) { return fastonosql::redis::testConnection(dynamic_cast<redis::RedisConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_MEMCACHED if (type == MEMCACHED) { return fastonosql::memcached::testConnection(dynamic_cast<memcached::MemcachedConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_SSDB if (type == SSDB) { return fastonosql::ssdb::testConnection(dynamic_cast<ssdb::SsdbConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_LEVELDB if (type == LEVELDB) { return fastonosql::leveldb::testConnection(dynamic_cast<leveldb::LeveldbConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_ROCKSDB if (type == ROCKSDB) { return fastonosql::rocksdb::testConnection(dynamic_cast<rocksdb::RocksdbConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_UNQLITE if (type == UNQLITE) { return fastonosql::unqlite::testConnection(dynamic_cast<unqlite::UnqliteConnectionSettings*>(connection.get())); } #endif #ifdef BUILD_WITH_LMDB if (type == LMDB) { return fastonosql::lmdb::testConnection(dynamic_cast<lmdb::LmdbConnectionSettings*>(connection.get())); } #endif return common::make_error_value("Invalid setting type", common::ErrorValue::E_ERROR); }