forecast

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 21 Imported by: 0

README

Forecast

Parity grade: A · SDK aws-sdk-go-v2/service/forecast@v1.42.0 · last audited 2026-07-13 (987784da)

Coverage

Metric Value
Operations audited 8 (8 ok)
Feature families 7 (7 ok)
Known gaps 3
Deferred items 3
Resource leaks clean
Known gaps
    • No cross-resource FK/state validation on Create*: CreateForecast accepts any PredictorArn string without checking the predictor exists or is ACTIVE; CreateDatasetImportJob accepts any DatasetArn; CreateForecastExportJob accepts any ForecastArn; etc. Real AWS returns ResourceNotFoundException for a dangling reference (and arguably ResourceInUseException / InvalidInputException for a referenced resource that hasn't reached ACTIVE). NOT fixed this pass: the existing test suite (handler_test.go, parity_a/c_test.go, handler_audit1_test.go) deliberately uses placeholder non-ARN strings like "predictor"/"forecast" as FK values across ~15 test cases, so adding FK validation is a cross-cutting change that would need to rewrite most of the existing test fixtures in the same pass — out of scope for a surgical bug-fix pass. Needs a dedicated pass.
    • No enum validation on Domain (CreateDataset/CreateDatasetGroup), DatasetType, DataFrequency, ImportMode, or other AWS-modeled enum fields — any string is accepted where AWS would return InvalidInputException for a value outside the enum. Only resource names are validated (charset + 256-char max).
    • Delete* never returns ResourceInUseException for a resource that still has dependents (e.g. deleting a DatasetGroup that still has Datasets, or a Predictor that still has Forecasts) — delete always succeeds if the resource exists. DeleteResourceTree is the only op that models the AWS cascade-delete-children behavior; the single-resource Delete* ops do not check for dependents at all.
Deferred
  • CreateDataset/CreateDatasetGroup Domain and other enum-field validation
  • Cross-resource FK existence/state validation on Create*
  • Delete* ResourceInUseException-on-dependents modeling

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested Forecast resource is absent.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a Forecast resource name already exists.
	ErrAlreadyExists = awserr.New("ResourceAlreadyExistsException", awserr.ErrConflict)
	// ErrValidation is returned when a Forecast request is invalid.
	ErrValidation = awserr.New("InvalidInputException", awserr.ErrInvalidParameter)
	// ErrInvalidNextToken is returned when a List* NextToken cannot be decoded.
	// Real Amazon Forecast models InvalidNextTokenException on every List operation.
	ErrInvalidNextToken = awserr.New("InvalidNextTokenException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("forecast: nil AppContext")

ErrNilAppContext is returned when Init receives nil context.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler serves Amazon Forecast JSON protocol operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates Forecast HTTP handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns supported fault injection operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns regions handled by instance.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns fault injection service identifier.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts operation from Forecast target.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(_ *echo.Context) string

ExtractResource returns no generic resource identifier.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations reports implemented Amazon Forecast operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns Echo handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns Forecast header match priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns service registry name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all backend state for the /_gopherstack/reset test hook.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches Forecast target requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend. Handler previously had no Snapshot/Restore of its own -- and neither did InMemoryBackend -- so cli.go's generic setupPersistence never picked Forecast up at all: dead wiring, with no persistence underneath it either. This delegation (matching the cleanrooms/codecommit/codepipeline/emr/ workmail pattern) is what wires Forecast into persistence for the first time.

type InMemoryBackend

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

InMemoryBackend stores Amazon Forecast state with concurrency-safe transitions.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend returns a stateful Amazon Forecast backend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns backend account.

func (*InMemoryBackend) DeleteResourceTree

func (b *InMemoryBackend) DeleteResourceTree(targetARN string) error

DeleteResourceTree deletes a resource and all dependent child resources transitively, mirroring AWS Forecast behavior.

func (*InMemoryBackend) GetAccuracyMetrics

func (b *InMemoryBackend) GetAccuracyMetrics(predictorArn string) (map[string]any, error)

GetAccuracyMetrics returns deterministic backtest accuracy metrics for a predictor, modeled on the AWS Forecast GetAccuracyMetrics response shape (PredictorEvaluationResults -> TestWindows -> Metrics with RMSE, weighted quantile losses, and WAPE/MAPE/MASE error metrics). Values are derived from a stable hash of the predictor ARN so repeated calls return identical numbers, which is what a Terraform/SDK client comparing state expects. This exceeds LocalStack, which returns no evaluation results at all.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)

ListTagsForResource lists tags for a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns backend region.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory Forecast state. It supports the /_gopherstack/reset test hook so suites start from a clean slate.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore deserializes backend state from a snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serializes the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error

TagResource adds tags to a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource -- TagResource does not silently create tag state for ARNs no resource ever owned.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error

UntagResource removes tags from a resource. Real Amazon Forecast returns ResourceNotFoundException when resourceARN does not identify an existing resource.

func (*InMemoryBackend) UpdateResourceStatus

func (b *InMemoryBackend) UpdateResourceStatus(resourceARN, newStatus string) error

UpdateResourceStatus handles StopResource and ResumeResource.

type MonitorEvaluation

type MonitorEvaluation struct {
	CreationTime    time.Time `json:"CreationTime"`
	EvaluationTime  time.Time `json:"EvaluationTime"`
	PredictorEvent  any       `json:"PredictorEvent,omitempty"`
	Message         string    `json:"Message,omitempty"`
	MonitorArn      string    `json:"MonitorArn"`
	MonitorName     string    `json:"MonitorName"`
	ResourceArn     string    `json:"ResourceArn,omitempty"`
	Status          string    `json:"Status"`
	EvaluationState string    `json:"EvaluationState"`
	MetricResults   []any     `json:"MetricResults"`
}

MonitorEvaluation represents one completed evaluation emitted by a predictor monitor.

type Provider

type Provider struct{}

Provider initializes Amazon Forecast.

func (*Provider) Init

Init initializes Amazon Forecast backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns provider name.

type Resource

type Resource struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	Data      map[string]any
	ARN       string
	Name      string
	Status    string
	Kind      resourceKind
}

Resource stores one Forecast API object with AWS response-shaped attributes.

Jump to

Keyboard shortcuts

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