Beispiel #1
0
 private V4EventList ReadFirehose(string id, int?maxMessages = null)
 {
     return(ApiExecutor.Execute(
                _firehoseApi.V4FirehoseIdReadGet,
                id, AuthTokens.SessionToken, AuthTokens.KeyManagerToken,
                maxMessages));
 }
Beispiel #2
0
        /// <summary>
        /// Creates a firehose.
        /// </summary>
        /// <returns>The ID of the firehose.</returns>
        public string CreateFirehose()
        {
            var firehose = ApiExecutor.Execute(_firehoseApi.V4FirehoseCreatePost, AuthTokens.SessionToken,
                                               AuthTokens.KeyManagerToken);

            return(firehose.Id);
        }
Beispiel #3
0
        private IEnumerable <V4Event> ReadFirehose(string id, int?maxMessages = null)
        {
            var task = ApiExecutor.ExecuteAsync(() =>
                                                _firehoseApi.V4ReadAsync(id, AuthTokens.SessionToken, AuthTokens.KeyManagerToken, maxMessages));

            try
            {
                return(task.Result);
            }
            catch (AggregateException ae)
            {
                ae.Handle((ex) =>
                {
                    if (ex is ApiException)
                    {
                        var se = ex as ApiException;
                        if (se.HttpStatusCode == 204)
                        {
                            return(true);
                        }
                    }
                    return(false);
                });
            }

            // if we're still here, that means we caught a 204 error from the swagger exception
            // this means there were no new messages so simply return an empty list
            return(new List <V4Event>());
        }
Beispiel #4
0
 /// <summary>
 /// Creates a datafeed.
 /// </summary>
 /// <returns>The ID of the datafeed.</returns>
 public string CreateDatafeed()
 {
     try
     {
         var datafeed = ApiExecutor.Execute(_datafeedApi.V4CreateAsync, AuthTokens.SessionToken, AuthTokens.KeyManagerToken);
         return(datafeed.Id);
     }
     catch (Exception e)
     {
         _log?.LogError(0, e, "An error has occured while trying to create a datafeed.");
         throw;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Creates a firehose.
 /// </summary>
 /// <returns>The ID of the firehose.</returns>
 public string CreateFirehose()
 {
     try
     {
         var firehose = ApiExecutor.Execute(_firehoseApi.V4CreateAsync, AuthTokens.SessionToken,
                                            AuthTokens.KeyManagerToken);
         return(firehose.Id);
     }
     catch (Exception e)
     {
         _log?.LogError(0, e, "An error has occured while trying to create a firehose.");
         throw;
     }
 }
Beispiel #6
0
        private V4EventList ReadDatafeed(string id, int?maxMessages = null)
        {
            _log?.LogDebug("Waiting for messages on datafeed id = {id}", id);

            // I suspect that when the pod is rebooted, V4DatafeedIdReadGet hangs.
            // This shouldn't happen as the HTTP call should timeout, so something
            // odd is going on and hopefully this will help sort things out.

            var task = Task.Run(() =>
            {
                return(ApiExecutor.Execute(
                           _datafeedApi.V4DatafeedIdReadGet,
                           id, AuthTokens.SessionToken, AuthTokens.KeyManagerToken,
                           maxMessages));
            });

            if (task.Wait(TimeSpan.FromSeconds(110)))
            {
                return(task.Result);
            } // this timed out
            throw new TimeoutException($"Datafeed read call timed out waiting for {id}");
        }
Beispiel #7
0
        /// <summary>
        /// Creates a datafeed.
        /// </summary>
        /// <returns>The ID of the datafeed.</returns>
        public string CreateDatafeed()
        {
            var datafeed = ApiExecutor.Execute(_datafeedApi.V4DatafeedCreatePost, AuthTokens.SessionToken, AuthTokens.KeyManagerToken);

            return(datafeed.Id);
        }
Beispiel #8
0
 private V2MessageList ReadDatafeed(string id, int?maxMessages = null)
 {
     return(ApiExecutor.Execute(_datafeedApi.V2DatafeedIdReadGet, id, AuthTokens.SessionToken, AuthTokens.KeyManagerToken, maxMessages));
 }
 public ClientController(ApiExecutor executor)
 {
     _executor = executor;
 }