Skip to content

Commit

Permalink
Initial edition of a Lock API
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Nov 25, 2021
1 parent 9648574 commit a0eca23
Show file tree
Hide file tree
Showing 4 changed files with 462 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cs3/gateway/v1beta1/gateway_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ service GatewayAPI {
// Unsets arbitrary metdata into a storage resource.
// Arbitrary metadata is returned in a cs3.storage.provider.v1beta1.ResourceInfo.
rpc UnsetArbitraryMetadata(cs3.storage.provider.v1beta1.UnsetArbitraryMetadataRequest) returns (cs3.storage.provider.v1beta1.UnsetArbitraryMetadataResponse);
// Locks a storage resource.
rpc SetLock(cs3.storage.provider.v1beta1.SetLockRequest) returns (cs3.storage.provider.v1beta1.SetLockResponse);
// Gets the lock metadata of a storage resource.
rpc GetLock(cs3.storage.provider.v1beta1.GetLockRequest) returns (cs3.storage.provider.v1beta1.GetLockResponse);
// Unlocks a storage resource.
rpc Unlock(cs3.storage.provider.v1beta1.UnlockRequest) returns (cs3.storage.provider.v1beta1.UnlockResponse);
// Creates the home directory for a user.
rpc CreateHome(cs3.storage.provider.v1beta1.CreateHomeRequest) returns (cs3.storage.provider.v1beta1.CreateHomeResponse);
// Creates a storage space.
Expand Down
71 changes: 71 additions & 0 deletions cs3/storage/provider/v1beta1/provider_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ service ProviderAPI {
// Unsets arbitrary metdata into a storage resource.
// Arbitrary metadata is returned in a cs3.storageprovider.v1beta1.ResourceInfo.
rpc UnsetArbitraryMetadata(UnsetArbitraryMetadataRequest) returns (UnsetArbitraryMetadataResponse);
// Locks a storage resource.
rpc SetLock(SetLockRequest) returns (SetLockResponse);
// Gets the lock metadata of a storage resource.
rpc GetLock(GetLockRequest) returns (GetLockResponse);
// Unlocks a storage resource.
rpc Unlock(UnlockRequest) returns (UnlockResponse);
// Creates the home directory for a user.
rpc CreateHome(CreateHomeRequest) returns (CreateHomeResponse);
// Gets the home path for the user.
Expand Down Expand Up @@ -762,6 +768,71 @@ message UnsetArbitraryMetadataResponse {
cs3.types.v1beta1.Opaque opaque = 2;
}

message SetLockRequest {
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 1;
// REQUIRED.
// The reference on which the lock should be set,
// if no lock is present.
// The storage driver MUST ensure atomic handling
// of lock/unlock operations.
Reference ref = 2;
// REQUIRED.
// The lock metadata.
Lock lock = 3;
}

message SetLockResponse {
// REQUIRED.
// The response status.
cs3.rpc.v1beta1.Status status = 1;
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 2;
}

message GetLockRequest {
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 1;
// REQUIRED.
// The reference the lock is associated to.
Reference ref = 2;
}

message GetLockResponse {
// REQUIRED.
// The response status.
cs3.rpc.v1beta1.Status status = 1;
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 2;
// REQUIRED.
// The lock metadata
Lock lock = 3;
}

message UnlockRequest {
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 1;
// REQUIRED.
// The reference the lock is associated to.
// The storage driver MUST ensure atomic handling
// of lock/unlock operations.
Reference ref = 2;
}

message UnlockResponse {
// REQUIRED.
// The response status.
cs3.rpc.v1beta1.Status status = 1;
// OPTIONAL.
// Opaque information.
cs3.types.v1beta1.Opaque opaque = 2;
}

message CreateHomeRequest {
// OPTIONAL.
// Opaque information.
Expand Down
22 changes: 22 additions & 0 deletions cs3/storage/provider/v1beta1/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ message ArbitraryMetadata {
map<string, string> metadata = 1;
}

// The available type of locks for a resource.
enum LockType {
LOCK_TYPE_INVALID = 0;
// Shared (advisory) lock: the resource can be read or
// written or unlocked by everyone who has access.
LOCK_TYPE_SHARED = 1;
// Write lock: the resource can be read by everyone who has
// access, but write and unlock is restricted to the lock holder.
LOCK_TYPE_WRITE = 2;
// Exclusive lock: the resource cannot be read nor written
// nor unlocked except by the user holding the lock.
LOCK_TYPE_EXCL = 3;
}

// The metadata associated with a lock on a resource.
message Lock {
// The type of lock.
LockType type = 1;
// Some arbitrary metadata associated with the lock.
string metadata = 2;
}

// The available types of resources.
enum ResourceType {
RESOURCE_TYPE_INVALID = 0;
Expand Down
Loading

0 comments on commit a0eca23

Please sign in to comment.