storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/dsync/rpc-client-interface.go (about) 1 /* 2 * Minio Cloud Storage, (C) 2016 Minio, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dsync 18 19 import "context" 20 21 // LockArgs is minimal required values for any dsync compatible lock operation. 22 type LockArgs struct { 23 // Unique ID of lock/unlock request. 24 UID string 25 26 // Resources contains single or multiple entries to be locked/unlocked. 27 Resources []string 28 29 // Source contains the line number, function and file name of the code 30 // on the client node that requested the lock. 31 Source string 32 33 // Owner represents unique ID for this instance, an owner who originally requested 34 // the locked resource, useful primarily in figuring our stale locks. 35 Owner string 36 37 // Quorum represents the expected quorum for this lock type. 38 Quorum int 39 } 40 41 // NetLocker is dsync compatible locker interface. 42 type NetLocker interface { 43 // Do read lock for given LockArgs. It should return 44 // * a boolean to indicate success/failure of the operation 45 // * an error on failure of lock request operation. 46 RLock(ctx context.Context, args LockArgs) (bool, error) 47 48 // Do write lock for given LockArgs. It should return 49 // * a boolean to indicate success/failure of the operation 50 // * an error on failure of lock request operation. 51 Lock(ctx context.Context, args LockArgs) (bool, error) 52 53 // Do read unlock for given LockArgs. It should return 54 // * a boolean to indicate success/failure of the operation 55 // * an error on failure of unlock request operation. 56 RUnlock(args LockArgs) (bool, error) 57 58 // Do write unlock for given LockArgs. It should return 59 // * a boolean to indicate success/failure of the operation 60 // * an error on failure of unlock request operation. 61 Unlock(args LockArgs) (bool, error) 62 63 // Refresh the given lock to prevent it from becoming stale 64 Refresh(ctx context.Context, args LockArgs) (bool, error) 65 66 // Unlock (read/write) forcefully for given LockArgs. It should return 67 // * a boolean to indicate success/failure of the operation 68 // * an error on failure of unlock request operation. 69 ForceUnlock(ctx context.Context, args LockArgs) (bool, error) 70 71 // Returns underlying endpoint of this lock client instance. 72 String() string 73 74 // Close closes any underlying connection to the service endpoint 75 Close() error 76 77 // Is the underlying connection online? (is always true for any local lockers) 78 IsOnline() bool 79 80 // Is the underlying locker local to this server? 81 IsLocal() bool 82 }