Пример #1
0
        /// <summary>
        /// DeleteCAS is used for a Delete Check-And-Set operation. The Key and ModifyIndex are respected. Returns true on success or false on failures.
        /// </summary>
        /// <param name="p">The key/value pair to delete</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the delete attempt succeeded</returns>
        public Task <WriteResult <bool> > DeleteCAS(KVPair p, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            p.Validate();
            var req = _client.DeleteReturning <bool>(string.Format("/v1/kv/{0}", p.Key.TrimStart('/')), q);

            req.Params.Add("cas", p.ModifyIndex.ToString());
            return(req.Execute(ct));
        }
Пример #2
0
        /// <summary>
        /// DeleteCAS is used for a Delete Check-And-Set operation. The Key and ModifyIndex are respected. Returns true on success or false on failures.
        /// </summary>
        /// <param name="p">The key/value pair to delete</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the delete attempt succeeded</returns>
        public Task <WriteResult <bool> > DeleteCAS(KVPair p, WriteOptions q)
        {
            p.Validate();
            var req = _client.Delete <bool>(string.Format("/v1/kv/{0}", p.Key), q);

            req.Params.Add("cas", p.ModifyIndex.ToString());
            return(req.Execute());
        }
Пример #3
0
        /// <summary>
        /// Put is used to write a new value. Only the Key, Flags and Value is respected.
        /// </summary>
        /// <param name="p">The key/value pair to store in Consul</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the write attempt succeeded</returns>
        public Task <WriteResult <bool> > Put(KVPair p, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            p.Validate();
            var req = _client.Put <byte[], bool>(string.Format("/v1/kv/{0}", p.Key.TrimStart('/')), p.Value, q);

            if (p.Flags > 0)
            {
                req.Params["flags"] = p.Flags.ToString();
            }
            return(req.Execute(ct));
        }
Пример #4
0
        /// <summary>
        /// Put is used to write a new value. Only the Key, Flags and Value is respected.
        /// </summary>
        /// <param name="p">The key/value pair to store in Consul</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the write attempt succeeded</returns>
        public Task <WriteResult <bool> > Put(KVPair p, WriteOptions q)
        {
            p.Validate();
            var req = _client.Put <byte[], bool>(string.Format("/v1/kv/{0}", p.Key), p.Value, q);

            if (p.Flags > 0)
            {
                req.Params["flags"] = p.Flags.ToString();
            }
            return(req.Execute());
        }
Пример #5
0
        /// <summary>
        /// Release is used for a lock release operation. The Key, Flags, Value and Session are respected.
        /// </summary>
        /// <param name="p">The key/value pair to store in Consul</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result indicating if the release attempt succeeded</returns>
        public Task <WriteResult <bool> > Release(KVPair p, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            p.Validate();
            var req = _client.Put <object, bool>(string.Format("/v1/kv/{0}", p.Key), q);

            if (p.Flags > 0)
            {
                req.Params["flags"] = p.Flags.ToString();
            }
            req.Params["release"] = p.Session;
            return(req.Execute(ct));
        }
Пример #6
0
 /// <summary>
 /// Release is used for a lock release operation. The Key, Flags, Value and Session are respected.
 /// </summary>
 /// <param name="p">The key/value pair to store in Consul</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result indicating if the release attempt succeeded</returns>
 public async Task<WriteResult<bool>> Release(KVPair p, WriteOptions q)
 {
     p.Validate();
     var req = _client.Put<object, bool>(string.Format("/v1/kv/{0}", p.Key), q);
     if (p.Flags > 0)
     {
         req.Params["flags"] = p.Flags.ToString();
     }
     req.Params["release"] = p.Session;
     return await req.Execute().ConfigureAwait(false);
 }
Пример #7
0
 /// <summary>
 /// DeleteCAS is used for a Delete Check-And-Set operation. The Key and ModifyIndex are respected. Returns true on success or false on failures.
 /// </summary>
 /// <param name="p">The key/value pair to delete</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result indicating if the delete attempt succeeded</returns>
 public async Task<WriteResult<bool>> DeleteCAS(KVPair p, WriteOptions q)
 {
     p.Validate();
     var req = _client.Delete<bool>(string.Format("/v1/kv/{0}", p.Key), q);
     req.Params.Add("cas", p.ModifyIndex.ToString());
     return await req.Execute().ConfigureAwait(false);
 }
Пример #8
0
 /// <summary>
 /// CAS is used for a Check-And-Set operation. The Key, ModifyIndex, Flags and Value are respected. Returns true on success or false on failures.
 /// </summary>
 /// <param name="p">The key/value pair to store in Consul</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result indicating if the write attempt succeeded</returns>
 public async Task<WriteResult<bool>> CAS(KVPair p, WriteOptions q)
 {
     p.Validate();
     var req = _client.Put<byte[], bool>(string.Format("/v1/kv/{0}", p.Key), p.Value, q);
     if (p.Flags > 0)
     {
         req.Params["flags"] = p.Flags.ToString();
     }
     req.Params["cas"] = p.ModifyIndex.ToString();
     return await req.Execute().ConfigureAwait(false);
 }
Пример #9
0
 /// <summary>
 /// Put is used to write a new value. Only the Key, Flags and Value is respected.
 /// </summary>
 /// <param name="p">The key/value pair to store in Consul</param>
 /// <param name="q">Customized write options</param>
 /// <returns>A write result indicating if the write attempt succeeded</returns>
 public Task<WriteResult<bool>> Put(KVPair p, WriteOptions q)
 {
     p.Validate();
     var req = _client.Put<byte[], bool>(string.Format("/v1/kv/{0}", p.Key), p.Value, q);
     if (p.Flags > 0)
     {
         req.Params["flags"] = p.Flags.ToString();
     }
     return req.Execute();
 }