private Task <ElasticsearchResponse <T> > SetResultOnRequestState <T>(Task <ElasticsearchResponse <T> > t, TransportRequestState <T> requestState) { var tcs = new TaskCompletionSource <ElasticsearchResponse <T> >(); if (t.Exception != null) { var authenticationException = t.Exception.InnerException as ElasticsearchAuthenticationException; if (authenticationException != null) { this.SetAuthenticationExceptionOnRequestState(requestState, authenticationException, tcs); } else { tcs.SetException(t.Exception.Flatten()); requestState.SetResult(null); } } else { tcs.SetResult(t.Result); requestState.SetResult(t.Result); } return(tcs.Task); }
/* ASYNC *** ********************************************/ public Task <ElasticsearchResponse <T> > DoRequestAsync <T>(string method, string path, object data = null, IRequestParameters requestParameters = null) { using (var requestState = new TransportRequestState <T>(this.Settings, requestParameters, method, path)) { var bytes = PostData(data); requestState.TickSerialization(bytes); return(this.DoRequestAsync <T>(requestState) .ContinueWith(t => { var tcs = new TaskCompletionSource <ElasticsearchResponse <T> >(); if (t.Exception != null) { tcs.SetException(t.Exception.Flatten()); requestState.SetResult(null); } else { tcs.SetResult(t.Result); requestState.SetResult(t.Result); } return tcs.Task; }).Unwrap() ); } }
protected void SetAuthenticationExceptionOnRequestState <T>( TransportRequestState <T> requestState, ElasticsearchAuthenticationException exception, TaskCompletionSource <ElasticsearchResponse <T> > tcs) { var result = this.HandleAuthenticationException(requestState, exception); tcs.SetResult(result); requestState.SetResult(result); }
public OrientdbResponse <T> Request <T>(TransportRequestState <T> requestState, object data = null) { byte[] postData = PostData(data); requestState.TickSerialization(postData); OrientdbResponse <T> response = DoRequest(requestState); requestState.SetResult(response); return(response); }
public ElasticsearchResponse <T> Request <T>(TransportRequestState <T> requestState, object data = null) { var postData = PostData(data); requestState.TickSerialization(postData); var response = this.DoRequest <T>(requestState); requestState.SetResult(response); return(response); }
/* SYNC *** ********************************************/ public ElasticsearchResponse <T> DoRequest <T>(string method, string path, object data = null, IRequestParameters requestParameters = null) { using (var requestState = new TransportRequestState <T>(this.Settings, requestParameters, method, path)) { var bytes = PostData(data); requestState.TickSerialization(bytes); var result = this.DoRequest <T>(requestState); requestState.SetResult(result); return(result); } }