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

fix: memory leaks #64

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ junit.xml
tests.xml

Scripts/*.yml
Scripts/influxdb-clients-apigen/
Scripts/influxdb-clients-apigen/
.DS_Store
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.7.0 [unreleased]

### Bug Fixes
1. [#63](https://github.com/influxdata/influxdb-client-swift/pull/64): Remove reference cycle

### CI
1. [#55](https://github.com/influxdata/influxdb-client-swift/pull/55): Use Swift 5.8, 5.9 and 5.10 in CI and update XCode to 15.3.0

Expand Down
2 changes: 1 addition & 1 deletion Scripts/templates/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension {{projectName}}API {

{{#description}}
/** {{description}} */{{/description}}
{{#objcCompatible}}@objc {{/objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}{{#objcCompatible}} : NSObject{{/objcCompatible}} {
{{#objcCompatible}}@objc {{/objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{^objcCompatible}}struct {{classname}}{{/objcCompatible}}{{#objcCompatible}}class {{classname}} : NSObject{{/objcCompatible}} {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MobileCoreServices
#endif
import InfluxDBSwift

class URLSessionRequestBuilderFactory: RequestBuilderFactory {
final class URLSessionRequestBuilderFactory: RequestBuilderFactory {
func getRequestNonDecodableBuilder<T>(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:], influxDB2API: InfluxDB2API) -> RequestBuilder<T> {
URLSessionRequestBuilder<T>(method: method, URLString: URLString, parameters: parameters, isBody: isBody, influxDB2API: influxDB2API)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwift/DeleteAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import FoundationNetworking
///
/// print("Successfully data data by:\n\n\(predicateRequest)")
/// ````
public class DeleteAPI {
public struct DeleteAPI {
/// Shared client.
private let client: InfluxDBClient

Expand Down
34 changes: 17 additions & 17 deletions Sources/InfluxDBSwift/InfluxDBClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import FoundationNetworking
///
/// client.close()
/// ````
public class InfluxDBClient {
public struct InfluxDBClient {
/// Version of client.
public static var version: String = "1.7.0dev"
/// InfluxDB host and port.
Expand All @@ -36,20 +36,20 @@ public class InfluxDBClient {
/// Shared URLSession across the client.
public let session: URLSession

/// Lazy initialized `QueryAPI`.
public lazy var queryAPI: QueryAPI = {
/// `QueryAPI`.
public var queryAPI: QueryAPI {
QueryAPI(client: self)
}()
}

/// Lazy initialized `DeleteAPI`.
public lazy var deleteAPI: DeleteAPI = {
/// `DeleteAPI`.
public var deleteAPI: DeleteAPI {
DeleteAPI(client: self)
}()
}

/// Lazy initialized `InvokableScriptsApi`.
public lazy var invokableScriptsApi: InvokableScriptsAPI = {
/// `InvokableScriptsApi`.
public var invokableScriptsApi: InvokableScriptsAPI {
InvokableScriptsAPI(client: self)
}()
}

/// Create a new client for a InfluxDB.
///
Expand Down Expand Up @@ -102,13 +102,13 @@ public class InfluxDBClient {
/// - protocolClasses: optional array of extra protocol subclasses that handle requests.
///
/// - SeeAlso: https://docs.influxdata.com/influxdb/v1.8/tools/api/#influxdb-2-0-api-compatibility-endpoints
public convenience init(url: String,
username: String,
password: String,
database: String,
retentionPolicy: String,
precision: TimestampPrecision = TimestampPrecision.ns,
protocolClasses: [AnyClass]? = nil) {
public init(url: String,
username: String,
password: String,
database: String,
retentionPolicy: String,
precision: TimestampPrecision = TimestampPrecision.ns,
protocolClasses: [AnyClass]? = nil) {
let options = InfluxDBOptions(bucket: "\(database)/\(retentionPolicy)", precision: precision)

self.init(url: url, token: "\(username):\(password)", options: options, protocolClasses: protocolClasses)
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwift/InvokableScriptsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
///
/// API invokable scripts let you assign scripts to API endpoints and then execute them
/// as standard REST operations in InfluxDB Cloud.
public class InvokableScriptsAPI {
public struct InvokableScriptsAPI {
/// Shared client.
private let client: InfluxDBClient

Expand Down
9 changes: 7 additions & 2 deletions Sources/InfluxDBSwift/Point.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ extension InfluxDBClient {
/// .addDefaultTag(key: "customer", value: "California Miner")
/// .addDefaultTag(key: "data_center", value: "${env.DATA_CENTER_LOCATION}")
/// ````
public class PointSettings {
public struct PointSettings {
// Default tags which will be added to each point written by api.
var tags: [String: String?] = [:]

/// Create a new PointSettings.
public init() {}

/// Add new default tag with key and value.
///
/// - Parameters:
Expand All @@ -107,7 +110,9 @@ extension InfluxDBClient {
/// - Returns: Self
public func addDefaultTag(key: String?, value: String?) -> PointSettings {
if let key = key {
tags[key] = value
var result = self
result.tags[key] = value
return result
}
return self
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwift/QueryAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Gzip
///
/// client.close()
/// ````
public class QueryAPI {
public struct QueryAPI {
/// The default Query Dialect with annotation = ["datatype", "group", "default"]
public static let defaultDialect = Dialect(annotations:
[
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwift/WriteAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import Gzip
/// print("Successfully written data:\n\n\(recordTuple)")
///
/// ````
public class WriteAPI {
public struct WriteAPI {
/// Shared client.
private let client: InfluxDBClient
/// Settings for DataPoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class AuthorizationsAPI {
public struct AuthorizationsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/BucketsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class BucketsAPI {
public struct BucketsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/DBRPsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class DBRPsAPI {
public struct DBRPsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/HealthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class HealthAPI {
public struct HealthAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/LabelsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class LabelsAPI {
public struct LabelsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class OrganizationsAPI {
public struct OrganizationsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/PingAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class PingAPI {
public struct PingAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/ReadyAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class ReadyAPI {
public struct ReadyAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class ScraperTargetsAPI {
public struct ScraperTargetsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/SecretsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class SecretsAPI {
public struct SecretsAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/SetupAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class SetupAPI {
public struct SetupAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/SourcesAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class SourcesAPI {
public struct SourcesAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/TasksAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class TasksAPI {
public struct TasksAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/InfluxDBSwiftApis/Generated/APIs/UsersAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class UsersAPI {
public struct UsersAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InfluxDBSwift
extension InfluxDB2API {


public class VariablesAPI {
public struct VariablesAPI {
private let influxDB2API: InfluxDB2API

public init(influxDB2API: InfluxDB2API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MobileCoreServices
#endif
import InfluxDBSwift

class URLSessionRequestBuilderFactory: RequestBuilderFactory {
final class URLSessionRequestBuilderFactory: RequestBuilderFactory {
func getRequestNonDecodableBuilder<T>(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:], influxDB2API: InfluxDB2API) -> RequestBuilder<T> {
URLSessionRequestBuilder<T>(method: method, URLString: URLString, parameters: parameters, isBody: isBody, influxDB2API: influxDB2API)
}
Expand Down
32 changes: 16 additions & 16 deletions Sources/InfluxDBSwiftApis/InfluxDB2API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import InfluxDBSwift
///
/// client.close()
/// ````
public class InfluxDB2API {
public struct InfluxDB2API {
internal let client: InfluxDBClient
internal let basePath: String
internal let requestBuilderFactory: RequestBuilderFactory
Expand All @@ -39,49 +39,49 @@ public class InfluxDB2API {
}

/// Lazy initialized `AuthorizationsAPI`.
public lazy var authorizationsAPI: AuthorizationsAPI = { AuthorizationsAPI(influxDB2API: self) }()
public var authorizationsAPI: AuthorizationsAPI { AuthorizationsAPI(influxDB2API: self) }

/// Lazy initialized `BucketsAPI`.
public lazy var bucketsAPI: BucketsAPI = { BucketsAPI(influxDB2API: self) }()
public var bucketsAPI: BucketsAPI { BucketsAPI(influxDB2API: self) }

/// Lazy initialized `DBRPsAPI`.
public lazy var dbrpsAPI: DBRPsAPI = { DBRPsAPI(influxDB2API: self) }()
public var dbrpsAPI: DBRPsAPI { DBRPsAPI(influxDB2API: self) }

/// Lazy initialized `HealthAPI`.
public lazy var healthAPI: HealthAPI = { HealthAPI(influxDB2API: self) }()
public var healthAPI: HealthAPI { HealthAPI(influxDB2API: self) }

/// Lazy initialized `PingAPI`.
public lazy var pingAPI: PingAPI = { PingAPI(influxDB2API: self) }()
public var pingAPI: PingAPI { PingAPI(influxDB2API: self) }

/// Lazy initialized `LabelsAPI`.
public lazy var labelsAPI: LabelsAPI = { LabelsAPI(influxDB2API: self) }()
public var labelsAPI: LabelsAPI { LabelsAPI(influxDB2API: self) }

/// Lazy initialized `OrganizationsAPI`.
public lazy var organizationsAPI: OrganizationsAPI = { OrganizationsAPI(influxDB2API: self) }()
public var organizationsAPI: OrganizationsAPI { OrganizationsAPI(influxDB2API: self) }

/// Lazy initialized `ReadyAPI`.
public lazy var readyAPI: ReadyAPI = { ReadyAPI(influxDB2API: self) }()
public var readyAPI: ReadyAPI { ReadyAPI(influxDB2API: self) }

/// Lazy initialized `ScraperTargetsAPI`.
public lazy var scraperTargetsAPI: ScraperTargetsAPI = { ScraperTargetsAPI(influxDB2API: self) }()
public var scraperTargetsAPI: ScraperTargetsAPI { ScraperTargetsAPI(influxDB2API: self) }

/// Lazy initialized `SecretsAPI`.
public lazy var secretsAPI: SecretsAPI = { SecretsAPI(influxDB2API: self) }()
public var secretsAPI: SecretsAPI { SecretsAPI(influxDB2API: self) }

/// Lazy initialized `SetupAPI`.
public lazy var setupAPI: SetupAPI = { SetupAPI(influxDB2API: self) }()
public var setupAPI: SetupAPI { SetupAPI(influxDB2API: self) }

/// Lazy initialized `SourcesAPI`.
public lazy var sourcesAPI: SourcesAPI = { SourcesAPI(influxDB2API: self) }()
public var sourcesAPI: SourcesAPI { SourcesAPI(influxDB2API: self) }

/// Lazy initialized `TasksAPI`.
public lazy var tasksAPI: TasksAPI = { TasksAPI(influxDB2API: self) }()
public var tasksAPI: TasksAPI { TasksAPI(influxDB2API: self) }

/// Lazy initialized `UsersAPI`.
public lazy var usersAPI: UsersAPI = { UsersAPI(influxDB2API: self) }()
public var usersAPI: UsersAPI { UsersAPI(influxDB2API: self) }

/// Lazy initialized `VariablesAPI`.
public lazy var variablesAPI: VariablesAPI = { VariablesAPI(influxDB2API: self) }()
public var variablesAPI: VariablesAPI { VariablesAPI(influxDB2API: self) }

/// Create a new managements client for a InfluxDB.
///
Expand Down