comprehend

package
v1.1.3 Latest Latest
Warning

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

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

README

Comprehend

Parity grade: A · SDK aws-sdk-go-v2/service/comprehend@v1.41.0 · last audited 2026-07-13 (0e933737)

Coverage

Metric Value
Operations audited 11 (11 ok)
Feature families 1 (1 ok)
Known gaps 2
Deferred items 2
Resource leaks clean
Known gaps
  • BatchDetect* never populates ErrorList even for oversized/invalid TextList entries (AWS enforces a 25-item/5KB-per-item limit and reports per-item BatchItemError); acceptable for now since input is never rejected, but a client relying on partial-failure semantics won't see it (no bd issue filed yet)
  • DocumentClassifierProperties/EntityRecognizerProperties never populate TrainingStartTime/TrainingEndTime/ClassifierMetadata/RecognizerMetadata (fields exist on the real shape, we return zero-ish mock values via Configuration passthrough only if the caller set them) -- low priority, no client code path in the wild depends on these for basic lifecycle polling (no bd issue filed yet)
Deferred
  • DetectDominantLanguage/DetectEntities/etc. input validation (LanguageCode required per real API for all Detect* ops except DetectDominantLanguage) -- emulator is more permissive than AWS, not flagged as a parity bug per the no-stub focus on state/wire/tags
  • EventsDetectionJob family (Start/Describe/List) -- routed and shaped consistently with the other 8 async job families via the same jobSpec table, not individually re-verified beyond that consistency check

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested Comprehend resource is absent.
	ErrNotFound = errors.New("ResourceNotFoundException")
	// ErrConflict is returned when a named Comprehend resource already exists.
	ErrConflict = errors.New("ResourceInUseException")
	// ErrValidation is returned for invalid request values.
	ErrValidation = errors.New("InvalidRequestException")
)

Functions

This section is empty.

Types

type FlywheelIteration

type FlywheelIteration struct {
	CreationTime            time.Time
	EndTime                 time.Time
	FlywheelArn             string
	FlywheelIterationID     string
	FlywheelIterationStatus string
	Message                 string
	// contains filtered or unexported fields
}

FlywheelIteration represents one model training iteration.

type Handler

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

Handler serves Amazon Comprehend JSON operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates Comprehend handler backed by in-memory state.

func (*Handler) ChaosOperations

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

ChaosOperations returns fault-injectable operations.

func (*Handler) ChaosRegions

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

ChaosRegions returns configured service region.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns service key for fault matching.

func (*Handler) ExtractOperation

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

ExtractOperation returns operation in request target.

func (*Handler) ExtractResource

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

ExtractResource retrieves common ARN and job identifier fields.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations reports implemented operations.

func (*Handler) Handler

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

