小编xbw*_*lvn的帖子

如何从 Rust 中连接 scylladb

我正在尝试从 Rust 代码连接到 scyllaDB,该代码给出的错误是

线程 'main' 在 'General("timed out waiting for connection")' 处恐慌

代码是

pub fn create_db_session() -> CDRSResult<CurrentSession> {
    println!("connecting to db");
    let auth = NoneAuthenticator;
    let node = NodeTcpConfigBuilder::new("9.78.45.122:32028", auth).build();
    let cluster_config = ClusterTcpConfig(vec![node]);
    new_session(&cluster_config, SingleNode::new())
}
Run Code Online (Sandbox Code Playgroud)

我正在使用的依赖项

[dependencies]
cdrs = "2"
cdrs_helpers_derive = "0.1.0"
uuid = "0.7"
time = "0.1"
Run Code Online (Sandbox Code Playgroud)

从 Python 中,我能够连接到相同的 IP/端口,但不能连接到 Rust。

工作 Python 代码

dynamodb_client = boto3.client('dynamodb', region_name='None')
dynamodb = boto3.resource('dynamodb', endpoint_url=scylla_host,
                          region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
Run Code Online (Sandbox Code Playgroud)

Rust 代码有什么问题?

rust

1
推荐指数
1
解决办法
106
查看次数

根据多个条件返回布尔值

我有一个用例,我想从函数返回布尔值

private boolean checkStatus(String param) {
  return param != null ?  randomBool() : true;
}

private boolean randomBool() {
  // return true or false on the basis of some condition 
}
Run Code Online (Sandbox Code Playgroud)

我收到了true关于声明的投诉问题。实现相同目标的另一种方法是什么?

声纳问题:应从表达式中删除冗余布尔文字以提高可读性。

java if-statement

-3
推荐指数
1
解决办法
75
查看次数

标签 统计

if-statement ×1

java ×1

rust ×1