Skip to content

Latest commit

 

History

History

AsyncAwait

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

AsyncAwait

This is an example how to use async/await with the InfluxDB client.

Prerequisites:

  • Docker
  • Cloned examples:
    git clone [email protected]:influxdata/influxdb-client-swift.git
    cd Examples/AsyncAwait

Sources:

How to test:

  1. Start InfluxDB:
    docker run --rm \
      --name influxdb_v2 \
      --detach \
      --publish 8086:8086 \
      influxdb:latest
  2. Configure your username, password, organization, bucket and token:
    docker run --rm \
       --link influxdb_v2 \
       curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \
          -H 'accept: application/json' \
          -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}'
  3. Start SwiftCLI by:
     docker run --rm \
       --link influxdb_v2 \
       --privileged \
       --interactive \
       --tty \
       --volume $PWD/../..:/client \
       --workdir /client/Examples/AsyncAwait \
       swift:5.7 /bin/bash
  4. Use async/await with WriteAPI, QueryAPI and BucketsAPI:
    swift run async-await --bucket my-bucket --org my-org --token my-token --url http://influxdb_v2:8086

Expected output

Written data:
 > Optional("demo,type=point value=2i")
Query results:
 > value: 2
Buckets:
 > Optional("10c59301e9077c50"): my-bucket
 > Optional("552d1011d2cdab2d"): _tasks
 > Optional("a1a02f67f7189b89"): _monitoring