Safe Haskell | None |
---|
- data Series = Series {
- seriesName :: !Text
- seriesData :: !SeriesData
- seriesColumns :: Series -> Vector Column
- seriesPoints :: Series -> DList (Vector Value)
- data SeriesData = SeriesData {}
- data Value
- class ToSeriesData a where
- toSeriesColumns :: Proxy a -> Vector Column
- toSeriesPoints :: a -> Vector Value
- class ToValue a where
- class FromSeries a where
- parseSeries :: Series -> Parser a
- fromSeries :: FromSeries a => Series -> Either String a
- class FromSeriesData a where
- fromSeriesData :: FromSeriesData a => SeriesData -> Either String [a]
- class FromValue a where
- parseValue :: Value -> Parser a
- fromValue :: FromValue a => Value -> Either String a
- withValues :: (Vector Value -> ValueParser a) -> Vector Column -> Vector Value -> Parser a
- (.:) :: FromValue a => Vector Value -> Column -> ValueParser a
- typeMismatch :: String -> Value -> Parser a
- data Config = Config {}
- data Credentials = Credentials {
- credsUser :: !Text
- credsPassword :: !Text
- rootCreds :: Credentials
- data TimePrecision
- data Server = Server {
- serverHost :: !Text
- serverPort :: !Int
- serverSsl :: !Bool
- localServer :: Server
- data ServerPool
- newServerPool :: Server -> [Server] -> IO (IORef ServerPool)
- data Database = Database {
- databaseName :: !Text
- databaseReplicationFactor :: !(Maybe Int)
- newtype User = User {}
- newtype Admin = Admin {}
- post :: Config -> Manager -> Database -> SeriesT IO a -> IO a
- postWithPrecision :: Config -> Manager -> Database -> TimePrecision -> SeriesT IO a -> IO a
- data SeriesT m a
- data PointT p m a
- writeSeries :: (Monad m, ToSeriesData a) => Text -> a -> SeriesT m ()
- withSeries :: forall m a. (Monad m, ToSeriesData a) => Text -> PointT a m () -> SeriesT m ()
- writePoints :: (Monad m, ToSeriesData a) => a -> PointT a m ()
- query :: FromSeries a => Config -> Manager -> Database -> Text -> IO [a]
- data Stream m a
- queryChunked :: FromSeries a => Config -> Manager -> Database -> Text -> (Stream IO a -> IO b) -> IO b
- listDatabases :: Config -> Manager -> IO [Database]
- createDatabase :: Config -> Manager -> Text -> IO Database
- dropDatabase :: Config -> Manager -> Database -> IO ()
- listClusterAdmins :: Config -> Manager -> IO [Admin]
- addClusterAdmin :: Config -> Manager -> Text -> IO Admin
- updateClusterAdminPassword :: Config -> Manager -> Admin -> Text -> IO ()
- deleteClusterAdmin :: Config -> Manager -> Admin -> IO ()
- listDatabaseUsers :: Config -> Manager -> Text -> IO [User]
- addDatabaseUser :: Config -> Manager -> Database -> Text -> IO User
- updateDatabaseUserPassword :: Config -> Manager -> Database -> User -> Text -> IO ()
- deleteDatabaseUser :: Config -> Manager -> Database -> User -> IO ()
- grantAdminPrivilegeTo :: Config -> Manager -> Database -> User -> IO ()
- revokeAdminPrivilegeFrom :: Config -> Manager -> Database -> User -> IO ()
Series data types
A series consists of name, columns and points. The columns and points are
expressed in a separate type SeriesData
.
Series | |
|
seriesColumns :: Series -> Vector ColumnSource
Convenient accessor for columns.
data SeriesData Source
SeriesData
consists of columns and points.
An InfluxDB value represented as a Haskell value.
Encoding
class ToSeriesData a whereSource
A type that can be converted to a SeriesData
. A typical implementation is
as follows.
import qualified Data.Vector as V data Event = Event Text EventType data EventType = Login | Logout instance ToSeriesData where toSeriesColumn _ = V.fromList ["user", "type"] toSeriesPoints (Event user ty) = V.fromList [toValue user, toValue ty] instance ToValue EventType
toSeriesColumns :: Proxy a -> Vector ColumnSource
Column names. You can safely ignore the proxy agument.
toSeriesPoints :: a -> Vector ValueSource
Data points.
A type that can be stored in InfluxDB.
Decoding
class FromSeries a whereSource
A type that can be converted from a Series
.
parseSeries :: Series -> Parser aSource
fromSeries :: FromSeries a => Series -> Either String aSource
Converte a value from a Series
, failing if the types do not match.
class FromSeriesData a whereSource
A type that can be converted from a SeriesData
. A typical implementation
is as follows.
import Control.Applicative ((<$>), (<*>)) import qualified Data.Vector as V data Event = Event Text EventType data EventType = Login | Logout instance FromSeriesData where parseSeriesData = withValues $ values -> Event <$> values .: "user" <*> values .: "type" instance FromValue EventType
fromSeriesData :: FromSeriesData a => SeriesData -> Either String [a]Source
Converte a value from a SeriesData
, failing if the types do not match.
A type that can be converted from a Value
.
parseValue :: Value -> Parser aSource
fromValue :: FromValue a => Value -> Either String aSource
Converte a value from a Value
, failing if the types do not match.
withValues :: (Vector Value -> ValueParser a) -> Vector Column -> Vector Value -> Parser aSource
typeMismatch :: String -> Value -> Parser aSource
HTTP API
Data types
Configurations for HTTP API client.
rootCreds :: CredentialsSource
Default credentials.
Server location.
Server | |
|
Default server location.
data ServerPool Source
Non-empty set of server locations. The active server will always be used until any HTTP communications fail.
newServerPool :: Server -> [Server] -> IO (IORef ServerPool)Source
Create a non-empty server pool. You must specify at least one server location to create a pool.
Database consits of name and replication factor.
Database | |
|
Writing Data
Updating Points
post :: Config -> Manager -> Database -> SeriesT IO a -> IO aSource
Post a bunch of writes for (possibly multiple) series into a database.
postWithPrecision :: Config -> Manager -> Database -> TimePrecision -> SeriesT IO a -> IO aSource
Post a bunch of writes for (possibly multiple) series into a database like
post
but with time precision.
Monad transformer to batch up multiple writes of series to speed up insertions.
MonadTrans SeriesT | |
Monad m => Monad (SeriesT m) | |
Functor m => Functor (SeriesT m) | |
Applicative m => Applicative (SeriesT m) | |
MonadIO m => MonadIO (SeriesT m) | |
Monad m => MonadWriter (DList Series) (SeriesT m) |
Monad transformer to batch up multiple writes of points to speed up insertions.
MonadTrans (PointT p) | |
Monad m => MonadWriter (DList (Vector Value)) (PointT p m) | |
Monad m => Monad (PointT p m) | |
Functor m => Functor (PointT p m) | |
Applicative m => Applicative (PointT p m) | |
MonadIO m => MonadIO (PointT p m) |
:: (Monad m, ToSeriesData a) | |
=> Text | Series name |
-> a | Series data |
-> SeriesT m () |
Write a single series data.
:: forall m a . (Monad m, ToSeriesData a) | |
=> Text | Series name |
-> PointT a m () | |
-> SeriesT m () |
Write a bunch of data for a single series. Columns for the points don't
need to be specified because they can be inferred from the type of a
.
writePoints :: (Monad m, ToSeriesData a) => a -> PointT a m ()Source
Write a data into a series.
Deleting Points
One Time Deletes (not implemented)
Regularly Scheduled Deletes (not implemented)
Querying Data
Query a specified database.
The query format is specified in the InfluxDB Query Language.
Effectful stream
:: FromSeries a | |
=> Config | |
-> Manager | |
-> Database | |
-> Text | Query text |
-> (Stream IO a -> IO b) | Action to handle the resulting stream of series |
-> IO b |
Query a specified database like query
but in a streaming fashion.
Administration & Security
Creating and Dropping Databases
createDatabase :: Config -> Manager -> Text -> IO DatabaseSource
Create a new database. Requires cluster admin privileges.
dropDatabase :: Config -> Manager -> Database -> IO ()Source
Drop a database. Requires cluster admin privileges.
Security
Cluster admin
addClusterAdmin :: Config -> Manager -> Text -> IO AdminSource
Add a new cluster administrator. Requires cluster admin privilege.
updateClusterAdminPassword :: Config -> Manager -> Admin -> Text -> IO ()Source
Update a cluster administrator's password. Requires cluster admin privilege.
deleteClusterAdmin :: Config -> Manager -> Admin -> IO ()Source
Delete a cluster administrator. Requires cluster admin privilege.
Database user
addDatabaseUser :: Config -> Manager -> Database -> Text -> IO UserSource
Add an user to the database users.
updateDatabaseUserPassword :: Config -> Manager -> Database -> User -> Text -> IO ()Source
Update password for the database user.
deleteDatabaseUser :: Config -> Manager -> Database -> User -> IO ()Source
Delete an user from the database users.