Handler returns Echo JSON target dispatcher.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns header matching priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears backend state.

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 Comprehend X-Amz-Target headers.

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 (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked Comprehend up at all: dead wiring, with no persistence underneath it either. This delegation (matching the codecommit/cleanrooms pattern) is what wires Comprehend into persistence for the first time.

type InMemoryBackend

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

InMemoryBackend stores Comprehend state safely for concurrent requests.

jobs, resources, and iterations are *store.Table[T] (see store_setup.go). Each keys off a real, non-json:"-" identity field the value type already carries (Job.JobID, Resource.Arn, FlywheelIteration.FlywheelIterationID), so all three register directly on registry -- no DTO indirection is needed. Neither table needs a secondary store.Index: every filtered listing (ListJobs by JobType, ListResources by Type, ListFlywheelIterations by FlywheelArn) scans the table's full contents, exactly as the original map-range loops did, and none of the fields mutated in place by advanceJob/advanceTrainingResource/etc. are ever used as an index key. tags, policies, and policyRevisions are left as plain maps: their values are not *T (map[string]string / string), so they do not fit store.Table's keyed-by-identity-value shape.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a configured Comprehend backend.

func (*InMemoryBackend) CreateResource

func (b *InMemoryBackend) CreateResource(
	resourceType, name, versionName string,
	values map[string]any,
	tags []Tag,
) (*Resource, error)

CreateResource creates a stateful Comprehend resource and optionally attaches tags.

func (*InMemoryBackend) DeleteResource

func (b *InMemoryBackend) DeleteResource(resourceArn, resourceType string) error

DeleteResource removes a stored resource and its tags. AWS returns ResourceInUseException when deleting a classifier or recognizer that is still training (status SUBMITTED or IN_PROGRESS).

func (*InMemoryBackend) DeleteResourcePolicy

func (b *InMemoryBackend) DeleteResourcePolicy(resourceArn, expectedRevision string) error

DeleteResourcePolicy removes a resource policy.

func (*InMemoryBackend) DescribeJob

func (b *InMemoryBackend) DescribeJob(id, jobType string) (*Job, error)

DescribeJob retrieves and advances a submitted job through its lifecycle.

func (*InMemoryBackend) GetFlywheelIteration

func (b *InMemoryBackend) GetFlywheelIteration(id string) (*FlywheelIteration, error)

GetFlywheelIteration returns and advances an iteration.

func (*InMemoryBackend) GetResource

func (b *InMemoryBackend) GetResource(resourceArn, resourceType string) (*Resource, error)

GetResource finds resource by ARN. For classifier and recognizer types, each Describe call advances training lifecycle: SUBMITTED → IN_PROGRESS → TRAINED (or FAILED when the name contains "[fail]"). This mirrors AWS async training.

func (*InMemoryBackend) GetResourcePolicy

func (b *InMemoryBackend) GetResourcePolicy(resourceArn string) (string, string, error)

GetResourcePolicy retrieves a resource policy.

func (*InMemoryBackend) ListFlywheelIterations

func (b *InMemoryBackend) ListFlywheelIterations(flywheelArn string) []*FlywheelIteration

ListFlywheelIterations lists iterations belonging to one flywheel.

func (*InMemoryBackend) ListJobs

func (b *InMemoryBackend) ListJobs(jobType string) []*Job

ListJobs returns jobs for one operation family in stable submission order.

func (*InMemoryBackend) ListResources

func (b *InMemoryBackend) ListResources(resourceType string) []*Resource

ListResources returns resources of one type. For classifier and recognizer types, listing advances the async training lifecycle one step (mirroring a status poll), consistent with how Describe advances it. This lets a create→describe→list→delete flow reach a deletable (TRAINED) state.

func (*InMemoryBackend) ListTags

func (b *InMemoryBackend) ListTags(resourceArn string) ([]Tag, error)

ListTags returns sorted resource tags.

func (*InMemoryBackend) PutResourcePolicy

func (b *InMemoryBackend) PutResourcePolicy(resourceArn, policy, expectedRevision string) (string, error)

PutResourcePolicy saves a resource policy.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns configured AWS region.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all stored Comprehend resources.

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) StartFlywheelIteration

func (b *InMemoryBackend) StartFlywheelIteration(flywheelArn string) (*FlywheelIteration, error)

StartFlywheelIteration creates an asynchronous flywheel iteration.

func (*InMemoryBackend) StartJob

func (b *InMemoryBackend) StartJob(jobType, name string, values map[string]any, tags []Tag) (*Job, error)

StartJob submits an analysis job with AWS-style initial status. tags are associated with the job's ARN in the same tag store Create* resources use, so ListTagsForResource/TagResource/UntagResource work against job ARNs too (Start*DetectionJob requests all accept an optional Tags field in the real API).

func (*InMemoryBackend) StopJob

func (b *InMemoryBackend) StopJob(id, jobType string) (*Job, error)

StopJob starts cancellation of an active job. AWS returns InvalidRequestException when the job is already in a terminal state (COMPLETED, FAILED, STOPPED, STOP_REQUESTED).

func (*InMemoryBackend) StopTrainingResource

func (b *InMemoryBackend) StopTrainingResource(resourceArn, resourceType string) error

StopTrainingResource sets a trainable resource's status to STOPPED.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceArn string, tags []Tag) error

TagResource adds or replaces tags on an existing resource.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceArn string, keys []string) error

UntagResource removes keys from an existing resource.

func (*InMemoryBackend) UpdateResource

func (b *InMemoryBackend) UpdateResource(resourceArn, resourceType string, values map[string]any) (*Resource, error)

UpdateResource changes stored configuration of a mutable resource.

type Job

type Job struct {
	SubmitTime            time.Time
	EndTime               time.Time
	JobID                 string
	JobArn                string
	JobName               string
	JobType               string
	JobStatus             string
	LanguageCode          string
	FailureReason         string
	InputDataConfig       map[string]any
	OutputDataConfig      map[string]any
	DataAccessRoleArn     string
	DocumentClassifierArn string
	EntityRecognizerArn   string
	TargetEventTypes      []string
	// contains filtered or unexported fields
}

Job represents an asynchronous document-analysis job.

type Provider

type Provider struct{}

Provider implements service.Provider for Amazon Comprehend.

func (*Provider) Init

Init creates a Comprehend 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
	Name          string
	Arn           string
	Type          string
	Status        string
	VersionName   string
	ModelArn      string
	FlywheelArn   string
	EndpointArn   string
	DatasetArn    string
	Configuration map[string]any
	FailureReason string
}

Resource stores a Comprehend trainable or hosted resource.

type Tag

type Tag struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

Tag is a Comprehend resource tag.

Jump to

Keyboard shortcuts

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