Struct fluvio::FluvioAdmin

source ·
pub struct FluvioAdmin { /* private fields */ }
Expand description

An interface for managing a Fluvio cluster

Most applications will not require administrator functionality. The FluvioAdmin interface is used to create, edit, and manage Topics and other operational items. Think of the difference between regular clients of a Database and its administrators. Regular clients may be applications which are reading and writing data to and from tables that exist in the database. Database administrators would be the ones actually creating, editing, or deleting tables. The same thing goes for Fluvio administrators.

If you are writing an application whose purpose is to manage a Fluvio cluster for you, you can gain access to the FluvioAdmin client via the regular Fluvio client, or through the connect or connect_with_config functions.

§Example

Note that this may fail if you are not authorized as a Fluvio administrator for the cluster you are connected to.

let admin = fluvio.admin().await;

Implementations§

source§

impl FluvioAdmin

source

pub async fn connect() -> Result<Self>

Creates a new admin connection using the current profile from ~/.fluvio/config

This will attempt to read a Fluvio cluster configuration from your ~/.fluvio/config file, or create one with default settings if you don’t have one. If you want to specify a configuration, see connect_with_config instead.

The admin interface requires you to have administrator privileges on the cluster which you are connecting to. If you don’t have the appropriate privileges, this connection will fail.

§Example
let admin = FluvioAdmin::connect().await?;
source

pub async fn connect_with_config(config: &FluvioConfig) -> Result<Self>

Creates a new admin connection using custom configurations

The admin interface requires you to have administrator privileges on the cluster which you are connecting to. If you don’t have the appropriate privileges, this connection will fail.

§Example
use fluvio::config::ConfigFile;
let config_file = ConfigFile::load_default_or_new()?;
let fluvio_config = config_file.config().current_cluster().unwrap();
let admin = FluvioAdmin::connect_with_config(fluvio_config).await?;
source

pub async fn create<S>( &self, name: String, dry_run: bool, spec: S, ) -> Result<()>

Create new object

source

pub async fn create_with_config<S>( &self, config: CommonCreateRequest, spec: S, ) -> Result<()>

source

pub async fn delete<S>(&self, key: impl Into<S::DeleteKey>) -> Result<()>

Delete object by key key is dependent on spec, most are string but some allow multiple types

For example, to delete a topic:

use fluvio::Fluvio;
use fluvio::metadata::topic::TopicSpec;

async fn delete_topic(name: String) -> anyhow::Result<()> {
    let fluvio = Fluvio::connect().await?;
    let admin = fluvio.admin().await;
    admin.delete::<TopicSpec>(name).await?;
    Ok(())
}
source

pub async fn force_delete<S>(&self, key: impl Into<S::DeleteKey>) -> Result<()>

Forcibly delete object by key key is dependent on spec, most are string but some allow multiple types.

This method allows to delete objects marked as ‘system’.

For example, to delete a system topic:

use fluvio::Fluvio;
use fluvio::metadata::topic::TopicSpec;

async fn delete_system_topic(name: String) -> anyhow::Result<()> {
    let fluvio = Fluvio::connect().await?;
    let admin = fluvio.admin().await;
    admin.force_delete::<TopicSpec>(name).await?;
    Ok(())
}
source

pub async fn all<S>(&self) -> Result<Vec<Metadata<S>>>
where S: AdminSpec, S::Status: Encoder + Decoder + Debug,

return all instance of this spec

source

pub async fn list<S, F>(&self, filters: Vec<F>) -> Result<Vec<Metadata<S>>>

return all instance of this spec by filter

source

pub async fn list_with_params<S, F>( &self, filters: Vec<F>, summary: bool, ) -> Result<Vec<Metadata<S>>>

source

pub async fn list_with_config<S, F>( &self, config: ListRequest<S>, ) -> Result<Vec<Metadata<S>>>

source

pub async fn watch<S>( &self, ) -> Result<impl Stream<Item = Result<WatchResponse<S>, IoError>>>
where S: AdminSpec, S::Status: Encoder + Decoder,

Watch stream of changes for metadata There is caching, this is just pass through

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> AsyncConnector for T
where T: Send + Sync,