Documentation
¶
Index ¶
- Variables
- type FlywheelIteration
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) CreateResource(resourceType, name, versionName string, values map[string]any, tags []Tag) (*Resource, error)
- func (b *InMemoryBackend) DeleteResource(resourceArn, resourceType string) error
- func (b *InMemoryBackend) DeleteResourcePolicy(resourceArn, expectedRevision string) error
- func (b *InMemoryBackend) DescribeJob(id, jobType string) (*Job, error)
- func (b *InMemoryBackend) GetFlywheelIteration(id string) (*FlywheelIteration, error)
- func (b *InMemoryBackend) GetResource(resourceArn, resourceType string) (*Resource, error)
- func (b *InMemoryBackend) GetResourcePolicy(resourceArn string) (string, string, error)
- func (b *InMemoryBackend) ListFlywheelIterations(flywheelArn string) []*FlywheelIteration
- func (b *InMemoryBackend) ListJobs(jobType string) []*Job
- func (b *InMemoryBackend) ListResources(resourceType string) []*Resource
- func (b *InMemoryBackend) ListTags(resourceArn string) ([]Tag, error)
- func (b *InMemoryBackend) PutResourcePolicy(resourceArn, policy, expectedRevision string) (string, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartFlywheelIteration(flywheelArn string) (*FlywheelIteration, error)
- func (b *InMemoryBackend) StartJob(jobType, name string, values map[string]any, tags []Tag) (*Job, error)
- func (b *InMemoryBackend) StopJob(id, jobType string) (*Job, error)
- func (b *InMemoryBackend) StopTrainingResource(resourceArn, resourceType string) error
- func (b *InMemoryBackend) TagResource(resourceArn string, tags []Tag) error
- func (b *InMemoryBackend) UntagResource(resourceArn string, keys []string) error
- func (b *InMemoryBackend) UpdateResource(resourceArn, resourceType string, values map[string]any) (*Resource, error)
- type Job
- type Provider
- type Resource
- type Tag
Constants ¶
This section is empty.
Variables ¶
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 ¶
ChaosOperations returns fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions returns configured service region.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns service key for fault matching.
func (*Handler) ExtractOperation ¶
ExtractOperation returns operation in request target.
func (*Handler) ExtractResource ¶
ExtractResource retrieves common ARN and job identifier fields.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations reports implemented operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns Echo JSON target dispatcher.
func (*Handler) MatchPriority ¶
MatchPriority returns header matching priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches Comprehend X-Amz-Target headers.
func (*Handler) Snapshot ¶
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates a Comprehend backend and handler.
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.