Interface StateRequest


public interface StateRequest
Variant state request, as returned by Session.targetForState(State). Exposes a set of methods supporting client's decision which code path to undertake. Each state request must be completed with either commit(Object) or fail(Object) before this session can target another state.
Since:
0.6
  • Method Details

    • getSession

      Session getSession()
      The Variant session which created with this request by calling Session.targetForState(State).
      Returns:
      An object of type Session.
      Since:
      0.6
    • getState

      State getState()
      The target State of this request, which was passed to Session.targetForState(State).
      Returns:
      An object of type State.
      Since:
      0.6
    • getStatus

      StateRequest.Status getStatus()
      The current status of this state request.
      Since:
      0.9
    • getStateParameters

      Map<String,String> getStateParameters()
      The resolved state parameters as an immutable map. In case of trivial resolution, resolved state parameters are the ones declared at the state level, if any. In the case of non-trivial resolution, the parameters declared at the StateVariant level override the likely-named state parameters declared at the state level.
      Returns:
      Immutable map keyed by parameter names.
      Since:
      0.7
    • getLiveExperiences

      Set<Experiment.Experience> getLiveExperiences()
      All of this session's live experiences on this state. An experience is live if the containing experiment is online, is instrumented on this state, and the session has been targeted for this experience.
      Returns:
      Set of Experiment.Experience object.
      Since:
      0.6
    • getLiveExperience

      Optional<Experiment.Experience> getLiveExperience(Experiment experiment)
      The live experience in a given experiment, if any. See getLiveExperiences() for definition of a live experience.
      Parameters:
      experiment - Experiment of interest.
      Returns:
      An Optional, containing the live experience in the given experiment, or empty if none.
      Since:
      0.6
    • getLiveExperience

      default Optional<Experiment.Experience> getLiveExperience(String experimentName)

      The live experience in a given experiment, by experiment name.

      Returns:
      An Optional containing the requested experience if the Set, returned by getLiveExperiences(), contains one for the given experiment, or empty otherwise. one from the given experiment.
      Since:
      0.10
    • getStateVisitedEvent

      TraceEvent getStateVisitedEvent()
      Pending state visited event. State visited events are generated implicitly whenever a new state request is created, and are triggered automatically at the time the state request is committed with commit(Object) or failed with fail(Object). This method allows client code to enrich the pending state visited event with extra attributes that will be useful for the downstream analysis. Note, that all session attributes are implicitly added to the state visited trace event.
      Returns:
      Object of type TraceEvent.
      Since:
      0.6
    • commit

      Object commit(Object userData)
      Complete this state request successfully.

      No-op if this request has already been committed in this or a parallel session.

      Parameters:
      userData - An instance of any Object, which is passed without interpretation to the user supplied implementation of SessionIdTracker.save(Object).
      Returns:
      The instance returned by SessionIdTracker.save(Object).
      Since:
      0.6
    • fail

      Object fail(Object userData)
      Complete this state request unsuccessfully.

      No-op if this request has already been committed in this or a parallel session.

      Parameters:
      userData - An instance of any Object, which is passed without interpretation to the user supplied implementation of SessionIdTracker.save(Object).
      Returns:
      The instance returned by SessionIdTracker.save(Object).
      Since:
      0.6