Fauna v10 .NET/C# Driver 1.0.0
 
Loading...
Searching...
No Matches
Configuration.cs
Go to the documentation of this file.
1using System.Threading;
2using Fauna.Core;
3using Fauna.Util;
4using Microsoft.Extensions.Logging;
5
6namespace Fauna;
7
12public record class Configuration
13{
17 public bool DisposeHttpClient { get; } = true;
18
23 public TimeSpan ClientBufferTimeout { get; init; } = TimeSpan.FromSeconds(5);
24
28 public HttpClient HttpClient { get; init; }
29
33 public string Secret { get; init; } = Environment.GetEnvironmentVariable("FAUNA_SECRET") ?? string.Empty;
34
38 public Uri Endpoint { get; init; } = Endpoints.GetFaunaEndpoint();
39
43 public QueryOptions DefaultQueryOptions { get; init; } = new();
44
48 public RetryConfiguration RetryConfiguration { get; init; } = new(3, TimeSpan.FromSeconds(20));
49
50
54 public IStatsCollector? StatsCollector { get; init; } = new StatsCollector();
55
62 public Configuration(string secret = "", HttpClient? httpClient = null, ILogger? logger = null)
63 {
64 if (string.IsNullOrEmpty(secret) && string.IsNullOrEmpty(Secret))
65 {
66 throw new ArgumentNullException(nameof(Secret), "Need to set FAUNA_SECRET environment variable or pass a secret as a parameter when creating the Client.");
67 }
68
69 if (!string.IsNullOrEmpty(secret))
70 {
71 Secret = secret;
72 }
73
74 if (httpClient != null)
75 {
76 HttpClient = httpClient;
77 DisposeHttpClient = false;
78 }
79 else
80 {
81 HttpClient = new HttpClient { Timeout = Timeout.InfiniteTimeSpan };
82 }
83
84 if (logger != null)
85 {
86 Logger.Initialize(logger);
87 }
88 }
89}
Configuration is a class used to configure a Fauna Client. It encapsulates various settings such as t...
HttpClient HttpClient
The HTTP Client to use for requests.
Uri Endpoint
The endpoint URL of the Fauna server.
string Secret
The secret key used for authentication.
bool DisposeHttpClient
Whether the Client should dispose of the HttpClient on Dispose.
Configuration(string secret="", HttpClient? httpClient=null, ILogger? logger=null)
Initializes a new instance of the Configuration record with the specified secret key.
TimeSpan ClientBufferTimeout
Additional buffer to add to QueryOptions.QueryTimeout when setting the HTTP request timeout on the Ht...
IStatsCollector? StatsCollector
StatsCollector for the client.
QueryOptions DefaultQueryOptions
Default options for queries sent to Fauna.
Represents the options for customizing Fauna queries.
A class representing a retry configuration for queries.
The default implementation of IStatsCollector.
An interface used by a client instance for aggregating stats across all queries.