{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# HLINT ignore "Use camelCase" #-}

module Asapo.Raw.Consumer
  ( AsapoConsumerHandle (AsapoConsumerHandle),
    AsapoMessageMetaHandle (AsapoMessageMetaHandle),
    AsapoMessageMetasHandle (AsapoMessageMetasHandle),
    AsapoIdListHandle (AsapoIdListHandle),
    AsapoDataSetHandle (AsapoDataSetHandle),
    AsapoPartialErrorDataHandle (AsapoPartialErrorDataHandle),
    AsapoConsumerErrorDataHandle (AsapoConsumerErrorDataHandle),
    AsapoConsumerErrorType,
    asapo_stream_infos_get_size,
    asapo_new_message_meta_handle,
    asapo_free_consumer_handle,
    asapo_free_message_metas_handle,
    asapo_free_id_list_handle,
    kNoData,
    kEndOfStream,
    kStreamFinished,
    kUnavailableService,
    kInterruptedTransaction,
    kLocalIOError,
    kWrongInput,
    kPartialData,
    kUnsupportedClient,
    kDataNotInCache,
    kUnknownError,
    AsapoStreamFilter,
    kAllStreams,
    kFinishedStreams,
    kUnfinishedStreams,
    AsapoNetworkConnectionType,
    kUndefined,
    kAsapoTcp,
    kFabric,
    asapo_error_get_type,
    asapo_create_consumer,
    asapo_consumer_generate_new_group_id,
    asapo_consumer_set_timeout,
    asapo_consumer_reset_last_read_marker,
    asapo_consumer_set_last_read_marker,
    asapo_consumer_acknowledge,
    asapo_consumer_negative_acknowledge,
    asapo_consumer_get_unacknowledged_messages,
    asapo_id_list_get_size,
    asapo_id_list_get_item,
    asapo_consumer_get_last_acknowledged_message,
    asapo_consumer_current_connection_type,
    asapo_consumer_get_stream_list,
    asapo_consumer_delete_stream,
    asapo_consumer_set_stream_persistent,
    asapo_consumer_get_current_size,
    asapo_consumer_get_current_dataset_count,
    asapo_consumer_get_beamtime_meta,
    asapo_consumer_retrieve_data,
    asapo_consumer_get_next_dataset,
    asapo_consumer_get_last_dataset,
    asapo_consumer_get_last_dataset_ingroup,
    asapo_consumer_get_by_id,
    asapo_consumer_get_last,
    asapo_consumer_get_last_ingroup,
    asapo_consumer_get_next,
    asapo_consumer_query_messages,
    asapo_consumer_set_resend_nacs,
    asapo_message_data_get_as_chars,
    asapo_message_meta_get_name,
    asapo_message_meta_get_timestamp,
    asapo_message_meta_get_size,
    asapo_message_meta_get_id,
    asapo_message_meta_get_source,
    asapo_message_meta_get_metadata,
    asapo_message_meta_get_buf_id,
    asapo_message_meta_get_dataset_substream,
    asapo_dataset_get_id,
    asapo_dataset_get_expected_size,
    asapo_dataset_get_size,
    asapo_dataset_get_item,
    asapo_message_metas_get_size,
    asapo_message_metas_get_item,
    asapo_error_get_payload_from_partial_error,
    asapo_partial_error_get_id,
    asapo_partial_error_get_expected_size,
    asapo_error_get_payload_from_consumer_error,
    asapo_consumer_error_get_id,
    asapo_consumer_error_get_next_stream,
  )
where

import Asapo.Raw.Common
  ( AsapoBool,
    AsapoErrorHandle (AsapoErrorHandle),
    AsapoMessageDataHandle (AsapoMessageDataHandle),
    AsapoSourceCredentialsHandle (AsapoSourceCredentialsHandle),
    AsapoStreamInfosHandle (AsapoStreamInfosHandle),
    AsapoStringHandle (AsapoStringHandle),
    ConstCString,
    asapo_free_handle,
    asapo_new_handle,
  )
import Data.Functor ((<$>))
import Data.Int (Int64)
import Data.Word (Word64)
import Foreign.C.ConstPtr (ConstPtr (ConstPtr))
import Foreign.C.Types (CInt (CInt), CLong (CLong), CSize (CSize))
import Foreign.Marshal (with)
import Foreign.Ptr (Ptr)
import Foreign.Storable (Storable)
import System.Clock (TimeSpec)
import System.IO (IO)
import Prelude ()

foreign import capi "asapo/consumer_c.h asapo_stream_infos_get_size" asapo_stream_infos_get_size :: AsapoStreamInfosHandle -> IO CSize

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoConsumerHandle" #-} AsapoConsumerHandle = AsapoConsumerHandle (Ptr ()) deriving (Ptr AsapoConsumerHandle -> IO AsapoConsumerHandle
Ptr AsapoConsumerHandle -> Int -> IO AsapoConsumerHandle
Ptr AsapoConsumerHandle -> Int -> AsapoConsumerHandle -> IO ()
Ptr AsapoConsumerHandle -> AsapoConsumerHandle -> IO ()
AsapoConsumerHandle -> Int
(AsapoConsumerHandle -> Int)
-> (AsapoConsumerHandle -> Int)
-> (Ptr AsapoConsumerHandle -> Int -> IO AsapoConsumerHandle)
-> (Ptr AsapoConsumerHandle -> Int -> AsapoConsumerHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoConsumerHandle)
-> (forall b. Ptr b -> Int -> AsapoConsumerHandle -> IO ())
-> (Ptr AsapoConsumerHandle -> IO AsapoConsumerHandle)
-> (Ptr AsapoConsumerHandle -> AsapoConsumerHandle -> IO ())
-> Storable AsapoConsumerHandle
forall b. Ptr b -> Int -> IO AsapoConsumerHandle
forall b. Ptr b -> Int -> AsapoConsumerHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoConsumerHandle -> Int
sizeOf :: AsapoConsumerHandle -> Int
$calignment :: AsapoConsumerHandle -> Int
alignment :: AsapoConsumerHandle -> Int
$cpeekElemOff :: Ptr AsapoConsumerHandle -> Int -> IO AsapoConsumerHandle
peekElemOff :: Ptr AsapoConsumerHandle -> Int -> IO AsapoConsumerHandle
$cpokeElemOff :: Ptr AsapoConsumerHandle -> Int -> AsapoConsumerHandle -> IO ()
pokeElemOff :: Ptr AsapoConsumerHandle -> Int -> AsapoConsumerHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoConsumerHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoConsumerHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoConsumerHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoConsumerHandle -> IO ()
$cpeek :: Ptr AsapoConsumerHandle -> IO AsapoConsumerHandle
peek :: Ptr AsapoConsumerHandle -> IO AsapoConsumerHandle
$cpoke :: Ptr AsapoConsumerHandle -> AsapoConsumerHandle -> IO ()
poke :: Ptr AsapoConsumerHandle -> AsapoConsumerHandle -> IO ()
Storable)

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoMessageMetaHandle" #-} AsapoMessageMetaHandle = AsapoMessageMetaHandle (Ptr ()) deriving (Ptr AsapoMessageMetaHandle -> IO AsapoMessageMetaHandle
Ptr AsapoMessageMetaHandle -> Int -> IO AsapoMessageMetaHandle
Ptr AsapoMessageMetaHandle
-> Int -> AsapoMessageMetaHandle -> IO ()
Ptr AsapoMessageMetaHandle -> AsapoMessageMetaHandle -> IO ()
AsapoMessageMetaHandle -> Int
(AsapoMessageMetaHandle -> Int)
-> (AsapoMessageMetaHandle -> Int)
-> (Ptr AsapoMessageMetaHandle -> Int -> IO AsapoMessageMetaHandle)
-> (Ptr AsapoMessageMetaHandle
    -> Int -> AsapoMessageMetaHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoMessageMetaHandle)
