LaunchDarkly Dotnet Server SDK
Search Results for

    Show / Hide Table of Contents

    Class Hook

    A Hook is a set of user-defined callbacks that are executed by the SDK at various points of interest. To create your own hook with customized logic, derive from Hook and override its methods.

    Hook currently defines an "evaluation" series, which is composed of two stages: "beforeEvaluation" and "afterEvaluation".

    These are executed by the SDK before and after the evaluation of a feature flag.

    Multiple hooks may be configured in the SDK. By default, the SDK will execute each hook's beforeEvaluation stage in the order they were configured, and afterEvaluation in reverse order.

    This means the last hook defined will tightly wrap the evaluation process, while hooks defined earlier in the sequence are nested outside of it.

    Inheritance
    object
    Hook
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: LaunchDarkly.Sdk.Server.Hooks
    Assembly: LaunchDarkly.ServerSdk.dll
    Syntax
    public class Hook : IDisposable

    Constructors

    | Edit this page View Source

    Hook(string)

    Constructs a new Hook with the given name. The name may be used in log messages.

    Declaration
    public Hook(string name)
    Parameters
    Type Name Description
    string name

    the name of the hook

    Properties

    | Edit this page View Source

    Metadata

    Access this hook's HookMetadata.

    Declaration
    public HookMetadata Metadata { get; }
    Property Value
    Type Description
    HookMetadata

    Methods

    | Edit this page View Source

    AfterEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>, EvaluationDetail<LdValue>)

    AfterEvaluation is executed by the SDK after the evaluation of a feature flag. It does not apply to evaluations performed during a call to AllFlagsState.

    The function should return the given ImmutableDictionary<TKey, TValue> unmodified, for forward compatibility with subsequent stages that may be added.

    Declaration
    public virtual ImmutableDictionary<string, object> AfterEvaluation(EvaluationSeriesContext context, ImmutableDictionary<string, object> data, EvaluationDetail<LdValue> detail)
    Parameters
    Type Name Description
    EvaluationSeriesContext context

    parameters associated with this evaluation

    ImmutableDictionary<string, object> data

    user-configurable data from the BeforeEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>) stage

    EvaluationDetail<LdValue> detail

    flag evaluation result

    Returns
    Type Description
    ImmutableDictionary<string, object>

    user-configurable data, which is currently unused but may be forwarded to subsequent stages in future versions of the SDK

    | Edit this page View Source

    BeforeEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>)

    BeforeEvaluation is executed by the SDK before the evaluation of a feature flag. It does not apply to evaluations performed during a call to AllFlagsState.

    To pass user-configured data to AfterEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>, EvaluationDetail<LdValue>), return a modification of the given ImmutableDictionary<TKey, TValue>. You may use existing ImmutableDictionary methods, for example:

    var builder = data.ToBuilder();
    builder["foo"] = "bar";
    return builder.ToImmutable();

    Or, you may use the SeriesDataBuilder for a fluent API:

    return new SeriesDataBuilder(data).Set("foo", "bar").Build();

    The modified data is not shared with any other hook. It will be passed to subsequent stages in the evaluation series, including AfterEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>, EvaluationDetail<LdValue>).

    Declaration
    public virtual ImmutableDictionary<string, object> BeforeEvaluation(EvaluationSeriesContext context, ImmutableDictionary<string, object> data)
    Parameters
    Type Name Description
    EvaluationSeriesContext context

    parameters associated with this evaluation

    ImmutableDictionary<string, object> data

    user-configurable data, currently empty

    Returns
    Type Description
    ImmutableDictionary<string, object>

    user-configurable data, which will be forwarded to AfterEvaluation(EvaluationSeriesContext, ImmutableDictionary<string, object>, EvaluationDetail<LdValue>)

    | Edit this page View Source

    Dispose()

    Disposes the hook. This method will be called when the SDK is disposed.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Dispose(bool)

    Disposes the hook. This method will be called when the SDK is disposed.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    true if the caller is Dispose, false if the caller is a finalizer

    Implements

    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX