Exemplo n.º 1
0
        /// <inheritdoc />
        public async Task LockAsync(TKey key, TimeSpan leaseTime)
        {
            var keyData = ToSafeData(key);

            var refId       = _lockReferenceIdSequence.GetNext();
            var leaseTimeMs = leaseTime.CodecMilliseconds(long.MaxValue);

            var requestMessage  = MapLockCodec.EncodeRequest(Name, keyData, ContextId, leaseTimeMs, refId);
            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CAF();

            _ = MapLockCodec.DecodeResponse(responseMessage);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task LockAsync(TKey key, TimeSpan leaseTime)
        {
            var keyData = ToSafeData(key);

            var refId = _lockReferenceIdSequence.GetNext();

            // codec wants -1 for server config, 0 for zero (useless), "max" for max = server config
            var leaseTimeMs = leaseTime.RoundedMilliseconds();

            var requestMessage  = MapLockCodec.EncodeRequest(Name, keyData, ContextId, leaseTimeMs, refId);
            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CfAwait();

            _ = MapLockCodec.DecodeResponse(responseMessage);
        }