source

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package source abstracts data acquisition from different transport layers.

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 provides access to local filesystem resources.

func NewFileSource

func NewFileSource(name string) FileSource

NewFileSource creates a FileSource for the specified file path.

func (FileSource) Open

Open prepares the file for reading. The context is ignored.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient abstracts HTTP request execution, primarily for testing.

type HTTPSource

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

HTTPSource retrieves data from a remote URL.

func NewDefaultHTTPSource

func NewDefaultHTTPSource(url string) HTTPSource

NewDefaultHTTPSource creates an HTTPSource using the default http.Client.

func NewHTTPSource

func NewHTTPSource(url string, client HTTPClient) HTTPSource

NewHTTPSource creates an HTTPSource with the given client.

func (HTTPSource) Open

func (s HTTPSource) Open(ctx context.Context) (io.ReadCloser, error)

Open executes a GET request and returns the response body.

type LocationSource

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

LocationSource infers the transport protocol from the location string and delegates the Open call to the corresponding implementation.

func NewLocationSource

func NewLocationSource(location string) LocationSource

NewLocationSource creates a LocationSource for the provided resource identifier.

func (LocationSource) Open

Open resolves the resource and initiates data retrieval based on the format of the location string.

type Source

type Source interface {
	// Open initiates access to the resource. The caller must close the stream.
	Open(ctx context.Context) (io.ReadCloser, error)
}

Source represents a provider of a data stream.

Jump to

Keyboard shortcuts

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