Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Point to be a sendable struct #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CraigSiemens
Copy link

@CraigSiemens CraigSiemens commented Jan 13, 2025

Closes #69, closes #70

Proposed Changes

Updated Point to be a sendable struct.

Deprecated addTag(key:value:), addField(key:value:), and time(time:) in favor of using the mutable properties.

Added mutating versions of addTag(key:value:), addField(key:value:), and time(time:) for use when the result is discarded. This is to try and minimize the number of complication errors introduced with this change. The following warnings will be produced in the following use cases.

Calling init and mutating functions in the same statement

let point = InfluxDBClient.Point("p")
    .addTag(key: "t1", value: "a")
    .addTag(key: "t2", value: "b")
     `- warning: 'point.addTag(key:value:)' is deprecated: Pass tags to Point.init or use the tags property

Calling init and mutating functions in separate statements

let point = InfluxDBClient.Point("p")

point
    .addTag(key: "t1", value: "a")
     `- warning: 'change()' is deprecated: Pass tags to Point.init or use the tags property
    .addTag(key: "t2", value: "b")
     `- warning: 'point.addTag(key:value:)' is deprecated: Pass tags to Point.init or use the tags property
     `- warning: result of call to 'change()' is unused

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • swift test completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

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

Hi @CraigSiemens, thanks for your PR.

I am fully OK with your changes. However, since this is a breaking change, please update the client version in Sources/InfluxDBSwift/InfluxDBClient.swift to 2.0.0. Additionally, please extend the description in the CHANGELOG.md with information about how the API has changed and the benefits of these changes. Once that’s done, we can proceed to quickly merge your PR.

Best Regards

Deprecated addTag(key:value:), addField(key:value:), and time(time:) in favor of using the mutable properties.

BREAKING CHANGE: Point is now a value type which can cause breaking behaviour in code expecting the behaviour of a reference type.
BREAKING CHANGE: addTag(key:value:), addField(key:value:), and time(time:) have mutating versions when called and the result is discarded.
BREAKING CHANGE: Minimum swift version is now 5.7
@CraigSiemens
Copy link
Author

I've added the changed requested. I also updated the minimum swift version to 5.7 since that's the version that added the Sendable protocol.

I also noticed the readme and examples are now going to be outdated. Is that something that should be updated in this PR too?

@bednar
Copy link
Contributor

bednar commented Jan 14, 2025

I've added the changed requested. I also updated the minimum swift version to 5.7 since that's the version that added the Sendable protocol.

I also noticed the readme and examples are now going to be outdated. Is that something that should be updated in this PR too?

Yes, we need to ensure the examples and README are aligned with the ‘current’ API, so please update those as well.

Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

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

Please update README and examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved usability of InfluxDBClient.Point if it was a struct Update InfluxDBClient.Point to be Sendable
2 participants