コード例 #1
0
        /// <inheritdoc />
        /// <summary>
        /// Construct a sink inserting into InfluxDB with the specified details.
        /// </summary>
        /// <param name="connectionInfo">Connection information used to construct InfluxDB client.</param>
        /// <param name="source">Measurement name in the InfluxDB database.</param>
        /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="formatProvider"></param>
        public InfluxDBSink(InfluxDBConnectionInfo connectionInfo, string source, int batchSizeLimit, TimeSpan period,
                            IFormatProvider formatProvider)
            : base(batchSizeLimit, period)
        {
            _connectionInfo = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
            _source         = source;
            _influxDbClient = CreateInfluxDbClient();
            _formatProvider = formatProvider;

            CreateDatabase();
        }
コード例 #2
0
        /// <inheritdoc />
        /// <summary>
        /// Construct a sink inserting into InfluxDB with the specified details.
        /// </summary>
        /// <param name="connectionInfo">Connection information used to construct InfluxDB client.</param>
        /// <param name="applicationName">Application name in the InfluxDB database.</param>
        /// <param name="instanceName">Facility name in the InfluxDB database.</param>
        /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="formatProvider"></param>
        public InfluxDBSink(InfluxDBConnectionInfo connectionInfo, string applicationName, string instanceName, int batchSizeLimit, TimeSpan period,
                            IFormatProvider formatProvider)
            : base(batchSizeLimit, period)
        {
            _connectionInfo  = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
            _applicationName = applicationName;
            _instanceName    = instanceName ?? applicationName;
            _influxDbClient  = CreateInfluxDbClient();
            _formatProvider  = formatProvider;

            CreateDatabaseIfNotExists();
        }
コード例 #3
0
        /// <inheritdoc />
        /// <summary>
        /// Construct a sink inserting into InfluxDB with the specified details.
        /// </summary>
        /// <param name="connectionInfo">Connection information used to construct InfluxDB client.</param>
        /// <param name="applicationName">Application name in the InfluxDB bucket.</param>
        /// <param name="instanceName">Facility name in the InfluxDB bucket.</param>
        /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="formatProvider"></param>
        public InfluxDBSink(InfluxDBSinkOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _connectionInfo  = options.ConnectionInfo ?? throw new ArgumentNullException(nameof(options.ConnectionInfo));
            _applicationName = options.ApplicationName ?? throw new ArgumentNullException(nameof(options.ApplicationName));

            if (_connectionInfo.Uri is null)
            {
                throw new ArgumentNullException(nameof(_connectionInfo.Uri));
            }
            if (_connectionInfo.BucketName is null)
            {
                throw new ArgumentNullException(nameof(_connectionInfo.BucketName));
            }
            if (_connectionInfo.OrganizationId is null)
            {
                throw new ArgumentNullException(nameof(_connectionInfo.OrganizationId));
            }
            if (string.IsNullOrWhiteSpace(_connectionInfo.Token) && string.IsNullOrWhiteSpace(_connectionInfo.AllAccessToken) && string.IsNullOrWhiteSpace(_connectionInfo.Username))
            {
                throw new ArgumentNullException($"At least one authentication field should be provided: {nameof(_connectionInfo.Username)}/{nameof(_connectionInfo.Password)} or {nameof(_connectionInfo.Token)}({nameof(_connectionInfo.AllAccessToken)} If Buckets has to be check and created if needed)");
            }

            if (string.IsNullOrWhiteSpace(_connectionInfo.Username))
            {
                _authMethod = AuthMethods.Token;
            }
            else
            {
                _authMethod = AuthMethods.Credentials;
            }

            if (_authMethod == AuthMethods.Token && string.IsNullOrWhiteSpace(_connectionInfo.Token) && string.IsNullOrWhiteSpace(_connectionInfo.AllAccessToken) && string.IsNullOrWhiteSpace(_connectionInfo.Username))
            {
                throw new ArgumentNullException(nameof(_connectionInfo.Token), $"At least one Token should be given either {nameof(_connectionInfo.Token)} if already created with write permissions or {nameof(_connectionInfo.AllAccessToken)}");
            }

            _instanceName   = options.InstanceName ?? _applicationName;
            _formatProvider = options.FormatProvider;

            _includeFullException = options.IncludeFullException ?? false;

            CreateBucketIfNotExists();

            _influxDbClient = CreateInfluxDbClientWithWriteAccess();
        }
コード例 #4
0
 /// <inheritdoc />
 /// <summary>
 /// Construct a sink inserting into InfluxDB with the specified details.
 /// </summary>
 /// <param name="connectionInfo">Connection information used to construct InfluxDB client.</param>
 /// <param name="applicationName">Measurement name in the InfluxDB database.</param>
 /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
 /// <param name="period">The time to wait between checking for event batches.</param>
 /// <param name="formatProvider"></param>
 public InfluxDBSink(InfluxDBConnectionInfo connectionInfo, string applicationName, int batchSizeLimit, TimeSpan period,
                     IFormatProvider formatProvider)
     : this(connectionInfo, applicationName, null, batchSizeLimit, period, formatProvider)
 {
 }