launchdarkly-server-sdk-4.3.0: Server-side SDK for integrating with LaunchDarkly
Safe HaskellNone
LanguageHaskell2010

LaunchDarkly.Server.Client

Description

This module contains the core functionality of the SDK.

Synopsis

Documentation

data Client Source #

Client is the LaunchDarkly client. Client instances are thread-safe. Applications should instantiate a single instance for the lifetime of their application.

Instances

Instances details
Generic Client Source # 
Instance details

Defined in LaunchDarkly.Server.Client.Internal

Associated Types

type Rep Client :: Type -> Type #

Methods

from :: Client -> Rep Client x #

to :: Rep Client x -> Client #

type Rep Client Source # 
Instance details

Defined in LaunchDarkly.Server.Client.Internal

type Rep Client

makeClient :: Config -> IO Client Source #

Create a new instance of the LaunchDarkly client.

clientVersion :: Text Source #

The version string for this library.

boolVariation :: Client -> Text -> Context -> Bool -> IO Bool Source #

Evaluate a Boolean typed flag.

boolVariationDetail :: Client -> Text -> Context -> Bool -> IO (EvaluationDetail Bool) Source #

Evaluate a Boolean typed flag, and return an explanation.

stringVariation :: Client -> Text -> Context -> Text -> IO Text Source #

Evaluate a String typed flag.

stringVariationDetail :: Client -> Text -> Context -> Text -> IO (EvaluationDetail Text) Source #

Evaluate a String typed flag, and return an explanation.

intVariation :: Client -> Text -> Context -> Int -> IO Int Source #

Evaluate a Number typed flag, and truncate the result.

intVariationDetail :: Client -> Text -> Context -> Int -> IO (EvaluationDetail Int) Source #

Evaluate a Number typed flag, truncate the result, and return an explanation.

doubleVariation :: Client -> Text -> Context -> Double -> IO Double Source #

Evaluate a Number typed flag.

doubleVariationDetail :: Client -> Text -> Context -> Double -> IO (EvaluationDetail Double) Source #

Evaluate a Number typed flag, and return an explanation.

jsonVariation :: Client -> Text -> Context -> Value -> IO Value Source #

Evaluate a JSON typed flag.

jsonVariationDetail :: Client -> Text -> Context -> Value -> IO (EvaluationDetail Value) Source #

Evaluate a JSON typed flag, and return an explanation.

data EvaluationDetail value Source #

Combines the result of a flag evaluation with an explanation of how it was calculated.

Constructors

EvaluationDetail 

Fields

  • value :: !value

    The result of the flag evaluation. This will be either one of the flag's variations or the default value passed by the application.

  • variationIndex :: !(Maybe Integer)

    The index of the returned value within the flag's list of variations, e.g. 0 for the first variation - or Nothing if the default value was returned.

  • reason :: !EvaluationReason

    Describes the main factor that influenced the flag evaluation value.

Instances

Instances details
Eq value => Eq (EvaluationDetail value) Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Methods

(==) :: EvaluationDetail value -> EvaluationDetail value -> Bool #

(/=) :: EvaluationDetail value -> EvaluationDetail value -> Bool #

Show value => Show (EvaluationDetail value) Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Generic (EvaluationDetail value) Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Associated Types

type Rep (EvaluationDetail value) :: Type -> Type #

Methods

from :: EvaluationDetail value -> Rep (EvaluationDetail value) x #

to :: Rep (EvaluationDetail value) x -> EvaluationDetail value #

ToJSON a => ToJSON (EvaluationDetail a) Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep (EvaluationDetail value) Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep (EvaluationDetail value) = D1 ('MetaData "EvaluationDetail" "LaunchDarkly.Server.Details" "launchdarkly-server-sdk-4.3.0-2CIex99hiyJKglxrflv0bm" 'False) (C1 ('MetaCons "EvaluationDetail" 'PrefixI 'True) (S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 value) :*: (S1 ('MetaSel ('Just "variationIndex") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Integer)) :*: S1 ('MetaSel ('Just "reason") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EvaluationReason))))

data EvaluationReason Source #

Defines the possible values of the Kind property of EvaluationReason.

Constructors

EvaluationReasonOff

Indicates that the flag was off and therefore returned its configured off value.

EvaluationReasonTargetMatch

indicates that the context key was specifically targeted for this flag.

EvaluationReasonRuleMatch 

Fields

  • ruleIndex :: !Natural

    The index of the rule that was matched (0 being the first).

  • ruleId :: !Text

    The unique identifier of the rule that was matched.

  • inExperiment :: !Bool

    Whether the evaluation was part of an experiment. Is true if the evaluation resulted in an experiment rollout *and* served one of the variations in the experiment. Otherwise false.

EvaluationReasonPrerequisiteFailed 

Fields

EvaluationReasonFallthrough 

Fields

  • inExperiment :: !Bool

    Whether the evaluation was part of an experiment. Is true if the evaluation resulted in an experiment rollout *and* served one of the variations in the experiment. Otherwise false.

EvaluationReasonError 

Fields

Instances

Instances details
Eq EvaluationReason Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Show EvaluationReason Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Generic EvaluationReason Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Associated Types

type Rep EvaluationReason :: Type -> Type #

ToJSON EvaluationReason Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep EvaluationReason Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep EvaluationReason = D1 ('MetaData "EvaluationReason" "LaunchDarkly.Server.Details" "launchdarkly-server-sdk-4.3.0-2CIex99hiyJKglxrflv0bm" 'False) ((C1 ('MetaCons "EvaluationReasonOff" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EvaluationReasonTargetMatch" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EvaluationReasonRuleMatch" 'PrefixI 'True) (S1 ('MetaSel ('Just "ruleIndex") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Natural) :*: (S1 ('MetaSel ('Just "ruleId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "inExperiment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))) :+: (C1 ('MetaCons "EvaluationReasonPrerequisiteFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "prerequisiteKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons "EvaluationReasonFallthrough" 'PrefixI 'True) (S1 ('MetaSel ('Just "inExperiment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "EvaluationReasonError" 'PrefixI 'True) (S1 ('MetaSel ('Just "errorKind") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EvalErrorKind)))))

data EvalErrorKind Source #

Defines the possible values of the errorKind property of EvaluationReason.

Constructors

EvalErrorKindMalformedFlag

Indicates that there was an internal inconsistency in the flag data, e.g. a rule specified a nonexistent variation.

EvalErrorFlagNotFound

Indicates that the caller provided a flag key that did not match any known flag.

EvalErrorWrongType

Indicates that the result value was not of the requested type, e.g. you called boolVariationDetail but the value was an integer.

EvalErrorClientNotReady

Indicates that the caller tried to evaluate a flag before the client had successfully initialized.

EvalErrorInvalidContext

Indicates that the caller tried to evaluate a flag with an invalid context

EvalErrorExternalStore !Text

Indicates that some error was returned by the external feature store.

Instances

Instances details
Eq EvalErrorKind Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Show EvalErrorKind Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Generic EvalErrorKind Source # 
Instance details

Defined in LaunchDarkly.Server.Details

Associated Types

type Rep EvalErrorKind :: Type -> Type #

ToJSON EvalErrorKind Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep EvalErrorKind Source # 
Instance details

Defined in LaunchDarkly.Server.Details

type Rep EvalErrorKind = D1 ('MetaData "EvalErrorKind" "LaunchDarkly.Server.Details" "launchdarkly-server-sdk-4.3.0-2CIex99hiyJKglxrflv0bm" 'False) ((C1 ('MetaCons "EvalErrorKindMalformedFlag" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EvalErrorFlagNotFound" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EvalErrorWrongType" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "EvalErrorClientNotReady" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EvalErrorInvalidContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EvalErrorExternalStore" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))))

allFlagsState :: Client -> Context -> Bool -> Bool -> Bool -> IO AllFlagsState Source #

Returns an object that encapsulates the state of all feature flags for a given context. This includes the flag values, and also metadata that can be used on the front end.

The most common use case for this method is to bootstrap a set of client-side feature flags from a back-end service.

The first parameter will limit to only flags that are marked for use with the client-side SDK (by default, all flags are included).

The second parameter will include evaluation reasons in the state.

The third parameter will omit any metadata that is normally only used for event generation, such as flag versions and evaluation reasons, unless the flag has event tracking or debugging turned on

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/all-flags#haskell

data AllFlagsState Source #

AllFlagsState captures the state of all feature flag keys as evaluated for a specific context. This includes their values, as well as other metadata.

secureModeHash :: Client -> Context -> Text Source #

Generates the secure mode hash value for a context.

For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/secure-mode#haskell.

close :: Client -> IO () Source #

Close shuts down the LaunchDarkly client. After calling this, the LaunchDarkly client should no longer be used. The method will block until all pending analytics events have been sent.

flushEvents :: Client -> IO () Source #

Flush tells the client that all pending analytics events (if any) should be delivered as soon as possible. Flushing is asynchronous, so this method will return before it is complete.

identify :: Client -> Context -> IO () Source #

Identify reports details about a context.

track :: Client -> Context -> Text -> Maybe Value -> Maybe Double -> IO () Source #

Track reports that a context has performed an event. Custom data can be attached to the event, and / or a numeric value.

The numeric value is used by the LaunchDarkly experimentation feature in numeric custom metrics, and will also be returned as part of the custom event for Data Export.

data Status Source #

The status of the client initialization.

Constructors

Uninitialized

The client has not yet finished connecting to LaunchDarkly.

Unauthorized

The client attempted to connect to LaunchDarkly and was denied.

Initialized

The client has successfuly connected to LaunchDarkly.

ShuttingDown

The client is being terminated

Instances

Instances details
Eq Status Source # 
Instance details

Defined in LaunchDarkly.Server.Client.Status

Methods

(==) :: Status -> Status -> Bool #

(/=) :: Status -> Status -> Bool #

Show Status Source # 
Instance details

Defined in LaunchDarkly.Server.Client.Status

getStatus :: Client -> IO Status Source #

Return the initialization status of the Client