MCPcopy
hub / github.com/olric-data/olric / Unlock

Method Unlock

internal/dmap/lock.go:74–88  ·  view source on GitHub ↗

Unlock takes key and token and tries to unlock the key. It redirects the request to the partition owner, if required.

(ctx context.Context, key string, token []byte)

Source from the content-addressed store, hash-verified

72// Unlock takes key and token and tries to unlock the key.
73// It redirects the request to the partition owner, if required.
74func (dm *DMap) Unlock(ctx context.Context, key string, token []byte) error {
75 hkey := partitions.HKey(dm.name, key)
76 member := dm.s.primary.PartitionByHKey(hkey).Owner()
77 if member.CompareByName(dm.s.rt.This()) {
78 return dm.unlockKey(ctx, key, token)
79 }
80
81 cmd := protocol.NewUnlock(dm.name, key, hex.EncodeToString(token)).Command(dm.s.ctx)
82 rc := dm.s.client.Get(member.String())
83 err := rc.Process(ctx, cmd)
84 if err != nil {
85 return protocol.ConvertError(err)
86 }
87 return protocol.ConvertError(cmd.Err())
88}
89
90// tryLock takes a deadline and env and sets a key-value pair by using
91// Put with NX and PX commands. It tries to acquire the lock 100 times per second

Implementers 2

ClusterDMapcluster_client.go
EmbeddedDMapembedded_client.go

Calls 11

unlockKeyMethod · 0.95
HKeyFunction · 0.92
NewUnlockFunction · 0.92
ConvertErrorFunction · 0.92
OwnerMethod · 0.80
PartitionByHKeyMethod · 0.80
CompareByNameMethod · 0.80
ThisMethod · 0.80
GetMethod · 0.65
CommandMethod · 0.45
StringMethod · 0.45