Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

GSP-109: Redesign Features #109

Merged
merged 7 commits into from
Jun 21, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions rfcs/109-redesign-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
author: Xuanwo <[email protected]>
status: draft
updated_at: 2021-06-17
---

# GSP-109: Redesign Features

## Background

[GSP-87](https://github.com/beyondstorage/specs/pull/87) introduces a new concept `Feature`. However, it's proved to be too complicated that both hard to understand and to implemented.

In GSP-87, we added new struct `ServiceFeatures` and `StorageFeatures`:

```go
type ServiceFeatures struct {
LooseOperationAll bool
LooseOperationCreate bool
LooseOperationDelete bool
LooseOperationGet bool
LooseOperationList bool

VirtualOperationAll bool

VirtualPairAll bool
}

type StorageFeatures struct {
LooseOperationAll bool
LooseOperationCompleteMultipart bool
LooseOperationCreate bool
LooseOperationCreateMultipart bool
LooseOperationDelete bool
LooseOperationList bool
LooseOperationListMultipart bool
LooseOperationMetadata bool
LooseOperationRead bool
LooseOperationStat bool
LooseOperationWrite bool
LooseOperationWriteMultipart bool

VirtualOperationAll bool

VirtualPairAll bool
}
```

There are the following problems:

- `LooseOperationXxx` is too verbose and there is no user who requires this feature.
- `VirtualOperationWriteDir` make developer-only care about it in `CreateDir`, but it's not correct: to implement `VirtualDir` support, the developer should check them everywhere.

## Proposal

Define features one by one and remove all autogenerated check, that means service implementer should check all features manually when required.

For now, we will introduce the following features, other features should be introduced by new GSPs.

### LoosePair

We will introduce a new feature called `LoosePair` to replace `LooseOperation` features.

If this feature is enabled, the service will not return an error for not support pairs.

### VirtualDir

We will introduce a new feature called `VirtualDir` to Replace `VirtualOperationCreateDir`.

Any operation that is related to dir SHOULD check `VirtualDir` in services that don't have native support for dir.

- `stat`: SHOULD check `VirtualDir` before set Dir ObjectMode
- `create`: SHOULD check `VirtualDir` before accept Dir ObjectMode
- `list`: SHOULD check `VirtualDir` before set Dir ObjectMode
- `delete`: SHOULD check `VirtualDir` before delete a dir Object.
- ...

### VirtualObjectMetadata

We will introduce a new feature called `VirtualObjectMetadata` to allow the service to handle object metadata even when it doesn't have native support.
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved

## Rationale

N/A

## Compatibility

Related fields `ServiceFeatures` and `StorageFeatures` will be deprecated, like:

- `LooseOperationAll`
- `LooseOperationRead`
- `VirtualOperationAll`
- `VirtualOperationCreateDir`
- `VirtualPairWriteContentMd5`
- ...

The check logic will be removed but related fields will be marked as deprecated.

## Implementation

- Mark fields as deprecated
- Remove not used check logic
- Add features in specs and go-storage
- Implement feature checks in all service