Skip to content

Commit

Permalink
definitions: Implement GSP-86 Add CreateLink (#674)
Browse files Browse the repository at this point in the history
* definitions: Implement GSP-86 Add CreateLink

* definitions: add more details about the behavior for create_link

* definitions:Implement GSP-86 add virtual_link feature
  • Loading branch information
abyss-w authored Jul 16, 2021
1 parent 4844e56 commit 3d8d457
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ type = "string"

[w]
type = "io.Writer"

[target]
type = "string"
19 changes: 19 additions & 0 deletions definitions/operations.toml
Original file line number Diff line number Diff line change
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
- `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.
"""
47 changes: 47 additions & 0 deletions types/operation.generated.go
Original file line number Diff line number Diff line change
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

0 comments on commit 3d8d457

Please sign in to comment.