-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Server-side SDK for integrating with LaunchDarkly -- -- Please see the README on GitHub at -- https://github.com/launchdarkly/haskell-server-sdk#readme @package launchdarkly-server-sdk @version 1.0.0 -- | This module contains details for external store implementations. module LaunchDarkly.Server.Store -- | The result type for every StoreInterface function. Instead of -- throwing an exception, any store related error should return -- Left. Exceptions unrelated to the store should not be caught. type StoreResult a = IO (Either Text a) -- | Represents the key for a given feature. type FeatureKey = Text -- | Represents a namespace such as flags or segments type FeatureNamespace = Text -- | The interface implemented by external stores for use by the SDK. data StoreInterface StoreInterface :: !FeatureNamespace -> StoreResult (HashMap Text RawFeature) -> !FeatureNamespace -> FeatureKey -> StoreResult RawFeature -> !FeatureNamespace -> FeatureKey -> RawFeature -> StoreResult Bool -> !StoreResult Bool -> !HashMap FeatureNamespace (HashMap FeatureKey RawFeature) -> StoreResult () -> StoreInterface -- | A map of all features in a given namespace including deleted. [$sel:storeInterfaceAllFeatures:StoreInterface] :: StoreInterface -> !FeatureNamespace -> StoreResult (HashMap Text RawFeature) -- | Return the value of a key in a namespace. [$sel:storeInterfaceGetFeature:StoreInterface] :: StoreInterface -> !FeatureNamespace -> FeatureKey -> StoreResult RawFeature -- | Upsert a given feature. Versions should be compared before upsert. The -- result should indicate if the feature was replaced or not. [$sel:storeInterfaceUpsertFeature:StoreInterface] :: StoreInterface -> !FeatureNamespace -> FeatureKey -> RawFeature -> StoreResult Bool -- | Checks if the external store has been initialized, which may have been -- done by another instance of the SDK. [$sel:storeInterfaceIsInitialized:StoreInterface] :: StoreInterface -> !StoreResult Bool -- | A map of namespaces, and items in namespaces. The entire store state -- should be replaced with these values. [$sel:storeInterfaceInitialize:StoreInterface] :: StoreInterface -> !HashMap FeatureNamespace (HashMap FeatureKey RawFeature) -> StoreResult () -- | An abstract representation of a store object. data RawFeature RawFeature :: !Maybe ByteString -> !Natural -> RawFeature -- | A serialized item. If the item is deleted or does not exist this -- should be Nothing. [$sel:rawFeatureBuffer:RawFeature] :: RawFeature -> !Maybe ByteString -- | The version of a given item. If the item does not exist this should be -- zero. [$sel:rawFeatureVersion:RawFeature] :: RawFeature -> !Natural -- | This module is for configuration of the SDK. module LaunchDarkly.Server.Config -- | Config allows advanced configuration of the LaunchDarkly client. data Config -- | Create a default configuration from a given SDK key. makeConfig :: Text -> Config -- | Set the SDK key used to authenticate with LaunchDarkly. configSetKey :: Text -> Config -> Config -- | The base URI of the main LaunchDarkly service. This should not -- normally be changed except for testing. configSetBaseURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly streaming service. This should not -- normally be changed except for testing. configSetStreamURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly service that accepts analytics -- events. This should not normally be changed except for testing. configSetEventsURI :: Text -> Config -> Config -- | Sets whether streaming mode should be enabled. By default, streaming -- is enabled. It should only be disabled on the advice of LaunchDarkly -- support. configSetStreaming :: Bool -> Config -> Config -- | Sets whether or not all user attributes (other than the key) should be -- hidden from LaunchDarkly. If this is true, all user attribute values -- will be private, not just the attributes specified in -- PrivateAttributeNames. configSetAllAttributesPrivate :: Bool -> Config -> Config -- | Marks a set of user attribute names private. Any users sent to -- LaunchDarkly with this configuration active will have attributes with -- these names removed. configSetPrivateAttributeNames :: Set Text -> Config -> Config -- | The time between flushes of the event buffer. Decreasing the flush -- interval means that the event buffer is less likely to reach capacity. configSetFlushIntervalSeconds :: Natural -> Config -> Config -- | The polling interval (when streaming is disabled). configSetPollIntervalSeconds :: Natural -> Config -> Config -- | The number of user keys that the event processor can remember at any -- one time, so that duplicate user details will not be sent in analytics -- events. configSetUserKeyLRUCapacity :: Natural -> Config -> Config -- | Set to true if you need to see the full user details in every -- analytics event. configSetInlineUsersInEvents :: Bool -> Config -> Config -- | The capacity of the events buffer. The client buffers up to this many -- events in memory before flushing. If the capacity is exceeded before -- the buffer is flushed, events will be discarded. configSetEventsCapacity :: Natural -> Config -> Config -- | Set the logger to be used by the client. configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config -- | Sets whether to send analytics events back to LaunchDarkly. By -- default, the client will send events. This differs from Offline in -- that it only affects sending events, not streaming or polling for -- events from the server. configSetSendEvents :: Bool -> Config -> Config -- | Sets whether this client is offline. An offline client will not make -- any network connections to LaunchDarkly, and will return default -- values for all feature flags. configSetOffline :: Bool -> Config -> Config -- | Sets how long an the HTTP client should wait before a response is -- returned. configSetRequestTimeoutSeconds :: Natural -> Config -> Config -- | Configures a handle to an external store such as Redis. configSetStoreBackend :: Maybe StoreInterface -> Config -> Config -- | When a store backend is configured, control how long values should be -- cached in memory before going back to the backend. configSetStoreTTL :: Natural -> Config -> Config -- | Sets whether this client should use the LaunchDarkly relay in daemon -- mode. In this mode, the client does not subscribe to the streaming or -- polling API, but reads data only from the feature store. See: -- https://docs.launchdarkly.com/docs/the-relay-proxy configSetUseLdd :: Bool -> Config -> Config -- | This module is for configuration of the user object. module LaunchDarkly.Server.User -- | User contains specific attributes of a user of your application -- -- The only mandatory property is the Key, which must uniquely identify -- each user. For authenticated users, this may be a username or e-mail -- address. For anonymous users, this could be an IP address or session -- ID. data User -- | Creates a new user identified by the given key. makeUser :: Text -> User -- | Set the primary key for a user. userSetKey :: Maybe Text -> User -> User -- | Set the secondary key for a user. userSetSecondary :: Maybe Text -> User -> User -- | Set the IP for a user. userSetIP :: Maybe Text -> User -> User -- | Set the country for a user. userSetCountry :: Maybe Text -> User -> User -- | Set the email for a user. userSetEmail :: Maybe Text -> User -> User -- | Set the first name for a user. userSetFirstName :: Maybe Text -> User -> User -- | Set the last name for a user. userSetLastName :: Maybe Text -> User -> User -- | Set the avatar for a user. userSetAvatar :: Maybe Text -> User -> User -- | Set the name for a user. userSetName :: Maybe Text -> User -> User -- | Set if the user is anonymous or not. userSetAnonymous :: Bool -> User -> User -- | Set custom fields for a user. userSetCustom :: HashMap Text Value -> User -> User -- | This contains list of attributes to keep private, whether they appear -- at the top-level or Custom The attribute "key" is always sent -- regardless of whether it is in this list, and "custom" cannot be used -- to eliminate all custom attributes userSetPrivateAttributeNames :: Set Text -> User -> User -- | This module contains the core functionality of the SDK. module LaunchDarkly.Server.Client -- | Client is the LaunchDarkly client. Client instances are thread-safe. -- Applications should instantiate a single instance for the lifetime of -- their application. data Client -- | Create a new instance of the LaunchDarkly client. makeClient :: Config -> IO Client -- | The version string for this library. clientVersion :: Text -- | Evaluate a Boolean typed flag. boolVariation :: Client -> Text -> User -> Bool -> IO Bool -- | Evaluate a Boolean typed flag, and return an explation. boolVariationDetail :: Client -> Text -> User -> Bool -> IO (EvaluationDetail Bool) -- | Evaluate a String typed flag. stringVariation :: Client -> Text -> User -> Text -> IO Text -- | Evaluate a String typed flag, and return an explanation. stringVariationDetail :: Client -> Text -> User -> Text -> IO (EvaluationDetail Text) -- | Evaluate a Number typed flag, and truncate the result. intVariation :: Client -> Text -> User -> Int -> IO Int -- | Evaluate a Number typed flag, truncate the result, and return an -- explanation. intVariationDetail :: Client -> Text -> User -> Int -> IO (EvaluationDetail Int) -- | Evaluate a Number typed flag. doubleVariation :: Client -> Text -> User -> Double -> IO Double -- | Evaluate a Number typed flag, and return an explanation. doubleVariationDetail :: Client -> Text -> User -> Double -> IO (EvaluationDetail Double) -- | Evaluate a JSON typed flag. jsonVariation :: Client -> Text -> User -> Value -> IO Value -- | Evaluate a JSON typed flag, and return an explanation. jsonVariationDetail :: Client -> Text -> User -> Value -> IO (EvaluationDetail Value) -- | Combines the result of a flag evaluation with an explanation of how it -- was calculated. data EvaluationDetail value EvaluationDetail :: !value -> !Maybe Natural -> !EvaluationReason -> EvaluationDetail 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. [$sel:value:EvaluationDetail] :: EvaluationDetail value -> !value -- | 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. [$sel:variationIndex:EvaluationDetail] :: EvaluationDetail value -> !Maybe Natural -- | Describes the main factor that influenced the flag evaluation value. [$sel:reason:EvaluationDetail] :: EvaluationDetail value -> !EvaluationReason -- | Defines the possible values of the Kind property of EvaluationReason. data EvaluationReason -- | Indicates that the flag was off and therefore returned its configured -- off value. EvaluationReasonOff :: EvaluationReason -- | indicates that the user key was specifically targeted for this flag. EvaluationReasonTargetMatch :: EvaluationReason -- | Indicates that the user matched one of the flag's rules. EvaluationReasonRuleMatch :: !Natural -> !Text -> EvaluationReason -- | The index of the rule that was matched (0 being the first). [$sel:ruleIndex:EvaluationReasonOff] :: EvaluationReason -> !Natural -- | The unique identifier of the rule that was matched. [$sel:ruleId:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Indicates that the flag was considered off because it had at least one -- prerequisite flag that either was off or did not return the desired -- variation. EvaluationReasonPrerequisiteFailed :: !Text -> EvaluationReason -- | The flag key of the prerequisite that failed. [$sel:prerequisiteKey:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Indicates that the flag was on but the user did not match any targets -- or rules. EvaluationReasonFallthrough :: EvaluationReason -- | Indicates that the flag could not be evaluated, e.g. because it does -- not exist or due to an unexpected error. In this case the result value -- will be the default value that the caller passed to the client. EvaluationReasonError :: !EvalErrorKind -> EvaluationReason -- | Describes the type of error. [$sel:errorKind:EvaluationReasonOff] :: EvaluationReason -> !EvalErrorKind -- | Defines the possible values of the errorKind property of -- EvaluationReason. data EvalErrorKind -- | Indicates that there was an internal inconsistency in the flag data, -- e.g. a rule specified a nonexistent variation. EvalErrorKindMalformedFlag :: EvalErrorKind -- | Indicates that the caller provided a flag key that did not match any -- known flag. EvalErrorFlagNotFound :: EvalErrorKind -- | Indicates that the result value was not of the requested type, e.g. -- you called boolVariationDetail but the value was an integer. EvalErrorWrongType :: EvalErrorKind -- | Indicates that the caller passed a user without a key for the user -- parameter. EvalErrorUserNotSpecified :: EvalErrorKind -- | Indicates that the caller tried to evaluate a flag before the client -- had successfully initialized. EvalErrorClientNotReady :: EvalErrorKind -- | Indicates that some error was returned by the external feature store. EvalErrorExternalStore :: !Text -> EvalErrorKind -- | Returns a map from feature flag keys to values for a given user. If -- the result of the flag's evaluation would result in the default value, -- Null will be returned. This method does not send analytics -- events back to LaunchDarkly. allFlags :: Client -> User -> IO (HashMap Text Value) -- | 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. close :: Client -> IO () -- | 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. flushEvents :: Client -> IO () -- | Identify reports details about a a user. identify :: Client -> User -> IO () -- | Track reports that a user 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. track :: Client -> User -> Text -> Maybe Value -> Maybe Double -> IO () -- | The status of the client initialization. data Status -- | The client has not yet finished connecting to LaunchDarkly. Uninitialized :: Status -- | The client attempted to connect to LaunchDarkly and was denied. Unauthorized :: Status -- | The client has successfuly connected to LaunchDarkly. Initialized :: Status -- | The client is being terminated ShuttingDown :: Status -- | Return the initialization status of the Client getStatus :: Client -> IO Status -- | This module re-exports the User, Client, and Config modules. module LaunchDarkly.Server -- | Config allows advanced configuration of the LaunchDarkly client. data Config -- | Create a default configuration from a given SDK key. makeConfig :: Text -> Config -- | Set the SDK key used to authenticate with LaunchDarkly. configSetKey :: Text -> Config -> Config -- | The base URI of the main LaunchDarkly service. This should not -- normally be changed except for testing. configSetBaseURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly streaming service. This should not -- normally be changed except for testing. configSetStreamURI :: Text -> Config -> Config -- | The base URI of the LaunchDarkly service that accepts analytics -- events. This should not normally be changed except for testing. configSetEventsURI :: Text -> Config -> Config -- | Sets whether streaming mode should be enabled. By default, streaming -- is enabled. It should only be disabled on the advice of LaunchDarkly -- support. configSetStreaming :: Bool -> Config -> Config -- | Sets whether or not all user attributes (other than the key) should be -- hidden from LaunchDarkly. If this is true, all user attribute values -- will be private, not just the attributes specified in -- PrivateAttributeNames. configSetAllAttributesPrivate :: Bool -> Config -> Config -- | Marks a set of user attribute names private. Any users sent to -- LaunchDarkly with this configuration active will have attributes with -- these names removed. configSetPrivateAttributeNames :: Set Text -> Config -> Config -- | The time between flushes of the event buffer. Decreasing the flush -- interval means that the event buffer is less likely to reach capacity. configSetFlushIntervalSeconds :: Natural -> Config -> Config -- | The polling interval (when streaming is disabled). configSetPollIntervalSeconds :: Natural -> Config -> Config -- | The number of user keys that the event processor can remember at any -- one time, so that duplicate user details will not be sent in analytics -- events. configSetUserKeyLRUCapacity :: Natural -> Config -> Config -- | Set to true if you need to see the full user details in every -- analytics event. configSetInlineUsersInEvents :: Bool -> Config -> Config -- | The capacity of the events buffer. The client buffers up to this many -- events in memory before flushing. If the capacity is exceeded before -- the buffer is flushed, events will be discarded. configSetEventsCapacity :: Natural -> Config -> Config -- | Set the logger to be used by the client. configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config -- | Sets whether to send analytics events back to LaunchDarkly. By -- default, the client will send events. This differs from Offline in -- that it only affects sending events, not streaming or polling for -- events from the server. configSetSendEvents :: Bool -> Config -> Config -- | Sets whether this client is offline. An offline client will not make -- any network connections to LaunchDarkly, and will return default -- values for all feature flags. configSetOffline :: Bool -> Config -> Config -- | Sets how long an the HTTP client should wait before a response is -- returned. configSetRequestTimeoutSeconds :: Natural -> Config -> Config -- | Configures a handle to an external store such as Redis. configSetStoreBackend :: Maybe StoreInterface -> Config -> Config -- | When a store backend is configured, control how long values should be -- cached in memory before going back to the backend. configSetStoreTTL :: Natural -> Config -> Config -- | Sets whether this client should use the LaunchDarkly relay in daemon -- mode. In this mode, the client does not subscribe to the streaming or -- polling API, but reads data only from the feature store. See: -- https://docs.launchdarkly.com/docs/the-relay-proxy configSetUseLdd :: Bool -> Config -> Config -- | User contains specific attributes of a user of your application -- -- The only mandatory property is the Key, which must uniquely identify -- each user. For authenticated users, this may be a username or e-mail -- address. For anonymous users, this could be an IP address or session -- ID. data User -- | Creates a new user identified by the given key. makeUser :: Text -> User -- | Set the primary key for a user. userSetKey :: Maybe Text -> User -> User -- | Set the secondary key for a user. userSetSecondary :: Maybe Text -> User -> User -- | Set the IP for a user. userSetIP :: Maybe Text -> User -> User -- | Set the country for a user. userSetCountry :: Maybe Text -> User -> User -- | Set the email for a user. userSetEmail :: Maybe Text -> User -> User -- | Set the first name for a user. userSetFirstName :: Maybe Text -> User -> User -- | Set the last name for a user. userSetLastName :: Maybe Text -> User -> User -- | Set the avatar for a user. userSetAvatar :: Maybe Text -> User -> User -- | Set the name for a user. userSetName :: Maybe Text -> User -> User -- | Set if the user is anonymous or not. userSetAnonymous :: Bool -> User -> User -- | Set custom fields for a user. userSetCustom :: HashMap Text Value -> User -> User -- | This contains list of attributes to keep private, whether they appear -- at the top-level or Custom The attribute "key" is always sent -- regardless of whether it is in this list, and "custom" cannot be used -- to eliminate all custom attributes userSetPrivateAttributeNames :: Set Text -> User -> User -- | Client is the LaunchDarkly client. Client instances are thread-safe. -- Applications should instantiate a single instance for the lifetime of -- their application. data Client -- | Create a new instance of the LaunchDarkly client. makeClient :: Config -> IO Client -- | The version string for this library. clientVersion :: Text -- | Evaluate a Boolean typed flag. boolVariation :: Client -> Text -> User -> Bool -> IO Bool -- | Evaluate a Boolean typed flag, and return an explation. boolVariationDetail :: Client -> Text -> User -> Bool -> IO (EvaluationDetail Bool) -- | Evaluate a String typed flag. stringVariation :: Client -> Text -> User -> Text -> IO Text -- | Evaluate a String typed flag, and return an explanation. stringVariationDetail :: Client -> Text -> User -> Text -> IO (EvaluationDetail Text) -- | Evaluate a Number typed flag, and truncate the result. intVariation :: Client -> Text -> User -> Int -> IO Int -- | Evaluate a Number typed flag, truncate the result, and return an -- explanation. intVariationDetail :: Client -> Text -> User -> Int -> IO (EvaluationDetail Int) -- | Evaluate a Number typed flag. doubleVariation :: Client -> Text -> User -> Double -> IO Double -- | Evaluate a Number typed flag, and return an explanation. doubleVariationDetail :: Client -> Text -> User -> Double -> IO (EvaluationDetail Double) -- | Evaluate a JSON typed flag. jsonVariation :: Client -> Text -> User -> Value -> IO Value -- | Evaluate a JSON typed flag, and return an explanation. jsonVariationDetail :: Client -> Text -> User -> Value -> IO (EvaluationDetail Value) -- | Combines the result of a flag evaluation with an explanation of how it -- was calculated. data EvaluationDetail value EvaluationDetail :: !value -> !Maybe Natural -> !EvaluationReason -> EvaluationDetail 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. [$sel:value:EvaluationDetail] :: EvaluationDetail value -> !value -- | 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. [$sel:variationIndex:EvaluationDetail] :: EvaluationDetail value -> !Maybe Natural -- | Describes the main factor that influenced the flag evaluation value. [$sel:reason:EvaluationDetail] :: EvaluationDetail value -> !EvaluationReason -- | Defines the possible values of the Kind property of EvaluationReason. data EvaluationReason -- | Indicates that the flag was off and therefore returned its configured -- off value. EvaluationReasonOff :: EvaluationReason -- | indicates that the user key was specifically targeted for this flag. EvaluationReasonTargetMatch :: EvaluationReason -- | Indicates that the user matched one of the flag's rules. EvaluationReasonRuleMatch :: !Natural -> !Text -> EvaluationReason -- | The index of the rule that was matched (0 being the first). [$sel:ruleIndex:EvaluationReasonOff] :: EvaluationReason -> !Natural -- | The unique identifier of the rule that was matched. [$sel:ruleId:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Indicates that the flag was considered off because it had at least one -- prerequisite flag that either was off or did not return the desired -- variation. EvaluationReasonPrerequisiteFailed :: !Text -> EvaluationReason -- | The flag key of the prerequisite that failed. [$sel:prerequisiteKey:EvaluationReasonOff] :: EvaluationReason -> !Text -- | Indicates that the flag was on but the user did not match any targets -- or rules. EvaluationReasonFallthrough :: EvaluationReason -- | Indicates that the flag could not be evaluated, e.g. because it does -- not exist or due to an unexpected error. In this case the result value -- will be the default value that the caller passed to the client. EvaluationReasonError :: !EvalErrorKind -> EvaluationReason -- | Describes the type of error. [$sel:errorKind:EvaluationReasonOff] :: EvaluationReason -> !EvalErrorKind -- | Defines the possible values of the errorKind property of -- EvaluationReason. data EvalErrorKind -- | Indicates that there was an internal inconsistency in the flag data, -- e.g. a rule specified a nonexistent variation. EvalErrorKindMalformedFlag :: EvalErrorKind -- | Indicates that the caller provided a flag key that did not match any -- known flag. EvalErrorFlagNotFound :: EvalErrorKind -- | Indicates that the result value was not of the requested type, e.g. -- you called boolVariationDetail but the value was an integer. EvalErrorWrongType :: EvalErrorKind -- | Indicates that the caller passed a user without a key for the user -- parameter. EvalErrorUserNotSpecified :: EvalErrorKind -- | Indicates that the caller tried to evaluate a flag before the client -- had successfully initialized. EvalErrorClientNotReady :: EvalErrorKind -- | Indicates that some error was returned by the external feature store. EvalErrorExternalStore :: !Text -> EvalErrorKind -- | Returns a map from feature flag keys to values for a given user. If -- the result of the flag's evaluation would result in the default value, -- Null will be returned. This method does not send analytics -- events back to LaunchDarkly. allFlags :: Client -> User -> IO (HashMap Text Value) -- | 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. close :: Client -> IO () -- | 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. flushEvents :: Client -> IO () -- | Identify reports details about a a user. identify :: Client -> User -> IO () -- | Track reports that a user 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. track :: Client -> User -> Text -> Maybe Value -> Maybe Double -> IO () -- | The status of the client initialization. data Status -- | The client has not yet finished connecting to LaunchDarkly. Uninitialized :: Status -- | The client attempted to connect to LaunchDarkly and was denied. Unauthorized :: Status -- | The client has successfuly connected to LaunchDarkly. Initialized :: Status -- | The client is being terminated ShuttingDown :: Status -- | Return the initialization status of the Client getStatus :: Client -> IO Status