-> (forall b. Ptr b -> Int -> AsapoMessageMetaHandle -> IO ())
-> (Ptr AsapoMessageMetaHandle -> IO AsapoMessageMetaHandle)
-> (Ptr AsapoMessageMetaHandle -> AsapoMessageMetaHandle -> IO ())
-> Storable AsapoMessageMetaHandle
forall b. Ptr b -> Int -> IO AsapoMessageMetaHandle
forall b. Ptr b -> Int -> AsapoMessageMetaHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoMessageMetaHandle -> Int
sizeOf :: AsapoMessageMetaHandle -> Int
$calignment :: AsapoMessageMetaHandle -> Int
alignment :: AsapoMessageMetaHandle -> Int
$cpeekElemOff :: Ptr AsapoMessageMetaHandle -> Int -> IO AsapoMessageMetaHandle
peekElemOff :: Ptr AsapoMessageMetaHandle -> Int -> IO AsapoMessageMetaHandle
$cpokeElemOff :: Ptr AsapoMessageMetaHandle
-> Int -> AsapoMessageMetaHandle -> IO ()
pokeElemOff :: Ptr AsapoMessageMetaHandle
-> Int -> AsapoMessageMetaHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoMessageMetaHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoMessageMetaHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoMessageMetaHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoMessageMetaHandle -> IO ()
$cpeek :: Ptr AsapoMessageMetaHandle -> IO AsapoMessageMetaHandle
peek :: Ptr AsapoMessageMetaHandle -> IO AsapoMessageMetaHandle
$cpoke :: Ptr AsapoMessageMetaHandle -> AsapoMessageMetaHandle -> IO ()
poke :: Ptr AsapoMessageMetaHandle -> AsapoMessageMetaHandle -> IO ()
Storable)

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoMessageMetasHandle" #-} AsapoMessageMetasHandle = AsapoMessageMetasHandle (Ptr ()) deriving (Ptr AsapoMessageMetasHandle -> IO AsapoMessageMetasHandle
Ptr AsapoMessageMetasHandle -> Int -> IO AsapoMessageMetasHandle
Ptr AsapoMessageMetasHandle
-> Int -> AsapoMessageMetasHandle -> IO ()
Ptr AsapoMessageMetasHandle -> AsapoMessageMetasHandle -> IO ()
AsapoMessageMetasHandle -> Int
(AsapoMessageMetasHandle -> Int)
-> (AsapoMessageMetasHandle -> Int)
-> (Ptr AsapoMessageMetasHandle
    -> Int -> IO AsapoMessageMetasHandle)
