pub struct Route { /* private fields */ }
Expand description
Statement route.
PgDog uses this to decide where a query should be sent to. Read statements are sent to a replica, while write ones are sent the primary. If the cluster has more than one shard, the statement can be sent to a specific database, or all of them.
§Example
use pgdog_plugin::{Shard, ReadWrite, Route};
// This sends the query to the primary database of shard 0.
let route = Route::new(Shard::Direct(0), ReadWrite::Write);
// This sends the query to all shards, routing them to a replica
// of each shard, if any are configured.
let route = Route::new(Shard::All, ReadWrite::Read);
// No routing information is available. PgDog will ignore it
// and make its own decision.
let route = Route::unknown();
Implementations§
Source§impl Route
impl Route
Sourcepub fn new(shard: Shard, read_write: ReadWrite) -> Route
pub fn new(shard: Shard, read_write: ReadWrite) -> Route
Create new route.
§Arguments
shard
: Which shard the statement should be sent to.read_write
: Does the statement read or write data. Read statements are sent to a replica. Write statements are sent to the primary.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Route
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more