Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Precision #42

Merged
merged 8 commits into from
Sep 5, 2017
Merged

Precision #42

merged 8 commits into from
Sep 5, 2017

Conversation

gambrose
Copy link
Contributor

@gambrose gambrose commented Sep 3, 2017

Allows writing LineProtocol using timestamps at a precision other than nanoseconds.

Precision to use is set when creating the LineProtocolWriter as I needs to be consistent for the whole batch. The client will set the precision parameter when asked to send a batch with precision set to something other than nanoseconds.

By default if given a timestamp at a higher precision that write setup to write (e.g. with seconds defined when writing hours) an error will be thrown. This behavior can be configured when creating the writer and overridden when writing each individual point.
Instead of erroring the writer can be setup to floor, ceiling or round the timestamp.

Copy link
Contributor

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍


position = LinePosition.TimestampWritten;
}

public void Timestamp(TimeSpan value)
public void Timestamp(TimeSpan value, PrecisionResolutionStrategy? resolutionStrategy = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ones will be binary breaking changes - not a big deal, but we should either:

  • add overloads instead of default args, or
  • bump the major version to 2.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking it wasn't a breaking change as the new param is optional but on further investigation it appears it would be a breaking change as although it would work if recompiled it would break if ref updated without recompiling.

I will add overloads.

@@ -36,20 +36,39 @@ public Task<LineProtocolWriteResult> WriteAsync(LineProtocolPayload payload, Can

payload.Format(writer);

return SendAsync(writer.ToString(), cancellationToken);
return SendAsync(writer.ToString(), Precision.Nanoseconds, cancellationToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, here we've got a variable writer that's a StringWriter, below we are using LineProtocolWriter writer ... my eyes keep wanting to see some symmetry that's not there :-) ... Could we rename this one stringWriter or something similar just to break the similarity?

@nblumhardt
Copy link
Contributor

👍 ready to go, @gambrose ?

@gambrose
Copy link
Contributor Author

gambrose commented Sep 4, 2017

Yeah I think it's good to go.

@nblumhardt nblumhardt merged commit a69b180 into influxdata:dev Sep 5, 2017
@nblumhardt
Copy link
Contributor

👍

This was referenced Feb 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy