lib

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fn

func Fn(dialTarget string, route *pb.Route) func(ctx context.Context)

Fn returns a function that attempts to add a route to caddycfginjector gRPC server via dialTarget.

Most likely this function will have to be called at least once, and then repeatedly using Periodically so that Caddy will have a chance to register the route in case of a later start.

Logging will be sent to a slog.Default() unless changed by SetLogger.

func Periodically

func Periodically(ctx context.Context, refreshDelay time.Duration, fn func(ctx context.Context))

Periodically is a helper that calls fn quickly and then repeats the call after refreshDelay duration until ctx requests a cancellation.

Provided ctx is also passed down to the fn.

go lib.Periodically(t, time.Second*2, fn)

func SetLogger

func SetLogger(l *slog.Logger)

SetLogger replaces default slog.Default() logger for targeting logging from this package. slog.SetDefault() would be a global way of changing slog destination.

Types

This section is empty.

Jump to

Keyboard shortcuts

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