-> (Ptr AsapoMessageMetasHandle
    -> Int -> AsapoMessageMetasHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoMessageMetasHandle)
-> (forall b. Ptr b -> Int -> AsapoMessageMetasHandle -> IO ())
-> (Ptr AsapoMessageMetasHandle -> IO AsapoMessageMetasHandle)
-> (Ptr AsapoMessageMetasHandle
    -> AsapoMessageMetasHandle -> IO ())
-> Storable AsapoMessageMetasHandle
forall b. Ptr b -> Int -> IO AsapoMessageMetasHandle
forall b. Ptr b -> Int -> AsapoMessageMetasHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoMessageMetasHandle -> Int
sizeOf :: AsapoMessageMetasHandle -> Int
$calignment :: AsapoMessageMetasHandle -> Int
alignment :: AsapoMessageMetasHandle -> Int
$cpeekElemOff :: Ptr AsapoMessageMetasHandle -> Int -> IO AsapoMessageMetasHandle
peekElemOff :: Ptr AsapoMessageMetasHandle -> Int -> IO AsapoMessageMetasHandle
$cpokeElemOff :: Ptr AsapoMessageMetasHandle
-> Int -> AsapoMessageMetasHandle -> IO ()
pokeElemOff :: Ptr AsapoMessageMetasHandle
-> Int -> AsapoMessageMetasHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoMessageMetasHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoMessageMetasHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoMessageMetasHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoMessageMetasHandle -> IO ()
$cpeek :: Ptr AsapoMessageMetasHandle -> IO AsapoMessageMetasHandle
peek :: Ptr AsapoMessageMetasHandle -> IO AsapoMessageMetasHandle
$cpoke :: Ptr AsapoMessageMetasHandle -> AsapoMessageMetasHandle -> IO ()
poke :: Ptr AsapoMessageMetasHandle -> AsapoMessageMetasHandle -> IO ()
Storable)

asapo_free_consumer_handle :: AsapoConsumerHandle -> IO ()
asapo_free_consumer_handle :: AsapoConsumerHandle -> IO ()
asapo_free_consumer_handle (AsapoConsumerHandle Ptr ()
ptr) = Ptr () -> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Ptr ()
ptr Ptr (Ptr ()) -> IO ()
asapo_free_handle

asapo_free_message_metas_handle :: AsapoMessageMetasHandle -> IO ()
asapo_free_message_metas_handle :: AsapoMessageMetasHandle -> IO ()
asapo_free_message_metas_handle (AsapoMessageMetasHandle Ptr ()
ptr) = Ptr () -> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Ptr ()
ptr Ptr (Ptr ()) -> IO ()
asapo_free_handle

