Table of Contents

Class AnalyticsApiFactory

Namespace
Cloudflare.NET.Analytics
Assembly
Cloudflare.NET.Analytics.dll

Factory that creates named IAnalyticsApi instances. Each named client is configured with its own GraphQL endpoint and authentication token from the corresponding CloudflareApiOptions.

public sealed class AnalyticsApiFactory : IAnalyticsApiFactory, IDisposable
Inheritance
AnalyticsApiFactory
Implements
Inherited Members

Remarks

This factory caches created clients to avoid the overhead of creating new GraphQL clients on every request. Clients are cached by name and reused for subsequent requests.

Named clients are registered using AddCloudflareAnalytics(IServiceCollection, string) .

Constructors

AnalyticsApiFactory(IHttpClientFactory, IOptionsMonitor<CloudflareApiOptions>, ILoggerFactory)

Initializes a new instance of the AnalyticsApiFactory class.

public AnalyticsApiFactory(IHttpClientFactory httpClientFactory, IOptionsMonitor<CloudflareApiOptions> optionsMonitor, ILoggerFactory loggerFactory)

Parameters

httpClientFactory IHttpClientFactory

The HTTP client factory.

optionsMonitor IOptionsMonitor<CloudflareApiOptions>

The options monitor for named Cloudflare API options.

loggerFactory ILoggerFactory

The logger factory.

Methods

CreateClient(string)

Creates an IAnalyticsApi instance configured with the specified named options.

public IAnalyticsApi CreateClient(string name)

Parameters

name string

The name of the client configuration to use. This must match the name used during registration.

Returns

IAnalyticsApi

A new IAnalyticsApi instance configured with the named options.

Exceptions

InvalidOperationException

Thrown when no client with the specified name has been registered.

Dispose()

Disposes all cached GraphQL clients.

public void Dispose()