This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Clientless runtime-agnostic architecture #32
Merged
+3,841
−3,387
Merged
Changes from all commits
Commits
Show all changes
114 commits
Select commit
Hold shift + click to select a range
ae3bc3b
factory dependencies
dmitrii-ubskii 392d864
fixup
dmitrii-ubskii 6cc3442
executor is already shared
dmitrii-ubskii 0286dd4
single executor per client
dmitrii-ubskii be50f6d
move to crosbeam channel everywhere
dmitrii-ubskii 861fbb5
remove tokio dep from main crate
dmitrii-ubskii e2b650e
use most explicit coercions
dmitrii-ubskii 8bbd1d8
cleanup
dmitrii-ubskii c9482cf
Server session pulse & auto-close
dmitrii-ubskii afb4861
cluster session pulse and auto-close
dmitrii-ubskii 9a210dd
rename
dmitrii-ubskii 45e205f
decouple executor from rpc
dmitrii-ubskii 935ad82
move session_manager into server
dmitrii-ubskii d75f08b
encapsulation
dmitrii-ubskii b00214e
revert to yielding sleep
dmitrii-ubskii 773a803
remove unneeded aliases
dmitrii-ubskii 1e030b0
add async single call to tx rpc
dmitrii-ubskii cf8a163
transaction: async commit and rollback
dmitrii-ubskii 089b61d
remove prints
dmitrii-ubskii 32920fd
naming
dmitrii-ubskii b26610f
parallel session close requests
dmitrii-ubskii d0bd284
remove thread pool, use tokio rt
dmitrii-ubskii d094719
remove print
dmitrii-ubskii 2b4908f
Update dependencies
dmitrii-ubskii 2b48cf1
blocking dispatcher stub
dmitrii-ubskii aafe355
blocking dispatcher cleanup
dmitrii-ubskii a9ac84a
move blocking dispatcherfrom rpc to common
dmitrii-ubskii d0b607f
clean up SyncFuture visibility
dmitrii-ubskii 7a29918
mutexed session manager
dmitrii-ubskii 2883103
ServerSession::force_close
dmitrii-ubskii 2d75e15
cleanup dead code
dmitrii-ubskii e9fbb9b
force closable sessions
dmitrii-ubskii 72a4f6d
session manager cleanup
dmitrii-ubskii cb65b2a
renames
dmitrii-ubskii a0a413b
TransactionRPC BatchingDispatcher
dmitrii-ubskii 971feca
tests
dmitrii-ubskii cc36885
force close database connections by force closing underlying RPC
dmitrii-ubskii a34ca49
cluster tests
dmitrii-ubskii 89a178a
internal error
dmitrii-ubskii bb64374
snapshot wip
dmitrii-ubskii 9903edb
clientless snapshot
dmitrii-ubskii 92b3ca0
move tonic to bgrt, merge tests, misc cleanup
dmitrii-ubskii eb3d9a9
restructure
dmitrii-ubskii a191532
restructure + compat test
dmitrii-ubskii 5055099
rearchitecture draft
dmitrii-ubskii c0575d4
transmitters
dmitrii-ubskii e993bec
proto serde traits
dmitrii-ubskii 485318f
uncomment test portion
dmitrii-ubskii 1354ce9
remove last tokio dep outside background thread
dmitrii-ubskii c6075fc
transaction transmitter
dmitrii-ubskii 78ff61f
split transmitter module
dmitrii-ubskii 895ae1f
rename mod transaction => transaction_stream
dmitrii-ubskii 401f551
error propagation in tests/queries
dmitrii-ubskii 35f1e8c
propagate stub send errors
dmitrii-ubskii 623dbd6
message error handling
dmitrii-ubskii 546be82
internal error on unexpected enum variants
dmitrii-ubskii ae992e6
protobuf deserialization error handling
dmitrii-ubskii 97422b5
update dependencies
dmitrii-ubskii a312dbb
clean up database + session
dmitrii-ubskii cd4905f
db & replica info
dmitrii-ubskii 1c3b75e
tighten visibility
dmitrii-ubskii a42aa3b
move address to common
dmitrii-ubskii 04a9e7f
rpc error handling
dmitrii-ubskii 6f429fc
clean up connection
dmitrii-ubskii cfb64c7
120
dmitrii-ubskii fdd65af
format permutation test macro
dmitrii-ubskii 38636bb
generic callback
dmitrii-ubskii 52aeff2
misc cleanup
dmitrii-ubskii 38ea2df
compat test cleanup
dmitrii-ubskii 76a4db4
misc cleanup
dmitrii-ubskii d180e89
last bits of error cleanup
dmitrii-ubskii afdd088
unexpected response/request type error messages
dmitrii-ubskii 2468bd6
enum out of bounds error
dmitrii-ubskii 6f2c36e
unknown address error
dmitrii-ubskii cb62bf1
remove fixmes
dmitrii-ubskii b2d720e
extract common functionality in tests
dmitrii-ubskii 8e26dc6
accept &str or owned String as db name
dmitrii-ubskii 9fc8aee
remove async-trait dep
dmitrii-ubskii 588b9cf
public conceptmap
dmitrii-ubskii f2f754d
callcreds => call_credentials
dmitrii-ubskii bbf57db
rename [CLI] Client Error => [CXN] Connection Error
dmitrii-ubskii 0ca99db
explicit pub(crate) for info structs
dmitrii-ubskii 5428381
removed stray pub
dmitrii-ubskii 90466fe
clean up transaction transmitter creation
dmitrii-ubskii 775c438
clean up imports
dmitrii-ubskii 49ae4bb
merged dependencies
dmitrii-ubskii 0152f1d
query doesn't need to be clonable
dmitrii-ubskii 77714c6
update IDE sync tool
dmitrii-ubskii caa1285
connection Debug
dmitrii-ubskii 3a7139e
connection API change
dmitrii-ubskii 71007f6
update dependencies
dmitrii-ubskii ffbb317
Err()? => return Err() in short circuit
dmitrii-ubskii 9bd94e3
redundant clone
dmitrii-ubskii e039990
clippy
dmitrii-ubskii 19bb2ea
options refactor
dmitrii-ubskii 56f7db4
replace prints with logging
dmitrii-ubskii 2745a0a
DatabaseManager doesn't need to be mut
dmitrii-ubskii bc91dad
rename permutation_tests => test_for_each_arg
dmitrii-ubskii 7f8e0ea
rename test compatibility => runtimes
dmitrii-ubskii 4692284
colon after TODO and FIXME
dmitrii-ubskii 46096f5
reorder impls to put Debug/Display after inherent impl
dmitrii-ubskii 5d02a7e
extraneous clone
dmitrii-ubskii 6e9a491
databases does not need to be mutable
dmitrii-ubskii a30c52c
remove ref (old syntax)
dmitrii-ubskii 9d9eb2e
block_on => run_blocking
dmitrii-ubskii d540766
pulse_shutdown_{sink,source}
dmitrii-ubskii 72842fa
use tokio stream instead of our own
dmitrii-ubskii 0cdb384
callback => response_sink
dmitrii-ubskii 0a0db2b
reorder channel.rs
dmitrii-ubskii 091da71
pull message into network, hide away protobuf
dmitrii-ubskii 7e2ff1c
grpc_sink => request_sink, grpc_stream => response_source
dmitrii-ubskii eea1541
remove unused imports
dmitrii-ubskii d8f89c4
cache tls config
dmitrii-ubskii 4385b43
proto/info => {common,database}
dmitrii-ubskii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ | |
imports_granularity = "Crate" | ||
group_imports = "StdExternalCrate" | ||
use_small_heuristics = "Max" | ||
max_width = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,22 +24,14 @@ use std::{ | |
ops::Index, | ||
}; | ||
|
||
use crate::{common::Result, concept::Concept}; | ||
use crate::concept::Concept; | ||
|
||
#[derive(Debug)] | ||
pub struct ConceptMap { | ||
pub map: HashMap<String, Concept>, | ||
} | ||
|
||
impl ConceptMap { | ||
pub(crate) fn from_proto(proto: typedb_protocol::ConceptMap) -> Result<Self> { | ||
let mut map = HashMap::with_capacity(proto.map.len()); | ||
for (k, v) in proto.map { | ||
map.insert(k, Concept::from_proto(v)?); | ||
} | ||
Ok(Self { map }) | ||
} | ||
|
||
Comment on lines
-35
to
-42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
pub fn get(&self, var_name: &str) -> Option<&Concept> { | ||
self.map.get(var_name) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,12 @@ | |
|
||
use std::{fmt, str::FromStr}; | ||
|
||
use tonic::transport::Uri; | ||
use http::Uri; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good catch! |
||
|
||
use crate::common::{Error, Result}; | ||
|
||
#[derive(Clone, Debug, Hash, PartialEq, Eq)] | ||
pub struct Address { | ||
pub(crate) struct Address { | ||
uri: Uri, | ||
} | ||
|
||
|
@@ -43,7 +43,7 @@ impl FromStr for Address { | |
let uri = if address.contains("://") { | ||
address.parse::<Uri>()? | ||
} else { | ||
format!("http://{}", address).parse::<Uri>()? | ||
format!("http://{address}").parse::<Uri>()? | ||
}; | ||
Ok(Self { uri }) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,43 +19,42 @@ | |
* under the License. | ||
*/ | ||
|
||
use std::{ | ||
fs, | ||
path::{Path, PathBuf}, | ||
sync::RwLock, | ||
}; | ||
use std::{fmt, fs, path::Path}; | ||
|
||
use tonic::{ | ||
transport::{Certificate, ClientTlsConfig}, | ||
Request, | ||
}; | ||
use tonic::transport::{Certificate, ClientTlsConfig}; | ||
|
||
use crate::Result; | ||
|
||
#[derive(Clone, Debug)] | ||
#[derive(Clone)] | ||
pub struct Credential { | ||
username: String, | ||
password: String, | ||
is_tls_enabled: bool, | ||
tls_root_ca: Option<PathBuf>, | ||
tls_config: Option<ClientTlsConfig>, | ||
} | ||
|
||
impl Credential { | ||
pub fn with_tls(username: &str, password: &str, tls_root_ca: Option<&Path>) -> Self { | ||
Credential { | ||
pub fn with_tls(username: &str, password: &str, tls_root_ca: Option<&Path>) -> Result<Self> { | ||
let tls_config = Some(if let Some(tls_root_ca) = tls_root_ca { | ||
ClientTlsConfig::new().ca_certificate(Certificate::from_pem(fs::read_to_string(tls_root_ca)?)) | ||
} else { | ||
ClientTlsConfig::new() | ||
}); | ||
|
||
Ok(Credential { | ||
username: username.to_owned(), | ||
password: password.to_owned(), | ||
is_tls_enabled: true, | ||
tls_root_ca: tls_root_ca.map(Path::to_owned), | ||
} | ||
tls_config, | ||
}) | ||
} | ||
|
||
pub fn without_tls(username: &str, password: &str) -> Self { | ||
Credential { | ||
username: username.to_owned(), | ||
password: password.to_owned(), | ||
is_tls_enabled: false, | ||
tls_root_ca: None, | ||
tls_config: None, | ||
} | ||
} | ||
|
||
|
@@ -71,51 +70,17 @@ impl Credential { | |
self.is_tls_enabled | ||
} | ||
|
||
pub fn tls_config(&self) -> Result<ClientTlsConfig> { | ||
if let Some(ref tls_root_ca) = self.tls_root_ca { | ||
Ok(ClientTlsConfig::new() | ||
.ca_certificate(Certificate::from_pem(fs::read_to_string(tls_root_ca)?))) | ||
} else { | ||
Ok(ClientTlsConfig::new()) | ||
} | ||
pub fn tls_config(&self) -> &Option<ClientTlsConfig> { | ||
&self.tls_config | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct CallCredentials { | ||
credential: Credential, | ||
token: RwLock<Option<String>>, | ||
} | ||
Comment on lines
-84
to
-88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved closer to channel. |
||
|
||
impl CallCredentials { | ||
pub(super) fn new(credential: Credential) -> Self { | ||
Self { credential, token: RwLock::new(None) } | ||
} | ||
|
||
pub(super) fn username(&self) -> &str { | ||
self.credential.username() | ||
} | ||
|
||
pub(super) fn password(&self) -> &str { | ||
self.credential.password() | ||
} | ||
|
||
pub(super) fn set_token(&self, token: String) { | ||
*self.token.write().unwrap() = Some(token); | ||
} | ||
|
||
pub(super) fn reset_token(&self) { | ||
*self.token.write().unwrap() = None; | ||
} | ||
|
||
pub(super) fn inject(&self, mut request: Request<()>) -> Request<()> { | ||
request.metadata_mut().insert("username", self.credential.username().try_into().unwrap()); | ||
match &*self.token.read().unwrap() { | ||
Some(token) => request.metadata_mut().insert("token", token.try_into().unwrap()), | ||
None => request | ||
.metadata_mut() | ||
.insert("password", self.credential.password().try_into().unwrap()), | ||
}; | ||
request | ||
impl fmt::Debug for Credential { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.debug_struct("Credential") | ||
.field("username", &self.username) | ||
.field("is_tls_enabled", &self.is_tls_enabled) | ||
.field("tls_config", &self.tls_config) | ||
.finish() | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query tests are now generated by a permutation macro for both core and cluster, so they are merged into a single test file and filtered at test time.