internal

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package internal contains core domain logic with zero Forge imports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHash

func NewHash(alg ChecksumAlgorithm) (hash.Hash, error)

NewHash returns a new hash.Hash for the given algorithm.

func VerifyChecksum

func VerifyChecksum(r io.Reader, expected Checksum) error

VerifyChecksum reads all data from r and verifies it matches the expected checksum.

Types

type Checksum

type Checksum struct {
	Algorithm ChecksumAlgorithm `json:"algorithm"`
	Value     string            `json:"value"`
}

Checksum holds integrity verification data.

func ComputeChecksum

func ComputeChecksum(r io.Reader, alg ChecksumAlgorithm) (Checksum, error)

ComputeChecksum reads all data from r and computes a checksum using the specified algorithm. The reader is consumed entirely.

func ComputeChecksumBytes

func ComputeChecksumBytes(data []byte, alg ChecksumAlgorithm) (Checksum, error)

ComputeChecksumBytes computes a checksum of the given byte slice.

type ChecksumAlgorithm

type ChecksumAlgorithm string

ChecksumAlgorithm identifies the hash algorithm used for integrity verification.

const (
	AlgSHA256 ChecksumAlgorithm = "sha256"
	AlgBlake3 ChecksumAlgorithm = "blake3"
	AlgXXHash ChecksumAlgorithm = "xxhash"
)

type Route

type Route struct {
	Pattern string
	Backend string
}

Route maps a key pattern to a named backend.

type RouteFunc

type RouteFunc func(bucket, key string) string

RouteFunc is a custom routing function that returns a backend name for the given bucket and key. Return empty string to use the default backend.

type Router

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

Router manages the default driver and named backends, resolving which driver should handle a given operation based on routing rules.

func NewRouter

func NewRouter(defaultDr driver.Driver) *Router

NewRouter creates a new Router with the given default driver.

func (*Router) AddBackend

func (r *Router) AddBackend(name string, drv driver.Driver)

AddBackend registers a named backend.

func (*Router) AddRoute

func (r *Router) AddRoute(pattern, backend string)

AddRoute adds a pattern-based routing rule.

func (*Router) AddRouteFunc

func (r *Router) AddRouteFunc(fn RouteFunc)

AddRouteFunc adds a custom routing function.

func (*Router) Backend

func (r *Router) Backend(name string) driver.Driver

Backend returns the driver registered under the given name. Returns nil if the backend is not found.

func (*Router) Backends

func (r *Router) Backends() []string

Backends returns the names of all registered backends.

func (*Router) Close

func (r *Router) Close(_ interface{ Done() <-chan struct{} }) error

Close closes the default driver and all named backends.

func (*Router) CloseAll

func (r *Router) CloseAll(closeFn func(driver.Driver) error) error

CloseAll closes all drivers. This uses a concrete approach accepting a close function per driver.

func (*Router) Default

func (r *Router) Default() driver.Driver

Default returns the default driver.

func (*Router) Resolve

func (r *Router) Resolve(bucket, key string) driver.Driver

Resolve returns the driver that should handle the given bucket/key operation. Resolution order:

  1. Custom route functions (first non-empty return wins)
  2. Pattern routes (first matching pattern wins)
  3. Default driver

Directories

Path Synopsis
Package telemetry is the tracing and metrics plumbing Trove's packages share: the tracer every span comes from, span names and attribute keys, how a failed span is marked, and how a measurement reaches the caller's observe.Recorder.
Package telemetry is the tracing and metrics plumbing Trove's packages share: the tracer every span comes from, span names and attribute keys, how a failed span is marked, and how a measurement reaches the caller's observe.Recorder.
Package telemetrytest records what Trove's telemetry emits, for tests: a span recorder installed as the global tracer provider, and an observe.Recorder that remembers every measurement and checks it against the metric definitions in package observe.
Package telemetrytest records what Trove's telemetry emits, for tests: a span recorder installed as the global tracer provider, and an observe.Recorder that remembers every measurement and checks it against the metric definitions in package observe.

Jump to

Keyboard shortcuts

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