docs(clientLibs): updated Swift examples to reflect actual version of client (#20824)
* docs(clientLibs): update version of JVM clientspull/20890/head
parent
e86ee475b2
commit
2931100576
|
@ -8,7 +8,7 @@ Build with Maven
|
|||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-java</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -16,7 +16,7 @@ Build with Gradle
|
|||
|
||||
```
|
||||
dependencies {
|
||||
compile "com.influxdb:influxdb-client-java:1.8.0"
|
||||
compile "com.influxdb:influxdb-client-java:2.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Build with Maven
|
|||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-kotlin</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -16,7 +16,7 @@ Build with Gradle
|
|||
|
||||
```
|
||||
dependencies {
|
||||
compile "com.influxdb:influxdb-client-kotlin:1.8.0"
|
||||
compile "com.influxdb:influxdb-client-kotlin:2.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ For more detailed and up to date information check out the [GitHub Repository](h
|
|||
Build with sbt
|
||||
|
||||
```
|
||||
libraryDependencies += "com.influxdb" % "influxdb-client-scala" % "1.8.0"
|
||||
libraryDependencies += "com.influxdb" % "influxdb-client-scala" % "2.0.0"
|
||||
```
|
||||
|
||||
Build with Maven
|
||||
|
@ -14,7 +14,7 @@ Build with Maven
|
|||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-scala</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -22,7 +22,7 @@ Build with Gradle
|
|||
|
||||
```
|
||||
dependencies {
|
||||
compile "com.influxdb:influxdb-client-scala:1.8.0"
|
||||
compile "com.influxdb:influxdb-client-scala:2.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import PackageDescription
|
|||
let package = Package(
|
||||
name: "MyPackage",
|
||||
dependencies: [
|
||||
.package(name: "influxdb-client-swift", url: "https://github.com/influxdata/influxdb-client-swift", from: "0.1.0"),
|
||||
.package(name: "influxdb-client-swift", url: "https://github.com/influxdata/influxdb-client-swift", from: "0.2.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "MyModule", dependencies: [
|
||||
|
@ -47,29 +47,8 @@ client.close()
|
|||
// Record defined as String
|
||||
//
|
||||
let recordString = "demo,type=string value=1i"
|
||||
//
|
||||
// Record defined as Data Point
|
||||
//
|
||||
let recordPoint = InfluxDBClient
|
||||
.Point("demo")
|
||||
.addTag(key: "type", value: "point")
|
||||
.addField(key: "value", value: 2)
|
||||
//
|
||||
// Record defined as Data Point with Timestamp
|
||||
//
|
||||
let recordPointDate = InfluxDBClient
|
||||
.Point("demo")
|
||||
.addTag(key: "type", value: "point-timestamp")
|
||||
.addField(key: "value", value: 2)
|
||||
.time(time: Date())
|
||||
//
|
||||
// Record defined as Tuple
|
||||
//
|
||||
let recordTuple = (measurement: "demo", tags: ["type": "tuple"], fields: ["value": 3])
|
||||
|
||||
let records: [Any] = [recordString, recordPoint, recordPointDate, recordTuple]
|
||||
|
||||
client.getWriteAPI().writeRecords(records: records) { result, error in
|
||||
client.makeWriteAPI().write(record: recordString) { result, error in
|
||||
// For handle error
|
||||
if let error = error {
|
||||
print("Error:\n\n\(error)")
|
||||
|
@ -77,7 +56,53 @@ client.getWriteAPI().writeRecords(records: records) { result, error in
|
|||
|
||||
// For Success write
|
||||
if result != nil {
|
||||
print("Successfully written data:\n\n\(records)")
|
||||
print("Successfully written data:\n\n\(recordString)")
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Record defined as Data Point
|
||||
//
|
||||
let recordPoint = InfluxDBClient
|
||||
.Point("demo")
|
||||
.addTag(key: "type", value: "point")
|
||||
.addField(key: "value", value: .int(2))
|
||||
//
|
||||
// Record defined as Data Point with Timestamp
|
||||
//
|
||||
let recordPointDate = InfluxDBClient
|
||||
.Point("demo")
|
||||
.addTag(key: "type", value: "point-timestamp")
|
||||
.addField(key: "value", value: .int(2))
|
||||
.time(time: .date(Date()))
|
||||
|
||||
client.makeWriteAPI().write(points: [recordPoint, recordPointDate]) { result, error in
|
||||
// For handle error
|
||||
if let error = error {
|
||||
print("Error:\n\n\(error)")
|
||||
}
|
||||
|
||||
// For Success write
|
||||
if result != nil {
|
||||
print("Successfully written data:\n\n\([recordPoint, recordPointDate])")
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Record defined as Tuple
|
||||
//
|
||||
let recordTuple: InfluxDBClient.Point.Tuple
|
||||
= (measurement: "demo", tags: ["type": "tuple"], fields: ["value": .int(3)], time: nil)
|
||||
|
||||
client.makeWriteAPI().write(tuple: recordTuple) { result, error in
|
||||
// For handle error
|
||||
if let error = error {
|
||||
print("Error:\n\n\(error)")
|
||||
}
|
||||
|
||||
// For Success write
|
||||
if result != nil {
|
||||
print("Successfully written data:\n\n\(recordTuple)")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue