feat(tvix/dirsvc/Cache): support building from url
Change-Id: I80121319795319bb977427efeca3666c6b87a1b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12147 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									07bf8a0b6d
								
							
						
					
					
						commit
						ba4e02c3ac
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -152,11 +152,12 @@ pub struct CacheConfig {
 | 
			
		|||
 | 
			
		||||
impl TryFrom<url::Url> for CacheConfig {
 | 
			
		||||
    type Error = Box<dyn std::error::Error + Send + Sync>;
 | 
			
		||||
    fn try_from(_url: url::Url) -> Result<Self, Self::Error> {
 | 
			
		||||
        Err(Error::StorageError(
 | 
			
		||||
            "Instantiating a CombinedDirectoryService from a url is not supported".into(),
 | 
			
		||||
        )
 | 
			
		||||
        .into())
 | 
			
		||||
    fn try_from(url: url::Url) -> Result<Self, Self::Error> {
 | 
			
		||||
        // cache doesn't support host or path in the URL.
 | 
			
		||||
        if url.has_host() || !url.path().is_empty() {
 | 
			
		||||
            return Err(Error::StorageError("invalid url".to_string()).into());
 | 
			
		||||
        }
 | 
			
		||||
        Ok(serde_qs::from_str(url.query().unwrap_or_default())?)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue