sagemakerruntime

package
v1.1.1 Latest Latest
Warning

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

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

README

SageMaker Runtime

Parity grade: A · SDK aws-sdk-go-v2/service/sagemakerruntime@v1.39.3 · last audited 2026-07-13 (95ab0584)

Coverage

Metric Value
Operations audited 3 (3 ok)
Feature families 2 (2 ok)
Known gaps 3
Deferred items 0
Resource leaks clean
Known gaps
  • Endpoint-name existence is never validated (real AWS returns ValidationError for an unknown EndpointName). The endpoint registry is owned by services/sagemaker's InMemoryBackend, which sagemakerruntime has no wiring to reach -- cross-service backend references in this codebase go through a BackendsProvider interface implemented in cli.go (see services/cloudformation/provider.go for the pattern), which is out of scope for a same-service-only pass. (bd: file a cross-service issue for wiring sagemakerruntime -> sagemaker.DescribeEndpoint through AppContext or a shared registry.)
  • ClosedSessionId (InvokeEndpointOutput) is never emitted. Real AWS sets it when the model container decides to close a stateful session -- this is inherently model-driven and can't be triggered by request semantics alone; separately, gopherstack's own session ExpiresAt is tracked but not enforced (TouchSession doesn't check expiry, so an 'expired' session just keeps working forever). Emulating expiry-driven closure would be a reasonable mock behavior but wasn't in scope for a header/wire-shape-focused audit; noting for a future pass.
  • ModelError/ModelNotReadyException/ServiceUnavailable/InternalDependencyException/ModelStreamError/InternalStreamFailure error paths have no request-side trigger (there is no real model to fail). Chaos-injection (ChaosServiceName/ChaosOperations/ChaosRegions) is wired at the framework level (pkgs/chaos) and can inject arbitrary faults independent of handler code, so this is not a gap in the handler itself -- just no organic way to hit these paths without chaos rules configured.

More

Documentation

Index

Constants

View Source
const MaxAsyncInvocations = maxAsyncInvocations

MaxAsyncInvocations is the exported value for testing.

View Source
const MaxInvocationHistory = maxInvocationHistory

MaxInvocationHistory is the exported value for testing.

View Source
const MaxSessions = maxSessions

MaxSessions is the exported value for testing.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncInvocation

type AsyncInvocation struct {
	CreatedAt       time.Time `json:"createdAt"`
	InferenceID     string    `json:"inferenceId"`
	EndpointName    string    `json:"endpointName"`
	Input           string    `json:"input"`
	OutputLocation  string    `json:"outputLocation"`
	FailureLocation string    `json:"failureLocation"`
}

AsyncInvocation records accepted asynchronous inference work.

type Handler

type Handler struct {
	Backend *InMemoryBackend
}

Handler is the Echo HTTP handler for AWS SageMaker Runtime operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new SageMaker Runtime handler backed by backend.

func (*Handler) ChaosOperations

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

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

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

ChaosRegions returns all regions this handler instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

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

ExtractOperation returns the operation name derived from the request path.

func (*Handler) ExtractResource

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

ExtractResource extracts the endpoint name from the request path.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for SageMaker Runtime requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

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 returns a function that matches SageMaker Runtime requests. It matches all requests to paths beginning with /endpoints/. The real AWS SageMaker Runtime endpoint hostname is "runtime.sagemaker.<region>.amazonaws.com" (see aws-sdk-go-v2/service/sagemakerruntime's endpoint resolver), not "sagemaker-runtime.<region>..." -- the latter would never match real traffic.

func (*Handler) Shutdown

func (h *Handler) Shutdown(_ context.Context)

Shutdown implements service.Shutdowner. SageMaker Runtime has no background goroutines so this is a no-op.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

type InMemoryBackend

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

InMemoryBackend stores SageMaker Runtime state in memory.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend.

func (*InMemoryBackend) ListAsyncInvocations

func (b *InMemoryBackend) ListAsyncInvocations() []*AsyncInvocation

ListAsyncInvocations returns accepted asynchronous inference work.

func (*InMemoryBackend) ListInvocations

func (b *InMemoryBackend) ListInvocations() []*Invocation

ListInvocations returns all recorded invocations.

func (*InMemoryBackend) ListSessions

func (b *InMemoryBackend) ListSessions() []*Session

ListSessions returns all active endpoint sessions.

func (*InMemoryBackend) RecordAsyncInvocation

func (b *InMemoryBackend) RecordAsyncInvocation(
	endpointName, requestedID, input, outputLocation string,
) *AsyncInvocation

RecordAsyncInvocation stores accepted asynchronous inference work. If outputLocation is empty a fake S3 location is synthesised.

func (*InMemoryBackend) RecordInvocation

func (b *InMemoryBackend) RecordInvocation(operation, endpointName, input, output string) *Invocation

RecordInvocation stores a completed invocation in memory.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) Restore

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

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

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

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

func (*InMemoryBackend) StartSession

func (b *InMemoryBackend) StartSession(endpointName string) *Session

StartSession creates stateful invocation session metadata.

func (*InMemoryBackend) TouchSession

func (b *InMemoryBackend) TouchSession(sessionID string)

TouchSession marks an existing stateful session as invoked.

type Invocation

type Invocation struct {
	CreatedAt    time.Time `json:"createdAt"`
	EndpointName string    `json:"endpointName"`
	Operation    string    `json:"operation"`
	Input        string    `json:"input"`
	Output       string    `json:"output"`
}

Invocation records a single SageMaker Runtime endpoint invocation.

type Provider

type Provider struct{}

Provider implements service.Provider for SageMaker Runtime.

func (*Provider) Init

Init initializes the SageMaker Runtime backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type Session

type Session struct {
	CreatedAt     time.Time `json:"createdAt"`
	LastInvokedAt time.Time `json:"lastInvokedAt"`
	ExpiresAt     time.Time `json:"expiresAt"`
	ID            string    `json:"id"`
	EndpointName  string    `json:"endpointName"`
}

Session records a stateful endpoint session established by InvokeEndpoint.

Jump to

Keyboard shortcuts

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