tool

package
v0.0.0-...-0d1d0b3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DevMode = false
View Source
const NoticeLevel = slog.LevelInfo + 2

Variables

This section is empty.

Functions

func CLICache

func CLICache() writefs.CompleteFS

Return the cache file system from CLI value. It need to call CLI before.

func FetchAll

func FetchAll(t *Tool, request *fetch.Request) []byte

func FetchJSON

func FetchJSON(t *Tool, ty sch.Type, dto any, request *fetch.Request) (fail bool)

Fetch and decode in JSON to dto.

Is devmode and ty is not nil, make a first request to check json in type.

Types

type Config

type Config struct {
	LogHandler slog.Handler

	Writefile writefs.Creator
	Fetcher   []fetch.Fetcher

	LongTasksCache writefs.CreateOpener
	LongTasksMap   map[string]func(*Tool, []byte) ([]byte, error)
}

func CLI

func CLI(delay map[string]time.Duration) *Config

Add some flags, call flag.Parse, and use result in the config.

func (*Config) Run

func (config *Config) Run(name string, do func(*Tool))

type Tool

type Tool struct {
	*slog.Logger
	// contains filtered or unexported fields
}

All information for one service.

Concerning WriteFile and Fetch: - log the result - consider error as fatal: return nothing because the service cannot resolve it.

func New

func New(config *Config) *Tool

func NewTestTool

func NewTestTool(fetcher fetch.Fetcher) (writefs.T, *Tool)

func (*Tool) Fetch

func (t *Tool) Fetch(request *fetch.Request) *fetch.Response

Make a HTTP call, and return the body. Return nil if cannot parse the url.

Logs results and errors.

If all internal fetchers return and error, return nil.

func (*Tool) LongTask

func (t *Tool) LongTask(name, logRef string, input []byte) []byte

Try to execute a long task. The result can be empty if error occure or no task function.

func (*Tool) WriteFile

func (t *Tool) WriteFile(path string, data []byte)

Directories

Path Synopsis
Make HTTP requests.
Make HTTP requests.
Tools collection to minify and prepare assets.
Tools collection to minify and prepare assets.
render is a lib for render secure HTML within go code.
render is a lib for render secure HTML within go code.
sch check that data observe a schema.
sch check that data observe a schema.
FS interface to read and write.
FS interface to read and write.

Jump to

Keyboard shortcuts

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