コード例 #1
0
        private void SetRequester(IApiEndpoint apiEndpoint, IAuthDataRetriever authDataRetriever = null)
        {
            var testCookie = new AuthData
            {
                CookieKey    = CookieName,
                CookieValue  = CookieValue,
                CookiePath   = CookiePath,
                CookieDomain = CookieDomain
            };

            var testCookieRetriever = authDataRetriever ?? new TestAuthDataRetriever(testCookie);

            _requester = new ApiRequester(new ExactUrlServiceUrlBuilder(), testCookieRetriever, new TestApiEndpiontFactory(apiEndpoint));
        }
コード例 #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="InfluxObserver"/> by
    /// using the given <paramref name="endpoint"/> and <paramref name="ttl"/>.
    /// </summary>
    /// <param name="endpoint">
    /// The <see cref="ApiEndpoint"/> to be used to send the measures.
    /// </param>
    /// <param name="ttl">
    /// The maximum time that a mesure should be keep in cache, before send it
    /// to influx's.
    /// </param>
    /// <remarks>
    /// The <paramref name="ttl"/> should be greater than or equals to
    /// <see cref="TimeSpan.Zero"/>. If <paramref name="ttl"/> is equals to
    /// <see cref="TimeSpan.Zero"/> the default <paramref name="ttl"/> of
    /// third seconds will be used.
    /// <para>
    /// The application's name will be added as a prefix to all measures
    /// before sending it to influx's endpoint.
    /// </para>
    /// </remarks>
    public InfluxObserver(IApiEndpoint endpoint, TimeSpan ttl) {
      if (ttl < TimeSpan.Zero) {
        throw new ArgumentOutOfRangeException("ttl",
          StringResources.ArgumentOutOfRange_NeedNonNegNum);
      }

      endpoint_ = endpoint;

      measures_ = new ConcurrentQueue<Serie>();

      TimeSpan half_ttl =
        ttl == TimeSpan.Zero
          ? TimeSpan.FromSeconds(15)
          : TimeSpan.FromSeconds(ttl.TotalSeconds/2);
      scheduler_ = NonReentrantSchedule.Every(half_ttl);
      scheduler_.Run(Post);
    }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InfluxObserver"/> by
 /// using the given <paramref name="endpoint"/>.
 /// </summary>
 /// <param name="endpoint">
 /// The <see cref="ApiEndpoint"/> to be used to send the measures.
 /// </param>
 public InfluxObserver(IApiEndpoint endpoint)
   : this(endpoint, TimeSpan.FromSeconds(30)) {
 }
コード例 #4
0
 public TestApiEndpiontFactory(IApiEndpoint apiEndpoint)
 {
     _apiEndpoint = apiEndpoint;
 }