Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Multiplexed subscription poller threads; see Hasura.GraphQL.Execute.Subscription for details.
Synopsis
- data SubscriberId
- newSubscriberId :: IO SubscriberId
- data SubscriberMetadata
- 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 PollerResponseState
- data Cohort streamCursorVars = Cohort {
- _cCohortId :: CohortId
- _cPreviousResponse :: TVar (Maybe ResponseHash)
- _cExistingSubscribers :: SubscriberMap
- _cNewSubscribers :: SubscriberMap
- _cStreamCursorVariables :: streamCursorVars
- newtype BatchId = BatchId {
- _unBatchId :: Int
- newtype ResponseHash = ResponseHash {}
- mkRespHash :: ByteString -> ResponseHash
- type CohortKey = CohortVariables
- type CohortMap streamCursor = TMap CohortKey (Cohort streamCursor)
- data CohortSnapshot = CohortSnapshot {}
- data Poller streamCursor = Poller {}
- data PollerIOState = PollerIOState {}
- data PollerKey b = PollerKey {}
- newtype BackendPollerKey = BackendPollerKey {}
- type PollerMap streamCursor = Map BackendPollerKey (Poller streamCursor)
- dumpPollerMap :: Bool -> PollerMap streamCursor -> IO Value
- newtype PollerId = PollerId {
- unPollerId :: UUID
- data SubscriberExecutionDetails = SubscriberExecutionDetails {}
- data CohortExecutionDetails = CohortExecutionDetails {}
- data BatchExecutionDetails = BatchExecutionDetails {}
- data PollDetailsError = PollDetailsError {}
- data PollDetails = PollDetails {
- _pdPollerId :: PollerId
- _pdKind :: SubscriptionType
- _pdGeneratedSql :: Text
- _pdSnapshotTime :: DiffTime
- _pdBatches :: [BatchExecutionDetails]
- _pdTotalTime :: DiffTime
- _pdLiveQueryOptions :: SubscriptionsOptions
- _pdSource :: SourceName
- _pdRole :: RoleName
- _pdParameterizedQueryHash :: ParameterizedQueryHash
- _pdLogLevel :: LogLevel
- _pdErrors :: Maybe [PollDetailsError]
- type SubscriptionPostPollHook = PollDetails -> IO ()
- defaultSubscriptionPostPollHook :: Logger Hasura -> SubscriptionPostPollHook
Documentation
data SubscriberId Source #
Instances
data 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
Instances
ToJSON SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toJSON :: SubscriberMetadata -> Value Source # toEncoding :: SubscriberMetadata -> Encoding Source # toJSONList :: [SubscriberMetadata] -> Value Source # toEncodingList :: [SubscriberMetadata] -> Encoding Source # | |
Show SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> SubscriberMetadata -> ShowS # show :: SubscriberMetadata -> String # showList :: [SubscriberMetadata] -> ShowS # | |
Eq SubscriberMetadata Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: SubscriberMetadata -> SubscriberMetadata -> Bool # (/=) :: SubscriberMetadata -> SubscriberMetadata -> Bool # |
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 PollerResponseState Source #
Instances
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 | |
|
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].
Instances
ToJSON ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toJSON :: ResponseHash -> Value Source # toEncoding :: ResponseHash -> Encoding Source # toJSONList :: [ResponseHash] -> Value Source # toEncodingList :: [ResponseHash] -> Encoding Source # | |
Show ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> ResponseHash -> ShowS # show :: ResponseHash -> String # showList :: [ResponseHash] -> ShowS # | |
Eq ResponseHash Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: ResponseHash -> ResponseHash -> Bool # (/=) :: ResponseHash -> ResponseHash -> Bool # |
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.
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 | |
|
data PollerIOState Source #
Instances
newtype BackendPollerKey Source #
Instances
Show BackendPollerKey Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> BackendPollerKey -> ShowS # show :: BackendPollerKey -> String # showList :: [BackendPollerKey] -> ShowS # | |
Eq BackendPollerKey Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: BackendPollerKey -> BackendPollerKey -> Bool # (/=) :: BackendPollerKey -> BackendPollerKey -> Bool # | |
Hashable BackendPollerKey Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common hashWithSalt :: Int -> BackendPollerKey -> Int Source # hash :: BackendPollerKey -> Int Source # |
dumpPollerMap :: Bool -> PollerMap streamCursor -> IO Value Source #
For dev debugging, output subject to change.
An ID to track unique Poller
s, so that we can gather metrics about each
poller
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
Show BatchExecutionDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> BatchExecutionDetails -> ShowS # show :: BatchExecutionDetails -> String # showList :: [BatchExecutionDetails] -> ShowS # | |
Eq BatchExecutionDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: BatchExecutionDetails -> BatchExecutionDetails -> Bool # (/=) :: BatchExecutionDetails -> BatchExecutionDetails -> Bool # |
data PollDetailsError Source #
Instances
ToJSON PollDetailsError Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toJSON :: PollDetailsError -> Value Source # toEncoding :: PollDetailsError -> Encoding Source # toJSONList :: [PollDetailsError] -> Value Source # toEncodingList :: [PollDetailsError] -> Encoding Source # | |
Show PollDetailsError Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> PollDetailsError -> ShowS # show :: PollDetailsError -> String # showList :: [PollDetailsError] -> ShowS # | |
Eq PollDetailsError Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: PollDetailsError -> PollDetailsError -> Bool # (/=) :: PollDetailsError -> PollDetailsError -> Bool # |
data PollDetails Source #
PollDetails | |
|
Instances
Show PollDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common showsPrec :: Int -> PollDetails -> ShowS # show :: PollDetails -> String # showList :: [PollDetails] -> ShowS # | |
Eq PollDetails Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common (==) :: PollDetails -> PollDetails -> Bool # (/=) :: PollDetails -> PollDetails -> Bool # | |
ToEngineLog PollDetails Hasura Source # | |
Defined in Hasura.GraphQL.Execute.Subscription.Poll.Common toEngineLog :: PollDetails -> (LogLevel, EngineLogType Hasura, Value) Source # |
type SubscriptionPostPollHook = PollDetails -> IO () Source #