| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.InfluxDB.Types
Synopsis
- newtype Query = Query Text
- data Server = Server {}
- host :: Lens' Server Text
- port :: Lens' Server Int
- ssl :: Lens' Server Bool
- defaultServer :: Server
- secureServer :: Server
- data Credentials = Credentials {}
- credentials :: Text -> Text -> Credentials
- user :: Lens' Credentials Text
- password :: Lens' Credentials Text
- newtype Database = Database {
- databaseName :: Text
- newtype Measurement = Measurement Text
- newtype Key = Key Text
- identifier :: String -> String -> Text
- data Nullability
- type QueryField = Field Nullable
- type LineField = Field NonNullable
- data Field (n :: Nullability) where
- data RequestType
- data Precision (ty :: RequestType) where
- Nanosecond :: Precision ty
- Microsecond :: Precision ty
- Millisecond :: Precision ty
- Second :: Precision ty
- Minute :: Precision ty
- Hour :: Precision ty
- RFC3339 :: Precision QueryRequest
- precisionName :: Precision ty -> Text
- class Timestamp time where
- roundTo :: Precision WriteRequest -> time -> Int64
- scaleTo :: Precision WriteRequest -> time -> Int64
- roundAt :: RealFrac a => a -> a -> a
- precisionScale :: Fractional a => Precision ty -> a
- timeSpecToSeconds :: TimeSpec -> Double
- data InfluxException
- class HasServer a where
- class HasDatabase a where
- class HasPrecision (ty :: RequestType) a | a -> ty where
- class HasManager a where
- manager :: Lens' a (Either ManagerSettings Manager)
- class HasCredentials a where
- authentication :: Lens' a (Maybe Credentials)
Documentation
>>>:set -XOverloadedStrings>>>import Database.InfluxDB
An InfluxDB query.
A spec of the format is available at https://docs.influxdata.com/influxdb/v1.7/query_language/spec/.
A Query can be constructed using either
- the
IsStringinstance with-XOverloadedStrings - or
formatQuery.
>>>:set -XOverloadedStrings>>>"SELECT * FROM series" :: Query"SELECT * FROM series">>>import qualified Database.InfluxDB.Format as F>>>formatQuery ("SELECT * FROM "%F.key) "series""SELECT * FROM \"series\""
NOTE: Currently this library doesn't support type-safe query construction.
InfluxDB server to connect to.
Following lenses are available to access its fields:
Instances
| Eq Server # | |
| Ord Server # | |
| Show Server # | |
| Generic Server # | |
| type Rep Server # | |
Defined in Database.InfluxDB.Types type Rep Server = D1 (MetaData "Server" "Database.InfluxDB.Types" "influxdb-1.6.1.2-1jjBHSQoxTCJzvJAZNLxB3" False) (C1 (MetaCons "Server" PrefixI True) (S1 (MetaSel (Just "_host") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text) :*: (S1 (MetaSel (Just "_port") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_ssl") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool)))) | |
If SSL is enabled
For secure connections (HTTPS), consider using one of the following packages:
defaultServer :: Server #
Default InfluxDB server settings
Default parameters:
>>>defaultServer ^. host"localhost">>>defaultServer ^. port8086>>>defaultServer ^. sslFalse
secureServer :: Server #
HTTPS-enabled InfluxDB server settings
data Credentials #
Constructors
| Credentials | |
Instances
| Show Credentials # | |
Defined in Database.InfluxDB.Types Methods showsPrec :: Int -> Credentials -> ShowS # show :: Credentials -> String # showList :: [Credentials] -> ShowS # | |
Arguments
| :: Text | User name |
| -> Text | Password |
| -> Credentials |
Smart constructor for Credentials
user :: Lens' Credentials Text #
User name to access InfluxDB.
>>>let creds = credentials "john" "passw0rd">>>creds ^. user"john"
password :: Lens' Credentials Text #
Password to access InfluxDB
>>>let creds = credentials "john" "passw0rd">>>creds ^. password"passw0rd"
Database name.
formatDatabase can be used to construct a
Database.
Constructors
| Database | |
Fields
| |
newtype Measurement #
String name that is used for measurements.
formatMeasurement can be used to construct a
Measurement.
Constructors
| Measurement Text |
Instances
| Eq Measurement # | |
Defined in Database.InfluxDB.Types | |
| Ord Measurement # | |
Defined in Database.InfluxDB.Types Methods compare :: Measurement -> Measurement -> Ordering # (<) :: Measurement -> Measurement -> Bool # (<=) :: Measurement -> Measurement -> Bool # (>) :: Measurement -> Measurement -> Bool # (>=) :: Measurement -> Measurement -> Bool # max :: Measurement -> Measurement -> Measurement # min :: Measurement -> Measurement -> Measurement # | |
| Show Measurement # | |
Defined in Database.InfluxDB.Types Methods showsPrec :: Int -> Measurement -> ShowS # show :: Measurement -> String # showList :: [Measurement] -> ShowS # | |
| IsString Measurement # | |
Defined in Database.InfluxDB.Types Methods fromString :: String -> Measurement # | |
String type that is used for tag keys/values and field keys.
identifier :: String -> String -> Text #
data Nullability #
Nullability of fields.
Queries can contain nulls but the line protocol cannot.
Constructors
| Nullable | |
| NonNullable |
type QueryField = Field Nullable #
Field type for queries. Queries can contain null values.
type LineField = Field NonNullable #
Field type for the line protocol. The line protocol doesn't accept null values.
data Field (n :: Nullability) where #
Constructors
| FieldInt :: !Int64 -> Field n | Signed 64-bit integers ( |
| FieldFloat :: !Double -> Field n | IEEE-754 64-bit floating-point numbers. This is the default numerical type. |
| FieldString :: !Text -> Field n | String field. Its length is limited to 64KB, which is not enforced by this library. |
| FieldBool :: !Bool -> Field n | Boolean field. |
| FieldNull :: Field Nullable | Null field. Note that a field can be null only in queries. The line protocol doesn't allow null values. |
data RequestType #
Type of a request
Constructors
| QueryRequest | Request for |
| WriteRequest | Request for |
Instances
| Show RequestType # | |
Defined in Database.InfluxDB.Types Methods showsPrec :: Int -> RequestType -> ShowS # show :: RequestType -> String # showList :: [RequestType] -> ShowS # | |
data Precision (ty :: RequestType) where #
Predefined set of time precision.
RFC3339 is only available for QueryRequests.
Constructors
| Nanosecond :: Precision ty | POSIX time in ns |
| Microsecond :: Precision ty | POSIX time in μs |
| Millisecond :: Precision ty | POSIX time in ms |
| Second :: Precision ty | POSIX time in s |
| Minute :: Precision ty | POSIX time in minutes |
| Hour :: Precision ty | POSIX time in hours |
| RFC3339 :: Precision QueryRequest | Nanosecond precision time in a human readable format, like
|
precisionName :: Precision ty -> Text #
Name of the time precision.
>>>precisionName Nanosecond"n">>>precisionName Microsecond"u">>>precisionName Millisecond"ms">>>precisionName Second"s">>>precisionName Minute"m">>>precisionName Hour"h">>>precisionName RFC3339"rfc3339"
A Timestamp is something that can be converted to a valid
InfluxDB timestamp, which is represented as a 64-bit integer.
Methods
roundTo :: Precision WriteRequest -> time -> Int64 #
Round a time to the given precision and scale it to nanoseconds
scaleTo :: Precision WriteRequest -> time -> Int64 #
Scale a time to the given precision
Instances
| Timestamp UTCTime # |
|
Defined in Database.InfluxDB.Types | |
| Timestamp TimeSpec # |
|
Defined in Database.InfluxDB.Types | |
| Timestamp NominalDiffTime # |
|
Defined in Database.InfluxDB.Types Methods roundTo :: Precision WriteRequest -> NominalDiffTime -> Int64 # scaleTo :: Precision WriteRequest -> NominalDiffTime -> Int64 # | |
precisionScale :: Fractional a => Precision ty -> a #
Scale of the type precision.
>>>precisionScale RFC33391.0e-9>>>precisionScale Microsecond1.0e-6
timeSpecToSeconds :: TimeSpec -> Double #
data InfluxException #
Exceptions used in this library.
In general, the library tries to convert exceptions from the dependent libraries to the following types of errors.
Constructors
| ServerError String | Server side error. You can expect to get a successful response once the issue is resolved on the server side. |
| ClientError String Request | Client side error. You need to fix your query to get a successful response. |
| UnexpectedResponse String Request ByteString | Received an unexpected response. The This can happen e.g. when the response from InfluxDB is incompatible with what this library expects due to an upstream format change or when the JSON response doesn't have expected fields etc. |
| HTTPException HttpException | HTTP communication error. Typical HTTP errors (4xx and 5xx) are covered by |
Instances
| Show InfluxException # | |
Defined in Database.InfluxDB.Types Methods showsPrec :: Int -> InfluxException -> ShowS # show :: InfluxException -> String # showList :: [InfluxException] -> ShowS # | |
| Exception InfluxException # | |
Defined in Database.InfluxDB.Types Methods toException :: InfluxException -> SomeException # | |
Class of data types that have a server field
Instances
| HasServer PingParams # |
|
Defined in Database.InfluxDB.Ping Methods server :: Lens' PingParams Server # | |
| HasServer QueryParams # |
|
Defined in Database.InfluxDB.Query Methods | |
| HasServer WriteParams # |
|
Defined in Database.InfluxDB.Write Methods | |
class HasDatabase a where #
Class of data types that have a database field
Instances
| HasDatabase QueryParams # |
|
Defined in Database.InfluxDB.Query Methods | |
| HasDatabase ShowQuery # |
|
| HasDatabase WriteParams # |
|
Defined in Database.InfluxDB.Write Methods | |
class HasPrecision (ty :: RequestType) a | a -> ty where #
Class of data types that have a precision field
Instances
| HasPrecision QueryRequest QueryParams # | Returning JSON responses contain timestamps in the specified precision/format.
|
Defined in Database.InfluxDB.Query Methods | |
| HasPrecision WriteRequest WriteParams # |
|
Defined in Database.InfluxDB.Write Methods | |
| HasPrecision WriteRequest WriteParams # | Timestamp precision. In the UDP API, all timestamps are sent in nanosecond but you can specify lower precision. The writer just rounds timestamps to the specified precision. |
Defined in Database.InfluxDB.Write.UDP Methods | |
class HasManager a where #
Class of data types that have a manager field
Methods
manager :: Lens' a (Either ManagerSettings Manager) #
HTTP manager settings or a manager itself.
If it's set to ManagerSettings, the library will create a Manager from
the settings for you.
Instances
| HasManager PingParams # |
|
Defined in Database.InfluxDB.Ping Methods manager :: Lens' PingParams (Either ManagerSettings Manager) # | |
| HasManager QueryParams # |
|
Defined in Database.InfluxDB.Query Methods manager :: Lens' QueryParams (Either ManagerSettings Manager) # | |
| HasManager WriteParams # |
|
Defined in Database.InfluxDB.Write Methods manager :: Lens' WriteParams (Either ManagerSettings Manager) # | |
class HasCredentials a where #
Class of data types that has an authentication field
Methods
authentication :: Lens' a (Maybe Credentials) #
User name and password to be used when sending requests to InfluxDB.
Instances
| HasCredentials QueryParams # | Authentication info for the query
|
Defined in Database.InfluxDB.Query Methods | |
| HasCredentials WriteParams # | Authentication info for the write
|
Defined in Database.InfluxDB.Write Methods | |