Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

definitions: Implement GSP-86 Add CreateLink #674

Merged
merged 5 commits into from Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -19,4 +19,8 @@ bin/
release/
coverage/
coverage.*
tests/*.yaml
tests/*.yaml

# Jetbrain IDE
.idea
*.iml
18 changes: 9 additions & 9 deletions cmd/definitions/bindata/bindata.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions definitions/features.toml
Expand Up @@ -26,3 +26,14 @@ virtual_object_metadata feature is designed for a service that doesn't have nati

This feature was introduced in GSP-109.
"""

[virtual_link]
description = """
virtual_link feature is designed for a service that doesn't have native support for link.

- If this feature is enabled, the service will run compatible mode: create link via native methods, but allow read link from old-style link object.
- If this feature is not enabled, the service will run in native as other service.

This feature was introduced in GSP-86.
"""

3 changes: 3 additions & 0 deletions definitions/fields.toml
Expand Up @@ -69,3 +69,6 @@ type = "string"

[w]
type = "io.Writer"

[target]
type = "string"
19 changes: 19 additions & 0 deletions definitions/operations.toml
Expand Up @@ -286,3 +286,22 @@ will write data into a file.
- Service that doesn't have native support for `overwrite` SHOULD check and delete the object if exists.
- A successful write operation SHOULD be complete, which means the object's content and metadata should be the same as specified in write request.
"""

[linker]
description = "is the interface for link"

[linker.op.create_link]
params = ["path", "target"]
results = ["o"]
description = """
Will create a link object.

# Behavior

abyss-w marked this conversation as resolved.
Show resolved Hide resolved
- `path` and `target` COULD be relative or absolute path.
- If `target` exists, CreateLink will create a link object on the target.
- If `path` does not exist, the CreateLink will fail, and no link object will be created anywhere.
- A link object COULD be returned in `Stat` or `List`.
- CreateLink COULD implement virtual_link feature when service without native support.
abyss-w marked this conversation as resolved.
Show resolved Hide resolved
- Users SHOULD enable this feature by themselves.
"""
47 changes: 47 additions & 0 deletions types/operation.generated.go
Expand Up @@ -274,6 +274,53 @@ func (s UnimplementedFetcher) FetchWithContext(ctx context.Context, path string,
return
}

// Linker is the interface for link
type Linker interface {

// CreateLink Will create a link object.
//
// # Behavior
//
// - `path` and `target` COULD be relative or absolute path.
// - If `target` exists, CreateLink will create a link object on the target.
// - If `path` does not exist, the CreateLink will fail, and no link object will be created anywhere.
// - A link object COULD be returned in `Stat` or `List`.
// - CreateLink COULD implement virtual_link feature when service without native support.
// - Users SHOULD enable this feature by themselves.
CreateLink(path string, target string, pairs ...Pair) (o *Object, err error)
// CreateLinkWithContext Will create a link object.
//
// # Behavior
//
// - `path` and `target` COULD be relative or absolute path.
// - If `target` exists, CreateLink will create a link object on the target.
// - If `path` does not exist, the CreateLink will fail, and no link object will be created anywhere.
// - A link object COULD be returned in `Stat` or `List`.
// - CreateLink COULD implement virtual_link feature when service without native support.
// - Users SHOULD enable this feature by themselves.
CreateLinkWithContext(ctx context.Context, path string, target string, pairs ...Pair) (o *Object, err error)

mustEmbedUnimplementedLinker()
}

// UnimplementedLinker must be embedded to have forward compatible implementations.
type UnimplementedLinker struct{}

func (s UnimplementedLinker) mustEmbedUnimplementedLinker() {}

func (s UnimplementedLinker) String() string {
return "UnimplementedLinker"
}

func (s UnimplementedLinker) CreateLink(path string, target string, pairs ...Pair) (o *Object, err error) {
err = NewOperationNotImplementedError("create_link")
return
}
func (s UnimplementedLinker) CreateLinkWithContext(ctx context.Context, path string, target string, pairs ...Pair) (o *Object, err error) {
err = NewOperationNotImplementedError("create_link")
return
}

// Mover is the interface for Move.
type Mover interface {

Expand Down