clientdiscovery

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package clientdiscovery owns normalized, source-scoped torrent-client discovery for canonical preparation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLiveTestPolicy added in v0.3.2

func WithLiveTestPolicy(client api.ClientService, policy *api.LiveTestPolicy) api.ClientService

WithLiveTestPolicy keeps injected client services behind process-owned guards. Read-only discovery remains available; force-recheck is a client mutation.

Types

type Disposition

type Disposition string

Disposition identifies whether a discovery request searched, was explicitly skipped, or could not search because no usable client adapter was available.

const (
	DispositionSearched    Disposition = "searched"
	DispositionSkipped     Disposition = "skipped"
	DispositionUnavailable Disposition = "unavailable"
)

type Evidence

type Evidence struct {
	// Disposition distinguishes an empty search result from no search.
	Disposition Disposition
	// InfoHash is the normalized hash of the matched local torrent.
	InfoHash string
	// TorrentPath is the reusable local metainfo path returned by the client search.
	TorrentPath string
	// TorrentDataVerified reports that TorrentPath belongs to a complete client
	// record whose content path exactly matched the searched source.
	TorrentDataVerified bool
	// TrackerIDs maps normalized tracker names to IDs extracted from the matched torrent.
	TrackerIDs map[string]string
	// FoundTrackerMatch reports whether any configured tracker matched.
	FoundTrackerMatch bool
	// TorrentComments contains detached tracker comment evidence.
	TorrentComments []api.TorrentMatch
	// PieceSizeConstraint carries any client-derived piece-size requirement.
	PieceSizeConstraint string
	// FoundPreferredPiece records the preferred reusable piece size when found.
	FoundPreferredPiece string
	// MatchedTrackers contains deduplicated, uppercase tracker names in sorted order.
	MatchedTrackers []string
}

Evidence is a detached normalized client snapshot. Callers decide which fields become private preparation evidence or operation-local state.

type Module

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

Module hides client availability, skip semantics, normalization, and error wrapping behind one operation-shaped interface.

func New

func New(clients api.ClientService, logger api.Logger) *Module

New constructs a client-discovery module. A nil client adapter represents a runtime without local client discovery and produces unavailable evidence.

func (*Module) Discover

func (m *Module) Discover(ctx context.Context, input SearchInput) (Evidence, error)

Discover obtains one current client snapshot and always reports why a search did or did not execute. Client failures produce unavailable evidence, while request validation and cancellation remain fatal.

type SearchInput

type SearchInput struct {
	// SourcePath is the canonical local source path supplied to the client adapter.
	SourcePath string
	// FileList contains source-relative or local file evidence used for matching.
	FileList []string
	// DiscType identifies disc layouts whose files require client-specific matching.
	DiscType string
	// Policy controls skipping and optional client selection.
	Policy api.ClientSearchPolicy
	// ForceRecheck forwards an explicit hash-recheck choice to the selected client.
	ForceRecheck *bool
}

SearchInput contains only source facts and search choices needed for one client-discovery operation.

Jump to

Keyboard shortcuts

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