opendal 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +89 -56
- data/Cargo.toml +1 -1
- data/DEPENDENCIES.rust.tsv +55 -41
- data/LICENSE +201 -0
- data/LICENSE-MPL-2.0.txt +373 -0
- data/NOTICE +5 -0
- data/core/CHANGELOG.md +175 -0
- data/core/Cargo.lock +225 -298
- data/core/Cargo.toml +100 -94
- data/core/DEPENDENCIES.rust.tsv +44 -73
- data/core/benches/metadata/README.md +21 -0
- data/core/benches/metadata/main.rs +541 -0
- data/core/benches/vs_fs/Cargo.toml +1 -1
- data/core/benches/vs_s3/Cargo.toml +1 -1
- data/core/core/Cargo.toml +7 -2
- data/core/core/src/blocking/delete.rs +5 -1
- data/core/core/src/blocking/operator.rs +12 -0
- data/core/core/src/blocking/read/std_reader.rs +25 -0
- data/core/core/src/docs/concepts.rs +70 -94
- data/core/core/src/docs/internals/accessor.rs +62 -293
- data/core/core/src/docs/internals/layer.rs +43 -59
- data/core/core/src/docs/internals/mod.rs +21 -23
- data/core/core/src/docs/mod.rs +10 -6
- data/core/core/src/docs/performance/concurrent_write.md +92 -55
- data/core/core/src/docs/performance/http_optimization.md +120 -104
- data/core/core/src/docs/performance/mod.rs +8 -6
- data/core/core/src/docs/rfcs/5485_conditional_reader.md +4 -0
- data/core/core/src/docs/rfcs/7182_restore_api.md +139 -557
- data/core/core/src/docs/rfcs/7945_limited_read.md +210 -0
- data/core/core/src/docs/rfcs/7948_s3_provider_presets.md +254 -0
- data/core/core/src/docs/rfcs/8109_writer_copy_from.md +330 -0
- data/core/core/src/docs/rfcs/8145_conflict_error_kind.md +210 -0
- data/core/core/src/docs/rfcs/8147_write_if_not_changed.md +233 -0
- data/core/core/src/docs/rfcs/8188_compose_api.md +292 -0
- data/core/core/src/docs/rfcs/8194_compact_metadata_and_operation_args.md +444 -0
- data/core/core/src/docs/rfcs/README.md +14 -3
- data/core/core/src/docs/rfcs/mod.rs +46 -22
- data/core/core/src/docs/specs/README.md +34 -0
- data/core/core/src/docs/specs/conditional-operations.md +156 -0
- data/core/core/src/docs/specs/metadata.md +63 -0
- data/core/core/src/docs/specs/mod.rs +26 -0
- data/core/core/src/docs/upgrade.md +114 -1
- data/core/core/src/layers/capability_override.rs +15 -2
- data/core/core/src/layers/complete.rs +347 -43
- data/core/core/src/layers/correctness_check.rs +718 -51
- data/core/core/src/layers/error_context.rs +76 -2
- data/core/core/src/layers/simulate.rs +91 -28
- data/core/core/src/lib.rs +1 -0
- data/core/core/src/raw/accessor.rs +91 -15
- data/core/core/src/raw/enum_utils.rs +7 -0
- data/core/core/src/raw/http_util/header.rs +22 -17
- data/core/core/src/raw/oio/compose/api.rs +92 -0
- data/core/core/src/raw/oio/compose/mod.rs +19 -0
- data/core/core/src/raw/oio/copy/api.rs +3 -3
- data/core/core/src/raw/oio/copy/block_copy.rs +32 -4
- data/core/core/src/raw/oio/copy/multipart_copy.rs +36 -7
- data/core/core/src/raw/oio/entry.rs +48 -22
- data/core/core/src/raw/oio/list/flat_list.rs +1 -1
- data/core/core/src/raw/oio/list/hierarchy_list.rs +3 -2
- data/core/core/src/raw/oio/mod.rs +3 -0
- data/core/core/src/raw/oio/read/position_read.rs +1 -1
- data/core/core/src/raw/oio/write/api.rs +40 -0
- data/core/core/src/raw/oio/write/append_write.rs +4 -4
- data/core/core/src/raw/oio/write/block_write.rs +2 -2
- data/core/core/src/raw/oio/write/multipart_write.rs +181 -48
- data/core/core/src/raw/oio/write/position_write.rs +1 -1
- data/core/core/src/raw/operation.rs +6 -0
- data/core/core/src/raw/ops.rs +1191 -456
- data/core/core/src/raw/rps.rs +11 -0
- data/core/core/src/raw/time.rs +14 -3
- data/core/core/src/services/memory/backend.rs +5 -10
- data/core/core/src/services/memory/lister.rs +4 -4
- data/core/core/src/services/memory/writer.rs +7 -6
- data/core/core/src/types/buffer.rs +102 -12
- data/core/core/src/types/bytes_range.rs +20 -1
- data/core/core/src/types/capability.rs +65 -0
- data/core/core/src/types/compact.rs +329 -0
- data/core/core/src/types/compose/composer.rs +183 -0
- data/core/core/src/types/compose/input.rs +57 -0
- data/core/core/src/types/compose/mod.rs +23 -0
- data/core/core/src/types/context/read.rs +16 -11
- data/core/core/src/types/context/write.rs +150 -2
- data/core/core/src/types/copy.rs +5 -3
- data/core/core/src/types/delete/deleter.rs +20 -12
- data/core/core/src/types/delete/input.rs +22 -64
- data/core/core/src/types/delete/mod.rs +0 -1
- data/core/core/src/types/entry.rs +8 -14
- data/core/core/src/types/error.rs +28 -11
- data/core/core/src/types/metadata.rs +709 -322
- data/core/core/src/types/mod.rs +9 -1
- data/core/core/src/types/operator/operator.rs +278 -29
- data/core/core/src/types/operator/operator_futures.rs +466 -105
- data/core/core/src/types/options.rs +631 -158
- data/core/core/src/types/read/futures_async_reader.rs +663 -50
- data/core/core/src/types/read/reader.rs +23 -5
- data/core/core/src/types/write/futures_async_writer.rs +27 -0
- data/core/core/src/types/write/writer.rs +47 -5
- data/core/http-transports/reqwest/Cargo.toml +1 -1
- data/core/layers/async-backtrace/Cargo.toml +2 -2
- data/core/layers/async-backtrace/src/lib.rs +21 -2
- data/core/layers/await-tree/Cargo.toml +2 -2
- data/core/layers/await-tree/src/lib.rs +25 -2
- data/core/layers/capability-check/Cargo.toml +2 -2
- data/core/layers/capability-check/src/lib.rs +98 -10
- data/core/layers/chaos/Cargo.toml +2 -2
- data/core/layers/chaos/src/lib.rs +18 -3
- data/core/layers/concurrent-limit/Cargo.toml +3 -3
- data/core/layers/concurrent-limit/src/lib.rs +53 -13
- data/core/layers/dtrace/Cargo.toml +2 -2
- data/core/layers/dtrace/src/lib.rs +29 -2
- data/core/layers/fastmetrics/Cargo.toml +3 -3
- data/core/layers/fastrace/Cargo.toml +2 -2
- data/core/layers/fastrace/src/lib.rs +28 -2
- data/core/layers/foyer/Cargo.toml +2 -2
- data/core/layers/foyer/src/full.rs +16 -19
- data/core/layers/foyer/src/lib.rs +67 -14
- data/core/layers/hotpath/Cargo.toml +2 -2
- data/core/layers/hotpath/src/lib.rs +20 -2
- data/core/layers/immutable-index/Cargo.toml +2 -2
- data/core/layers/immutable-index/src/lib.rs +48 -24
- data/core/layers/logging/Cargo.toml +2 -2
- data/core/layers/logging/src/lib.rs +46 -2
- data/core/layers/metrics/Cargo.toml +3 -3
- data/core/layers/mime-guess/Cargo.toml +2 -2
- data/core/layers/mime-guess/src/lib.rs +31 -4
- data/core/layers/observe-metrics-common/Cargo.toml +2 -2
- data/core/layers/observe-metrics-common/src/lib.rs +55 -2
- data/core/layers/otelmetrics/Cargo.toml +3 -3
- data/core/layers/oteltrace/Cargo.toml +2 -2
- data/core/layers/oteltrace/src/lib.rs +27 -2
- data/core/layers/prometheus/Cargo.toml +3 -3
- data/core/layers/prometheus-client/Cargo.toml +3 -3
- data/core/layers/retry/Cargo.toml +4 -4
- data/core/layers/retry/src/lib.rs +76 -19
- data/core/layers/route/Cargo.toml +3 -3
- data/core/layers/route/src/lib.rs +34 -7
- data/core/layers/tail-cut/Cargo.toml +2 -2
- data/core/layers/tail-cut/src/lib.rs +28 -2
- data/core/layers/throttle/Cargo.toml +2 -2
- data/core/layers/throttle/src/lib.rs +19 -2
- data/core/layers/timeout/Cargo.toml +3 -3
- data/core/layers/timeout/src/lib.rs +38 -13
- data/core/layers/tracing/Cargo.toml +2 -2
- data/core/layers/tracing/src/lib.rs +24 -3
- data/core/services/aliyun-drive/Cargo.toml +2 -2
- data/core/services/aliyun-drive/src/backend.rs +34 -24
- data/core/services/aliyun-drive/src/core.rs +143 -54
- data/core/services/aliyun-drive/src/lister.rs +19 -18
- data/core/services/aliyun-drive/src/reader.rs +4 -1
- data/core/services/aliyun-drive/src/writer.rs +3 -3
- data/core/services/alluxio/Cargo.toml +1 -1
- data/core/services/alluxio/src/backend.rs +1 -1
- data/core/services/alluxio/src/core.rs +113 -94
- data/core/services/alluxio/src/reader.rs +7 -3
- data/core/services/alluxio/src/writer.rs +2 -2
- data/core/services/azblob/Cargo.toml +2 -2
- data/core/services/azblob/src/backend.rs +17 -9
- data/core/services/azblob/src/copier.rs +41 -15
- data/core/services/azblob/src/core.rs +372 -135
- data/core/services/azblob/src/deleter.rs +41 -18
- data/core/services/azblob/src/lister.rs +16 -10
- data/core/services/azblob/src/reader.rs +4 -1
- data/core/services/azblob/src/writer.rs +48 -15
- data/core/services/azdls/Cargo.toml +3 -3
- data/core/services/azdls/src/backend.rs +45 -15
- data/core/services/azdls/src/config.rs +4 -1
- data/core/services/azdls/src/core.rs +276 -87
- data/core/services/azdls/src/deleter.rs +13 -4
- data/core/services/azdls/src/lister.rs +18 -12
- data/core/services/azdls/src/reader.rs +6 -2
- data/core/services/azdls/src/writer.rs +44 -23
- data/core/services/azfile/Cargo.toml +2 -2
- data/core/services/azfile/src/backend.rs +24 -8
- data/core/services/azfile/src/core.rs +195 -77
- data/core/services/azfile/src/deleter.rs +8 -1
- data/core/services/azfile/src/lister.rs +20 -14
- data/core/services/azfile/src/reader.rs +5 -2
- data/core/services/azfile/src/writer.rs +27 -15
- data/core/services/azure-common/Cargo.toml +1 -1
- data/core/services/b2/Cargo.toml +2 -2
- data/core/services/b2/src/backend.rs +30 -11
- data/core/services/b2/src/core.rs +134 -120
- data/core/services/b2/src/deleter.rs +1 -1
- data/core/services/b2/src/lister.rs +5 -2
- data/core/services/b2/src/reader.rs +5 -2
- data/core/services/b2/src/writer.rs +29 -12
- data/core/services/cacache/Cargo.toml +1 -1
- data/core/services/cacache/src/backend.rs +4 -5
- data/core/services/cacache/src/reader.rs +4 -1
- data/core/services/cacache/src/writer.rs +6 -2
- data/core/services/cloudflare-kv/Cargo.toml +1 -1
- data/core/services/cloudflare-kv/src/backend.rs +26 -15
- data/core/services/cloudflare-kv/src/config.rs +13 -2
- data/core/services/cloudflare-kv/src/core.rs +62 -56
- data/core/services/cloudflare-kv/src/deleter.rs +12 -3
- data/core/services/cloudflare-kv/src/lister.rs +66 -17
- data/core/services/cloudflare-kv/src/reader.rs +14 -9
- data/core/services/cloudflare-kv/src/writer.rs +10 -7
- data/core/services/compfs/Cargo.toml +1 -1
- data/core/services/compfs/src/backend.rs +11 -7
- data/core/services/compfs/src/lister.rs +7 -7
- data/core/services/compfs/src/writer.rs +1 -1
- data/core/services/cos/Cargo.toml +1 -1
- data/core/services/cos/src/backend.rs +129 -16
- data/core/services/cos/src/core.rs +198 -80
- data/core/services/cos/src/deleter.rs +4 -1
- data/core/services/cos/src/lister.rs +42 -27
- data/core/services/cos/src/reader.rs +6 -2
- data/core/services/cos/src/writer.rs +45 -21
- data/core/services/d1/Cargo.toml +1 -1
- data/core/services/d1/src/backend.rs +6 -5
- data/core/services/d1/src/core.rs +79 -63
- data/core/services/d1/src/reader.rs +4 -1
- data/core/services/d1/src/writer.rs +6 -2
- data/core/services/dashmap/Cargo.toml +1 -1
- data/core/services/dashmap/src/backend.rs +2 -2
- data/core/services/dashmap/src/reader.rs +4 -1
- data/core/services/dashmap/src/writer.rs +11 -8
- data/core/services/dbfs/Cargo.toml +1 -1
- data/core/services/dbfs/src/backend.rs +21 -15
- data/core/services/dbfs/src/core.rs +65 -60
- data/core/services/dbfs/src/deleter.rs +4 -1
- data/core/services/dbfs/src/lister.rs +10 -10
- data/core/services/dbfs/src/writer.rs +6 -3
- data/core/services/dropbox/Cargo.toml +2 -2
- data/core/services/dropbox/src/backend.rs +30 -23
- data/core/services/dropbox/src/core.rs +65 -63
- data/core/services/dropbox/src/deleter.rs +1 -1
- data/core/services/dropbox/src/lister.rs +17 -8
- data/core/services/dropbox/src/reader.rs +4 -1
- data/core/services/dropbox/src/writer.rs +13 -10
- data/core/services/etcd/Cargo.toml +1 -1
- data/core/services/etcd/src/backend.rs +8 -5
- data/core/services/etcd/src/core.rs +5 -11
- data/core/services/etcd/src/lister.rs +6 -1
- data/core/services/etcd/src/reader.rs +4 -1
- data/core/services/etcd/src/writer.rs +6 -3
- data/core/services/foundationdb/Cargo.toml +1 -1
- data/core/services/foundationdb/src/backend.rs +6 -5
- data/core/services/foundationdb/src/reader.rs +4 -1
- data/core/services/foundationdb/src/writer.rs +6 -2
- data/core/services/foyer/Cargo.toml +3 -3
- data/core/services/foyer/src/backend.rs +6 -5
- data/core/services/foyer/src/reader.rs +4 -1
- data/core/services/foyer/src/writer.rs +6 -2
- data/core/services/fs/Cargo.toml +1 -1
- data/core/services/fs/src/backend.rs +4 -3
- data/core/services/fs/src/core.rs +44 -26
- data/core/services/fs/src/lister.rs +9 -6
- data/core/services/fs/src/writer.rs +20 -13
- data/core/services/ftp/Cargo.toml +4 -6
- data/core/services/ftp/src/backend.rs +9 -5
- data/core/services/ftp/src/core.rs +9 -7
- data/core/services/ftp/src/lister.rs +7 -8
- data/core/services/ftp/src/reader.rs +3 -3
- data/core/services/ftp/src/writer.rs +3 -3
- data/core/services/gcs/Cargo.toml +4 -2
- data/core/services/gcs/src/backend.rs +53 -7
- data/core/services/gcs/src/composer.rs +705 -0
- data/core/services/gcs/src/copier.rs +14 -4
- data/core/services/gcs/src/core.rs +828 -124
- data/core/services/gcs/src/deleter.rs +33 -18
- data/core/services/gcs/src/lib.rs +1 -0
- data/core/services/gcs/src/lister.rs +21 -12
- data/core/services/gcs/src/reader.rs +12 -5
- data/core/services/gcs/src/writer.rs +632 -10
- data/core/services/gcs-grpc/Cargo.toml +58 -0
- data/core/services/gcs-grpc/README.md +19 -0
- data/core/services/gcs-grpc/proto/README.md +23 -0
- data/core/services/gcs-grpc/proto/google/storage/v2/storage.proto +171 -0
- data/core/services/gcs-grpc/proto/upstream-descriptor.bin +0 -0
- data/core/services/gcs-grpc/src/backend.rs +449 -0
- data/core/services/gcs-grpc/src/config.rs +116 -0
- data/core/services/gcs-grpc/src/copier.rs +98 -0
- data/core/services/gcs-grpc/src/core.rs +298 -0
- data/core/services/gcs-grpc/src/deleter.rs +65 -0
- data/core/services/gcs-grpc/src/docs.md +19 -0
- data/core/services/gcs-grpc/src/generated/google.storage.v2.rs +541 -0
- data/core/services/gcs-grpc/src/generated/mod.rs +24 -0
- data/core/services/gcs-grpc/src/lib.rs +43 -0
- data/core/services/gcs-grpc/src/lister.rs +125 -0
- data/core/services/gcs-grpc/src/reader.rs +140 -0
- data/core/services/gcs-grpc/src/writer.rs +780 -0
- data/core/services/gdrive/Cargo.toml +2 -2
- data/core/services/gdrive/src/backend.rs +123 -69
- data/core/services/gdrive/src/core.rs +87 -69
- data/core/services/gdrive/src/deleter.rs +8 -2
- data/core/services/gdrive/src/lister.rs +38 -26
- data/core/services/gdrive/src/path_index.rs +2 -2
- data/core/services/gdrive/src/reader.rs +9 -3
- data/core/services/gdrive/src/writer.rs +13 -7
- data/core/services/ghac/Cargo.toml +2 -2
- data/core/services/ghac/src/backend.rs +5 -2
- data/core/services/ghac/src/core.rs +59 -37
- data/core/services/ghac/src/reader.rs +5 -2
- data/core/services/ghac/src/writer.rs +16 -6
- data/core/services/github/Cargo.toml +1 -1
- data/core/services/github/src/backend.rs +16 -8
- data/core/services/github/src/core.rs +88 -76
- data/core/services/github/src/lister.rs +17 -15
- data/core/services/github/src/reader.rs +5 -2
- data/core/services/github/src/writer.rs +12 -6
- data/core/services/goosefs/Cargo.toml +2 -2
- data/core/services/goosefs/src/backend.rs +2 -2
- data/core/services/goosefs/src/core.rs +291 -208
- data/core/services/goosefs/src/docs.md +3 -0
- data/core/services/goosefs/src/lister.rs +2 -3
- data/core/services/goosefs/src/reader.rs +7 -3
- data/core/services/goosefs/src/writer.rs +21 -10
- data/core/services/goosefs/tests/safe_conditional_put.rs +37 -0
- data/core/services/gridfs/Cargo.toml +2 -2
- data/core/services/gridfs/src/backend.rs +12 -8
- data/core/services/gridfs/src/core.rs +1 -1
- data/core/services/gridfs/src/reader.rs +4 -1
- data/core/services/gridfs/src/writer.rs +6 -2
- data/core/services/hdfs/Cargo.toml +1 -1
- data/core/services/hdfs/src/backend.rs +1 -1
- data/core/services/hdfs/src/core.rs +7 -4
- data/core/services/hdfs/src/lister.rs +7 -9
- data/core/services/hdfs/src/writer.rs +5 -1
- data/core/services/hdfs-native/Cargo.toml +1 -1
- data/core/services/hdfs-native/src/backend.rs +1 -1
- data/core/services/hdfs-native/src/core.rs +44 -50
- data/core/services/hdfs-native/src/lister.rs +8 -10
- data/core/services/hdfs-native/src/writer.rs +5 -1
- data/core/services/hf/Cargo.toml +4 -3
- data/core/services/hf/src/backend.rs +4 -3
- data/core/services/hf/src/core.rs +907 -153
- data/core/services/hf/src/lister.rs +16 -6
- data/core/services/hf/src/reader.rs +377 -57
- data/core/services/hf/src/writer.rs +6 -2
- data/core/services/http/Cargo.toml +3 -3
- data/core/services/http/src/backend.rs +8 -6
- data/core/services/http/src/core.rs +57 -35
- data/core/services/http/src/reader.rs +5 -2
- data/core/services/ipfs/Cargo.toml +1 -1
- data/core/services/ipfs/src/backend.rs +20 -9
- data/core/services/ipfs/src/core.rs +43 -34
- data/core/services/ipfs/src/reader.rs +5 -2
- data/core/services/ipmfs/Cargo.toml +1 -1
- data/core/services/ipmfs/src/backend.rs +17 -8
- data/core/services/ipmfs/src/core.rs +66 -60
- data/core/services/ipmfs/src/deleter.rs +5 -2
- data/core/services/ipmfs/src/lister.rs +15 -12
- data/core/services/ipmfs/src/reader.rs +5 -2
- data/core/services/ipmfs/src/writer.rs +6 -3
- data/core/services/koofr/Cargo.toml +2 -2
- data/core/services/koofr/src/backend.rs +46 -17
- data/core/services/koofr/src/core.rs +64 -48
- data/core/services/koofr/src/deleter.rs +4 -1
- data/core/services/koofr/src/lister.rs +11 -10
- data/core/services/koofr/src/reader.rs +5 -2
- data/core/services/koofr/src/writer.rs +13 -7
- data/core/services/lakefs/Cargo.toml +1 -1
- data/core/services/lakefs/src/backend.rs +25 -8
- data/core/services/lakefs/src/core.rs +79 -73
- data/core/services/lakefs/src/deleter.rs +4 -1
- data/core/services/lakefs/src/lister.rs +17 -14
- data/core/services/lakefs/src/reader.rs +5 -2
- data/core/services/lakefs/src/writer.rs +11 -10
- data/core/services/memcached/Cargo.toml +1 -1
- data/core/services/memcached/src/backend.rs +57 -7
- data/core/services/memcached/src/config.rs +13 -2
- data/core/services/memcached/src/core.rs +11 -1
- data/core/services/memcached/src/reader.rs +4 -1
- data/core/services/memcached/src/writer.rs +6 -2
- data/core/services/mini_moka/Cargo.toml +1 -1
- data/core/services/mini_moka/src/backend.rs +8 -8
- data/core/services/mini_moka/src/reader.rs +4 -1
- data/core/services/mini_moka/src/writer.rs +11 -7
- data/core/services/moka/Cargo.toml +1 -1
- data/core/services/moka/src/backend.rs +7 -7
- data/core/services/moka/src/reader.rs +4 -1
- data/core/services/moka/src/writer.rs +10 -6
- data/core/services/mongodb/Cargo.toml +2 -2
- data/core/services/mongodb/src/backend.rs +7 -6
- data/core/services/mongodb/src/core.rs +1 -1
- data/core/services/mongodb/src/reader.rs +4 -1
- data/core/services/mongodb/src/writer.rs +6 -2
- data/core/services/monoiofs/Cargo.toml +2 -2
- data/core/services/monoiofs/src/backend.rs +16 -10
- data/core/services/monoiofs/src/core.rs +8 -9
- data/core/services/monoiofs/src/reader.rs +8 -10
- data/core/services/monoiofs/src/writer.rs +19 -24
- data/core/services/mysql/Cargo.toml +2 -2
- data/core/services/mysql/src/backend.rs +7 -6
- data/core/services/mysql/src/core.rs +1 -1
- data/core/services/mysql/src/lister.rs +7 -3
- data/core/services/mysql/src/reader.rs +4 -1
- data/core/services/mysql/src/writer.rs +6 -2
- data/core/services/obs/Cargo.toml +1 -1
- data/core/services/obs/src/backend.rs +29 -11
- data/core/services/obs/src/core.rs +81 -82
- data/core/services/obs/src/deleter.rs +4 -1
- data/core/services/obs/src/lister.rs +12 -5
- data/core/services/obs/src/reader.rs +5 -2
- data/core/services/obs/src/writer.rs +40 -19
- data/core/services/onedrive/Cargo.toml +2 -2
- data/core/services/onedrive/src/backend.rs +30 -21
- data/core/services/onedrive/src/config.rs +2 -2
- data/core/services/onedrive/src/core.rs +191 -90
- data/core/services/onedrive/src/deleter.rs +5 -2
- data/core/services/onedrive/src/graph_model.rs +10 -51
- data/core/services/onedrive/src/lister.rs +60 -24
- data/core/services/onedrive/src/reader.rs +17 -2
- data/core/services/onedrive/src/writer.rs +26 -15
- data/core/services/opfs/Cargo.toml +1 -1
- data/core/services/opfs/src/backend.rs +6 -13
- data/core/services/opfs/src/core.rs +33 -37
- data/core/services/opfs/src/lister.rs +4 -4
- data/core/services/opfs/src/writer.rs +1 -3
- data/core/services/oss/Cargo.toml +1 -1
- data/core/services/oss/src/backend.rs +40 -8
- data/core/services/oss/src/core.rs +192 -92
- data/core/services/oss/src/deleter.rs +16 -6
- data/core/services/oss/src/lister.rs +43 -27
- data/core/services/oss/src/reader.rs +6 -2
- data/core/services/oss/src/writer.rs +40 -22
- data/core/services/pcloud/Cargo.toml +1 -1
- data/core/services/pcloud/src/backend.rs +40 -6
- data/core/services/pcloud/src/core.rs +80 -66
- data/core/services/pcloud/src/deleter.rs +8 -1
- data/core/services/pcloud/src/lister.rs +4 -1
- data/core/services/pcloud/src/reader.rs +5 -2
- data/core/services/pcloud/src/writer.rs +6 -3
- data/core/services/persy/Cargo.toml +1 -1
- data/core/services/persy/src/backend.rs +6 -5
- data/core/services/persy/src/core.rs +60 -15
- data/core/services/persy/src/reader.rs +4 -1
- data/core/services/persy/src/writer.rs +6 -2
- data/core/services/postgresql/Cargo.toml +2 -2
- data/core/services/postgresql/src/backend.rs +7 -6
- data/core/services/postgresql/src/core.rs +1 -1
- data/core/services/postgresql/src/reader.rs +4 -1
- data/core/services/postgresql/src/writer.rs +6 -2
- data/core/services/redb/Cargo.toml +1 -1
- data/core/services/redb/src/backend.rs +6 -5
- data/core/services/redb/src/reader.rs +4 -1
- data/core/services/redb/src/writer.rs +6 -2
- data/core/services/redis/Cargo.toml +1 -1
- data/core/services/redis/src/backend.rs +18 -8
- data/core/services/redis/src/config.rs +13 -2
- data/core/services/redis/src/reader.rs +8 -4
- data/core/services/redis/src/writer.rs +6 -2
- data/core/services/rocksdb/Cargo.toml +1 -1
- data/core/services/rocksdb/src/backend.rs +6 -5
- data/core/services/rocksdb/src/lister.rs +6 -5
- data/core/services/rocksdb/src/reader.rs +4 -1
- data/core/services/rocksdb/src/writer.rs +6 -2
- data/core/services/s3/Cargo.toml +5 -4
- data/core/services/s3/src/backend.rs +995 -39
- data/core/services/s3/src/compatible_services.md +57 -0
- data/core/services/s3/src/config.rs +16 -0
- data/core/services/s3/src/copier.rs +190 -55
- data/core/services/s3/src/core.rs +299 -190
- data/core/services/s3/src/deleter.rs +26 -7
- data/core/services/s3/src/docs.md +57 -0
- data/core/services/s3/src/lister.rs +55 -36
- data/core/services/s3/src/reader.rs +22 -2
- data/core/services/s3/src/writer.rs +154 -32
- data/core/services/seafile/Cargo.toml +2 -2
- data/core/services/seafile/src/backend.rs +3 -3
- data/core/services/seafile/src/core.rs +105 -79
- data/core/services/seafile/src/lister.rs +11 -8
- data/core/services/seafile/src/reader.rs +5 -2
- data/core/services/seafile/src/writer.rs +6 -3
- data/core/services/sftp/Cargo.toml +1 -1
- data/core/services/sftp/src/backend.rs +19 -4
- data/core/services/sftp/src/core.rs +51 -46
- data/core/services/sftp/src/lister.rs +4 -4
- data/core/services/sftp/src/writer.rs +1 -1
- data/core/services/sled/Cargo.toml +1 -1
- data/core/services/sled/src/backend.rs +6 -5
- data/core/services/sled/src/core.rs +28 -6
- data/core/services/sled/src/lister.rs +6 -5
- data/core/services/sled/src/reader.rs +4 -1
- data/core/services/sled/src/writer.rs +6 -2
- data/core/services/sqlite/Cargo.toml +2 -2
- data/core/services/sqlite/src/backend.rs +12 -7
- data/core/services/sqlite/src/core.rs +3 -3
- data/core/services/sqlite/src/reader.rs +4 -1
- data/core/services/sqlite/src/writer.rs +7 -3
- data/core/services/surrealdb/Cargo.toml +2 -2
- data/core/services/surrealdb/src/backend.rs +7 -6
- data/core/services/surrealdb/src/core.rs +1 -1
- data/core/services/surrealdb/src/reader.rs +4 -1
- data/core/services/surrealdb/src/writer.rs +6 -2
- data/core/services/swift/Cargo.toml +1 -1
- data/core/services/swift/src/backend.rs +38 -8
- data/core/services/swift/src/core.rs +63 -67
- data/core/services/swift/src/deleter.rs +8 -2
- data/core/services/swift/src/lister.rs +11 -8
- data/core/services/swift/src/reader.rs +5 -2
- data/core/services/swift/src/writer.rs +17 -8
- data/core/services/tikv/Cargo.toml +2 -2
- data/core/services/tikv/src/backend.rs +7 -6
- data/core/services/tikv/src/core.rs +31 -14
- data/core/services/tikv/src/reader.rs +4 -1
- data/core/services/tikv/src/writer.rs +6 -2
- data/core/services/tos/Cargo.toml +2 -2
- data/core/services/tos/src/backend.rs +45 -21
- data/core/services/tos/src/copier.rs +44 -17
- data/core/services/tos/src/core.rs +147 -117
- data/core/services/tos/src/deleter.rs +9 -3
- data/core/services/tos/src/docs.md +1 -1
- data/core/services/tos/src/lister.rs +43 -28
- data/core/services/tos/src/reader.rs +5 -2
- data/core/services/tos/src/writer.rs +37 -16
- data/core/services/upyun/Cargo.toml +1 -1
- data/core/services/upyun/src/backend.rs +30 -7
- data/core/services/upyun/src/core.rs +122 -87
- data/core/services/upyun/src/deleter.rs +4 -1
- data/core/services/upyun/src/lister.rs +10 -10
- data/core/services/upyun/src/reader.rs +5 -2
- data/core/services/upyun/src/writer.rs +19 -7
- data/core/services/vercel-artifacts/Cargo.toml +1 -1
- data/core/services/vercel-artifacts/src/backend.rs +6 -3
- data/core/services/vercel-artifacts/src/core.rs +32 -27
- data/core/services/vercel-artifacts/src/reader.rs +5 -2
- data/core/services/vercel-artifacts/src/writer.rs +6 -3
- data/core/services/vercel-blob/Cargo.toml +1 -1
- data/core/services/vercel-blob/src/backend.rs +23 -6
- data/core/services/vercel-blob/src/core.rs +92 -81
- data/core/services/vercel-blob/src/lister.rs +12 -3
- data/core/services/vercel-blob/src/reader.rs +5 -2
- data/core/services/vercel-blob/src/writer.rs +19 -7
- data/core/services/webdav/Cargo.toml +2 -2
- data/core/services/webdav/src/backend.rs +25 -5
- data/core/services/webdav/src/core.rs +116 -59
- data/core/services/webdav/src/deleter.rs +4 -1
- data/core/services/webdav/src/lister.rs +4 -1
- data/core/services/webdav/src/reader.rs +6 -2
- data/core/services/webdav/src/writer.rs +17 -7
- data/core/services/webhdfs/Cargo.toml +2 -2
- data/core/services/webhdfs/src/backend.rs +24 -11
- data/core/services/webhdfs/src/core.rs +99 -98
- data/core/services/webhdfs/src/deleter.rs +5 -2
- data/core/services/webhdfs/src/lister.rs +21 -9
- data/core/services/webhdfs/src/reader.rs +5 -2
- data/core/services/webhdfs/src/writer.rs +49 -14
- data/core/services/yandex-disk/Cargo.toml +1 -1
- data/core/services/yandex-disk/src/backend.rs +28 -6
- data/core/services/yandex-disk/src/core.rs +97 -79
- data/core/services/yandex-disk/src/deleter.rs +4 -1
- data/core/services/yandex-disk/src/lister.rs +25 -9
- data/core/services/yandex-disk/src/reader.rs +5 -2
- data/core/services/yandex-disk/src/writer.rs +6 -3
- data/core/src/lib.rs +5 -0
- data/core/testkit/Cargo.toml +4 -4
- data/core/testkit/src/utils.rs +53 -8
- data/core/tests/behavior/async_compose.rs +297 -0
- data/core/tests/behavior/async_copy.rs +162 -1
- data/core/tests/behavior/async_delete.rs +364 -3
- data/core/tests/behavior/async_read.rs +86 -0
- data/core/tests/behavior/async_restore.rs +162 -0
- data/core/tests/behavior/async_stat.rs +90 -0
- data/core/tests/behavior/async_write.rs +330 -2
- data/core/tests/behavior/main.rs +4 -0
- data/core/upgrade.md +114 -1
- data/src/capability.rs +0 -1
- data/src/io.rs +0 -1
- data/src/lister.rs +0 -1
- data/src/metadata.rs +0 -1
- data/src/operator_info.rs +0 -1
- metadata +44 -2
|
@@ -144,7 +144,7 @@ impl LakefsCore {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
if let Some(after) = after {
|
|
147
|
-
url.push_str(&format!("&after={
|
|
147
|
+
url.push_str(&format!("&after={}", percent_encode_path(&after)));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
let mut req = Request::get(&url);
|
|
@@ -262,7 +262,7 @@ impl LakefsCore {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/// Parse LakefsStatus into Metadata
|
|
265
|
-
pub fn parse_lakefs_status_into_metadata(status: &LakefsStatus) -> Metadata {
|
|
265
|
+
pub fn parse_lakefs_status_into_metadata(status: &LakefsStatus) -> Result<Metadata> {
|
|
266
266
|
// Determine entry mode based on path_type
|
|
267
267
|
// "common_prefix" indicates a directory in list operations
|
|
268
268
|
let mode = if status.path_type == "common_prefix" {
|
|
@@ -271,29 +271,33 @@ impl LakefsCore {
|
|
|
271
271
|
EntryMode::FILE
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
let mut meta =
|
|
274
|
+
let mut meta = if mode == EntryMode::FILE {
|
|
275
|
+
MetadataBuilder::file(status.size_bytes.ok_or_else(|| {
|
|
276
|
+
Error::new(
|
|
277
|
+
ErrorKind::Unexpected,
|
|
278
|
+
"lakefs response does not contain file size",
|
|
279
|
+
)
|
|
280
|
+
})?)
|
|
281
|
+
} else {
|
|
282
|
+
MetadataBuilder::dir()
|
|
283
|
+
};
|
|
275
284
|
|
|
276
285
|
// Set checksum as etag
|
|
277
286
|
if !status.checksum.is_empty() {
|
|
278
|
-
meta.
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Set content length
|
|
282
|
-
if let Some(size) = status.size_bytes {
|
|
283
|
-
meta.set_content_length(size);
|
|
287
|
+
meta.etag(&status.checksum);
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
// Set content type
|
|
287
291
|
if let Some(ref content_type) = status.content_type {
|
|
288
|
-
meta.
|
|
292
|
+
meta.content_type(content_type);
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
// Set last modified time
|
|
292
296
|
if let Ok(timestamp) = Timestamp::from_second(status.mtime) {
|
|
293
|
-
meta.
|
|
297
|
+
meta.last_modified(timestamp);
|
|
294
298
|
}
|
|
295
299
|
|
|
296
|
-
meta
|
|
300
|
+
Ok(meta.build())
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
303
|
|
|
@@ -322,81 +326,83 @@ pub(super) struct Pagination {
|
|
|
322
326
|
pub results: u64,
|
|
323
327
|
}
|
|
324
328
|
|
|
325
|
-
|
|
326
|
-
use std::fmt::Debug;
|
|
329
|
+
use http::StatusCode;
|
|
327
330
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
/// LakefsError is the error returned by Lakefs File System.
|
|
335
|
-
#[derive(Default, Deserialize)]
|
|
336
|
-
struct LakefsError {
|
|
337
|
-
error: String,
|
|
338
|
-
}
|
|
331
|
+
/// LakefsError is the error returned by Lakefs File System.
|
|
332
|
+
#[derive(Default, Deserialize)]
|
|
333
|
+
struct LakefsError {
|
|
334
|
+
error: String,
|
|
335
|
+
}
|
|
339
336
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
337
|
+
impl Debug for LakefsError {
|
|
338
|
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
339
|
+
f.debug_struct("LakefsError")
|
|
340
|
+
.field("message", &self.error.replace('\n', " "))
|
|
341
|
+
.finish()
|
|
346
342
|
}
|
|
343
|
+
}
|
|
347
344
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
|
|
354
|
-
StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
|
|
355
|
-
(ErrorKind::PermissionDenied, false)
|
|
356
|
-
}
|
|
357
|
-
StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
|
|
358
|
-
StatusCode::INTERNAL_SERVER_ERROR
|
|
359
|
-
| StatusCode::BAD_GATEWAY
|
|
360
|
-
| StatusCode::SERVICE_UNAVAILABLE
|
|
361
|
-
| StatusCode::GATEWAY_TIMEOUT => (ErrorKind::Unexpected, true),
|
|
362
|
-
_ => (ErrorKind::Unexpected, false),
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
let message = match serde_json::from_slice::<LakefsError>(&bs) {
|
|
366
|
-
Ok(hf_error) => format!("{:?}", hf_error.error),
|
|
367
|
-
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
let mut err = Error::new(kind, message);
|
|
371
|
-
|
|
372
|
-
err = with_error_response_context(err, parts);
|
|
345
|
+
/// Context needed to classify an error from this service.
|
|
346
|
+
#[derive(Clone, Copy, Debug)]
|
|
347
|
+
pub(crate) struct ErrorContext {
|
|
348
|
+
service_operation: ServiceOperation,
|
|
349
|
+
}
|
|
373
350
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
351
|
+
impl ErrorContext {
|
|
352
|
+
pub(crate) const fn new(service_operation: ServiceOperation) -> Self {
|
|
353
|
+
Self { service_operation }
|
|
354
|
+
}
|
|
355
|
+
}
|
|
377
356
|
|
|
378
|
-
|
|
357
|
+
/// Parse an error response using its service request context.
|
|
358
|
+
pub(crate) fn parse_error(ctx: ErrorContext, resp: Response<Buffer>) -> Error {
|
|
359
|
+
let (parts, body) = resp.into_parts();
|
|
360
|
+
let bs = body.to_bytes();
|
|
361
|
+
|
|
362
|
+
let (kind, retryable) = match parts.status {
|
|
363
|
+
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
|
|
364
|
+
StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
|
|
365
|
+
StatusCode::PRECONDITION_FAILED => (ErrorKind::ConditionNotMatch, false),
|
|
366
|
+
StatusCode::INTERNAL_SERVER_ERROR
|
|
367
|
+
| StatusCode::BAD_GATEWAY
|
|
368
|
+
| StatusCode::SERVICE_UNAVAILABLE
|
|
369
|
+
| StatusCode::GATEWAY_TIMEOUT => (ErrorKind::Unexpected, true),
|
|
370
|
+
_ => (ErrorKind::Unexpected, false),
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
let message = match serde_json::from_slice::<LakefsError>(&bs) {
|
|
374
|
+
Ok(hf_error) => format!("{:?}", hf_error.error),
|
|
375
|
+
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
let mut err = Error::new(kind, message);
|
|
379
|
+
|
|
380
|
+
err = err.with_context("service_operation", ctx.service_operation.0);
|
|
381
|
+
err = with_error_response_context(err, parts);
|
|
382
|
+
|
|
383
|
+
if retryable {
|
|
384
|
+
err = err.set_temporary();
|
|
379
385
|
}
|
|
380
386
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
err
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
#[cfg(test)]
|
|
391
|
+
mod tests {
|
|
392
|
+
use super::*;
|
|
384
393
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
394
|
+
#[test]
|
|
395
|
+
fn test_parse_error() -> Result<()> {
|
|
396
|
+
let resp = r#"
|
|
388
397
|
{
|
|
389
398
|
"error": "Invalid username or password."
|
|
390
399
|
}
|
|
391
400
|
"#;
|
|
392
|
-
|
|
393
|
-
|
|
401
|
+
let decoded_response = serde_json::from_slice::<LakefsError>(resp.as_bytes())
|
|
402
|
+
.map_err(new_json_deserialize_error)?;
|
|
394
403
|
|
|
395
|
-
|
|
404
|
+
assert_eq!(decoded_response.error, "Invalid username or password.");
|
|
396
405
|
|
|
397
|
-
|
|
398
|
-
}
|
|
406
|
+
Ok(())
|
|
399
407
|
}
|
|
400
408
|
}
|
|
401
|
-
|
|
402
|
-
pub(super) use error::*;
|
|
@@ -49,7 +49,10 @@ impl oio::OneShotDelete for LakefsDeleter {
|
|
|
49
49
|
match status {
|
|
50
50
|
StatusCode::NO_CONTENT => Ok(()),
|
|
51
51
|
StatusCode::NOT_FOUND => Ok(()),
|
|
52
|
-
_ => Err(parse_error(
|
|
52
|
+
_ => Err(parse_error(
|
|
53
|
+
ErrorContext::new(ServiceOperation("DeleteObject")),
|
|
54
|
+
resp,
|
|
55
|
+
)),
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -21,9 +21,9 @@ use bytes::Buf;
|
|
|
21
21
|
use opendal_core::raw::*;
|
|
22
22
|
use opendal_core::*;
|
|
23
23
|
|
|
24
|
-
use super::core::LakefsCore;
|
|
25
24
|
use super::core::LakefsListResponse;
|
|
26
25
|
use super::core::parse_error;
|
|
26
|
+
use super::core::{ErrorContext, LakefsCore};
|
|
27
27
|
|
|
28
28
|
pub struct LakefsLister {
|
|
29
29
|
core: Arc<LakefsCore>,
|
|
@@ -64,18 +64,19 @@ impl oio::PageList for LakefsLister {
|
|
|
64
64
|
&self.path,
|
|
65
65
|
self.delimiter,
|
|
66
66
|
&self.amount,
|
|
67
|
-
//
|
|
67
|
+
// start_after applies to the first page; later pages resume from the
|
|
68
|
+
// cursor the previous response returned.
|
|
68
69
|
if ctx.token.is_empty() {
|
|
69
70
|
self.after.clone()
|
|
70
71
|
} else {
|
|
71
|
-
|
|
72
|
+
Some(ctx.token.clone())
|
|
72
73
|
},
|
|
73
74
|
)
|
|
74
75
|
.await?;
|
|
75
76
|
|
|
76
77
|
let status_code = response.status();
|
|
77
78
|
if !status_code.is_success() {
|
|
78
|
-
let error = parse_error(response);
|
|
79
|
+
let error = parse_error(ErrorContext::new(ServiceOperation("ListObjects")), response);
|
|
79
80
|
return Err(error);
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -84,7 +85,9 @@ impl oio::PageList for LakefsLister {
|
|
|
84
85
|
let decoded_response: LakefsListResponse =
|
|
85
86
|
serde_json::from_reader(bytes.reader()).map_err(new_json_deserialize_error)?;
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
let pagination = decoded_response.pagination;
|
|
89
|
+
ctx.done = !pagination.has_more;
|
|
90
|
+
ctx.token = pagination.next_offset;
|
|
88
91
|
|
|
89
92
|
for status in decoded_response.results {
|
|
90
93
|
let entry_type = match status.path_type.as_str() {
|
|
@@ -93,16 +96,16 @@ impl oio::PageList for LakefsLister {
|
|
|
93
96
|
_ => EntryMode::Unknown,
|
|
94
97
|
};
|
|
95
98
|
|
|
96
|
-
let mut meta =
|
|
99
|
+
let mut meta = match entry_type {
|
|
100
|
+
EntryMode::FILE => status
|
|
101
|
+
.size_bytes
|
|
102
|
+
.map_or_else(MetadataBuilder::unknown, MetadataBuilder::file),
|
|
103
|
+
EntryMode::DIR => MetadataBuilder::dir(),
|
|
104
|
+
EntryMode::Unknown => MetadataBuilder::unknown(),
|
|
105
|
+
};
|
|
97
106
|
|
|
98
107
|
if status.mtime != 0 {
|
|
99
|
-
meta.
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if entry_type == EntryMode::FILE
|
|
103
|
-
&& let Some(size_bytes) = status.size_bytes
|
|
104
|
-
{
|
|
105
|
-
meta.set_content_length(size_bytes);
|
|
108
|
+
meta.last_modified(Timestamp::from_second(status.mtime).unwrap());
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
let path = if entry_type == EntryMode::DIR {
|
|
@@ -113,7 +116,7 @@ impl oio::PageList for LakefsLister {
|
|
|
113
116
|
|
|
114
117
|
ctx.entries.push_back(oio::Entry::new(
|
|
115
118
|
&build_rel_path(&self.core.root, &path),
|
|
116
|
-
meta,
|
|
119
|
+
meta.build(),
|
|
117
120
|
));
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
18
|
use super::backend::*;
|
|
19
|
-
use super::core::parse_error;
|
|
19
|
+
use super::core::{ErrorContext, parse_error};
|
|
20
20
|
use http::Response;
|
|
21
21
|
use http::StatusCode;
|
|
22
22
|
use opendal_core::raw::*;
|
|
@@ -66,7 +66,10 @@ impl oio::StreamRead for LakefsReader {
|
|
|
66
66
|
_ => {
|
|
67
67
|
let (part, mut body) = resp.into_parts();
|
|
68
68
|
let buf = body.to_buffer().await?;
|
|
69
|
-
return Err(parse_error(
|
|
69
|
+
return Err(parse_error(
|
|
70
|
+
ErrorContext::new(ServiceOperation("GetObject")),
|
|
71
|
+
Response::from_parts(part, buf),
|
|
72
|
+
));
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
75
|
|
|
@@ -22,9 +22,9 @@ use http::StatusCode;
|
|
|
22
22
|
use opendal_core::raw::*;
|
|
23
23
|
use opendal_core::*;
|
|
24
24
|
|
|
25
|
-
use super::core::LakefsCore;
|
|
26
25
|
use super::core::LakefsStatus;
|
|
27
26
|
use super::core::parse_error;
|
|
27
|
+
use super::core::{ErrorContext, LakefsCore};
|
|
28
28
|
|
|
29
29
|
pub struct LakefsWriter {
|
|
30
30
|
core: Arc<LakefsCore>,
|
|
@@ -61,10 +61,7 @@ impl oio::OneShotWrite for LakefsWriter {
|
|
|
61
61
|
// Try to parse metadata from upload response body
|
|
62
62
|
match serde_json::from_slice::<LakefsStatus>(&body_bytes) {
|
|
63
63
|
Ok(lakefs_status) => {
|
|
64
|
-
|
|
65
|
-
Ok(LakefsCore::parse_lakefs_status_into_metadata(
|
|
66
|
-
&lakefs_status,
|
|
67
|
-
))
|
|
64
|
+
LakefsCore::parse_lakefs_status_into_metadata(&lakefs_status)
|
|
68
65
|
}
|
|
69
66
|
Err(_) => {
|
|
70
67
|
// Upload response doesn't contain ObjectStats, fetch via stat API
|
|
@@ -77,16 +74,20 @@ impl oio::OneShotWrite for LakefsWriter {
|
|
|
77
74
|
serde_json::from_reader(stat_resp.into_body().reader())
|
|
78
75
|
.map_err(new_json_deserialize_error)?;
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
&lakefs_status,
|
|
82
|
-
))
|
|
77
|
+
LakefsCore::parse_lakefs_status_into_metadata(&lakefs_status)
|
|
83
78
|
}
|
|
84
|
-
_ => Err(parse_error(
|
|
79
|
+
_ => Err(parse_error(
|
|
80
|
+
ErrorContext::new(ServiceOperation("StatObject")),
|
|
81
|
+
stat_resp,
|
|
82
|
+
)),
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
_ => Err(parse_error(
|
|
87
|
+
_ => Err(parse_error(
|
|
88
|
+
ErrorContext::new(ServiceOperation("UploadObject")),
|
|
89
|
+
resp,
|
|
90
|
+
)),
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -33,7 +33,7 @@ all-features = true
|
|
|
33
33
|
|
|
34
34
|
[dependencies]
|
|
35
35
|
fastpool = "1.0.2"
|
|
36
|
-
opendal-core = { path = "../../core", version = "0.
|
|
36
|
+
opendal-core = { path = "../../core", version = "0.59.0", default-features = false }
|
|
37
37
|
serde = { workspace = true, features = ["derive"] }
|
|
38
38
|
tokio = { workspace = true, features = ["io-util", "macros", "net", "time"] }
|
|
39
39
|
url = { workspace = true }
|
|
@@ -34,6 +34,7 @@ use super::writer::MemcachedWriter;
|
|
|
34
34
|
#[derive(Debug, Default)]
|
|
35
35
|
pub struct MemcachedBuilder {
|
|
36
36
|
pub(super) config: MemcachedConfig,
|
|
37
|
+
pub(super) default_ttl: Option<Duration>,
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
impl MemcachedBuilder {
|
|
@@ -74,7 +75,7 @@ impl MemcachedBuilder {
|
|
|
74
75
|
|
|
75
76
|
/// Set the default ttl for memcached services.
|
|
76
77
|
pub fn default_ttl(mut self, ttl: Duration) -> Self {
|
|
77
|
-
self.
|
|
78
|
+
self.default_ttl = Some(ttl);
|
|
78
79
|
self
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -97,6 +98,26 @@ impl Builder for MemcachedBuilder {
|
|
|
97
98
|
type Config = MemcachedConfig;
|
|
98
99
|
|
|
99
100
|
fn build(self) -> Result<impl Service> {
|
|
101
|
+
let default_ttl = match self.default_ttl {
|
|
102
|
+
Some(ttl) => Some(ttl),
|
|
103
|
+
None => self
|
|
104
|
+
.config
|
|
105
|
+
.default_ttl
|
|
106
|
+
.map(signed_duration_to_duration)
|
|
107
|
+
.transpose()?,
|
|
108
|
+
};
|
|
109
|
+
if let Some(ttl) = default_ttl
|
|
110
|
+
&& ttl.as_secs() > MAX_RELATIVE_EXPIRATION_SECS
|
|
111
|
+
{
|
|
112
|
+
return Err(Error::new(
|
|
113
|
+
ErrorKind::ConfigInvalid,
|
|
114
|
+
"default_ttl is larger than 30 days, which memcached reads as an absolute \
|
|
115
|
+
unix timestamp rather than an offset, storing the entry already expired",
|
|
116
|
+
)
|
|
117
|
+
.with_context("service", MEMCACHED_SCHEME)
|
|
118
|
+
.with_context("default_ttl", ttl.as_secs().to_string()));
|
|
119
|
+
}
|
|
120
|
+
|
|
100
121
|
let endpoint_raw = self.config.endpoint.clone().ok_or_else(|| {
|
|
101
122
|
Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
|
|
102
123
|
.with_context("service", MEMCACHED_SCHEME)
|
|
@@ -171,7 +192,7 @@ impl Builder for MemcachedBuilder {
|
|
|
171
192
|
endpoint,
|
|
172
193
|
self.config.username,
|
|
173
194
|
self.config.password,
|
|
174
|
-
|
|
195
|
+
default_ttl,
|
|
175
196
|
self.config.connection_pool_max_size,
|
|
176
197
|
))
|
|
177
198
|
.with_normalized_root(root))
|
|
@@ -221,6 +242,7 @@ impl Service for MemcachedBackend {
|
|
|
221
242
|
type Lister = ();
|
|
222
243
|
type Deleter = oio::OneShotDeleter<MemcachedDeleter>;
|
|
223
244
|
type Copier = ();
|
|
245
|
+
type Composer = ();
|
|
224
246
|
|
|
225
247
|
fn info(&self) -> ServiceInfo {
|
|
226
248
|
self.info.clone()
|
|
@@ -246,13 +268,14 @@ impl Service for MemcachedBackend {
|
|
|
246
268
|
let p = build_abs_path(&self.root, path);
|
|
247
269
|
|
|
248
270
|
if p == build_abs_path(&self.root, "") {
|
|
249
|
-
Ok(RpStat::new(
|
|
271
|
+
Ok(RpStat::new(MetadataBuilder::dir().build()))
|
|
250
272
|
} else {
|
|
251
273
|
let bs = self.core.get(&p).await?;
|
|
252
274
|
match bs {
|
|
253
|
-
Some(bs) => Ok(RpStat::new(
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
Some(bs) => Ok(RpStat::new({
|
|
276
|
+
let metadata = MetadataBuilder::file(bs.len() as u64);
|
|
277
|
+
metadata.build()
|
|
278
|
+
})),
|
|
256
279
|
None => Err(Error::new(ErrorKind::NotFound, "kv not found in memcached")),
|
|
257
280
|
}
|
|
258
281
|
}
|
|
@@ -302,7 +325,6 @@ impl Service for MemcachedBackend {
|
|
|
302
325
|
_from: &str,
|
|
303
326
|
_to: &str,
|
|
304
327
|
_args: OpCopy,
|
|
305
|
-
_opts: OpCopier,
|
|
306
328
|
) -> Result<Self::Copier> {
|
|
307
329
|
Err(Error::new(
|
|
308
330
|
ErrorKind::Unsupported,
|
|
@@ -335,3 +357,31 @@ impl Service for MemcachedBackend {
|
|
|
335
357
|
))
|
|
336
358
|
}
|
|
337
359
|
}
|
|
360
|
+
|
|
361
|
+
#[cfg(test)]
|
|
362
|
+
mod tests {
|
|
363
|
+
use std::time::Duration;
|
|
364
|
+
|
|
365
|
+
use super::*;
|
|
366
|
+
|
|
367
|
+
/// memcached reads an expiration over 30 days as an absolute unix timestamp,
|
|
368
|
+
/// so a longer offset would store the entry already expired. Refuse it at
|
|
369
|
+
/// build time rather than writing data that silently disappears.
|
|
370
|
+
#[test]
|
|
371
|
+
fn build_rejects_a_ttl_over_thirty_days() {
|
|
372
|
+
let thirty_days = Duration::from_secs(MAX_RELATIVE_EXPIRATION_SECS);
|
|
373
|
+
|
|
374
|
+
let ok = MemcachedBuilder::default()
|
|
375
|
+
.endpoint("tcp://127.0.0.1:11211")
|
|
376
|
+
.default_ttl(thirty_days)
|
|
377
|
+
.build();
|
|
378
|
+
assert!(ok.is_ok(), "thirty days exactly must still be accepted");
|
|
379
|
+
|
|
380
|
+
let err = MemcachedBuilder::default()
|
|
381
|
+
.endpoint("tcp://127.0.0.1:11211")
|
|
382
|
+
.default_ttl(thirty_days + Duration::from_secs(1))
|
|
383
|
+
.build()
|
|
384
|
+
.expect_err("a ttl over thirty days must be rejected");
|
|
385
|
+
assert_eq!(err.kind(), ErrorKind::ConfigInvalid);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
@@ -44,7 +44,7 @@ pub struct MemcachedConfig {
|
|
|
44
44
|
/// Memcached password, optional.
|
|
45
45
|
pub password: Option<String>,
|
|
46
46
|
/// The default ttl for put operations.
|
|
47
|
-
pub default_ttl: Option<
|
|
47
|
+
pub default_ttl: Option<SignedDuration>,
|
|
48
48
|
/// The maximum number of connections allowed.
|
|
49
49
|
///
|
|
50
50
|
/// default is 10
|
|
@@ -81,7 +81,10 @@ impl Configurator for MemcachedConfig {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
fn into_builder(self) -> Self::Builder {
|
|
84
|
-
MemcachedBuilder {
|
|
84
|
+
MemcachedBuilder {
|
|
85
|
+
config: self,
|
|
86
|
+
default_ttl: None,
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -101,4 +104,12 @@ mod tests {
|
|
|
101
104
|
assert_eq!(cfg.root.as_deref(), Some("app/session"));
|
|
102
105
|
Ok(())
|
|
103
106
|
}
|
|
107
|
+
|
|
108
|
+
#[test]
|
|
109
|
+
fn from_iter_parses_default_ttl() -> Result<()> {
|
|
110
|
+
let cfg = MemcachedConfig::from_iter([("default_ttl".to_string(), "1500ms".to_string())])?;
|
|
111
|
+
|
|
112
|
+
assert_eq!(cfg.default_ttl, Some(SignedDuration::from_millis(1500)));
|
|
113
|
+
Ok(())
|
|
114
|
+
}
|
|
104
115
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
18
|
use std::sync::Arc;
|
|
19
|
+
use std::time::Duration;
|
|
19
20
|
|
|
20
21
|
use fastpool::ManageObject;
|
|
21
22
|
use fastpool::ObjectStatus;
|
|
@@ -163,6 +164,14 @@ pub struct MemcachedCore {
|
|
|
163
164
|
conn: Arc<bounded::Pool<MemcacheConnectionManager>>,
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
/// memcached reads an expiration larger than 30 days as an absolute Unix
|
|
168
|
+
/// timestamp rather than as an offset from now, so a longer TTL sent verbatim
|
|
169
|
+
/// lands in 1970 and the server stores the item as already expired.
|
|
170
|
+
///
|
|
171
|
+
/// See the `Expiration times` section of memcached's protocol.txt. The builder
|
|
172
|
+
/// rejects a `default_ttl` above this, so `set` can pass the value through.
|
|
173
|
+
pub(super) const MAX_RELATIVE_EXPIRATION_SECS: u64 = 60 * 60 * 24 * 30;
|
|
174
|
+
|
|
166
175
|
impl MemcachedCore {
|
|
167
176
|
pub fn new(
|
|
168
177
|
endpoint: Endpoint,
|
|
@@ -205,7 +214,8 @@ impl MemcachedCore {
|
|
|
205
214
|
conn.set(
|
|
206
215
|
&percent_encode_path(key),
|
|
207
216
|
&value.to_vec(),
|
|
208
|
-
//
|
|
217
|
+
// The builder rejects anything above MAX_RELATIVE_EXPIRATION_SECS, so
|
|
218
|
+
// this stays an offset and never lands in memcached's absolute range.
|
|
209
219
|
self.default_ttl
|
|
210
220
|
.map(|v| v.as_secs() as u32)
|
|
211
221
|
.unwrap_or_default(),
|
|
@@ -44,7 +44,10 @@ impl oio::StreamRead for MemcachedReader {
|
|
|
44
44
|
None => return Err(Error::new(ErrorKind::NotFound, "kv not found in memcached")),
|
|
45
45
|
};
|
|
46
46
|
let content = bs.slice(range.to_content_range(bs.len())?);
|
|
47
|
-
let metadata =
|
|
47
|
+
let metadata = {
|
|
48
|
+
let metadata = MetadataBuilder::file(bs.len() as u64);
|
|
49
|
+
metadata.build()
|
|
50
|
+
};
|
|
48
51
|
Ok((
|
|
49
52
|
RpRead::new(metadata),
|
|
50
53
|
Box::new(content) as Box<dyn oio::ReadStreamDyn>,
|
|
@@ -49,8 +49,12 @@ impl oio::Write for MemcachedWriter {
|
|
|
49
49
|
let length = buf.len() as u64;
|
|
50
50
|
self.core.set(&self.path, buf).await?;
|
|
51
51
|
|
|
52
|
-
let
|
|
53
|
-
|
|
52
|
+
let metadata = if self.path.ends_with('/') {
|
|
53
|
+
MetadataBuilder::dir()
|
|
54
|
+
} else {
|
|
55
|
+
MetadataBuilder::file(length)
|
|
56
|
+
};
|
|
57
|
+
Ok(metadata.build())
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
async fn abort(&mut self) -> Result<()> {
|
|
@@ -34,5 +34,5 @@ all-features = true
|
|
|
34
34
|
[dependencies]
|
|
35
35
|
log = { workspace = true }
|
|
36
36
|
mini-moka = "0.10"
|
|
37
|
-
opendal-core = { path = "../../core", version = "0.
|
|
37
|
+
opendal-core = { path = "../../core", version = "0.59.0", default-features = false }
|
|
38
38
|
serde = { workspace = true, features = ["derive"] }
|
|
@@ -153,6 +153,7 @@ impl Service for MiniMokaBackend {
|
|
|
153
153
|
type Lister = oio::HierarchyLister<MiniMokaLister>;
|
|
154
154
|
type Deleter = oio::OneShotDeleter<MiniMokaDeleter>;
|
|
155
155
|
type Copier = ();
|
|
156
|
+
type Composer = ();
|
|
156
157
|
|
|
157
158
|
fn info(&self) -> ServiceInfo {
|
|
158
159
|
ServiceInfo::new(MINI_MOKA_SCHEME, &self.root, "")
|
|
@@ -180,13 +181,13 @@ impl Service for MiniMokaBackend {
|
|
|
180
181
|
// Check if path exists directly in cache
|
|
181
182
|
match self.core.get(&p) {
|
|
182
183
|
Some(value) => {
|
|
183
|
-
let mut metadata = value.metadata.clone();
|
|
184
|
+
let mut metadata = value.metadata.clone().into_builder();
|
|
184
185
|
if p.ends_with('/') {
|
|
185
|
-
metadata.
|
|
186
|
+
metadata.set_dir();
|
|
186
187
|
} else {
|
|
187
|
-
metadata.
|
|
188
|
+
metadata.set_file(value.metadata.content_length());
|
|
188
189
|
}
|
|
189
|
-
Ok(RpStat::new(metadata))
|
|
190
|
+
Ok(RpStat::new(metadata.build()))
|
|
190
191
|
}
|
|
191
192
|
None => {
|
|
192
193
|
if p.ends_with('/') {
|
|
@@ -197,9 +198,9 @@ impl Service for MiniMokaBackend {
|
|
|
197
198
|
.any(|entry| entry.key().starts_with(&p) && entry.key() != &p);
|
|
198
199
|
|
|
199
200
|
if is_prefix {
|
|
200
|
-
let mut metadata =
|
|
201
|
-
metadata.
|
|
202
|
-
return Ok(RpStat::new(metadata));
|
|
201
|
+
let mut metadata = MetadataBuilder::unknown();
|
|
202
|
+
metadata.set_dir();
|
|
203
|
+
return Ok(RpStat::new(metadata.build()));
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
|
|
@@ -260,7 +261,6 @@ impl Service for MiniMokaBackend {
|
|
|
260
261
|
_from: &str,
|
|
261
262
|
_to: &str,
|
|
262
263
|
_args: OpCopy,
|
|
263
|
-
_opts: OpCopier,
|
|
264
264
|
) -> Result<Self::Copier> {
|
|
265
265
|
Err(Error::new(
|
|
266
266
|
ErrorKind::Unsupported,
|
|
@@ -46,7 +46,10 @@ impl oio::StreamRead for MiniMokaReader {
|
|
|
46
46
|
let sliced_content = value
|
|
47
47
|
.content
|
|
48
48
|
.slice(range.to_content_range(value.content.len())?);
|
|
49
|
-
let metadata =
|
|
49
|
+
let metadata = {
|
|
50
|
+
let metadata = MetadataBuilder::file(total_size);
|
|
51
|
+
metadata.build()
|
|
52
|
+
};
|
|
50
53
|
|
|
51
54
|
Ok((
|
|
52
55
|
RpRead::new(metadata),
|