port

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package port defines repository and other ports (interfaces) used by use cases. Implementations live in infrastructure (e.g. repositories package); domain does not depend on them.

Role in architecture:

  • Ports: interfaces that use cases depend on; implemented by adapters in other packages.

Responsibilities:

  • Define minimal, use-case-oriented interfaces (e.g. GetByID).
  • No methods except those required by use cases; avoid fat interfaces.

This package must NOT:

  • Import infrastructure packages or contain implementations.
  • Define business rules; only interface contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetByID

type GetByID interface {
	GetByID(ctx context.Context, id string) (interface{}, bool, error)
}

GetByID is a minimal read port for use cases that fetch an entity by ID.

Implementations adapt infrastructure (e.g. repositories.BaseRepository) to this interface. Use in use cases so they depend only on domain; wire a concrete implementation in main.

Contract:

  • ctx: used for cancellation and timeouts; implementations must pass it to storage calls.
  • id: non-empty identifier (format is implementation-defined).
  • Returns (value, true, nil) when found, (nil, false, nil) when not found, (nil, false, err) on error.

Error contract: do not return (nil, true, err). On storage errors return (nil, false, err).

Jump to

Keyboard shortcuts

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