Exemplo n.º 1
0
        /// <summary>
        /// Write a Measurement 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="measurement">specifies the Measurement to write into bucket</param>
        /// <typeparam name="TM">measurement type</typeparam>
        public void WriteMeasurement <TM>(string bucket, string org, WritePrecision precision, TM measurement)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));
            Arguments.CheckNotNull(precision, nameof(precision));

            if (measurement == null)
            {
                return;
            }

            var options = new BatchWriteOptions(bucket, org, precision);

            _subject.OnNext(new BatchWriteMeasurement <TM>(options, _options, measurement, _measurementMapper));
        }
        /// <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);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
 private bool Equals(BatchWriteOptions other)
 {
     return(string.Equals(Bucket, other.Bucket) && string.Equals(OrganizationId, other.OrganizationId) &&
            Precision == other.Precision);
 }
Exemplo n.º 5
0
        internal BatchWriteRecord(BatchWriteOptions options, string record) : base(options)
        {
            Arguments.CheckNotNull(record, nameof(record));

            _record = record;
        }
Exemplo n.º 6
0
        protected BatchWriteData(BatchWriteOptions options)
        {
            Arguments.CheckNotNull(options, "options");

            Options = options;
        }