asapo_new_message_meta_handle :: IO AsapoMessageMetaHandle
asapo_new_message_meta_handle :: IO AsapoMessageMetaHandle
asapo_new_message_meta_handle = Ptr () -> AsapoMessageMetaHandle
AsapoMessageMetaHandle (Ptr () -> AsapoMessageMetaHandle)
-> IO (Ptr ()) -> IO AsapoMessageMetaHandle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO (Ptr ())
asapo_new_handle

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoIdListHandle" #-} AsapoIdListHandle = AsapoIdListHandle (Ptr ()) deriving (Ptr AsapoIdListHandle -> IO AsapoIdListHandle
Ptr AsapoIdListHandle -> Int -> IO AsapoIdListHandle
Ptr AsapoIdListHandle -> Int -> AsapoIdListHandle -> IO ()
Ptr AsapoIdListHandle -> AsapoIdListHandle -> IO ()
AsapoIdListHandle -> Int
(AsapoIdListHandle -> Int)
-> (AsapoIdListHandle -> Int)
-> (Ptr AsapoIdListHandle -> Int -> IO AsapoIdListHandle)
-> (Ptr AsapoIdListHandle -> Int -> AsapoIdListHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoIdListHandle)
-> (forall b. Ptr b -> Int -> AsapoIdListHandle -> IO ())
-> (Ptr AsapoIdListHandle -> IO AsapoIdListHandle)
-> (Ptr AsapoIdListHandle -> AsapoIdListHandle -> IO ())
-> Storable AsapoIdListHandle
forall b. Ptr b -> Int -> IO AsapoIdListHandle
forall b. Ptr b -> Int -> AsapoIdListHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoIdListHandle -> Int
sizeOf :: AsapoIdListHandle -> Int
$calignment :: AsapoIdListHandle -> Int
alignment :: AsapoIdListHandle -> Int
$cpeekElemOff :: Ptr AsapoIdListHandle -> Int -> IO AsapoIdListHandle
peekElemOff :: Ptr AsapoIdListHandle -> Int -> IO AsapoIdListHandle
$cpokeElemOff :: Ptr AsapoIdListHandle -> Int -> AsapoIdListHandle -> IO ()
pokeElemOff :: Ptr AsapoIdListHandle -> Int -> AsapoIdListHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoIdListHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoIdListHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoIdListHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoIdListHandle -> IO ()
$cpeek :: Ptr AsapoIdListHandle -> IO AsapoIdListHandle
peek :: Ptr AsapoIdListHandle -> IO AsapoIdListHandle
$cpoke :: Ptr AsapoIdListHandle -> AsapoIdListHandle -> IO ()
poke :: Ptr AsapoIdListHandle -> AsapoIdListHandle -> IO ()
Storable)

asapo_free_id_list_handle :: AsapoIdListHandle -> IO ()
asapo_free_id_list_handle :: AsapoIdListHandle -> IO ()
asapo_free_id_list_handle (AsapoIdListHandle Ptr ()
ptr) = Ptr () -> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Ptr ()
ptr Ptr (Ptr ()) -> IO ()
asapo_free_handle

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoDataSetHandle" #-} AsapoDataSetHandle = AsapoDataSetHandle (Ptr ()) deriving (Ptr AsapoDataSetHandle -> IO AsapoDataSetHandle
Ptr AsapoDataSetHandle -> Int -> IO AsapoDataSetHandle
Ptr AsapoDataSetHandle -> Int -> AsapoDataSetHandle -> IO ()
Ptr AsapoDataSetHandle -> AsapoDataSetHandle -> IO ()
AsapoDataSetHandle -> Int
(AsapoDataSetHandle -> Int)
-> (AsapoDataSetHandle -> Int)
-> (Ptr AsapoDataSetHandle -> Int -> IO AsapoDataSetHandle)
-> (Ptr AsapoDataSetHandle -> Int -> AsapoDataSetHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoDataSetHandle)
-> (forall b. Ptr b -> Int -> AsapoDataSetHandle -> IO ())
-> (Ptr AsapoDataSetHandle -> IO AsapoDataSetHandle)
-> (Ptr AsapoDataSetHandle -> AsapoDataSetHandle -> IO ())
-> Storable AsapoDataSetHandle
forall b. Ptr b -> Int -> IO AsapoDataSetHandle
forall b. Ptr b -> Int -> AsapoDataSetHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoDataSetHandle -> Int
sizeOf :: AsapoDataSetHandle -> Int
$calignment :: AsapoDataSetHandle -> Int
alignment :: AsapoDataSetHandle -> Int
$cpeekElemOff :: Ptr AsapoDataSetHandle -> Int -> IO AsapoDataSetHandle
peekElemOff :: Ptr AsapoDataSetHandle -> Int -> IO AsapoDataSetHandle
$cpokeElemOff :: Ptr AsapoDataSetHandle -> Int -> AsapoDataSetHandle -> IO ()
pokeElemOff :: Ptr AsapoDataSetHandle -> Int -> AsapoDataSetHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoDataSetHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoDataSetHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoDataSetHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoDataSetHandle -> IO ()
$cpeek :: Ptr AsapoDataSetHandle -> IO AsapoDataSetHandle
peek :: Ptr AsapoDataSetHandle -> IO AsapoDataSetHandle
$cpoke :: Ptr AsapoDataSetHandle -> AsapoDataSetHandle -> IO ()
poke :: Ptr AsapoDataSetHandle -> AsapoDataSetHandle -> IO ()
Storable)

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoPartialErrorDataHandle" #-} AsapoPartialErrorDataHandle = AsapoPartialErrorDataHandle (Ptr ()) deriving (Ptr AsapoPartialErrorDataHandle -> IO AsapoPartialErrorDataHandle
Ptr AsapoPartialErrorDataHandle
-> Int -> IO AsapoPartialErrorDataHandle
Ptr AsapoPartialErrorDataHandle
-> Int -> AsapoPartialErrorDataHandle -> IO ()
Ptr AsapoPartialErrorDataHandle
-> AsapoPartialErrorDataHandle -> IO ()
AsapoPartialErrorDataHandle -> Int
(AsapoPartialErrorDataHandle -> Int)
-> (AsapoPartialErrorDataHandle -> Int)
-> (Ptr AsapoPartialErrorDataHandle
    -> Int -> IO AsapoPartialErrorDataHandle)
-> (Ptr AsapoPartialErrorDataHandle
    -> Int -> AsapoPartialErrorDataHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoPartialErrorDataHandle)
-> (forall b. Ptr b -> Int -> AsapoPartialErrorDataHandle -> IO ())
-> (Ptr AsapoPartialErrorDataHandle
    -> IO AsapoPartialErrorDataHandle)
-> (Ptr AsapoPartialErrorDataHandle
    -> AsapoPartialErrorDataHandle -> IO ())
-> Storable AsapoPartialErrorDataHandle
forall b. Ptr b -> Int -> IO AsapoPartialErrorDataHandle
forall b. Ptr b -> Int -> AsapoPartialErrorDataHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoPartialErrorDataHandle -> Int
sizeOf :: AsapoPartialErrorDataHandle -> Int
$calignment :: AsapoPartialErrorDataHandle -> Int
alignment :: AsapoPartialErrorDataHandle -> Int
$cpeekElemOff :: Ptr AsapoPartialErrorDataHandle
-> Int -> IO AsapoPartialErrorDataHandle
peekElemOff :: Ptr AsapoPartialErrorDataHandle
-> Int -> IO AsapoPartialErrorDataHandle
$cpokeElemOff :: Ptr AsapoPartialErrorDataHandle
-> Int -> AsapoPartialErrorDataHandle -> IO ()
pokeElemOff :: Ptr AsapoPartialErrorDataHandle
-> Int -> AsapoPartialErrorDataHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoPartialErrorDataHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoPartialErrorDataHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoPartialErrorDataHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoPartialErrorDataHandle -> IO ()
$cpeek :: Ptr AsapoPartialErrorDataHandle -> IO AsapoPartialErrorDataHandle
peek :: Ptr AsapoPartialErrorDataHandle -> IO AsapoPartialErrorDataHandle
$cpoke :: Ptr AsapoPartialErrorDataHandle
-> AsapoPartialErrorDataHandle -> IO ()
poke :: Ptr AsapoPartialErrorDataHandle
-> AsapoPartialErrorDataHandle -> IO ()
Storable)

newtype {-# CTYPE "asapo/consumer_c.h" "AsapoConsumerErrorDataHandle" #-} AsapoConsumerErrorDataHandle = AsapoConsumerErrorDataHandle (Ptr ()) deriving (Ptr AsapoConsumerErrorDataHandle -> IO AsapoConsumerErrorDataHandle
Ptr AsapoConsumerErrorDataHandle
-> Int -> IO AsapoConsumerErrorDataHandle
Ptr AsapoConsumerErrorDataHandle
-> Int -> AsapoConsumerErrorDataHandle -> IO ()
Ptr AsapoConsumerErrorDataHandle
-> AsapoConsumerErrorDataHandle -> IO ()
AsapoConsumerErrorDataHandle -> Int
(AsapoConsumerErrorDataHandle -> Int)
-> (AsapoConsumerErrorDataHandle -> Int)
-> (Ptr AsapoConsumerErrorDataHandle
    -> Int -> IO AsapoConsumerErrorDataHandle)
-> (Ptr AsapoConsumerErrorDataHandle
    -> Int -> AsapoConsumerErrorDataHandle -> IO ())
-> (forall b. Ptr b -> Int -> IO AsapoConsumerErrorDataHandle)
-> (forall b.
    Ptr b -> Int -> AsapoConsumerErrorDataHandle -> IO ())
-> (Ptr AsapoConsumerErrorDataHandle
    -> IO AsapoConsumerErrorDataHandle)
-> (Ptr AsapoConsumerErrorDataHandle
    -> AsapoConsumerErrorDataHandle -> IO ())
-> Storable AsapoConsumerErrorDataHandle
forall b. Ptr b -> Int -> IO AsapoConsumerErrorDataHandle
forall b. Ptr b -> Int -> AsapoConsumerErrorDataHandle -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: AsapoConsumerErrorDataHandle -> Int
sizeOf :: AsapoConsumerErrorDataHandle -> Int
$calignment :: AsapoConsumerErrorDataHandle -> Int
alignment :: AsapoConsumerErrorDataHandle -> Int
$cpeekElemOff :: Ptr AsapoConsumerErrorDataHandle
-> Int -> IO AsapoConsumerErrorDataHandle
peekElemOff :: Ptr AsapoConsumerErrorDataHandle
-> Int -> IO AsapoConsumerErrorDataHandle
$cpokeElemOff :: Ptr AsapoConsumerErrorDataHandle
-> Int -> AsapoConsumerErrorDataHandle -> IO ()
pokeElemOff :: Ptr AsapoConsumerErrorDataHandle
-> Int -> AsapoConsumerErrorDataHandle -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AsapoConsumerErrorDataHandle
peekByteOff :: forall b. Ptr b -> Int -> IO AsapoConsumerErrorDataHandle
$cpokeByteOff :: forall b. Ptr b -> Int -> AsapoConsumerErrorDataHandle -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> AsapoConsumerErrorDataHandle -> IO ()
$cpeek :: Ptr AsapoConsumerErrorDataHandle -> IO AsapoConsumerErrorDataHandle
peek :: Ptr AsapoConsumerErrorDataHandle -> IO AsapoConsumerErrorDataHandle
$cpoke :: Ptr AsapoConsumerErrorDataHandle
-> AsapoConsumerErrorDataHandle -> IO ()
poke :: Ptr AsapoConsumerErrorDataHandle
-> AsapoConsumerErrorDataHandle -> IO ()
Storable)

type AsapoConsumerErrorType = CInt

foreign import capi "asapo/consumer_c.h value kNoData" kNoData :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kEndOfStream" kEndOfStream :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kStreamFinished" kStreamFinished :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kUnavailableService" kUnavailableService :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kInterruptedTransaction" kInterruptedTransaction :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kLocalIOError" kLocalIOError :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kWrongInput" kWrongInput :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kPartialData" kPartialData :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kUnsupportedClient" kUnsupportedClient :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kDataNotInCache" kDataNotInCache :: AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h value kUnknownError" kUnknownError :: AsapoConsumerErrorType

type AsapoStreamFilter = CInt

foreign import capi "asapo/consumer_c.h value kAllStreams" kAllStreams :: AsapoStreamFilter

foreign import capi "asapo/consumer_c.h value kFinishedStreams" kFinishedStreams :: AsapoStreamFilter

foreign import capi "asapo/consumer_c.h value kUnfinishedStreams" kUnfinishedStreams :: AsapoStreamFilter

type AsapoNetworkConnectionType = CInt

foreign import capi "asapo/consumer_c.h value kUndefined" kUndefined :: AsapoNetworkConnectionType

foreign import capi "asapo/consumer_c.h value kAsapoTcp" kAsapoTcp :: AsapoNetworkConnectionType

