Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Query = Query Text
- data Server = Server {}
- defaultServer :: Server
- host :: Lens' Server Text
- port :: Lens' Server Int
- ssl :: Lens' Server Bool
- 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
- 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
- class HasCredentials a where
Documentation
>>>
:set -XOverloadedStrings
>>>
import Database.InfluxDB
An InfluxDB query.
A spec of the format is available at https://docs.influxdata.com/influxdb/v1.5/query_language/spec/.
A Query
can be constructed using either
- the
IsString
instance 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.
Instances
Eq Server Source # | |
Ord Server Source # | |
Show Server Source # | |
Generic Server Source # | |
type Rep Server Source # | |
Defined in Database.InfluxDB.Types type Rep Server = D1 (MetaData "Server" "Database.InfluxDB.Types" "influxdb-1.6.0.7-JQhSEyKMeUhLPmcsxdxKP5" 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)))) |
data Credentials Source #
User credentials
Instances
Show Credentials Source # | |
Defined in Database.InfluxDB.Types showsPrec :: Int -> Credentials -> ShowS # show :: Credentials -> String # showList :: [Credentials] -> ShowS # |
:: Text | User name |
-> Text | Password |
-> Credentials |
user :: Lens' Credentials Text Source #
User name to access InfluxDB.
>>>
let creds = credentials "john" "passw0rd"
>>>
creds ^. user
"john"
Database name.
formatDatabase
can be used to construct a
Database
.
newtype Measurement Source #
String name that is used for measurements.
formatMeasurement
can be used to construct a
Measurement
.
Instances
Eq Measurement Source # | |
Defined in Database.InfluxDB.Types (==) :: Measurement -> Measurement -> Bool # (/=) :: Measurement -> Measurement -> Bool # | |
Ord Measurement Source # | |
Defined in Database.InfluxDB.Types 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 Source # | |
Defined in Database.InfluxDB.Types showsPrec :: Int -> Measurement -> ShowS # show :: Measurement -> String # showList :: [Measurement] -> ShowS # | |
IsString Measurement Source # | |
Defined in Database.InfluxDB.Types fromString :: String -> Measurement # |
String type that is used for tag keys/values and field keys.
type QueryField = Field Nullable Source #
Field type for queries. Queries can contain null values.
type LineField = Field NonNullable Source #
Field type for the line protocol. The line protocol doesn't accept null values.
data Field (n :: Nullability) where Source #
FieldInt :: !Int64 -> Field n | |
FieldFloat :: !Double -> Field n | |
FieldString :: !Text -> Field n | |
FieldBool :: !Bool -> Field n | |
FieldNull :: Field Nullable |
data RequestType Source #
Type of a request
QueryRequest | Request for |
WriteRequest | Request for |
Instances
Show RequestType Source # | |
Defined in Database.InfluxDB.Types showsPrec :: Int -> RequestType -> ShowS # show :: RequestType -> String # showList :: [RequestType] -> ShowS # |
data Precision (ty :: RequestType) where Source #
Predefined set of time precision.
RFC3339
is only available for QueryRequest
s.
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 Source #
Name of the time precision.
>>>
precisionName Nanosecond
"n"
class Timestamp time where Source #
A Timestamp
is something that can be converted to a valid
InfluxDB timestamp, which is represented as a 64-bit integer.
roundTo :: Precision WriteRequest -> time -> Int64 Source #
Round a time to the given precision and scale it to nanoseconds
scaleTo :: Precision WriteRequest -> time -> Int64 Source #
Scale a time to the given precision
Instances
Timestamp UTCTime Source # |
|
Defined in Database.InfluxDB.Types | |
Timestamp TimeSpec Source # |
|
Defined in Database.InfluxDB.Types | |
Timestamp NominalDiffTime Source # |
|
Defined in Database.InfluxDB.Types roundTo :: Precision WriteRequest -> NominalDiffTime -> Int64 Source # scaleTo :: Precision WriteRequest -> NominalDiffTime -> Int64 Source # |
precisionScale :: Fractional a => Precision ty -> a Source #
Scale of the type precision.
>>>
precisionScale RFC3339
1.0e-9>>>
precisionScale Microsecond
1.0e-6
timeSpecToSeconds :: TimeSpec -> Double Source #
data InfluxException Source #
Exceptions used in this library.
In general, the library tries to convert exceptions from the dependent libraries to the following types of errors.
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 Source # | |
Defined in Database.InfluxDB.Types showsPrec :: Int -> InfluxException -> ShowS # show :: InfluxException -> String # showList :: [InfluxException] -> ShowS # | |
Exception InfluxException Source # | |
Defined in Database.InfluxDB.Types |
class HasServer a where Source #
Instances
HasServer PingParams Source # |
|
Defined in Database.InfluxDB.Ping | |
HasServer QueryParams Source # |
|
Defined in Database.InfluxDB.Query | |
HasServer WriteParams Source # |
|
Defined in Database.InfluxDB.Write |
class HasDatabase a where Source #
Instances
HasDatabase QueryParams Source # |
|
Defined in Database.InfluxDB.Query | |
HasDatabase ShowQuery Source # |
|
HasDatabase WriteParams Source # |
|
Defined in Database.InfluxDB.Write |
class HasPrecision (ty :: RequestType) a | a -> ty where Source #
Instances
HasPrecision QueryRequest QueryParams Source # | Returning JSON responses contain timestamps in the specified precision/format.
|
Defined in Database.InfluxDB.Query | |
HasPrecision WriteRequest WriteParams Source # |
|
Defined in Database.InfluxDB.Write | |
HasPrecision WriteRequest WriteParams Source # | 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 |
class HasManager a where Source #
manager :: Lens' a (Either ManagerSettings Manager) Source #
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 Source # |
|
Defined in Database.InfluxDB.Ping | |
HasManager QueryParams Source # |
|
Defined in Database.InfluxDB.Query | |
HasManager WriteParams Source # |
|
Defined in Database.InfluxDB.Write |
class HasCredentials a where Source #
authentication :: Lens' a (Maybe Credentials) Source #
User name and password to be used when sending requests to InfluxDB.
Instances
HasCredentials QueryParams Source # | Authentication info for the query
|
Defined in Database.InfluxDB.Query | |
HasCredentials WriteParams Source # | Authentication info for the write
|
Defined in Database.InfluxDB.Write |