influxdb-client-swift icon indicating copy to clipboard operation
influxdb-client-swift copied to clipboard

feat: updated Point to be a sendable struct

Open CraigSiemens opened this issue 11 months ago • 4 comments

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

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

CraigSiemens avatar Jan 13 '25 04:01 CraigSiemens

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?

CraigSiemens avatar Jan 14 '25 03:01 CraigSiemens

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.

bednar avatar Jan 14 '25 04:01 bednar

@bednar Could you re-review this PR and possibly give some insight on why the checks are failing?

check-documentation appears to be failing due to the swift version now being 5.7. It looks like the latest version in https://github.com/norio-nomura/docker-jazzy is 5.3.3 so I'm not sure how to support a newer version of swift.

test-macOS is failing when running starting InfluxDB with the following error.

./influxdb/influxd: Bad CPU type in executable

Googling suggests the binary may be incompatible with the runner, though I ran the same steps on my M1 Mac and influxdb started with no issues.

CraigSiemens avatar Feb 12 '25 16:02 CraigSiemens

Thanks, your PR looks good, and I’m okay with it. Our team will look into fixing the CI, and after that, we’ll be able to merge this PR.

bednar avatar Feb 13 '25 07:02 bednar