Skip to content

lib/cluster: unify collector/publisher factories#1300

Open
bigbes wants to merge 2 commits into
v3from
bigbes/tntp-7390-lib-cluster-cleanup-v2
Open

lib/cluster: unify collector/publisher factories#1300
bigbes wants to merge 2 commits into
v3from
bigbes/tntp-7390-lib-cluster-cleanup-v2

Conversation

@bigbes
Copy link
Copy Markdown
Collaborator

@bigbes bigbes commented May 27, 2026

  • Collapse the twin DataCollectorFactory/DataPublisherFactory into a single Factory and drop redundant shims (CSConnection/ConnectCStorage, IRawStorage, CreateDataCollector, NewConfigStorage); rename FileDataPublisher → FilePublisher.
  • Simplify storage wiring: merge datacollector.go/datapublisher.go/errors.go into types.go, collapse RawStorage's *byKey/*byRange pairs into Get/Put/Collect/Publish, and fold optional cleanup into RawStorage.Close via SetCleanup (drops failoverStorage).
  • Expose NewCollectorFactory/NewPublisherFactory in cli/cluster as a single source of truth and inline the cli/cmd/common.go delegation wrappers at all 13 call sites.
  • Trim lib/integrity: merge dummy_repository.go into integrity.go, drop unused AddHash/Add stubs, shrink redundant flag-registrar tests.

Part of TNTP-7390

@bigbes bigbes requested review from Mockird31 and sssciel May 27, 2026 20:19
Base automatically changed from bigbes/tntp-7390-lib-cluster-cleanup to v3 May 29, 2026 15:37
bigbes added 2 commits May 29, 2026 18:39
Collapse the twin DataCollectorFactory and DataPublisherFactory into a
single Factory type. RawStorage already implements both DataCollector and
DataPublisher, so the two factories were mechanically duplicating each
other; their only real difference was which integrity options
(verifiers vs signer/verifiers) the caller wired up.

Along the way drop a handful of redundant shims now subsumed by the
unified factory and RawStorage:

  - CSConnection / ConnectCStorage: a duplicate codec wrapper around
    RawStorage. The two failover callers now build a RawStorage
    directly via NewStorage with an empty objectLocation.
  - IRawStorage: declared but never used as a type.
  - CreateDataCollector: a three-line wiring helper with a single
    caller; inlined.
  - NewConfigStorage: a one-line default-argument helper folded into
    Factory.NewRemoteStorage.

Rename FileDataPublisher -> FilePublisher for symmetry with
FileCollector. Helpers in cli/cmd that constructed the two factories
are consolidated into createCollectorFactory /
createPublisherFactory / createCollectorAndPublisherFactories. The
cli/cluster/cmd nil-checking createPublisherAndCollector splits into
openRemoteCollector (show) and openCollectorAndPublisher (publish).

Part of TNTP-7390
Drop redundant indirection across lib/cluster and lib/integrity and
wire the cleaned-up API through cli/cmd:

- Merge datacollector.go, datapublisher.go, errors.go into types.go;
  remove unused CollectEmptyError and errWrongRevision.
- Inline defaultFileReadFunc and the newFileCollector wrapper.
- Collapse RawStorage's collectByKey/publishByKey/collectByRange/
  publishByRange into Get/Put/Collect/Publish; inline
  applyIntegrityBuilderOptions into NewStorage.
- Wire optional cleanup into RawStorage.Close via SetCleanup so
  callers don't need a wrapper; drop failoverStorage.
- Expose NewCollectorFactory/NewPublisherFactory in cli/cluster as a
  single source of truth, inline the cli/cmd/common.go delegation
  wrappers at the 13 call sites in cli/cmd, and wrap pass-through
  errors crossing the cli/cluster boundary.
- Merge dummy_repository.go into lib/integrity/integrity.go; drop
  unused AddHash/Add stubs; shrink redundant flag-registrar tests;
  wrap os.Open's error in dummyRepository.Read with the path.
- Annotate three RawStorage internal pass-throughs with
  //nolint:wrapcheck — the callee already wraps with the storage type.

Part of TNTP-7390
@bigbes bigbes force-pushed the bigbes/tntp-7390-lib-cluster-cleanup-v2 branch from 471754d to d336530 Compare May 29, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants