in core/src/services/nebula_graph/backend.rs [143:221]
fn build(self) -> Result<impl Access> {
let host = match self.config.host.clone() {
Some(v) => v,
None => {
return Err(Error::new(ErrorKind::ConfigInvalid, "host is empty")
.with_context("service", Scheme::NebulaGraph))
}
};
let port = match self.config.port {
Some(v) => v,
None => {
return Err(Error::new(ErrorKind::ConfigInvalid, "port is empty")
.with_context("service", Scheme::NebulaGraph))
}
};
let username = match self.config.username.clone() {
Some(v) => v,
None => {
return Err(Error::new(ErrorKind::ConfigInvalid, "username is empty")
.with_context("service", Scheme::NebulaGraph))
}
};
let password = match self.config.password.clone() {
Some(v) => v,
None => "".to_string(),
};
let space = match self.config.space.clone() {
Some(v) => v,
None => {
return Err(Error::new(ErrorKind::ConfigInvalid, "space is empty")
.with_context("service", Scheme::NebulaGraph))
}
};
let tag = match self.config.tag.clone() {
Some(v) => v,
None => {
return Err(Error::new(ErrorKind::ConfigInvalid, "tag is empty")
.with_context("service", Scheme::NebulaGraph))
}
};
let key_field = match self.config.key_field.clone() {
Some(v) => v,
None => "key".to_string(),
};
let value_field = match self.config.value_field.clone() {
Some(v) => v,
None => "value".to_string(),
};
let root = normalize_root(
self.config
.root
.clone()
.unwrap_or_else(|| "/".to_string())
.as_str(),
);
let mut session_config = SingleConnSessionConf::new(
vec![HostAddress::new(&host, port)],
username,
password,
Some(space),
);
// NebulaGraph use fbthrift for communication. fbthrift's max_buffer_size is default 4 KB,
// which is too small to store something.
// So we could set max_buffer_size to 10 MB so that NebulaGraph can store files with filesize < 1 MB at least.
session_config.set_buf_size(1024 * 1024);
session_config.set_max_buf_size(64 * 1024 * 1024);
session_config.set_max_parse_response_bytes_count(254);
Ok(NebulaGraphBackend::new(Adapter {
session_pool: OnceCell::new(),
session_config,
tag,
key_field,
value_field,
})
.with_root(root.as_str()))
}