cvmfs_server_scraper

Struct Scraper

source
pub struct Scraper<State = WithoutServers> { /* private fields */ }
Expand description

A scraper for CVMFS servers.

This struct provides a builder interface for scraping CVMFS servers, and it has three states: WithoutServers, WithServers, and ValidatedAndReady. The scraper is created with the new() method, and then servers can be added with the with_servers() method.

Transitions:

  • new(): creates a Scraper in the WithoutServers state.
  • with_servers(): WithoutServers -> WithServers.
  • validate(): WithServers -> ValidatedAndReady

Notes:

  • You may only add servers in the WithoutServers state.
  • You may only validate the scraper in the WithServers state.
  • You may only scrape the servers in the ValidatedAndReady state.
  • Once the scraper is in the ValidatedAndReady state, it is no longer mutable.

§Example

use cvmfs_server_scraper::{Scraper, ScraperCommon, Hostname, Server, ServerType, ServerBackendType};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let servers = vec![
        Server::new(
            ServerType::Stratum1,
            ServerBackendType::CVMFS,
            Hostname::try_from("azure-us-east-s1.eessi.science").unwrap(),
        ),
        Server::new(
            ServerType::Stratum1,
            ServerBackendType::AutoDetect,
            Hostname::try_from("aws-eu-central-s1.eessi.science").unwrap(),
        ),
    ];
    
    let scraper = Scraper::new()
       .forced_repositories(vec!["repo1", "repo2"])
       .with_servers(servers)
       .ignored_repositories(vec!["repo3", "repo4"])
       .geoapi_servers(vec!["cvmfs-stratum-one.cern.ch", "cvmfs-stratum-one.ihep.ac.cn"])?;
    
    let server_results = scraper.validate()?.scrape().await;
    Ok(())
}

Implementations§

source§

impl Scraper<WithoutServers>

source

pub fn new() -> Self

Create a new Scraper.

This method creates a new Scraper with no servers added and in the WithoutServers state. To add servers, use the with_servers() method.

source

pub fn with_servers(self, servers: Vec<Server>) -> Scraper<WithServers>

Add a list of servers to the scraper.

This method transitions the scraper to the WithServers state, and you may no longer add servers after calling this method.

source§

impl Scraper<WithServers>

source

pub fn validate(self) -> Result<Scraper<ValidatedAndReady>, ScrapeError>

Validate the scraper and transition to the ValidatedAndReady state.

This method performs some basic pre-flight checks to ensure that the scraper is correctly configured. If the checks pass, the scraper transitions to the ValidatedAndReady state, and you may no longer add servers or repositories.

The checks performed are:

  • If any servers use the S3 backend, the forced repositories list cannot be empty.
source§

impl Scraper<ValidatedAndReady>

source

pub async fn scrape(&self) -> Vec<ScrapedServer>

Scrape the servers.

This method scrapes the servers and returns a list of ScrapedServer objects, which contain the results of the scrape. This list will contain either PopulatedServer objects or FailedServer objects, depending on whether the scrape was successful or not for that specific server.

Trait Implementations§

source§

impl Default for Scraper<WithoutServers>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl ScraperCommon for Scraper<WithoutServers>

source§

fn forced_repositories<I, S>(self, repos: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add a list of forced repositories to the scraper. Read more
source§

fn ignored_repositories<I, S>(self, repos: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add a list of ignored repositories to the scraper. Read more
source§

fn geoapi_servers<I, S>(self, servers: I) -> Result<Self, HostnameError>
where I: IntoIterator<Item = S>, Hostname: TryFrom<S>, <Hostname as TryFrom<S>>::Error: Into<HostnameError>,

Add a list of geoapi servers to the scraper. Read more
source§

impl ScraperCommon for Scraper<WithServers>

source§

fn forced_repositories<I, S>(self, repos: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add a list of forced repositories to the scraper. Read more
source§

fn ignored_repositories<I, S>(self, repos: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add a list of ignored repositories to the scraper. Read more
source§

fn geoapi_servers<I, S>(self, servers: I) -> Result<Self, HostnameError>
where I: IntoIterator<Item = S>, Hostname: TryFrom<S>, <Hostname as TryFrom<S>>::Error: Into<HostnameError>,

Add a list of geoapi servers to the scraper. Read more

Auto Trait Implementations§

§

impl<State> Freeze for Scraper<State>

§

impl<State> RefUnwindSafe for Scraper<State>
where State: RefUnwindSafe,

§

impl<State> Send for Scraper<State>
where State: Send,

§

impl<State> Sync for Scraper<State>
where State: Sync,

§

impl<State> Unpin for Scraper<State>
where State: Unpin,

§

impl<State> UnwindSafe for Scraper<State>
where State: UnwindSafe,

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>,

source§

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>,

source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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