ports

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package ports provides stable generic utilities used across independent core packages: Logger, Clock, and IDGen. Domain, HTTP, persistence, and adapter contracts live with the package that consumes them or in github.com/aatuh/api-toolkit/contrib/v4/contracts. See docs/v4-plan.md for the v4 ownership boundary.

Purpose: See the package summary above. Import: `github.com/aatuh/api-toolkit/v4/ports`. Example: See docs/api-reference.md for package example links and docs/cookbook.md for task recipes. Errors: Constructors, parsers, and handlers return or write documented errors according to their signatures; packages with plain data types do not add hidden error channels. Concurrency: Treat configured middleware and helpers as immutable after construction; request and response values remain request-scoped unless a type documents stronger guarantees. Stability: Stable core API under VERSIONING.md and scripts/apicheck.sh. When not to use: Prefer net/http, application-owned types, or narrower helpers when this package contract is not needed.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock allows deterministic tests.

type IDGen

type IDGen interface {
	New() string
}

IDGen generates unique IDs.

type Logger

type Logger interface {
	Debug(msg string, kv ...any)
	Info(msg string, kv ...any)
	Warn(msg string, kv ...any)
	Error(msg string, kv ...any)
}

Logger is a tiny façade to avoid vendor lock-in.

type NopLogger

type NopLogger struct{}

NopLogger is a no-op logger for safe defaults.

Example
package main

import (
	"github.com/aatuh/api-toolkit/v4/ports"
)

func main() {
	var logger ports.Logger = ports.NopLogger{}
	logger.Info("request completed", "request_id", "req_123")
}

func (NopLogger) Debug

func (NopLogger) Debug(string, ...any)

Debug implements Logger.

func (NopLogger) Error

func (NopLogger) Error(string, ...any)

Error implements Logger.

func (NopLogger) Info

func (NopLogger) Info(string, ...any)

Info implements Logger.

func (NopLogger) Warn

func (NopLogger) Warn(string, ...any)

Warn implements Logger.

type SystemClock

type SystemClock struct{}

SystemClock implements Clock using time.Now.

func (SystemClock) Now

func (SystemClock) Now() time.Time

Now returns the current time.

Jump to

Keyboard shortcuts

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