graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.GraphQL.Execute.Subscription.State

Description

Top-level management of subscription poller threads. The implementation of the polling itself is in Hasura.GraphQL.Execute.Subscription.Poll. See Hasura.GraphQL.Execute.Subscription for high-level details.

Synopsis

Documentation

data SubscriptionsState Source #

The top-level datatype that holds the state for all active subscriptions.

NOTE!: This must be kept consistent with a websocket connection's OperationMap, in onClose and onStart.

data SubscriberDetails a Source #

SubscriberDetails contains the data required to locate a subscriber in the correct cohort within the correct poller in the operation map.

Instances

Instances details
Show a => Show (SubscriberDetails a) Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Subscription.State

type StreamingSubscriberDetails = SubscriberDetails (CohortKey, TVar CursorVariableValues) Source #

The CohortKey contains the variables with which the subscription was started and which will remain unchanged. The second type contains the mutable reference through which we can get the latest value of the cursor and using both the CohortKey and the latest cursor value, we locate the subscriber in the operation map to find its details and then stop it.

findPollerForSubscriber :: Subscriber -> CohortId -> PollerMap streamCursorVars -> PollerKey -> CohortKey -> (Subscriber -> Cohort streamCursorVars -> STM streamCursorVars) -> (Subscriber -> CohortId -> Poller streamCursorVars -> STM streamCursorVars) -> STM (Maybe (Poller streamCursorVars), streamCursorVars) Source #

findPollerForSubscriber places a subscriber in the correct poller. If the poller doesn't exist then we create one otherwise we return the existing one.

addLiveQuery Source #

Arguments

:: forall b. BackendTransport b 
=> Logger Hasura 
-> ServerMetrics 
-> PrometheusMetrics 
-> SubscriberMetadata 
-> SubscriptionsState 
-> SourceName 
-> ParameterizedQueryHash 
-> Maybe OperationName

operation name of the query

-> RequestId 
-> SubscriptionQueryPlan b (MultiplexedQuery b) 
-> OnChange

the action to be executed when result changes

-> IO LiveQuerySubscriberDetails 

Fork a thread handling a regular (live query) subscription

addStreamSubscriptionQuery Source #

Arguments

:: forall b. BackendTransport b 
=> Logger Hasura 
-> ServerMetrics 
-> PrometheusMetrics 
-> SubscriberMetadata 
-> SubscriptionsState 
-> SourceName 
-> ParameterizedQueryHash 
-> Maybe OperationName

operation name of the query

-> RequestId 
-> Name

root field name

-> SubscriptionQueryPlan b (MultiplexedQuery b) 
-> OnChange

the action to be executed when result changes

-> IO StreamingSubscriberDetails 

Fork a thread handling a streaming subscription

data LiveAsyncActionQueryOnSource Source #

An async action query whose relationships are refered to table in a source. We need to generate an SQL statement with the action response and execute it in the source database so as to fetch response joined with relationship rows. For more details see Note [Resolving async action query]

Constructors

LiveAsyncActionQueryOnSource 

Fields

data LiveAsyncActionQueryWithNoRelationships Source #

Constructors

LiveAsyncActionQueryWithNoRelationships 

Fields

data AsyncActionQueryLive Source #

Constructors

AsyncActionQueryLive 

Fields

type AsyncActionSubscriptionState = TMap OperationId AsyncActionQueryLive Source #

A share-able state map which stores an async action live query with it's subscription operation id