-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Remote monitoring of processes
--   
--   This library lets you remotely monitor a running process over HTTP. It
--   provides a simple way to integrate a monitoring server into any
--   application.
@package ekg
@version 0.3.1.3


-- | This module defines a type for mutable, string-valued labels. Labels
--   are variable values and can be used to track e.g. the command line
--   arguments or other free-form values. All operations on labels are
--   thread-safe.
module System.Remote.Label

-- | A mutable, text-valued label.
data Label

-- | Set the label to the given value.
set :: Label -> Text -> IO ()

-- | Set the label to the result of applying the given function to the
--   value.
modify :: (Text -> Text) -> Label -> IO ()


-- | This module defines a type for mutable, integer-valued gauges. Gauges
--   are variable values and can be used to track e.g. the current number
--   of concurrent connections. All operations on gauges are thread-safe.
module System.Remote.Gauge

-- | A mutable, integer-valued gauge.
data Gauge

-- | Increase the gauge by one.
inc :: Gauge -> IO ()

-- | Decrease the gauge by one.
dec :: Gauge -> IO ()

-- | Increase the gauge by the given amount.
add :: Gauge -> Int -> IO ()

-- | Decrease the gauge by the given amount.
subtract :: Gauge -> Int -> IO ()

-- | Set the gauge to the given value.
set :: Gauge -> Int -> IO ()

-- | Set the gauge to the result of applying the given function to the
--   value.
modify :: (Int -> Int) -> Gauge -> IO ()


-- | This module defines a type for mutable, integer-valued counters.
--   Counters are non-negative, monotonically increasing values and can be
--   used to track e.g. the number of requests served since program start.
--   All operations on counters are thread-safe.
module System.Remote.Counter

-- | A mutable, integer-valued counter.
data Counter

-- | Increase the counter by one.
inc :: Counter -> IO ()

-- | Increase the counter by the given amount.
add :: Counter -> Int -> IO ()


-- | This module provides remote monitoring of a running process over HTTP.
--   It can be used to run an HTTP server that provides both a web-based
--   user interface and a machine-readable API (e.g. JSON.) The former can
--   be used by a human to get an overview of what the program is doing and
--   the latter can be used by automated monitoring tools.
--   
--   Typical usage is to start the monitoring server at program startup
--   
--   <pre>
--   main = do
--       forkServer "localhost" 8000
--       ...
--   </pre>
--   
--   and then periodically check the stats using a web browser or a command
--   line tool (e.g. curl)
--   
--   <pre>
--   $ curl -H "Accept: application/json" http://localhost:8000/
--   </pre>
module System.Remote.Monitoring

-- | A handle that can be used to control the monitoring server. Created by
--   <tt>forkServer</tt>.
data Server

-- | The thread ID of the server. You can kill the server by killing this
--   thread (i.e. by throwing it an asynchronous exception.)
serverThreadId :: Server -> ThreadId

-- | Start an HTTP server in a new thread. The server replies to GET
--   requests to the given host and port. The host argument can be either a
--   numeric network address (dotted quad for IPv4, colon-separated hex for
--   IPv6) or a hostname (e.g. "localhost".) The client can control the
--   Content-Type used in responses by setting the Accept header. At the
--   moment three content types are available: "application/json",
--   "text/html", and "text/plain".
forkServer :: ByteString -> Int -> IO Server

-- | Return the counter associated with the given name and server. Multiple
--   calls to <a>getCounter</a> with the same arguments will return the
--   same counter. The first time <a>getCounter</a> is called for a given
--   name and server, a new, zero-initialized counter will be returned.
getCounter :: Text -> Server -> IO Counter

-- | Return the gauge associated with the given name and server. Multiple
--   calls to <a>getGauge</a> with the same arguments will return the same
--   gauge. The first time <a>getGauge</a> is called for a given name and
--   server, a new, zero-initialized gauge will be returned.
getGauge :: Text -> Server -> IO Gauge

-- | Return the label associated with the given name and server. Multiple
--   calls to <a>getLabel</a> with the same arguments will return the same
--   label. The first time <a>getLabel</a> is called for a given name and
--   server, a new, empty label will be returned.
getLabel :: Text -> Server -> IO Label
