service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package service provides domain services that orchestrate transformer execution. Services coordinate between entities and ports without depending on adapters.

pkg/domain/service/enrichment_service.go

pkg/domain/service/transformation_service.go

pkg/domain/service/validation_service.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnrichmentService

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

EnrichmentService manages data enrichment operations

func NewEnrichmentService

func NewEnrichmentService(enrichmentPort port.EnrichmentPort, metricsPort port.MetricsPort) *EnrichmentService

NewEnrichmentService creates a new enrichment service

func (*EnrichmentService) BatchEnrich

func (s *EnrichmentService) BatchEnrich(ctx context.Context, keys []string, data []map[string]any) ([]map[string]any, error)

BatchEnrich enhances multiple records

func (*EnrichmentService) Enrich

func (s *EnrichmentService) Enrich(ctx context.Context, key string, data map[string]any) (map[string]any, error)

Enrich enhances data with external source

type ServiceConfig

type ServiceConfig struct {
	// CacheTTL is the default time-to-live for cached transformation results
	CacheTTL time.Duration

	// MetricsEnabled controls whether services emit metrics
	MetricsEnabled bool

	// RetryAttempts is the number of times to retry failed operations
	RetryAttempts int

	// CircuitBreakerThreshold is the failure threshold before opening circuit
	CircuitBreakerThreshold float64
}

ServiceConfig holds common configuration for all domain services

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

DefaultServiceConfig returns sensible defaults for service configuration

type TransformationService

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

TransformationService orchestrates transformations with caching and metrics

func NewTransformationService

func NewTransformationService(cachePort port.CachePort, metricsPort port.MetricsPort) *TransformationService

NewTransformationService creates a new service

func (*TransformationService) Execute

func (s *TransformationService) Execute(ctx context.Context, transformer entity.Transformer, input any) *entity.TransformResult

Execute performs a transformation with caching

func (*TransformationService) ExecuteChain

func (s *TransformationService) ExecuteChain(ctx context.Context, transformers []entity.Transformer, input any) *entity.TransformResult

ExecuteChain applies multiple transformers in sequence

func (*TransformationService) SetCacheTTL

func (s *TransformationService) SetCacheTTL(ttl time.Duration)

SetCacheTTL sets the cache TTL for transformation results.

type ValidationService

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

ValidationService validates inputs and rules

func NewValidationService

func NewValidationService() *ValidationService

NewValidationService creates a new validation service

func NewValidationServiceWithMetrics

func NewValidationServiceWithMetrics(metricsPort port.MetricsPort) *ValidationService

NewValidationServiceWithMetrics creates a new validation service with metrics

func (*ValidationService) Validate

func (s *ValidationService) Validate(input any) error

Validate checks if input is valid

func (*ValidationService) ValidateChain

func (s *ValidationService) ValidateChain(transformers []any) error

ValidateChain checks if transformer chain is valid

func (*ValidationService) ValidateTransformer

func (s *ValidationService) ValidateTransformer(transformer any) error

ValidateTransformer checks if transformer is valid

Jump to

Keyboard shortcuts

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