Package com.variant.client
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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The current status of a state request. -
Method Summary
Modifier and TypeMethodDescriptionComplete this state request successfully.Complete this state request unsuccessfully.getLiveExperience
(Experiment experiment) The live experience in a given experiment, if any.default Optional<Experiment.Experience>
getLiveExperience
(String experimentName) The live experience in a given experiment, by experiment name.All of this session's live experiences on this state.The Variant session which created with this request by callingSession.targetForState(State)
.getState()
The targetState
of this request, which was passed toSession.targetForState(State)
.The resolved state parameters as an immutable map.Pending state visited event.The current status of this state request.
-
Method Details
-
getSession
Session getSession()The Variant session which created with this request by callingSession.targetForState(State)
.- Returns:
- An object of type
Session
. - Since:
- 0.6
-
getState
State getState()The targetState
of this request, which was passed toSession.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
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 theStateVariant
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
The live experience in a given experiment, by experiment name.
- Returns:
- An
Optional
containing the requested experience if theSet
, returned bygetLiveExperiences()
, 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 withcommit(Object)
or failed withfail(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
Complete this state request successfully.- The associated state visited trace event is triggered implicitly with the status of
StateRequest.Status.Committed
. - The associated session tracker's method
SessionIdTracker.save(Object)
is called.
No-op if this request has already been committed in this or a parallel session.
- Parameters:
userData
- An instance of anyObject
, which is passed without interpretation to the user supplied implementation ofSessionIdTracker.save(Object)
.- Returns:
- The instance returned by
SessionIdTracker.save(Object)
. - Since:
- 0.6
- The associated state visited trace event is triggered implicitly with the status of
-
fail
Complete this state request unsuccessfully.- The associated state visited trace event is triggered implicitly with the status of
StateRequest.Status.Failed
. - The associated session tracker's method
SessionIdTracker.save(Object)
is called.
No-op if this request has already been committed in this or a parallel session.
- Parameters:
userData
- An instance of anyObject
, which is passed without interpretation to the user supplied implementation ofSessionIdTracker.save(Object)
.- Returns:
- The instance returned by
SessionIdTracker.save(Object)
. - Since:
- 0.6
- The associated state visited trace event is triggered implicitly with the status of
-