Table of Contents

Class EndpointOptions

Namespace
Phetch.Core
Assembly
Phetch.Core.dll

A re-usable version of EndpointOptions<TArg, TResult> without type arguments, which can be used to share endpoint settings across multiple endpoints.

public sealed record EndpointOptions : IEquatable<EndpointOptions>
Inheritance
EndpointOptions
Implements
Inherited Members

Remarks

This can be customized for each endpoint using the EndpointOptions<TArg, TResult> constructor.

var defaultEndpointOptions = new EndpointOptions
       {
           RetryHandler = RetryHandler.Simple(3)
       };
       var endpoint = new Endpoint<int, string>(..., new(defaultEndpointOptions)
       {
           RetryHandler = RetryHandler.None,
           CacheTime = TimeSpan.Zero,
       });

Properties

CacheTime

The amount of time to store query results in the cache after they stop being used.

public TimeSpan CacheTime { get; init; }

Property Value

TimeSpan

Remarks

When set to Zero, queries will be removed from the cache as soon as they have no observers.

When set to MaxValue, queries will never be removed from the cache.

DefaultStaleTime

Default stale time to be used if not supplied when using the endpoint. This defaults to zero, so queries are considered stale as soon as they finish fetching.

When set to MaxValue, queries will never be considered stale (unless they are manually invalidated).
public TimeSpan DefaultStaleTime { get; init; }

Property Value

TimeSpan

Remarks

This can be overridden by StaleTime

OnFailure

A function that gets run whenever this query fails.

public Action<QueryFailureEventArgs>? OnFailure { get; init; }

Property Value

Action<QueryFailureEventArgs>

Remarks

Unlike OnFailure, this will be called even if the query is not being observed.

OnSuccess

A function that gets run whenever this query succeeds.

public Action<EventArgs>? OnSuccess { get; init; }

Property Value

Action<EventArgs>

Remarks

Unlike OnSuccess, this will be called exactly once per successful invokation of the underlying query function. This means:

RetryHandler

An optional object to control whether and how the query function is retried if it fails. If left null, the query will not be retried when it fails.

public IRetryHandler? RetryHandler { get; init; }

Property Value

IRetryHandler

Remarks

Example:
var endpoint = new Endpoint<int, string>(..., new() {
      RetryHandler = RetryHandler.Simple(3)
  });