Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- write :: Timestamp time => WriteParams -> Line time -> IO ()
- writeBatch :: (Timestamp time, Foldable f) => WriteParams -> f (Line time) -> IO ()
- writeByteString :: WriteParams -> ByteString -> IO ()
- data WriteParams
- writeParams :: Socket -> SockAddr -> WriteParams
- socket :: Lens' WriteParams Socket
- sockAddr :: Lens' WriteParams SockAddr
- precision :: HasPrecision ty a => Lens' a (Precision ty)
Documentation
This module is desined to be used with the network package and be imported qualified.
>>>
:set -XOverloadedStrings -XNoOverloadedLists
>>>
import qualified Data.Map as Map
>>>
import Data.Time
>>>
import Network.Socket
>>>
import Database.InfluxDB
>>>
import qualified Database.InfluxDB.Write.UDP as UDP
>>>
sock <- Network.Socket.socket AF_INET Datagram defaultProtocol
>>>
let localhost = tupleToHostAddress (127, 0, 0, 1)
>>>
let params = UDP.writeParams sock $ SockAddrInet 8089 localhost
>>>
UDP.write params $ Line "measurement1" Map.empty (Map.fromList [("value", FieldInt 42)]) (Nothing :: Maybe UTCTime)
>>>
close sock
Make sure that the UDP service is enabled in the InfluxDB config. This API doesn't tell you if any error occurs. See the official doc for details.
Writers
writeBatch :: (Timestamp time, Foldable f) => WriteParams -> f (Line time) -> IO () Source #
writeByteString :: WriteParams -> ByteString -> IO () Source #
Write a lazy ByteString
Writer parameters
data WriteParams Source #
The full set of parameters for the UDP writer.
Instances
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 |
writeParams :: Socket -> SockAddr -> WriteParams Source #