Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/OpenFeature.Contrib.Providers.Flagd/FlagdConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public enum ResolverType
/// locally for in-process evaluation.
/// Evaluations are preformed in-process.
/// </summary>
IN_PROCESS
IN_PROCESS,
/// <summary>
/// This is the in-process offline mode resolving type, where flags are fetched from a file and stored
/// locally for in-process evaluation.
/// Evaluations are preformed in-process.
/// </summary>
FILE,
}

/// <summary>
Expand Down Expand Up @@ -147,6 +153,16 @@ public string SourceSelector
set => _sourceSelector = value;
}

/// <summary>
/// File source of flags to be used by offline mode.
/// Provide full path including directory and file name.
/// </summary>
public string OfflineFlagSourceFullPath
{
get => this._offlineFlagSourceFullPath;
set => this._offlineFlagSourceFullPath = value;
}

internal bool UseCertificate => _cert.Length > 0;

private string _host;
Expand All @@ -158,6 +174,7 @@ public string SourceSelector
private int _maxCacheSize;
private int _maxEventStreamRetries;
private string _sourceSelector;
private string _offlineFlagSourceFullPath;
private ResolverType _resolverType;

internal FlagdConfig()
Expand Down Expand Up @@ -327,6 +344,16 @@ public FlagdConfigBuilder WithSourceSelector(string sourceSelector)
return this;
}

/// <summary>
/// File source of flags to be used by offline mode.
/// Provide full path including directory and file name.
/// </summary>
public FlagdConfigBuilder OfflineFlagSourceFullPath(string path)
{
_config.OfflineFlagSourceFullPath = path;
return this;
}

/// <summary>
/// Builds the FlagdConfig object.
/// </summary>
Expand Down
11 changes: 4 additions & 7 deletions src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ public FlagdProvider(FlagdConfig config)

_config = config;

if (_config.ResolverType == ResolverType.IN_PROCESS)
_resolver = _config.ResolverType switch
{
_resolver = new InProcessResolver(_config, EventChannel, _providerMetadata);
}
else
{
_resolver = new RpcResolver(config, EventChannel, _providerMetadata);
}
ResolverType.RPC => new RpcResolver(config, EventChannel, _providerMetadata),
_ => new InProcessResolver(_config, EventChannel, _providerMetadata)
};
}

// just for testing, internal but visible in tests
Expand Down
Loading
Loading