Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Jan 7, 2025
1 parent 5f28391 commit cb284d6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
1 change: 0 additions & 1 deletion pgdog-plugin/src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub extern "C" fn pgdog_row_new(num_columns: c_int) -> Row {
std::mem::align_of::<RowColumn>(),
)
.unwrap();


Row {
num_columns,
Expand Down
4 changes: 3 additions & 1 deletion pgdog-plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ impl<'a> Plugin<'a> {

/// Route query.
pub fn route(&self, query: Query) -> Option<Route> {
self.route.as_ref().map(|route| unsafe { route(query.into()) })
self.route
.as_ref()
.map(|route| unsafe { route(query.into()) })
}

/// Perform initialization.
Expand Down
1 change: 0 additions & 1 deletion pgdog/src/backend/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub struct Databases {
databases: HashMap<User, Cluster>,
}


impl Databases {
/// Get a cluster for the user/database pair if it's configured.
pub fn cluster(&self, user: impl ToUser) -> Result<Cluster, Error> {
Expand Down
1 change: 1 addition & 0 deletions pgdog/src/backend/pool/stats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions pgdog/src/frontend/router/parser/select.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 1 addition & 3 deletions pgdog/src/net/messages/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ impl FromBytes for Parse {
let name = c_string_buf(&mut bytes);
let query = c_string_buf(&mut bytes);
let params = bytes.get_i16() as usize;
let data_types = (0..params)
.map(|_| bytes.get_i32())
.collect::<Vec<_>>();
let data_types = (0..params).map(|_| bytes.get_i32()).collect::<Vec<_>>();

Ok(Self {
name,
Expand Down
3 changes: 2 additions & 1 deletion pgdog/src/net/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl Parameters {
/// Find a paramaeter by name.
pub fn get(&self, name: &str) -> Option<&str> {
self.params
.iter().find(|p| p.name == name)
.iter()
.find(|p| p.name == name)
.map(|p| p.value.as_str())
}

Expand Down
6 changes: 5 additions & 1 deletion pgdog/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ pub fn load(names: &[&str]) -> Result<(), libloading::Error> {

/// Get plugin by name.
pub fn plugin(name: &str) -> Option<&Plugin> {
PLUGINS.get().unwrap().iter().find(|&plugin| plugin.name() == name)
PLUGINS
.get()
.unwrap()
.iter()
.find(|&plugin| plugin.name() == name)
}

/// Get all loaded plugins.
Expand Down
24 changes: 14 additions & 10 deletions plugins/pgdog-routing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ pub extern "C" fn pgdog_route_query(query: bindings::Query) -> Route {
fn route_internal(query: &str) -> Result<Route, pg_query::Error> {
let ast = parse(query)?;

if let Some(query) = ast.protobuf.stmts.first() { if let Some(ref node) = query.stmt { match node.node {
Some(NodeEnum::SelectStmt(ref _stmt)) => {
return Ok(Route {
affinity: Affinity_READ,
shard: Shard_ANY,
});
}
if let Some(query) = ast.protobuf.stmts.first() {
if let Some(ref node) = query.stmt {
match node.node {
Some(NodeEnum::SelectStmt(ref _stmt)) => {
return Ok(Route {
affinity: Affinity_READ,
shard: Shard_ANY,
});
}

Some(_) => (),
Some(_) => (),

None => (),
} } }
None => (),
}
}
}

Ok(Route {
affinity: Affinity_WRITE,
Expand Down

0 comments on commit cb284d6

Please sign in to comment.