Safe Haskell | None |
---|---|
Language | Haskell2010 |
Multiplexed subscription poller threads; see Hasura.GraphQL.Execute.Subscription for details.
Synopsis
- newtype SubscriberId = SubscriberId {
- unSubscriberId :: UUID
- newSubscriberId :: IO SubscriberId
- newtype SubscriberMetadata = SubscriberMetadata {
- unSubscriberMetadata :: Value
- mkSubscriberMetadata :: WSId -> OperationId -> Maybe OperationName -> RequestId -> SubscriberMetadata
- data Subscriber = Subscriber {}
- data SubscriptionMetadata = SubscriptionMetadata {}
- data SubscriptionResponse = SubscriptionResponse {}
- type SubscriptionGQResponse = GQResult SubscriptionResponse
- type OnChange = SubscriptionGQResponse -> IO ()
- type SubscriberMap = TMap SubscriberId Subscriber
- data Cohort streamCursorVars = Cohort {
- _cCohortId :: !CohortId
- _cPreviousResponse :: !(TVar (Maybe ResponseHash))
- _cExistingSubscribers :: !SubscriberMap
- _cNewSubscribers :: !SubscriberMap
- _cStreamCursorVariables :: !streamCursorVars
- newtype BatchId = BatchId {
- _unBatchId :: Int
- newtype ResponseHash = ResponseHash {
- unResponseHash :: Digest Blake2b_256
- mkRespHash :: ByteString -> ResponseHash
- type CohortKey = CohortVariables
- type CohortMap streamCursor = TMap CohortKey (Cohort streamCursor)
- dumpCohortMap :: CohortMap streamCursor -> IO Value
- data CohortSnapshot = CohortSnapshot {}
- data Poller streamCursor = Poller {
- _pCohorts :: !(CohortMap streamCursor)
- _pIOState :: !(TMVar PollerIOState)
- data PollerIOState = PollerIOState {}
- data PollerKey = PollerKey {
- _lgSource :: !SourceName
- _lgRole :: !RoleName
- _lgQuery :: !Text
- type PollerMap streamCursor = Map PollerKey (Poller streamCursor)
- dumpPollerMap :: Bool -> PollerMap streamCursor -> IO Value
- newtype PollerId = PollerId {
- unPollerId :: UUID
- data SubscriberExecutionDetails = SubscriberExecutionDetails {}
- data CohortExecutionDetails = CohortExecutionDetails {}
- data BatchExecutionDetails = BatchExecutionDetails {}
- batchExecutionDetailMinimal :: BatchExecutionDetails -> Value
- data PollDetails = PollDetails {}
- pollDetailMinimal :: PollDetails -> Value
- type SubscriptionPostPollHook = PollDetails -> IO ()
- defaultSubscriptionPostPollHook :: Logger Hasura -> SubscriptionPostPollHook
Documentation
newtype SubscriberId Source #
SubscriberId | |
|
Instances
newtype SubscriberMetadata Source #
Allows a user of the live query subsystem (currently websocket transport) to attach arbitrary metadata about a subscriber. This information is available as part of Subscriber in CohortExecutionDetails and can be logged by customizing in pollerlog
SubscriberMetadata | |
|
Instances
Eq SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: SubscriberMetadata -> SubscriberMetadata -> Bool # (/=) :: SubscriberMetadata -> SubscriberMetadata -> Bool # | |
Show SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> SubscriberMetadata -> ShowS # show :: SubscriberMetadata -> String # showList :: [SubscriberMetadata] -> ShowS # | |
ToJSON SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toJSON :: SubscriberMetadata -> Value toEncoding :: SubscriberMetadata -> Encoding toJSONList :: [SubscriberMetadata] -> Value toEncodingList :: [SubscriberMetadata] -> Encoding |
mkSubscriberMetadata :: WSId -> OperationId -> Maybe OperationName -> RequestId -> SubscriberMetadata Source #
data Subscriber Source #
data SubscriptionMetadata Source #
Subscription onChange metadata, used for adding more extra analytics data
data SubscriptionResponse Source #
type OnChange = SubscriptionGQResponse -> IO () Source #
type SubscriberMap = TMap SubscriberId Subscriber Source #
data Cohort streamCursorVars Source #
A batched group of Subscriber
s who are not only listening to the same query but also have
identical session and query variables. Each result pushed to a Cohort
is forwarded along to
each of its Subscriber
s.
In SQL, each Cohort
corresponds to a single row in the laterally-joined _subs
table (and
therefore a single row in the query result).
See also CohortMap
.
Cohort | |
|
The BatchId
is a number based ID to uniquely identify a batch in a single poll and
it's used to identify the batch to which a cohort belongs to.
BatchId | |
|
Instances
Eq BatchId Source # | |
Show BatchId Source # | |
ToJSON BatchId Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toEncoding :: BatchId -> Encoding toJSONList :: [BatchId] -> Value toEncodingList :: [BatchId] -> Encoding |
newtype ResponseHash Source #
A hash used to determine if the result changed without having to keep the entire result in memory. Using a cryptographic hash ensures that a hash collision is almost impossible: with 256 bits, even if a subscription changes once per second for an entire year, the probability of a hash collision is ~4.294417×10-63. See Note [Blake2b faster than SHA-256].
ResponseHash | |
|
Instances
Eq ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: ResponseHash -> ResponseHash -> Bool # (/=) :: ResponseHash -> ResponseHash -> Bool # | |
Show ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> ResponseHash -> ShowS # show :: ResponseHash -> String # showList :: [ResponseHash] -> ShowS # | |
ToJSON ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toJSON :: ResponseHash -> Value toEncoding :: ResponseHash -> Encoding toJSONList :: [ResponseHash] -> Value toEncodingList :: [ResponseHash] -> Encoding |
mkRespHash :: ByteString -> ResponseHash Source #
type CohortKey = CohortVariables Source #
A key we use to determine if two Subscriber
s belong in the same Cohort
(assuming they already meet the criteria to be in the same Poller
). Note
the distinction between this and CohortId
; the latter is a completely
synthetic key used only to identify the cohort in the generated SQL query.
type CohortMap streamCursor = TMap CohortKey (Cohort streamCursor) Source #
This has the invariant, maintained in removeLiveQuery
, that it contains
no Cohort
with zero total (existing + new) subscribers.
dumpCohortMap :: CohortMap streamCursor -> IO Value Source #
data CohortSnapshot Source #
data Poller streamCursor Source #
A unique, multiplexed query. Each Poller
has its own polling thread that
periodically polls Postgres and pushes results to each of its listening
Cohort
s.
In SQL, an Poller
corresponds to a single, multiplexed query, though in
practice, Poller
s with large numbers of Cohort
s are batched into
multiple concurrent queries for performance reasons.
Poller | |
|
Instances
Eq PollerKey Source # | |
Show PollerKey Source # | |
Generic PollerKey Source # | |
Hashable PollerKey Source # | |
ToJSON PollerKey Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toEncoding :: PollerKey -> Encoding toJSONList :: [PollerKey] -> Value toEncodingList :: [PollerKey] -> Encoding | |
type Rep PollerKey Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common type Rep PollerKey = D1 ('MetaData "PollerKey" "Hasura.GraphQL.Execute.Subscription.Poll.Common" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "PollerKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "_lgSource") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SourceName) :*: (S1 ('MetaSel ('Just "_lgRole") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RoleName) :*: S1 ('MetaSel ('Just "_lgQuery") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) |
An ID to track unique Poller
s, so that we can gather metrics about each
poller
PollerId | |
|
data SubscriberExecutionDetails Source #
Instances
data CohortExecutionDetails Source #
Execution information related to a cohort on a poll cycle
CohortExecutionDetails | |
|
Instances
data BatchExecutionDetails Source #
Execution information related to a single batched execution
BatchExecutionDetails | |
|
Instances
Eq BatchExecutionDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: BatchExecutionDetails -> BatchExecutionDetails -> Bool # (/=) :: BatchExecutionDetails -> BatchExecutionDetails -> Bool # | |
Show BatchExecutionDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> BatchExecutionDetails -> ShowS # show :: BatchExecutionDetails -> String # showList :: [BatchExecutionDetails] -> ShowS # |
batchExecutionDetailMinimal :: BatchExecutionDetails -> Value Source #
see Note [Minimal LiveQuery Poller Log]
data PollDetails Source #
PollDetails | |
|
Instances
Eq PollDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: PollDetails -> PollDetails -> Bool # (/=) :: PollDetails -> PollDetails -> Bool # | |
Show PollDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> PollDetails -> ShowS # show :: PollDetails -> String # showList :: [PollDetails] -> ShowS # | |
ToEngineLog PollDetails Hasura Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toEngineLog :: PollDetails -> (LogLevel, EngineLogType Hasura, Value) Source # |
pollDetailMinimal :: PollDetails -> Value Source #
see Note [Minimal LiveQuery Poller Log]
type SubscriptionPostPollHook = PollDetails -> IO () Source #