{-# language BangPatterns #-}
{-# language DerivingStrategies #-}
{-# language DuplicateRecordFields #-}
{-# language NamedFieldPuns #-}
{-# language ScopedTypeVariables #-}
{-# language TypeApplications #-}
{-# language OverloadedRecordDot #-}

module Kafka.Metadata.Response.V12
  ( Response(..)
  , Broker(..)
  , Topic(..)
  , Partition(..)
  , Error(..)
  , parser
  , decode
  , decodeHeaded
    -- * Predicates
  , hasErrorCode
  , findErrorCode
  ) where

import Prelude hiding (id)

import Control.Applicative (liftA2)
import Data.Bytes (Bytes)
import Data.Bytes.Parser (Parser)
import Data.Int (Int16,Int32)
import Data.Primitive (SmallArray,PrimArray)
import Data.Text (Text)
import Data.WideWord (Word128)
import Data.Word (Word32,Word16)
import Kafka.ErrorCode (ErrorCode)
import Kafka.Parser.Context (Context(Top,Field,Index))
import Kafka.Parser.Context (ContextualizedErrorCode(..))
import Kafka.TaggedField (TaggedField)
import Data.Monoid (Any(Any),getAny)

import qualified Data.Bytes.Parser as Parser
import qualified Data.Primitive as PM
import qualified Kafka.ErrorCode as ErrorCode
import qualified Kafka.Parser.Context as Ctx
import qualified Kafka.TaggedField as TaggedField
import qualified Kafka.Parser
import qualified Kafka.Header.Response.V1 as Header

-- | Search through all topics and partitions for any error codes
-- that are not set to @NONE@.
hasErrorCode :: Response -> Bool
hasErrorCode :: Response -> Bool
hasErrorCode Response{SmallArray Topic
topics :: SmallArray Topic
$sel:topics:Response :: Response -> SmallArray Topic
topics} = Any -> Bool
getAny (Any -> Bool) -> Any -> Bool
forall a b. (a -> b) -> a -> b
$ (Topic -> Any) -> SmallArray Topic -> Any
forall m a. Monoid m => (a -> m) -> SmallArray a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap
  (\Topic
t -> Bool -> Any
Any (Topic
t.errorCode ErrorCode -> ErrorCode -> Bool
forall a. Eq a => a -> a -> Bool
/= ErrorCode
ErrorCode.None) Any -> Any -> Any
forall a. Semigroup a => a -> a -> a
<> (Partition -> Any) -> SmallArray Partition -> Any
forall m a. Monoid m => (a -> m) -> SmallArray a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap
    (\Partition
p -> Bool -> Any
Any (Partition
p.errorCode ErrorCode -> ErrorCode -> Bool
forall a. Eq a => a -> a -> Bool
/= ErrorCode
ErrorCode.None)
    ) Topic
t.partitions
  ) SmallArray Topic
topics

-- | Find the first error code of any kind in the response.
-- This looks for topic-level error codes first and then
-- moves on searching for partition-level error codes.
findErrorCode :: Response -> Maybe ContextualizedErrorCode
findErrorCode :: Response -> Maybe ContextualizedErrorCode
findErrorCode Response{SmallArray Topic
$sel:topics:Response :: Response -> SmallArray Topic
topics :: SmallArray Topic
topics}
  | c :: Maybe ContextualizedErrorCode
c@Just{} <- Int -> Maybe ContextualizedErrorCode
goTopic Int
0 = Maybe ContextualizedErrorCode
c
  | c :: Maybe ContextualizedErrorCode
c@Just{} <- Int -> Maybe ContextualizedErrorCode
goPartitionOuter Int
0 = Maybe ContextualizedErrorCode
c
  | Bool
otherwise = Maybe ContextualizedErrorCode
forall a. Maybe a
Nothing
  where
  ctxTopics :: Context
ctxTopics = Field -> Context -> Context
Field Field
Ctx.Topics Context
Top
  goTopic :: Int -> Maybe ContextualizedErrorCode
  goTopic :: Int -> Maybe ContextualizedErrorCode
goTopic !Int
ix = if Int
ix Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< SmallArray Topic -> Int
forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray Topic
topics
    then
      let t :: Topic
t = SmallArray Topic -> Int -> Topic
forall a. SmallArray a -> Int -> a
PM.indexSmallArray SmallArray Topic
topics Int
ix
       in case Topic
t.errorCode of
            ErrorCode
ErrorCode.None -> Int -> Maybe ContextualizedErrorCode
goTopic (Int
ix Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
            ErrorCode
e -> ContextualizedErrorCode -> Maybe ContextualizedErrorCode
forall a. a -> Maybe a
Just (Context -> ErrorCode -> ContextualizedErrorCode
ContextualizedErrorCode (Int -> Context -> Context
Index Int
ix Context
ctxTopics) ErrorCode
e)
    else Maybe ContextualizedErrorCode
forall a. Maybe a
Nothing
  goPartitionOuter :: Int -> Maybe ContextualizedErrorCode
  goPartitionOuter :: Int -> Maybe ContextualizedErrorCode
goPartitionOuter !Int
ix = if Int
ix Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< SmallArray Topic -> Int
forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray Topic
topics
    then
      let t :: Topic
t = SmallArray Topic -> Int -> Topic
forall a. SmallArray a -> Int -> a
PM.indexSmallArray SmallArray Topic
topics Int
ix
          ps :: SmallArray Partition
ps = Topic
t.partitions
          goPartitionInner :: Int -> Maybe ContextualizedErrorCode
goPartitionInner !Int
j = if Int
j Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< SmallArray Partition -> Int
forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray Partition
ps
            then
              let p :: Partition
p = SmallArray Partition -> Int -> Partition
forall a. SmallArray a -> Int -> a
PM.indexSmallArray SmallArray Partition
ps Int
j
               in case Partition
p.errorCode of
                    ErrorCode
ErrorCode.None -> Int -> Maybe ContextualizedErrorCode
goPartitionInner (Int
j Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
                    ErrorCode
e -> ContextualizedErrorCode -> Maybe ContextualizedErrorCode
forall a. a -> Maybe a
Just (Context -> ErrorCode -> ContextualizedErrorCode
ContextualizedErrorCode (Int -> Context -> Context
Index Int
j (Field -> Context -> Context
Field Field
Ctx.Partitions (Int -> Context -> Context
Index Int
ix Context
ctxTopics))) ErrorCode
e)
            else Maybe ContextualizedErrorCode
forall a. Maybe a
Nothing
       in case Int -> Maybe ContextualizedErrorCode
goPartitionInner Int
0 of
            Maybe ContextualizedErrorCode
Nothing -> Int -> Maybe ContextualizedErrorCode
goPartitionOuter (Int
ix Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
            x :: Maybe ContextualizedErrorCode
x@Just{} -> Maybe ContextualizedErrorCode
x
    else Maybe ContextualizedErrorCode
forall a. Maybe a
Nothing

data Response = Response
  { Response -> Int32
throttleTimeMilliseconds :: !Int32
  , Response -> SmallArray Broker
brokers :: !(SmallArray Broker)
  , Response -> Text
clusterId :: !Text
  , Response -> Int32
controllerId :: !Int32
  , Response -> SmallArray Topic
topics :: !(SmallArray Topic)
  , Response -> SmallArray TaggedField
taggedFields :: !(SmallArray TaggedField)
  } deriving stock (Int -> Response -> ShowS
[Response] -> ShowS
Response -> String
(Int -> Response -> ShowS)
-> (Response -> String) -> ([Response] -> ShowS) -> Show Response
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Response -> ShowS
showsPrec :: Int -> Response -> ShowS
$cshow :: Response -> String
show :: Response -> String
$cshowList :: [Response] -> ShowS
showList :: [Response] -> ShowS
Show)

data Broker = Broker
  { Broker -> Int32
nodeId :: !Int32
  , Broker -> Text
host :: !Text
  , Broker -> Word16
port :: !Word16
    -- ^ Even though Kafka has this as a 32-bit signed integer,
    -- I believe that it should only ever be a 16-bit unsigned
    -- integer.
  , Broker -> Text
rack :: !Text
  , Broker -> SmallArray TaggedField
taggedFields :: !(SmallArray TaggedField)
  } deriving stock (Int -> Broker -> ShowS
[Broker] -> ShowS
Broker -> String
(Int -> Broker -> ShowS)
-> (Broker -> String) -> ([Broker] -> ShowS) -> Show Broker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Broker -> ShowS
showsPrec :: Int -> Broker -> ShowS
$cshow :: Broker -> String
show :: Broker -> String
$cshowList :: [Broker] -> ShowS
showList :: [Broker] -> ShowS
Show)

data Topic = Topic
  { Topic -> ErrorCode
errorCode :: !ErrorCode
  , Topic -> Text
name :: !Text
  , Topic -> Word128
id :: {-# UNPACK #-} !Word128
  , Topic -> Bool
internal :: !Bool
  , Topic -> SmallArray Partition
partitions :: !(SmallArray Partition)
  , Topic -> Word32
authorizedOperations :: !Word32
    -- ^ Authorized Operations: a bitfield. The spec has this as a
    -- signed integral type, but that was probably only done because
    -- of limitations with Java.
  , Topic -> SmallArray TaggedField
taggedFields :: !(SmallArray TaggedField)
  } deriving stock (Int -> Topic -> ShowS
[Topic] -> ShowS
Topic -> String
(Int -> Topic -> ShowS)
-> (Topic -> String) -> ([Topic] -> ShowS) -> Show Topic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Topic -> ShowS
showsPrec :: Int -> Topic -> ShowS
$cshow :: Topic -> String
show :: Topic -> String
$cshowList :: [Topic] -> ShowS
showList :: [Topic] -> ShowS
Show)

data Partition = Partition
  { Partition -> ErrorCode
errorCode :: !ErrorCode
  , Partition -> Int32
index :: !Int32
  , Partition -> Int32
leaderId :: !Int32
  , Partition -> Int32
leaderEpoch :: !Int32
  , Partition -> PrimArray Int32
replicaNodes :: !(PrimArray Int32)
  , Partition -> PrimArray Int32
isrNodes :: !(PrimArray Int32)
  , Partition -> PrimArray Int32
offlineReplicas :: !(PrimArray Int32)
  , Partition -> SmallArray TaggedField
taggedFields :: !(SmallArray TaggedField)
  } deriving stock (Int -> Partition -> ShowS
[Partition] -> ShowS
Partition -> String
(Int -> Partition -> ShowS)
-> (Partition -> String)
-> ([Partition] -> ShowS)
-> Show Partition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Partition -> ShowS
showsPrec :: Int -> Partition -> ShowS
$cshow :: Partition -> String
show :: Partition -> String
$cshowList :: [Partition] -> ShowS
showList :: [Partition] -> ShowS
Show)

data Error = Error
  { Error -> Int32
index :: !Int32
  , Error -> Text
message :: !Text
  , Error -> SmallArray TaggedField
taggedFields :: !(SmallArray TaggedField)
  } deriving stock (Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
(Int -> Error -> ShowS)
-> (Error -> String) -> ([Error] -> ShowS) -> Show Error
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Error -> ShowS
showsPrec :: Int -> Error -> ShowS
$cshow :: Error -> String
show :: Error -> String
$cshowList :: [Error] -> ShowS
showList :: [Error] -> ShowS
Show)

decodeHeaded :: Bytes -> Either Context (Header.Headed Response)
decodeHeaded :: Bytes -> Either Context (Headed Response)
decodeHeaded !Bytes
b = (forall s. Parser Context s (Headed Response))
-> Bytes -> Either Context (Headed Response)
forall e a. (forall s. Parser e s a) -> Bytes -> Either e a
Parser.parseBytesEither
  ((Header -> Response -> Headed Response)
-> Parser Context s Header
-> Parser Context s Response
-> Parser Context s (Headed Response)
forall a b c.
(a -> b -> c)
-> Parser Context s a -> Parser Context s b -> Parser Context s c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Header -> Response -> Headed Response
forall a. Header -> a -> Headed a
Header.Headed
    (Context -> Parser Context s Header
forall s. Context -> Parser Context s Header
Header.parser Context
Ctx.Top)
    (Context -> Parser Context s Response
forall s. Context -> Parser Context s Response
parser Context
Ctx.Top Parser Context s Response
-> Parser Context s () -> Parser Context s Response
forall a b.
Parser Context s a -> Parser Context s b -> Parser Context s a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Context -> Parser Context s ()
forall e s. e -> Parser e s ()
Parser.endOfInput Context
Ctx.End)
  ) Bytes
b

decode :: Bytes -> Either Context Response
decode :: Bytes -> Either Context Response
decode !Bytes
b = (forall s. Parser Context s Response)
-> Bytes -> Either Context Response
forall e a. (forall s. Parser e s a) -> Bytes -> Either e a
Parser.parseBytesEither (Context -> Parser Context s Response
forall s. Context -> Parser Context s Response
parser Context
Ctx.Top Parser Context s Response
-> Parser Context s () -> Parser Context s Response
forall a b.
Parser Context s a -> Parser Context s b -> Parser Context s a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Context -> Parser Context s ()
forall e s. e -> Parser e s ()
Parser.endOfInput Context
Ctx.End) Bytes
b

parser :: Context -> Parser Context s Response
parser :: forall s. Context -> Parser Context s Response
parser Context
ctx = do
  Int32
throttleTimeMilliseconds <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.ThrottleTimeMilliseconds Context
ctx)
  SmallArray Broker
brokers <- (Context -> Parser Context s Broker)
-> Context -> Parser Context s (SmallArray Broker)
forall s a.
(Context -> Parser Context s a)
-> Context -> Parser Context s (SmallArray a)
Kafka.Parser.compactArray Context -> Parser Context s Broker
forall s. Context -> Parser Context s Broker
parserBroker (Field -> Context -> Context
Ctx.Field Field
Ctx.Brokers Context
ctx)
  Text
clusterId <- Context -> Parser Context s Text
forall s. Context -> Parser Context s Text
Kafka.Parser.compactString (Field -> Context -> Context
Ctx.Field Field
Ctx.ClusterId Context
ctx)
  Int32
controllerId <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.ControllerId Context
ctx)
  SmallArray Topic
topics <- (Context -> Parser Context s Topic)
-> Context -> Parser Context s (SmallArray Topic)
forall s a.
(Context -> Parser Context s a)
-> Context -> Parser Context s (SmallArray a)
Kafka.Parser.compactArray Context -> Parser Context s Topic
forall s. Context -> Parser Context s Topic
parserTopic (Field -> Context -> Context
Ctx.Field Field
Ctx.Topics Context
ctx)
  SmallArray TaggedField
taggedFields <- Context -> Parser Context s (SmallArray TaggedField)
forall s. Context -> Parser Context s (SmallArray TaggedField)
TaggedField.parserMany (Field -> Context -> Context
Ctx.Field Field
Ctx.TagBuffer Context
ctx)
  Response -> Parser Context s Response
forall a. a -> Parser Context s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Response{Int32
$sel:throttleTimeMilliseconds:Response :: Int32
throttleTimeMilliseconds :: Int32
throttleTimeMilliseconds,SmallArray Broker
$sel:brokers:Response :: SmallArray Broker
brokers :: SmallArray Broker
brokers,Text
$sel:clusterId:Response :: Text
clusterId :: Text
clusterId,Int32
$sel:controllerId:Response :: Int32
controllerId :: Int32
controllerId,SmallArray Topic
$sel:topics:Response :: SmallArray Topic
topics :: SmallArray Topic
topics,SmallArray TaggedField
$sel:taggedFields:Response :: SmallArray TaggedField
taggedFields :: SmallArray TaggedField
taggedFields}

parserBroker :: Context -> Parser Context s Broker
parserBroker :: forall s. Context -> Parser Context s Broker
parserBroker Context
ctx = do
  Int32
nodeId <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.NodeId Context
ctx)
  Text
host <- Context -> Parser Context s Text
forall s. Context -> Parser Context s Text
Kafka.Parser.compactString (Field -> Context -> Context
Ctx.Field Field
Ctx.Host Context
ctx)
  Int32
port32 <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.Port Context
ctx)
  Word16
port :: Word16 <- if Int32
port32 Int32 -> Int32 -> Bool
forall a. Ord a => a -> a -> Bool
< Int32
0 Bool -> Bool -> Bool
|| Int32
port32 Int32 -> Int32 -> Bool
forall a. Ord a => a -> a -> Bool
> Int32
65535
    then Context -> Parser Context s Word16
forall e s a. e -> Parser e s a
Kafka.Parser.fail (Field -> Context -> Context
Ctx.Field Field
Ctx.Port Context
ctx)
    else Word16 -> Parser Context s Word16
forall a. a -> Parser Context s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word16 -> Parser Context s Word16)
-> Word16 -> Parser Context s Word16
forall a b. (a -> b) -> a -> b
$! forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int32 @Word16 Int32
port32
  Text
rack <- Context -> Parser Context s Text
forall s. Context -> Parser Context s Text
Kafka.Parser.compactString (Field -> Context -> Context
Ctx.Field Field
Ctx.Rack Context
ctx)
  SmallArray TaggedField
taggedFields <- Context -> Parser Context s (SmallArray TaggedField)
forall s. Context -> Parser Context s (SmallArray TaggedField)
TaggedField.parserMany (Field -> Context -> Context
Ctx.Field Field
Ctx.TagBuffer Context
ctx)
  Broker -> Parser Context s Broker
forall a. a -> Parser Context s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Broker{Int32
$sel:nodeId:Broker :: Int32
nodeId :: Int32
nodeId,Text
$sel:host:Broker :: Text
host :: Text
host,Word16
$sel:port:Broker :: Word16
port :: Word16
port,Text
$sel:rack:Broker :: Text
rack :: Text
rack,SmallArray TaggedField
$sel:taggedFields:Broker :: SmallArray TaggedField
taggedFields :: SmallArray TaggedField
taggedFields}

parserTopic :: Context -> Parser Context s Topic
parserTopic :: forall s. Context -> Parser Context s Topic
parserTopic Context
ctx = do
  ErrorCode
errorCode <- Context -> Parser Context s ErrorCode
forall e s. e -> Parser e s ErrorCode
Kafka.Parser.errorCode (Field -> Context -> Context
Ctx.Field Field
Ctx.ErrorCode Context
ctx)
  Text
name <- Context -> Parser Context s Text
forall s. Context -> Parser Context s Text
Kafka.Parser.compactString (Field -> Context -> Context
Ctx.Field Field
Ctx.Name Context
ctx)
  Word128
id <- Context -> Parser Context s Word128
forall e s. e -> Parser e s Word128
Kafka.Parser.word128 (Field -> Context -> Context
Ctx.Field Field
Ctx.Id Context
ctx)
  Bool
internal <- Context -> Parser Context s Bool
forall s. Context -> Parser Context s Bool
Kafka.Parser.boolean (Field -> Context -> Context
Ctx.Field Field
Ctx.Internal Context
ctx)
  SmallArray Partition
partitions <- (Context -> Parser Context s Partition)
-> Context -> Parser Context s (SmallArray Partition)
forall s a.
(Context -> Parser Context s a)
-> Context -> Parser Context s (SmallArray a)
Kafka.Parser.compactArray Context -> Parser Context s Partition
forall s. Context -> Parser Context s Partition
parserPartition
    (Field -> Context -> Context
Ctx.Field Field
Ctx.Partitions Context
ctx)
  Word32
authorizedOperations <- Context -> Parser Context s Word32
forall e s. e -> Parser e s Word32
Kafka.Parser.word32 (Field -> Context -> Context
Ctx.Field Field
Ctx.AuthorizedOperations Context
ctx)
  SmallArray TaggedField
taggedFields <- Context -> Parser Context s (SmallArray TaggedField)
forall s. Context -> Parser Context s (SmallArray TaggedField)
TaggedField.parserMany (Field -> Context -> Context
Ctx.Field Field
Ctx.TagBuffer Context
ctx)
  Topic -> Parser Context s Topic
forall a. a -> Parser Context s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Topic{ErrorCode
$sel:errorCode:Topic :: ErrorCode
errorCode :: ErrorCode
errorCode,Text
$sel:name:Topic :: Text
name :: Text
name,Word128
$sel:id:Topic :: Word128
id :: Word128
id,Bool
$sel:internal:Topic :: Bool
internal :: Bool
internal,SmallArray Partition
$sel:partitions:Topic :: SmallArray Partition
partitions :: SmallArray Partition
partitions,Word32
$sel:authorizedOperations:Topic :: Word32
authorizedOperations :: Word32
authorizedOperations,SmallArray TaggedField
$sel:taggedFields:Topic :: SmallArray TaggedField
taggedFields :: SmallArray TaggedField
taggedFields}

parserPartition :: Context -> Parser Context s Partition
parserPartition :: forall s. Context -> Parser Context s Partition
parserPartition Context
ctx = do
  ErrorCode
errorCode <- Context -> Parser Context s ErrorCode
forall e s. e -> Parser e s ErrorCode
Kafka.Parser.errorCode (Field -> Context -> Context
Ctx.Field Field
Ctx.ErrorCode Context
ctx)
  Int32
index <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.Ix Context
ctx)
  Int32
leaderId <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.LeaderId Context
ctx)
  Int32
leaderEpoch <- Context -> Parser Context s Int32
forall e s. e -> Parser e s Int32
Kafka.Parser.int32 (Field -> Context -> Context
Ctx.Field Field
Ctx.LeaderEpoch Context
ctx)
  PrimArray Int32
replicaNodes <- Context -> Parser Context s (PrimArray Int32)
forall s. Context -> Parser Context s (PrimArray Int32)
Kafka.Parser.compactInt32Array (Field -> Context -> Context
Ctx.Field Field
Ctx.ReplicaNodes Context
ctx)
  PrimArray Int32
isrNodes <- Context -> Parser Context s (PrimArray Int32)
forall s. Context -> Parser Context s (PrimArray Int32)
Kafka.Parser.compactInt32Array (Field -> Context -> Context
Ctx.Field Field
Ctx.IsrNodes Context
ctx)
  PrimArray Int32
offlineReplicas <- Context -> Parser Context s (PrimArray Int32)
forall s. Context -> Parser Context s (PrimArray Int32)
Kafka.Parser.compactInt32Array (Field -> Context -> Context
Ctx.Field Field
Ctx.OfflineReplicas Context
ctx)
  SmallArray TaggedField
taggedFields <- Context -> Parser Context s (SmallArray TaggedField)
forall s. Context -> Parser Context s (SmallArray TaggedField)
TaggedField.parserMany (Field -> Context -> Context
Ctx.Field Field
Ctx.TagBuffer Context
ctx)
  Partition -> Parser Context s Partition
forall a. a -> Parser Context s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Partition
    { ErrorCode
$sel:errorCode:Partition :: ErrorCode
errorCode :: ErrorCode
errorCode
    , Int32
$sel:index:Partition :: Int32
index :: Int32
index
    , Int32
$sel:leaderId:Partition :: Int32
leaderId :: Int32
leaderId
    , Int32
$sel:leaderEpoch:Partition :: Int32
leaderEpoch :: Int32
leaderEpoch
    , PrimArray Int32
$sel:replicaNodes:Partition :: PrimArray Int32
replicaNodes :: PrimArray Int32
replicaNodes
    , PrimArray Int32
$sel:isrNodes:Partition :: PrimArray Int32
isrNodes :: PrimArray Int32
isrNodes
    , PrimArray Int32
$sel:offlineReplicas:Partition :: PrimArray Int32
offlineReplicas :: PrimArray Int32
offlineReplicas
    , SmallArray TaggedField
$sel:taggedFields:Partition :: SmallArray TaggedField
taggedFields :: SmallArray TaggedField
taggedFields
    }