protected void OnOperatonExecuted(KeyValueOperation e) { var handler = OperatonExecuted; if (handler != null) { handler(this, e); } }
public Task<HttpResponseMessage> Set([FromUri] string key, [FromUri] string val) { JToken jVal; try { jVal = JToken.Parse(val); } catch (JsonReaderException) { jVal = val; } var op = new KeyValueOperation { Key = key, Type = KeyValueOperationTypes.Add, Value = jVal }; return Batch(new[] { op }); }
private async Task<HttpResponseMessage> Batch(KeyValueOperation[] operations) { var taskCompletionSource = new TaskCompletionSource<object>(); try { RaftEngine.AppendCommand(new OperationBatchCommand { Batch = operations, Completion = taskCompletionSource }); } catch (NotLeadingException e) { return this.RedirectToLeader(e.CurrentLeader, Request.RequestUri); } await taskCompletionSource.Task; return Request.CreateResponse(HttpStatusCode.Accepted); }
public Task<HttpResponseMessage> Del([FromUri] string key) { var op = new KeyValueOperation { Key = key, Type = KeyValueOperationTypes.Del, }; return Batch(new[] { op }); }
protected void OnOperatonExecuted(KeyValueOperation e) { var handler = OperatonExecuted; if (handler != null) handler(this, e); }