-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Append-only database
--
-- Please see the README on GitHub at
-- https://github.com/tsurucapital/franz#readme
@package franz
@version 0.4
module Database.Franz.Internal
-- | Better implementation of getInt64le
getInt64le :: Num a => Get a
runGetRecv :: IORef ByteString -> Socket -> Get a -> IO (Either String a)
hGetRange :: Handle -> Int -> Int -> IO ByteString
module Database.Franz.Protocol
apiVersion :: ByteString
defaultPort :: PortNumber
type IndexName = ByteString
newtype StreamName
StreamName :: ByteString -> StreamName
[unStreamName] :: StreamName -> ByteString
streamNameToPath :: StreamName -> FilePath
data FranzException
MalformedRequest :: !String -> FranzException
StreamNotFound :: !FilePath -> FranzException
IndexNotFound :: !IndexName -> ![IndexName] -> FranzException
InternalError :: !String -> FranzException
ClientError :: !String -> FranzException
data RequestType
AllItems :: RequestType
LastItem :: RequestType
data ItemRef
-- | sequential number
BySeqNum :: !Int -> ItemRef
-- | index name and value
ByIndex :: !IndexName -> !Int -> ItemRef
data Query
Query :: !StreamName -> !ItemRef -> !ItemRef -> !RequestType -> Query
[reqStream] :: Query -> !StreamName
-- | name of the index to search
[reqFrom] :: Query -> !ItemRef
-- | name of the index to search
[reqTo] :: Query -> !ItemRef
[reqType] :: Query -> !RequestType
data RawRequest
RawRequest :: !ResponseId -> !Query -> RawRequest
RawClean :: !ResponseId -> RawRequest
type ResponseId = Int
data ResponseHeader
-- | response ID, number of streams; there are items satisfying the query
Response :: !ResponseId -> ResponseHeader
-- | response ID; requested elements are not available right now
ResponseWait :: !ResponseId -> ResponseHeader
-- | something went wrong
ResponseError :: !ResponseId -> !FranzException -> ResponseHeader
-- | Initial seqno, final seqno, base offset, index names
data PayloadHeader
PayloadHeader :: !Int -> !Int -> !Int -> !Vector IndexName -> PayloadHeader
instance Data.Serialize.Serialize Database.Franz.Protocol.StreamName
instance Data.Hashable.Class.Hashable Database.Franz.Protocol.StreamName
instance GHC.Classes.Ord Database.Franz.Protocol.StreamName
instance GHC.Classes.Eq Database.Franz.Protocol.StreamName
instance GHC.Show.Show Database.Franz.Protocol.StreamName
instance GHC.Generics.Generic Database.Franz.Protocol.FranzException
instance GHC.Show.Show Database.Franz.Protocol.FranzException
instance GHC.Generics.Generic Database.Franz.Protocol.RequestType
instance GHC.Show.Show Database.Franz.Protocol.RequestType
instance GHC.Generics.Generic Database.Franz.Protocol.ItemRef
instance GHC.Show.Show Database.Franz.Protocol.ItemRef
instance GHC.Generics.Generic Database.Franz.Protocol.Query
instance GHC.Show.Show Database.Franz.Protocol.Query
instance GHC.Generics.Generic Database.Franz.Protocol.RawRequest
instance GHC.Generics.Generic Database.Franz.Protocol.ResponseHeader
instance GHC.Show.Show Database.Franz.Protocol.ResponseHeader
instance Data.Serialize.Serialize Database.Franz.Protocol.PayloadHeader
instance Data.Serialize.Serialize Database.Franz.Protocol.ResponseHeader
instance Data.Serialize.Serialize Database.Franz.Protocol.RawRequest
instance Data.Serialize.Serialize Database.Franz.Protocol.Query
instance Data.Serialize.Serialize Database.Franz.Protocol.ItemRef
instance Data.Serialize.Serialize Database.Franz.Protocol.RequestType
instance Data.Serialize.Serialize Database.Franz.Protocol.FranzException
instance GHC.Exception.Type.Exception Database.Franz.Protocol.FranzException
instance Data.String.IsString Database.Franz.Protocol.StreamName
module Database.Franz.Reader
data StreamStatus
CaughtUp :: StreamStatus
Outdated :: StreamStatus
Gone :: StreamStatus
data Stream
Stream :: FilePath -> !TVar (IntMap Int) -> !Vector IndexName -> !HashMap IndexName (TVar (IntMap Int)) -> !TVar Int -> !TVar StreamStatus -> !ThreadId -> !Handle -> !Handle -> !TVar Activity -> Stream
[streamPath] :: Stream -> FilePath
[vOffsets] :: Stream -> !TVar (IntMap Int)
[indexNames] :: Stream -> !Vector IndexName
[indices] :: Stream -> !HashMap IndexName (TVar (IntMap Int))
[vCount] :: Stream -> !TVar Int
[vStatus] :: Stream -> !TVar StreamStatus
[followThread] :: Stream -> !ThreadId
[indexHandle] :: Stream -> !Handle
[payloadHandle] :: Stream -> !Handle
[vActivity] :: Stream -> !TVar Activity
type Activity = Either Double Int
addActivity :: Stream -> STM ()
removeActivity :: Stream -> IO ()
closeStream :: Stream -> IO ()
createStream :: WatchManager -> FilePath -> IO Stream
type QueryResult = ((Int, Int), (Int, Int))
range :: Int -> Int -> RequestType -> IntMap Int -> (Bool, QueryResult)
splitR :: Int -> IntMap a -> (IntMap a, IntMap a)
data FranzReader
FranzReader :: WatchManager -> TVar (HashMap FranzDirectory (HashMap StreamName Stream)) -> FranzReader
[watchManager] :: FranzReader -> WatchManager
[vStreams] :: FranzReader -> TVar (HashMap FranzDirectory (HashMap StreamName Stream))
data ReaperState
ReaperState :: !Int -> !Int -> ReaperState
-- | How many streams we pruned.
[prunedStreams] :: ReaperState -> !Int
-- | How many streams we saw in total.
[totalStreams] :: ReaperState -> !Int
reaper :: Double -> Double -> FranzReader -> IO ()
withFranzReader :: (FranzReader -> IO ()) -> IO ()
newFranzReader :: IO FranzReader
closeFranzReader :: FranzReader -> IO ()
-- | Globally-configured path which contains franz directories.
newtype FranzPrefix
FranzPrefix :: FilePath -> FranzPrefix
[unFranzPrefix] :: FranzPrefix -> FilePath
-- | Directory which contains franz streams. Values of this type serve two
-- purposes:
--
--
-- - Arbitrary prefix so that clients don't have to specify the full
-- path
--
newtype FranzDirectory
FranzDirectory :: FilePath -> FranzDirectory
getFranzDirectory :: FranzPrefix -> FranzDirectory -> FilePath
getFranzStreamPath :: FranzPrefix -> FranzDirectory -> StreamName -> FilePath
handleQuery :: FranzPrefix -> FranzReader -> FranzDirectory -> Query -> (FranzException -> IO r) -> (Stream -> STM (Bool, QueryResult) -> IO r) -> IO r
instance GHC.Classes.Eq Database.Franz.Reader.StreamStatus
instance Data.Hashable.Class.Hashable Database.Franz.Reader.FranzPrefix
instance GHC.Classes.Eq Database.Franz.Reader.FranzPrefix
instance Data.Hashable.Class.Hashable Database.Franz.Reader.FranzDirectory
instance GHC.Classes.Eq Database.Franz.Reader.FranzDirectory
module Database.Franz.Contents
data Contents
indexNames :: Contents -> Vector IndexName
data Item
Item :: !Int -> !Vector Int64 -> !ByteString -> Item
[seqNo] :: Item -> !Int
[indices] :: Item -> !Vector Int64
[payload] :: Item -> !ByteString
toList :: Contents -> [Item]
last :: Contents -> Maybe Item
length :: Contents -> Int
index :: Contents -> Int -> Maybe Item
lookupIndex :: Contents -> IndexName -> Maybe (Item -> Int64)
getResponse :: Get Contents
readContents :: Stream -> QueryResult -> IO Contents
instance GHC.Classes.Eq Database.Franz.Contents.Item
instance GHC.Show.Show Database.Franz.Contents.Item
module Database.Franz.Server
data Settings
Settings :: Double -> Double -> PortNumber -> FranzPrefix -> Maybe FranzPrefix -> FranzPrefix -> Settings
[reapInterval] :: Settings -> Double
[streamLifetime] :: Settings -> Double
[port] :: Settings -> PortNumber
[livePrefix] :: Settings -> FranzPrefix
[archivePrefix] :: Settings -> Maybe FranzPrefix
[mountPrefix] :: Settings -> FranzPrefix
startServer :: Settings -> IO ()
defaultPort :: PortNumber
mountFuse :: FilePath -> FilePath -> IO ProcessHandle
killFuse :: ProcessHandle -> FilePath -> IO ()
instance Data.ConcurrentResourceMap.ResourceMap Database.Franz.Server.MountMap
module Database.Franz.URI
data FranzPath
FranzPath :: !HostName -> !PortNumber -> !FilePath -> FranzPath
[franzHost] :: FranzPath -> !HostName
[franzPort] :: FranzPath -> !PortNumber
-- | Prefix of franz directories
[franzDir] :: FranzPath -> !FilePath
LocalFranzPath :: !FilePath -> FranzPath
-- | Parse a franz URI (franz:/host:portpath or franz-local:path).
toFranzPath :: String -> Either String FranzPath
-- | Render FranzPath as a franz URI.
fromFranzPath :: (Monoid a, IsString a) => FranzPath -> a
instance GHC.Classes.Ord Database.Franz.URI.FranzPath
instance GHC.Classes.Eq Database.Franz.URI.FranzPath
instance GHC.Show.Show Database.Franz.URI.FranzPath
module Database.Franz.Client
data FranzPath
FranzPath :: !HostName -> !PortNumber -> !FilePath -> FranzPath
[franzHost] :: FranzPath -> !HostName
[franzPort] :: FranzPath -> !PortNumber
-- | Prefix of franz directories
[franzDir] :: FranzPath -> !FilePath
LocalFranzPath :: !FilePath -> FranzPath
-- | Render FranzPath as a franz URI.
fromFranzPath :: (Monoid a, IsString a) => FranzPath -> a
-- | Parse a franz URI (franz:/host:portpath or franz-local:path).
toFranzPath :: String -> Either String FranzPath
defaultPort :: PortNumber
data Connection
withConnection :: FranzPath -> (Connection -> IO r) -> IO r
connect :: FranzPath -> IO Connection
disconnect :: Connection -> IO ()
newtype StreamName
StreamName :: ByteString -> StreamName
[unStreamName] :: StreamName -> ByteString
data Query
Query :: !StreamName -> !ItemRef -> !ItemRef -> !RequestType -> Query
[reqStream] :: Query -> !StreamName
-- | name of the index to search
[reqFrom] :: Query -> !ItemRef
-- | name of the index to search
[reqTo] :: Query -> !ItemRef
[reqType] :: Query -> !RequestType
data ItemRef
-- | sequential number
BySeqNum :: !Int -> ItemRef
-- | index name and value
ByIndex :: !IndexName -> !Int -> ItemRef
data RequestType
AllItems :: RequestType
LastItem :: RequestType
defQuery :: StreamName -> Query
-- | When it is Right, it might block until the content arrives.
type Response = Either Contents (STM Contents)
awaitResponse :: STM (Either a (STM a)) -> STM a
data Contents
-- | Fetch requested data from the server.
--
-- Termination of fetch continuation cancels the request, allowing
-- flexible control of its lifetime.
fetch :: Connection -> Query -> (STM Response -> IO r) -> IO r
-- | Send a single query and wait for the result.
fetchSimple :: Connection -> Int -> Query -> IO (Maybe Contents)
atomicallyWithin :: Int -> STM a -> IO (Maybe a)
data FranzException
MalformedRequest :: !String -> FranzException
StreamNotFound :: !FilePath -> FranzException
IndexNotFound :: !IndexName -> ![IndexName] -> FranzException
InternalError :: !String -> FranzException
ClientError :: !String -> FranzException
instance GHC.Base.Functor Database.Franz.Client.ResponseStatus
instance GHC.Show.Show a => GHC.Show.Show (Database.Franz.Client.ResponseStatus a)
instance Data.ConcurrentResourceMap.ResourceMap Database.Franz.Client.ConnStateMap
module Database.Franz.Reconnect
data Pool
poolLogFunc :: Pool -> String -> IO ()
poolRetryPolicy :: Pool -> RetryPolicyM IO
withPool :: RetryPolicyM IO -> (String -> IO ()) -> FranzPath -> (Pool -> IO a) -> IO a
-- | Run an action which takes a Connection, reconnecting whenever
-- it throws an exception.
withReconnection :: Pool -> (Connection -> IO a) -> IO a
data Reconnect
Reconnect :: Reconnect
-- | Run an STM action, throwing Reconnect when it exceeds
-- the given timeout.
atomicallyReconnecting :: Int -> STM a -> IO a
-- | A wrapper of fetch which calls withReconnection
-- internally
fetchWithPool :: Pool -> Query -> (STM Response -> IO r) -> IO r
instance GHC.Classes.Eq Database.Franz.Reconnect.Reconnect
instance GHC.Show.Show Database.Franz.Reconnect.Reconnect
instance GHC.Exception.Type.Exception Database.Franz.Reconnect.Reconnect
module Database.Franz.Writer
data WriterHandle (f :: Type -> Type)
openWriter :: Foldable f => f String -> FilePath -> IO (WriterHandle f)
-- | Flush any pending data and close a WriterHandle.
closeWriter :: WriterHandle f -> IO ()
withWriter :: Foldable f => f String -> FilePath -> (WriterHandle f -> IO a) -> IO a
write :: Foldable f => WriterHandle f -> f Int64 -> Builder -> IO Int
-- | Flush the changes.
flush :: WriterHandle f -> IO ()
-- | Get the sequential number of the last item item written.
getLastSeqNo :: WriterHandle f -> IO Int
instance Control.DeepSeq.NFData (Database.Franz.Writer.WriterHandle f)
module Database.Franz.Writer.Simple
data WriterHandle (f :: Type -> Type)
openWriter :: FilePath -> IO (WriterHandle Proxy)
-- | Flush any pending data and close a WriterHandle.
closeWriter :: WriterHandle f -> IO ()
withWriter :: FilePath -> (WriterHandle Proxy -> IO a) -> IO a
write :: WriterHandle Proxy -> Builder -> IO Int
-- | Flush the changes.
flush :: WriterHandle f -> IO ()
-- | Get the sequential number of the last item item written.
getLastSeqNo :: WriterHandle f -> IO Int
class ToFastBuilder a
toFastBuilder :: ToFastBuilder a => a -> Builder
instance Database.Franz.Writer.Simple.ToFastBuilder Data.ByteString.Internal.ByteString
instance Database.Franz.Writer.Simple.ToFastBuilder Data.ByteString.Lazy.Internal.ByteString
instance Database.Franz.Writer.Simple.ToFastBuilder Data.ByteString.FastBuilder.Internal.Builder