pub enum Volume {
Ephemeral(EphemeralVolume),
Persistent(PersistentVolume),
Shared(SharedVolume),
}
Expand description
Enum to represent the different types of volumes in OmniCloud.
This enum defines the various volume types that can be used in OmniCloud, allowing for flexibility in how data is stored and accessed.
The possible volume types include:
- Ephemeral: A temporary volume that is killed when the app instance is killed, used for ephemeral storage within a single app instance.
- Persistent: A persistent volume that can be shared across nodes in the cluster, used for applications that require data to persist across app restarts or need to maintain state beyond the lifecycle of a single app instance.
- Shared: A network-shared volume that allows for data consistency and state management across app instances running on different nodes in the cluster.
§WARNING
Each volume type has its own characteristics and limitations, and it is important to choose the right type based on the application’s requirements for data persistence, availability, and performance.
Variants§
Ephemeral(EphemeralVolume)
Represents a temporary volume killed when the app instance is killed used for ephemeral storage within a single app instance.
In the event that multiple app instances are running on the same node, each instance will have its own version of the ephemeral volume, which is not shared with the other instances.
This allows for isolated storage for each app instance, ensuring that data is not inadvertently shared or corrupted between instances. This is useful for caching, temporary files, or any data that does not need to persist beyond the lifecycle of the app instance.
Persistent(PersistentVolume)
Represents a persistent volume that can be shared across nodes in the cluster
This volume type is used for applications that require data to persist across app restarts or need to maintain state beyond the lifecycle of a single app instance. It is also used for applications that require data to be shared across multiple app instances running on different nodes in the cluster.
This volume type has a few different modes, each with its own characteristics:
Local Persistent Volumes are stored on worker node local disks but managed in a way that preserves the data even if the container using them is removed. These volumes offer excellent performance due to their local nature but are tied to a specific node. If that node fails, the volume becomes unavailable until the node recovers. This approach is suitable for workloads that prioritize performance over availability, or in clusters where node failures are rare.
Network-Attached Volumes are implemented via network storage protocols such as NFS, iSCSI, or specialized storage vendor APIs. These volumes can be accessed from any node in the cluster, allowing containers to be rescheduled freely without losing access to their data. The tradeoff is increased latency due to network communication, though modern networks and storage protocols can minimize this impact. Network-attached volumes are ideal for workloads that require flexibility in placement and moderate performance.
Distributed Volumes are spread across multiple physical nodes for redundancy and improved availability. Technologies like Ceph, GlusterFS, or Longhorn underpin these volumes, storing multiple copies of the data or using erasure coding to protect against node failures. Distributed volumes offer the best combination of availability and performance, though they typically require more resources due to the replication overhead. They’re well-suited for mission-critical applications where both performance and reliability are important.
Represents a network-shared volume
This volume type is used for applications that require data to be shared across app instances running on different nodes in the cluster, and for applications which require data integrity across in the event of a node failure.
Multiple app instances running on different nodes can share this volume, allowing for data consistency and state management across those instances.
This is useful for distributed databases, shared logs, or any data that needs to be consistent and available across the cluster.
§WARNING
This volume type is shared across nodes, which means that if multiple nodes are running the same app, they will all share the same version of the persistent volume. This can lead to data inconsistency if not managed properly, especially in the event of a node failure when writing to a file or an accidental network partition.
Implementations§
Source§impl Volume
impl Volume
Sourcepub fn create(config: VolumeConfig) -> Result<Self, VolumeError>
pub fn create(config: VolumeConfig) -> Result<Self, VolumeError>
Creates a new volume based on the provided configuration
Sourcepub fn delete(&self) -> Result<(), VolumeError>
pub fn delete(&self) -> Result<(), VolumeError>
Deletes this volume
Sourcepub fn attach(&mut self, node_id: &str) -> Result<(), VolumeError>
pub fn attach(&mut self, node_id: &str) -> Result<(), VolumeError>
Attaches this volume to a specified node
Sourcepub fn detach(&mut self) -> Result<(), VolumeError>
pub fn detach(&mut self) -> Result<(), VolumeError>
Detaches this volume from its current node
Sourcepub fn expand(&mut self, new_size: u64) -> Result<(), VolumeError>
pub fn expand(&mut self, new_size: u64) -> Result<(), VolumeError>
Expands this volume to a new size
Sourcepub fn snapshot(&self, name: &str) -> Result<VolumeSnapshot, VolumeError>
pub fn snapshot(&self, name: &str) -> Result<VolumeSnapshot, VolumeError>
Creates a snapshot of this volume
Sourcepub fn restore_from_snapshot(
&mut self,
snapshot: &VolumeSnapshot,
) -> Result<(), VolumeError>
pub fn restore_from_snapshot( &mut self, snapshot: &VolumeSnapshot, ) -> Result<(), VolumeError>
Restores this volume from a snapshot
Sourcepub fn clone(&self, name: &str) -> Result<Self, VolumeError>
pub fn clone(&self, name: &str) -> Result<Self, VolumeError>
Creates a clone of this volume
Sourcepub fn transform(&self, to_type: String) -> Result<Self, VolumeError>
pub fn transform(&self, to_type: String) -> Result<Self, VolumeError>
Transforms this volume to a different type
Sourcepub fn check_integrity(&self) -> Result<bool, VolumeError>
pub fn check_integrity(&self) -> Result<bool, VolumeError>
Checks the integrity of this volume
Sourcepub fn repair(&mut self) -> Result<(), VolumeError>
pub fn repair(&mut self) -> Result<(), VolumeError>
Repairs this volume if possible
Sourcepub fn update_qos(&mut self, qos: QoSConfig) -> Result<(), VolumeError>
pub fn update_qos(&mut self, qos: QoSConfig) -> Result<(), VolumeError>
Updates the QoS configuration for this volume
Sourcepub fn update_security(
&mut self,
security: SecurityConfig,
) -> Result<(), VolumeError>
pub fn update_security( &mut self, security: SecurityConfig, ) -> Result<(), VolumeError>
Updates the security configuration for this volume
Sourcepub fn update_backup_policy(
&mut self,
policy: BackupPolicy,
) -> Result<(), VolumeError>
pub fn update_backup_policy( &mut self, policy: BackupPolicy, ) -> Result<(), VolumeError>
Updates the backup policy for this volume
Auto Trait Implementations§
impl Freeze for Volume
impl RefUnwindSafe for Volume
impl Send for Volume
impl Sync for Volume
impl Unpin for Volume
impl UnwindSafe for Volume
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
§fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self
into a collection.fn mapped<U, F, A>(self, f: F) -> SmallVec<A>where
F: FnMut(T) -> U,
A: Array<Item = U>,
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>
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>
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§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);