Class ContextPropagationHelper

java.lang.Object
org.springframework.graphql.execution.ContextPropagationHelper
Direct Known Subclasses:
ContextSnapshotFactoryHelper

public abstract class ContextPropagationHelper extends Object
Helper for propagating context values from and to Reactor and GraphQL contexts.
Since:
1.3.5
Author:
Rossen Stoyanchev, Brian Clozel
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> reactor.core.publisher.Flux<T>
    bindCancelFrom(reactor.core.publisher.Flux<T> source, GraphQLContext context)
    Bind the source Flux to the publisher from the given GraphQLContext.
    static <T> reactor.core.publisher.Mono<T>
    bindCancelFrom(reactor.core.publisher.Mono<T> source, GraphQLContext context)
    Bind the source Mono to the publisher from the given GraphQLContext.
    static io.micrometer.context.ContextSnapshot
    Shortcut to obtain the ContextSnapshotFactory instance, and to capture from the given GraphQLContext.
    static io.micrometer.context.ContextSnapshot
    captureFrom(reactor.util.context.ContextView contextView)
    Shortcut to obtain the ContextSnapshotFactory instance, and to capture from the given ContextView.
    static reactor.core.publisher.Sinks.Empty<Void>
    Create a publisher and store it into the given GraphQLContext.
    static io.micrometer.context.ContextSnapshotFactory
    Access the ContextSnapshotFactory from the given GraphQLContext or return a shared, static instance.
    static io.micrometer.context.ContextSnapshotFactory
    getInstance(reactor.util.context.ContextView contextView)
    Access the ContextSnapshotFactory from the given ContextView or return a shared, static instance.
    static void
    saveInstance(io.micrometer.context.ContextSnapshotFactory factory, GraphQLContext context)
    Save the ContextSnapshotFactory in the given Context.
    static reactor.util.context.Context
    saveInstance(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context)
    Save the ContextSnapshotFactory in the given Context.
    static io.micrometer.context.ContextSnapshotFactory
    selectInstance(io.micrometer.context.ContextSnapshotFactory factory)
    Select a ContextSnapshotFactory instance to use, either the one passed in if it is not null, or a shared, static instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContextPropagationHelper

      public ContextPropagationHelper()
  • Method Details

    • selectInstance

      public static io.micrometer.context.ContextSnapshotFactory selectInstance(@Nullable io.micrometer.context.ContextSnapshotFactory factory)
      Select a ContextSnapshotFactory instance to use, either the one passed in if it is not null, or a shared, static instance.
      Parameters:
      factory - the candidate factory instance to use if not null
      Returns:
      the instance to use
    • saveInstance

      public static reactor.util.context.Context saveInstance(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context)
      Save the ContextSnapshotFactory in the given Context.
      Parameters:
      factory - the instance to save
      context - the context to save the instance to
      Returns:
      a new context with the saved instance
    • saveInstance

      public static void saveInstance(io.micrometer.context.ContextSnapshotFactory factory, GraphQLContext context)
      Save the ContextSnapshotFactory in the given Context.
      Parameters:
      factory - the instance to save
      context - the context to save the instance to
    • getInstance

      public static io.micrometer.context.ContextSnapshotFactory getInstance(reactor.util.context.ContextView contextView)
      Access the ContextSnapshotFactory from the given ContextView or return a shared, static instance.
      Parameters:
      contextView - the context where the instance is saved
      Returns:
      the instance to use
    • getInstance

      public static io.micrometer.context.ContextSnapshotFactory getInstance(GraphQLContext context)
      Access the ContextSnapshotFactory from the given GraphQLContext or return a shared, static instance.
      Parameters:
      context - the context where the instance is saved
      Returns:
      the instance to use
    • captureFrom

      public static io.micrometer.context.ContextSnapshot captureFrom(reactor.util.context.ContextView contextView)
      Shortcut to obtain the ContextSnapshotFactory instance, and to capture from the given ContextView.
      Parameters:
      contextView - the context to capture from
      Returns:
      a snapshot from the capture
    • captureFrom

      public static io.micrometer.context.ContextSnapshot captureFrom(GraphQLContext context)
      Shortcut to obtain the ContextSnapshotFactory instance, and to capture from the given GraphQLContext.
      Parameters:
      context - the context to capture from
      Returns:
      a snapshot from the capture
    • createCancelPublisher

      public static reactor.core.publisher.Sinks.Empty<Void> createCancelPublisher(GraphQLContext context)
      Create a publisher and store it into the given GraphQLContext. This publisher can then be used to propagate cancel signals to upstream publishers.
      Parameters:
      context - the current GraphQL context
      Since:
      1.3.5
    • bindCancelFrom

      public static <T> reactor.core.publisher.Mono<T> bindCancelFrom(reactor.core.publisher.Mono<T> source, GraphQLContext context)
      Bind the source Mono to the publisher from the given GraphQLContext. The returned Mono will be cancelled when this publisher completes. Subscribers must use the returned Mono instance.
      Type Parameters:
      T - the type of published elements
      Parameters:
      source - the source Mono
      context - the current GraphQL context
      Returns:
      the new Mono that will be cancelled when notified
      Since:
      1.3.5
    • bindCancelFrom

      public static <T> reactor.core.publisher.Flux<T> bindCancelFrom(reactor.core.publisher.Flux<T> source, GraphQLContext context)
      Bind the source Flux to the publisher from the given GraphQLContext. The returned Flux will be cancelled when this publisher completes. Subscribers must use the returned Mono instance.
      Type Parameters:
      T - the type of published elements
      Parameters:
      source - the source Mono
      context - the current GraphQL context
      Returns:
      the new Mono that will be cancelled when notified
      Since:
      1.3.5