From c030f1e0eccc3b38b71ae16262977076a32afd63 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 6 Sep 2021 19:08:59 +0800 Subject: [PATCH] fix: Add storage_features and default_storage_pairs support Signed-off-by: Xuanwo --- generated.go | 78 ++++++++++++++++++++++++++++++++++++++-------------- service.toml | 11 ++++++++ 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/generated.go b/generated.go index c27315a..2c65077 100644 --- a/generated.go +++ b/generated.go @@ -68,25 +68,47 @@ func setStorageSystemMetadata(s *StorageMeta, sm StorageSystemMetadata) { s.SetSystemMetadata(sm) } +// WithDefaultStoragePairs will apply default_storage_pairs value to Options. +// +// DefaultStoragePairs set default pairs for storager actions +func WithDefaultStoragePairs(v DefaultStoragePairs) Pair { + return Pair{ + Key: "default_storage_pairs", + Value: v, + } +} + +// WithStorageFeatures will apply storage_features value to Options. +// +// StorageFeatures set storage features +func WithStorageFeatures(v StorageFeatures) Pair { + return Pair{ + Key: "storage_features", + Value: v, + } +} + var pairMap = map[string]string{ - "content_md5": "string", - "content_type": "string", - "context": "context.Context", - "continuation_token": "string", - "credential": "string", - "endpoint": "string", - "expire": "time.Duration", - "http_client_options": "*httpclient.Options", - "interceptor": "Interceptor", - "io_callback": "func([]byte)", - "list_mode": "ListMode", - "location": "string", - "multipart_id": "string", - "name": "string", - "object_mode": "ObjectMode", - "offset": "int64", - "size": "int64", - "work_dir": "string", + "content_md5": "string", + "content_type": "string", + "context": "context.Context", + "continuation_token": "string", + "credential": "string", + "default_storage_pairs": "DefaultStoragePairs", + "endpoint": "string", + "expire": "time.Duration", + "http_client_options": "*httpclient.Options", + "interceptor": "Interceptor", + "io_callback": "func([]byte)", + "list_mode": "ListMode", + "location": "string", + "multipart_id": "string", + "name": "string", + "object_mode": "ObjectMode", + "offset": "int64", + "size": "int64", + "storage_features": "StorageFeatures", + "work_dir": "string", } var ( _ Appender = &Storage{} @@ -105,6 +127,10 @@ type pairStorageNew struct { // Required pairs // Optional pairs + HasDefaultStoragePairs bool + DefaultStoragePairs DefaultStoragePairs + HasStorageFeatures bool + StorageFeatures StorageFeatures // Enable features // Default pairs } @@ -119,8 +145,20 @@ func parsePairStorageNew(opts []Pair) (pairStorageNew, error) { switch v.Key { // Required pairs // Optional pairs - // Enable features - // Default pairs + case "default_storage_pairs": + if result.HasDefaultStoragePairs { + continue + } + result.HasDefaultStoragePairs = true + result.DefaultStoragePairs = v.Value.(DefaultStoragePairs) + case "storage_features": + if result.HasStorageFeatures { + continue + } + result.HasStorageFeatures = true + result.StorageFeatures = v.Value.(StorageFeatures) + // Enable features + // Default pairs } } diff --git a/service.toml b/service.toml index e39907a..d06012a 100644 --- a/service.toml +++ b/service.toml @@ -3,6 +3,9 @@ name = "memory" [namespace.storage] implement = ["copier", "mover", "appender", "direr"] +[namespace.storage.new] +optional = ["storage_features", "default_storage_pairs"] + [namespace.storage.op.create] optional = ["object_mode"] @@ -20,3 +23,11 @@ optional = ["object_mode"] [namespace.storage.op.write] optional = ["content_md5", "content_type", "io_callback"] + +[pairs.storage_features] +type = "StorageFeatures" +description = "set storage features" + +[pairs.default_storage_pairs] +type = "DefaultStoragePairs" +description = "set default pairs for storager actions"