status

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package status provides a cache for the MarketData API status endpoint, used to avoid retrying requests when the service is known to be offline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache tracks the API's online/offline status for use in retry decisions. It is safe for concurrent use.

func New

func New(fetcher Fetcher) *Cache

New creates a new status cache with the given fetcher function.

func (*Cache) IsOnline

func (c *Cache) IsOnline() bool

IsOnline returns whether the API is currently considered online. It applies the caching strategy with 270s/300s thresholds:

  • Cached offline: always re-probe immediately (see below), return false until a probe succeeds.
  • Cache age < 270s: return cached status.
  • Cache age 270s-300s: return cached status, trigger non-blocking refresh.
  • Cache age >= 300s or empty: return unknown (true), trigger non-blocking refresh.

func (*Cache) Update

func (c *Cache) Update(online bool)

Update directly sets the cache status. Used when a status response is received as part of normal operations (e.g., during startup validation).

type Fetcher

type Fetcher func(ctx context.Context) (online bool, err error)

Fetcher is a function that fetches the current API status. It returns true if the API is online.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL