Class: InfluxDB::Client
- Inherits:
-
Object
- Object
- InfluxDB::Client
- Includes:
- HTTP, Logging, Query::Cluster, Query::ContinuousQuery, Query::Core, Query::Database, Query::RetentionPolicy, Query::Series, Query::User
- Defined in:
- lib/influxdb/client.rb
Overview
InfluxDB client class
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(database = nil, **opts) ⇒ Client
constructor
Initializes a new InfluxDB client.
- #stop! ⇒ Object
- #stopped? ⇒ Boolean
Methods included from Query::Series
Methods included from Query::RetentionPolicy
#alter_retention_policy, #create_retention_policy, #delete_retention_policy, #list_retention_policies
Methods included from Query::ContinuousQuery
#create_continuous_query, #delete_continuous_query, #list_continuous_queries
Methods included from Query::User
#create_database_user, #delete_user, #grant_user_admin_privileges, #grant_user_privileges, #list_user_grants, #list_users, #revoke_user_privileges, #update_user_password
Methods included from Query::Database
#create_database, #delete_database, #list_databases, #show_field_keys
Methods included from Query::Cluster
#create_cluster_admin, #list_cluster_admins, #revoke_cluster_admin_privileges
Methods included from Query::Core
#builder, #ping, #query, #version, #write, #write_point, #write_points
Methods included from HTTP
Methods included from Logging
Constructor Details
#initialize(database = nil, **opts) ⇒ Client
Initializes a new InfluxDB client
Examples:
# connect to localhost using root/root
# as the credentials and doesn't connect to a db
InfluxDB::Client.new
# connect to localhost using root/root
# as the credentials and 'db' as the db name
InfluxDB::Client.new 'db'
# override username, other defaults remain unchanged
InfluxDB::Client.new username: 'username'
# override username, use 'db' as the db name
Influxdb::Client.new 'db', username: 'username'
Valid options in hash
:host
-
the hostname to connect to
:port
-
the port to connect to
:prefix
-
the specified path prefix when building the url e.g.: /prefix/db/dbname…
:username
-
the username to use when executing commands
:password
-
the password associated with the username
:use_ssl
-
use ssl to connect
:verify_ssl
-
verify ssl server certificate?
:ssl_ca_cert
-
ssl CA certificate, chainfile or CA path. The system CA path is automatically included
- +:retry
-
number of times a failed request should be retried. Defaults to infinite.
51 52 53 54 55 56 57 58 |
# File 'lib/influxdb/client.rb', line 51 def initialize(database = nil, **opts) opts[:database] = database if database.is_a? String @config = InfluxDB::Config.new(opts) @stopped = false @writer = find_writer at_exit { stop! } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/influxdb/client.rb', line 6 def config @config end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
6 7 8 |
# File 'lib/influxdb/client.rb', line 6 def writer @writer end |
Instance Method Details
#stop! ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/influxdb/client.rb', line 60 def stop! if config.async? # If retry was infinite (-1), set it to zero to give the main thread one # last chance to flush the queue config.retry = 0 if config.retry < 0 writer.worker.stop! end @stopped = true end |
#stopped? ⇒ Boolean
70 71 72 |
# File 'lib/influxdb/client.rb', line 70 def stopped? @stopped end |