Skip to content

Commit

Permalink
Add HttpStore (#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Dec 20, 2022
1 parent 9cdc1c1 commit 4dca8a0
Show file tree
Hide file tree
Showing 8 changed files with 631 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/object_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
AZURE_USE_EMULATOR: "1"
AZURITE_BLOB_STORAGE_URL: "http://localhost:10000"
AZURITE_QUEUE_STORAGE_URL: "http://localhost:10001"
HTTP_URL: "http://localhost:8080"
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
OBJECT_STORE_BUCKET: test-bucket

Expand All @@ -91,6 +92,9 @@ jobs:
curl -v -X POST --data-binary '{"name":"test-bucket"}' -H "Content-Type: application/json" "http://localhost:4443/storage/v1/b"
echo '{"gcs_base_url": "http://localhost:4443", "disable_oauth": true, "client_email": "", "private_key": ""}' > "$GOOGLE_SERVICE_ACCOUNT"
- name: Setup WebDav
run: docker run -d -p 8080:80 rclone/rclone serve webdav /data --addr :80

- name: Setup LocalStack (AWS emulation)
env:
AWS_DEFAULT_REGION: "us-east-1"
Expand Down Expand Up @@ -120,7 +124,7 @@ jobs:
OBJECT_STORE_AWS_ACCESS_KEY_ID: test
OBJECT_STORE_AWS_SECRET_ACCESS_KEY: test
OBJECT_STORE_AWS_ENDPOINT: http://localhost:4566
run: cargo test -p object_store --features=aws,azure,gcp
run: cargo test -p object_store --features=aws,azure,gcp,http

# test the object_store crate builds against wasm32 in stable rust
wasm32-build:
Expand Down
1 change: 1 addition & 0 deletions object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cloud = ["serde", "serde_json", "quick-xml", "reqwest", "reqwest/json", "reqwest
azure = ["cloud"]
gcp = ["cloud", "rustls-pemfile"]
aws = ["cloud"]
http = ["cloud"]

# Experimental support for AWS_PROFILE
aws_profile = ["aws", "aws-config", "aws-types"]
Expand Down
14 changes: 2 additions & 12 deletions object_store/src/azure/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::azure::credential::*;
use crate::client::pagination::stream_paginated;
use crate::client::retry::RetryExt;
use crate::path::DELIMITER;
use crate::util::{format_http_range, format_prefix};
use crate::util::{deserialize_rfc1123, format_http_range, format_prefix};
use crate::{
BoxStream, ClientOptions, ListResult, ObjectMeta, Path, Result, RetryConfig,
StreamExt,
Expand Down Expand Up @@ -479,7 +479,7 @@ impl TryFrom<Blob> for ObjectMeta {
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "PascalCase")]
struct BlobProperties {
#[serde(deserialize_with = "deserialize_http_date", rename = "Last-Modified")]
#[serde(deserialize_with = "deserialize_rfc1123", rename = "Last-Modified")]
pub last_modified: DateTime<Utc>,
pub etag: String,
#[serde(rename = "Content-Length")]
Expand All @@ -492,16 +492,6 @@ struct BlobProperties {
pub content_language: Option<String>,
}

// deserialize dates used in Azure payloads according to rfc1123
fn deserialize_http_date<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Utc.datetime_from_str(&s, RFC1123_FMT)
.map_err(serde::de::Error::custom)
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct BlockId(Bytes);

Expand Down
3 changes: 2 additions & 1 deletion object_store/src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use std::sync::Arc;
use tokio::io::AsyncWrite;
use url::Url;

use crate::util::RFC1123_FMT;
pub use credential::authority_hosts;

mod client;
Expand Down Expand Up @@ -219,7 +220,7 @@ impl ObjectStore for MicrosoftAzure {
.to_str()
.context(BadHeaderSnafu)?;
let last_modified = Utc
.datetime_from_str(last_modified, credential::RFC1123_FMT)
.datetime_from_str(last_modified, RFC1123_FMT)
.context(InvalidLastModifiedSnafu { last_modified })?;

let content_length = headers
Expand Down
2 changes: 2 additions & 0 deletions object_store/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
pub mod backoff;
#[cfg(test)]
pub mod mock_server;
#[cfg(not(feature = "http"))]
pub mod pagination;
pub mod retry;
#[cfg(not(feature = "http"))]
pub mod token;

use reqwest::header::{HeaderMap, HeaderValue};
Expand Down

0 comments on commit 4dca8a0

Please sign in to comment.