foreign import capi "asapo/consumer_c.h value kFabric" kFabric :: AsapoNetworkConnectionType

foreign import capi "asapo/consumer_c.h asapo_error_get_type" asapo_error_get_type :: AsapoErrorHandle -> IO AsapoConsumerErrorType

foreign import capi "asapo/consumer_c.h asapo_create_consumer"
  asapo_create_consumer ::
    -- server_name
    ConstCString ->
    -- source_path
    ConstCString ->
    -- has filesystem
    AsapoBool ->
    AsapoSourceCredentialsHandle ->
    Ptr AsapoErrorHandle ->
    IO AsapoConsumerHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_generate_new_group_id" asapo_consumer_generate_new_group_id :: AsapoConsumerHandle -> Ptr AsapoErrorHandle -> IO AsapoStringHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_set_timeout" asapo_consumer_set_timeout :: AsapoConsumerHandle -> Word64 -> IO ()

foreign import capi "asapo/consumer_c.h asapo_consumer_reset_last_read_marker"
  asapo_consumer_reset_last_read_marker ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_set_last_read_marker"
  asapo_consumer_set_last_read_marker ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- value
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_acknowledge"
  asapo_consumer_acknowledge ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- id
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_negative_acknowledge"
  asapo_consumer_negative_acknowledge ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- id
    Word64 ->
    -- delay_ms
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_unacknowledged_messages"
  asapo_consumer_get_unacknowledged_messages ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- from id
    Word64 ->
    -- to id
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO AsapoIdListHandle

foreign import capi "asapo/consumer_c.h asapo_id_list_get_size" asapo_id_list_get_size :: AsapoIdListHandle -> IO CSize

foreign import capi "asapo/consumer_c.h asapo_id_list_get_item" asapo_id_list_get_item :: AsapoIdListHandle -> CSize -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_consumer_get_last_acknowledged_message"
  asapo_consumer_get_last_acknowledged_message ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CLong

-- foreign import capi "asapo/consumer_c.h asapo_consumer_force_no_rdma" asapo_consumer_force_no_rdma :: AsapoConsumerHandle -> IO ()

foreign import capi "asapo/consumer_c.h asapo_consumer_current_connection_type" asapo_consumer_current_connection_type :: AsapoConsumerHandle -> IO AsapoNetworkConnectionType

-- Again, a typo in the original (no "asapo_" prefix, but corrected in the Haskell code)
-- foreign import capi "asapo/consumer_c.h enable_new_monitoring_api_format" asapo_enable_new_monitoring_api_format :: AsapoConsumerHandle -> AsapoBool -> Ptr AsapoErrorHandle -> IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_stream_list"
  asapo_consumer_get_stream_list ::
    AsapoConsumerHandle ->
    -- stream
    ConstCString ->
    AsapoStreamFilter ->
    Ptr AsapoErrorHandle ->
    IO AsapoStreamInfosHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_delete_stream"
  asapo_consumer_delete_stream ::
    AsapoConsumerHandle ->
    -- stream
    ConstCString ->
    -- delete_meta
    AsapoBool ->
    -- error_on_not_exist
    AsapoBool ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_set_stream_persistent"
  asapo_consumer_set_stream_persistent ::
    AsapoConsumerHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_current_size"
  asapo_consumer_get_current_size ::
    AsapoConsumerHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO Int64

foreign import capi "asapo/consumer_c.h asapo_consumer_get_current_dataset_count"
  asapo_consumer_get_current_dataset_count ::
    AsapoConsumerHandle ->
    -- stream
    ConstCString ->
    -- include_incomplete
    AsapoBool ->
    Ptr AsapoErrorHandle ->
    IO Int64

foreign import capi "asapo/consumer_c.h asapo_consumer_get_beamtime_meta" asapo_consumer_get_beamtime_meta :: AsapoConsumerHandle -> Ptr AsapoErrorHandle -> IO AsapoStringHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_retrieve_data"
  asapo_consumer_retrieve_data ::
    AsapoConsumerHandle ->
    AsapoMessageMetaHandle ->
    Ptr AsapoMessageDataHandle ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_next_dataset"
  asapo_consumer_get_next_dataset ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- min_size
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO AsapoDataSetHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_get_last_dataset"
  asapo_consumer_get_last_dataset ::
    AsapoConsumerHandle ->
    -- min_size
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO AsapoDataSetHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_get_last_dataset_ingroup"
  asapo_consumer_get_last_dataset_ingroup ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    -- min_size
    Word64 ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO AsapoDataSetHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_get_by_id"
  asapo_consumer_get_by_id ::
    AsapoConsumerHandle ->
    -- id
    Word64 ->
    Ptr AsapoMessageMetaHandle ->
    Ptr AsapoMessageDataHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_last"
  asapo_consumer_get_last ::
    AsapoConsumerHandle ->
    Ptr AsapoMessageMetaHandle ->
    Ptr AsapoMessageDataHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_last_ingroup"
  asapo_consumer_get_last_ingroup ::
    AsapoConsumerHandle ->
    -- group_id
    AsapoStringHandle ->
    Ptr AsapoMessageMetaHandle ->
    Ptr AsapoMessageDataHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_get_next"
  asapo_consumer_get_next ::
    AsapoConsumerHandle ->
    -- group id
    AsapoStringHandle ->
    Ptr AsapoMessageMetaHandle ->
    Ptr AsapoMessageDataHandle ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO CInt

foreign import capi "asapo/consumer_c.h asapo_consumer_query_messages"
  asapo_consumer_query_messages ::
    AsapoConsumerHandle ->
    -- query
    ConstCString ->
    -- stream
    ConstCString ->
    Ptr AsapoErrorHandle ->
    IO AsapoMessageMetasHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_set_resend_nacs"
  asapo_consumer_set_resend_nacs ::
    AsapoConsumerHandle ->
    -- resend
    AsapoBool ->
    -- delay_ms
    Word64 ->
    -- resend_attempts
    Word64 ->
    IO ()

foreign import capi "asapo/consumer_c.h asapo_message_data_get_as_chars" asapo_message_data_get_as_chars :: AsapoMessageDataHandle -> IO ConstCString

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_name" asapo_message_meta_get_name :: AsapoMessageMetaHandle -> IO ConstCString

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_timestamp" asapo_message_meta_get_timestamp :: AsapoMessageMetaHandle -> Ptr TimeSpec -> IO ()

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_size" asapo_message_meta_get_size :: AsapoMessageMetaHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_id" asapo_message_meta_get_id :: AsapoMessageMetaHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_source" asapo_message_meta_get_source :: AsapoMessageMetaHandle -> IO ConstCString

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_metadata" asapo_message_meta_get_metadata :: AsapoMessageMetaHandle -> IO ConstCString

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_buf_id" asapo_message_meta_get_buf_id :: AsapoMessageMetaHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_message_meta_get_dataset_substream" asapo_message_meta_get_dataset_substream :: AsapoMessageMetaHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_dataset_get_id" asapo_dataset_get_id :: AsapoDataSetHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_dataset_get_expected_size" asapo_dataset_get_expected_size :: AsapoDataSetHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_dataset_get_size" asapo_dataset_get_size :: AsapoDataSetHandle -> IO CSize

foreign import capi "asapo/consumer_c.h asapo_dataset_get_item" asapo_dataset_get_item :: AsapoDataSetHandle -> CSize -> IO AsapoMessageMetaHandle

foreign import capi "asapo/consumer_c.h asapo_message_metas_get_size" asapo_message_metas_get_size :: AsapoMessageMetasHandle -> IO CSize

foreign import capi "asapo/consumer_c.h asapo_message_metas_get_item" asapo_message_metas_get_item :: AsapoMessageMetasHandle -> CSize -> IO AsapoMessageMetaHandle

foreign import capi "asapo/consumer_c.h asapo_error_get_payload_from_partial_error" asapo_error_get_payload_from_partial_error :: AsapoErrorHandle -> IO AsapoPartialErrorDataHandle

foreign import capi "asapo/consumer_c.h asapo_partial_error_get_id" asapo_partial_error_get_id :: AsapoPartialErrorDataHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_partial_error_get_expected_size" asapo_partial_error_get_expected_size :: AsapoPartialErrorDataHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_error_get_payload_from_consumer_error" asapo_error_get_payload_from_consumer_error :: AsapoErrorHandle -> IO AsapoConsumerErrorDataHandle

foreign import capi "asapo/consumer_c.h asapo_consumer_error_get_id" asapo_consumer_error_get_id :: AsapoConsumerErrorDataHandle -> IO Word64

foreign import capi "asapo/consumer_c.h asapo_consumer_error_get_next_stream" asapo_consumer_error_get_next_stream :: AsapoConsumerErrorDataHandle -> IO ConstCString