/// <summary>
        /// Write Measurements into specified bucket.
        /// </summary>
        /// <param name="bucket">specifies the destination bucket for writes</param>
        /// <param name="org">specifies the destination organization for writes</param>
        /// <param name="precision">specifies the precision for the unix timestamps within the body line-protocol</param>
        /// <param name="measurements">specifies Measurements to write into bucket</param>
        /// <typeparam name="TM">measurement type</typeparam>
        public async Task WriteMeasurementsAsync <TM>(string bucket, string org, WritePrecision precision,
                                                      List <TM> measurements)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));
            Arguments.CheckNotNull(precision, nameof(precision));

            var list = new List <BatchWriteData>();

            foreach (var measurement in measurements)
            {
                var options = new BatchWriteOptions(bucket, org, precision);

                BatchWriteData data = new BatchWriteMeasurement <TM>(options, _options, measurement, _measurementMapper);
                list.Add(data);
            }

            await WriteData(org, bucket, precision, list);
        }
Beispiel #2
0
        /// <summary>
        /// Write Measurements into specified bucket.
        /// </summary>
        /// <param name="bucket">specifies the destination bucket for writes</param>
        /// <param name="org">specifies the destination organization for writes</param>
        /// <param name="precision">specifies the precision for the unix timestamps within the body line-protocol</param>
        /// <param name="measurements">specifies Measurements to write into bucket</param>
        /// <param name="cancellationToken">specifies the token to monitor for cancellation requests</param>
        /// <typeparam name="TM">measurement type</typeparam>
        public Task WriteMeasurementsAsync <TM>(string bucket, string org, WritePrecision precision,
                                                List <TM> measurements, CancellationToken cancellationToken = default)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));
            Arguments.CheckNotNull(precision, nameof(precision));

            var list = new List <BatchWriteData>();

            foreach (var measurement in measurements)
            {
                var options = new BatchWriteOptions(bucket, org, precision);

                BatchWriteData data = new BatchWriteMeasurement <TM>(options, _options, measurement, _mapper);
                list.Add(data);
            }

            return(WriteData(org, bucket, precision, list, cancellationToken));
        }