packages feed

raft-consensus-0.2.0.0: src/Distributed/Consensus/Raft/Domain/Client.hs

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}

module Distributed.Consensus.Raft.Domain.Client
  ( SessionId (..),
    SequenceNum,
    ClientRequestId (..),
    ClientRequest,
    ClientResponse,
  )
where

import Data.Binary (Binary)
import Distributed.Consensus.Raft.Domain (SequenceNum, SessionId (..))
import Distributed.Consensus.Raft.Messaging (Request (..), Response (..))
import GHC.Generics (Generic)

-- | Client-sourced request ID. This allows to correlate multiple client
-- side-responses.
data ClientRequestId
  = ClientRequestId
      SessionId
      SequenceNum
  deriving stock (Generic, Eq, Ord, Show)

instance Binary ClientRequestId

type ClientRequest entry node =
  Request
    ClientRequestId
    node
    entry

type ClientResponse node result = Response ClientRequestId node result