source

package
v4.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSource

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

FileSource loads JSON files from one directory and keys them by filename.

func NewFileSource

func NewFileSource(directory string) (*FileSource, error)

NewFileSource loads all .json files in directory. A missing directory is represented by an empty source.

func (*FileSource) Fetch

func (s *FileSource) Fetch(_ context.Context, key string) (json.RawMessage, bool, error)

func (*FileSource) FetchAll

func (s *FileSource) FetchAll(context.Context) (map[string]json.RawMessage, error)

type HTTPSource

type HTTPSource[K comparable] struct {
	// contains filtered or unexported fields
}

HTTPSource fetches keyed raw values over HTTP using caller-provided protocol functions.

func NewHTTPSource

func NewHTTPSource[K comparable](client *http.Client, endpoint string, buildRequest RequestBuilder[K], decodeResponse ResponseDecoder[K]) (*HTTPSource[K], error)

NewHTTPSource builds a reusable HTTP source. Request construction and response decoding remain with the consuming data type.

func (*HTTPSource[K]) Fetch

func (s *HTTPSource[K]) Fetch(ctx context.Context, key K) (json.RawMessage, bool, error)

type NilSource

type NilSource[K comparable] struct{}

NilSource reports every key as not found.

func (NilSource[K]) Fetch

func (NilSource[K]) Fetch(context.Context, K) (json.RawMessage, bool, error)

type RequestBuilder

type RequestBuilder[K comparable] func(ctx context.Context, endpoint *url.URL, key K) (*http.Request, error)

RequestBuilder creates a request for one source key.

type ResponseDecoder

type ResponseDecoder[K comparable] func(key K, body []byte) (raw json.RawMessage, found bool, err error)

ResponseDecoder extracts one source value from a successful HTTP response.

Jump to

Keyboard shortcuts

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