Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change source reporter interfaces to not return errors #3900

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update source reporter interfaces to not return errors
  • Loading branch information
mcastorina committed Feb 11, 2025
commit fd5d00ff55b72362a91e8f64ec1f7014b8b934dc
20 changes: 10 additions & 10 deletions pkg/sources/sources.go
Original file line number Diff line number Diff line change
@@ -97,9 +97,9 @@ type SourceUnitEnumerator interface {
// reporting them or any errors to the UnitReporter. This method is
// synchronous but can be called in a goroutine to support concurrent
// enumeration and chunking. An error should only be returned from this
// method in the case of context cancellation, fatal source errors, or
// errors returned by the reporter. All other errors related to unit
// enumeration are tracked by the UnitReporter.
// method in the case of context cancellation or fatal source errors
// All other errors related to unit enumeration are tracked by the
// UnitReporter.
Enumerate(ctx context.Context, reporter UnitReporter) error
}

@@ -130,27 +130,27 @@ func (b baseUnitReporter) UnitErr(ctx context.Context, err error) error {
// unit was found during enumeration. Either method may be called any number of
// times. Implementors of this interface should allow for concurrent calls.
type UnitReporter interface {
UnitOk(ctx context.Context, unit SourceUnit) error
UnitErr(ctx context.Context, err error) error
UnitOk(ctx context.Context, unit SourceUnit)
UnitErr(ctx context.Context, err error)
}

// SourceUnitChunker defines an optional interface a Source can implement to
// support chunking a single SourceUnit.
type SourceUnitChunker interface {
// ChunkUnit creates 0 or more chunks from a unit, reporting them or
// any errors to the ChunkReporter. An error should only be returned
// from this method in the case of context cancellation, fatal source
// errors, or errors returned by the reporter. All other errors related
// to unit chunking are tracked by the ChunkReporter.
// from this method in the case of context cancellation or fatal source
// errors. All other errors related to unit chunking are tracked by the
// ChunkReporter.
ChunkUnit(ctx context.Context, unit SourceUnit, reporter ChunkReporter) error
}

// ChunkReporter defines the interface a source will use to report whether a
// chunk was found during unit chunking. Either method may be called any number
// of times. Implementors of this interface should allow for concurrent calls.
type ChunkReporter interface {
ChunkOk(ctx context.Context, chunk Chunk) error
ChunkErr(ctx context.Context, err error) error
ChunkOk(ctx context.Context, chunk Chunk)
ChunkErr(ctx context.Context, err error)
}

type SourceUnitKind string