private ICassandraClient CreateClient(CassandraSettings settings) { var cassandraClient = new CassandraClient(CreateSession(settings)) { RetrySetting = settings.RetrySetting ?? new RetrySetting() }; return(cassandraClient); }
public override async void Process(ApplicationEvent msg) { using (await _lock.LockAsync()) { CassandraSettings updatedSettings = await _configProvider.GetSettings(); if (_signature.Equals(updatedSettings.Signature) == false) { _client = CreateClient(updatedSettings); _signature = updatedSettings.Signature; } } }
private async Task <ICassandraClient> GetClient() { if (_client != null) { return(_client); } else { using (await _lock.LockAsync()) { if (_client != null) { return(_client); } CassandraSettings settings = await _configProvider.GetSettings(); _client = CreateClient(settings); _signature = settings.Signature; return(_client); } } }
private ISession CreateSession(CassandraSettings db) { CompressionType compression = CompressionType.LZ4; if (string.IsNullOrWhiteSpace(db.Compression)) { compression = CompressionType.LZ4; } else { if (Enum.TryParse(db.Compression, out compression) == false) { compression = CompressionType.LZ4; } } try { return(string.IsNullOrEmpty(db.Username) || string.IsNullOrEmpty(db.Password) ? Cluster .Builder() .AddContactPoints(db.Hosts) .Build() .Connect(db.KeySpace) : Cluster .Builder() .AddContactPoints(db.Hosts) .WithCredentials(db.Username, db.Password) .Build() .Connect(db.KeySpace)); } catch (Exception ex) { throw ex; } }