Movatterモバイル変換


[0]ホーム

URL:


reload

package
v1.92.2Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:9Imported by:0

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package reload contains functions that allow periodically reloading a value(e.g. a config file) from various sources.

Index

Constants

View Source
const DefaultInterval = 5 *time.Minute

DefaultInterval is the default value for ReloadOpts.Interval if none isprovided.

Variables

This section is empty.

Functions

funcNew

func New[Tany](ctxcontext.Context, optsReloadOpts[T]) (func() T,error)

New creates and starts reloading the provided value as per opts. It returnsa function that, when called, returns the current stored value, or an errorthat indicates something went wrong.

The value will be present immediately upon return.

Types

typeReloadOpts

type ReloadOpts[Tany] struct {// Read is called to obtain the data to be unmarshaled; e.g. by reading// from a file, or making a network request, etc.//// An error from this function is fatal when calling New, but only a// warning during reload.//// This value is required.Read func(context.Context) ([]byte,error)// Unmarshal is called with the data that the Read function returns and// should return a parsed form of the given value, or an error.//// An error from this function is fatal when calling New, but only a// warning during reload.//// This value is required.Unmarshal func([]byte) (T,error)// Logf is a logger used to print errors that occur on reload. If nil,// no messages are printed.Logflogger.Logf// Interval is the interval at which to reload the given data from the// source; if zero, DefaultInterval will be used.Intervaltime.Duration// IntervalJitter is the jitter to be added to the given Interval; if// provided, a duration between 0 and this value will be added to each// Interval when waiting.IntervalJittertime.Duration}

ReloadOpts specifies options for reloading a value. Various helper functionsin this package can be used to create one of these specialized for a givenuse-case.

funcFromJSONFile

func FromJSONFile[Tany](pathstring)ReloadOpts[T]

FromJSONFile creates a ReloadOpts describing reloading a value of type Tfrom the given JSON file on-disk.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp