Documentation
¶
Index ¶
- Constants
- Variables
- type AsyncInvoke
- 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) Purge(ctx context.Context, cutoff time.Time)
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) AdvanceAsyncInvokesForTest(minAge time.Duration)
- func (b *InMemoryBackend) GetAsyncInvoke(invocationArn string) (*AsyncInvoke, error)
- func (b *InMemoryBackend) ListAsyncInvokes(filter ListAsyncInvokesFilter) []*AsyncInvoke
- func (b *InMemoryBackend) ListInvocations() []*Invocation
- func (b *InMemoryBackend) Purge(ctx context.Context, cutoff time.Time)
- func (b *InMemoryBackend) RecordInvocation(operation, modelID, input, output string) *Invocation
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RunJanitor(ctx context.Context, interval time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartAsyncInvoke(modelID, s3URI, clientToken string, tags map[string]string) (*AsyncInvoke, error)
- type Invocation
- type ListAsyncInvokesFilter
- type Provider
Constants ¶
const ( AsyncInvokeStatusInProgress = "InProgress" AsyncInvokeStatusCompleted = "Completed" AsyncInvokeStatusFailed = "Failed" )
Async invoke status values.
const MaxInvocationHistory = maxInvocationHistory
MaxInvocationHistory is the exported value for testing.
Variables ¶
var ( // ErrValidation is returned when a request parameter fails validation. ErrValidation = errors.New("ValidationException") // ErrNotFound is returned when a requested resource does not exist. ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) )
Sentinel errors for the bedrockruntime backend.
Functions ¶
This section is empty.
Types ¶
type AsyncInvoke ¶
type AsyncInvoke struct {
SubmitTime time.Time
LastModifiedTime time.Time
EndTime *time.Time
FailureMessage *string
ClientRequestToken *string
Tags map[string]string
InvocationArn string
ModelArn string
OutputS3URI string
Status string
}
AsyncInvoke records an asynchronous model invocation.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for AWS Bedrock Runtime operations.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a new Bedrock Runtime handler backed by backend. backend must not be nil.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name from the request path.
func (*Handler) ExtractResource ¶
ExtractResource extracts the primary resource identifier from the request path. For metrics/logging purposes, returns stable low-cardinality values: model paths return the modelId, guardrail paths return the guardrailIdentifier, and /async-invoke item paths return "async-invoke" (stable, not the ARN).
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for Bedrock Runtime requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Purge ¶
Purge implements service.Purgeable by removing all Bedrock Runtime invocation records older than cutoff.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears all backend state. Implements service.Resettable.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Bedrock Runtime requests. It matches paths for /model/, /guardrail/, and /async-invoke.
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 BedrockRuntime up at all: dead wiring, with no persistence underneath it either. This delegation (matching the cleanrooms/codecommit pattern) is what wires BedrockRuntime into persistence for the first time.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend stores Bedrock Runtime state in memory.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new InMemoryBackend with a background service context.
func NewInMemoryBackendWithContext ¶
func NewInMemoryBackendWithContext(svcCtx context.Context, accountID, region string) *InMemoryBackend
NewInMemoryBackendWithContext creates a new InMemoryBackend whose background goroutines are bounded by svcCtx. If svcCtx is nil, context.Background is used.
func (*InMemoryBackend) AdvanceAsyncInvokesForTest ¶
func (b *InMemoryBackend) AdvanceAsyncInvokesForTest(minAge time.Duration)
AdvanceAsyncInvokesForTest is a test helper that immediately advances all InProgress invocations whose age exceeds minAge. Pass 0 to advance all immediately.
func (*InMemoryBackend) GetAsyncInvoke ¶
func (b *InMemoryBackend) GetAsyncInvoke(invocationArn string) (*AsyncInvoke, error)
GetAsyncInvoke returns the async invocation with the given ARN. Returns ErrNotFound if the invocation does not exist.
func (*InMemoryBackend) ListAsyncInvokes ¶
func (b *InMemoryBackend) ListAsyncInvokes(filter ListAsyncInvokesFilter) []*AsyncInvoke
ListAsyncInvokes returns async invocations sorted by submit time (oldest first). An optional filter may restrict results by status.
func (*InMemoryBackend) ListInvocations ¶
func (b *InMemoryBackend) ListInvocations() []*Invocation
ListInvocations returns all recorded invocations in insertion order (oldest first).
func (*InMemoryBackend) Purge ¶
func (b *InMemoryBackend) Purge(ctx context.Context, cutoff time.Time)
Purge removes all model invocations recorded before the cutoff time.
func (*InMemoryBackend) RecordInvocation ¶
func (b *InMemoryBackend) RecordInvocation(operation, modelID, input, output string) *Invocation
RecordInvocation stores a completed invocation in memory. When the ring is full, the oldest entry is evicted and a warning is logged via the background context.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the AWS region this backend is configured for.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all backend state, returning the backend to its initial empty state.
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) RunJanitor ¶
func (b *InMemoryBackend) RunJanitor(ctx context.Context, interval time.Duration)
RunJanitor periodically cleans up old async invocations and advances InProgress ones.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartAsyncInvoke ¶
func (b *InMemoryBackend) StartAsyncInvoke( modelID, s3URI, clientToken string, tags map[string]string, ) (*AsyncInvoke, error)
StartAsyncInvoke creates a new asynchronous model invocation and returns it. If clientToken is non-empty and an invocation with that token already exists, the existing invocation is returned (idempotency). Returns an error if required parameters are missing.
type Invocation ¶
type Invocation struct {
CreatedAt time.Time
ModelID string
Operation string
Input string
Output string
}
Invocation records a single model invocation.
type ListAsyncInvokesFilter ¶
type ListAsyncInvokesFilter struct {
// StatusEquals filters to invocations with the given status; empty means no filter.
StatusEquals string
}
ListAsyncInvokesFilter holds optional filter criteria for listing async invocations.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Bedrock Runtime.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Bedrock Runtime backend and handler.