Help us shape the future of Go! Take the 2026 Go Developer Survey

sagemakerruntime

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 22 Imported by: 0

README

SageMaker Runtime

Parity grade: A · SDK aws-sdk-go-v2/service/sagemakerruntime@v1.43.4 · last audited 2026-10-10 (ab7ac08a7)

Coverage

Metric Value
PARITY entries audited 3 (3 ok)
Feature families 3 (3 ok)
Known gaps none
Structural gaps (can't be emulated) 1
Deferred items 0
Resource leaks clean
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • InvokeEndpointAsync.InvocationTimeoutSeconds/RequestTTLSeconds: request-only headers with no output member, and no async queue or processing-duration engine to expire a request against.

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 EndpointLookup added in v1.2.0

type EndpointLookup interface {
	DescribeEndpoint(ctx context.Context, name string) (*sagemaker.Endpoint, error)
}

EndpointLookup is the minimal read surface into services/sagemaker's endpoint registry needed to validate an EndpointName (and its InService status) before invoking it. *sagemaker.InMemoryBackend already satisfies this interface via its exported, lock-safe DescribeEndpoint method -- no change to services/sagemaker is required. See provider.go's wireEndpointLookup for how the two services get connected at server start-up, following the precedent established by services/cloudwatchlogs/provider.go's s3HandlerProvider/wireExportSink.

type Handler

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

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

func (h *Handler) BackendFor(region string) *InMemoryBackend

BackendFor returns the backend serving region: the home backend, or the sibling built on first use.

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

func (h *Handler) EnableRegions()

EnableRegions makes h serve every other region through lazily built per-region siblings.

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 serves each request from the handler of its region.

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

func (h *Handler) RegionBackends() []*InMemoryBackend

RegionBackends returns the home backend followed by every sibling built so far.

func (*Handler) RegionHandler

func (h *Handler) RegionHandler(region string) *Handler

RegionHandler returns the handler serving region: h itself for the home region, else its sibling.

func (*Handler) Restore

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

Restore implements persistence.Persistable.

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; other regions ride in an additive "regions" key.

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, filename string,
) *AsyncInvocation

RecordAsyncInvocation stores accepted asynchronous inference work. If outputLocation is empty a fake S3 location is synthesised, using filename as its final path segment when the caller supplied one -- matching InvokeEndpointAsyncInput.Filename's documented behaviour ("If not specified, Amazon SageMaker AI generates a filename based on the inference ID").

func (*InMemoryBackend) RecordAsyncInvocationWithExtension

func (b *InMemoryBackend) RecordAsyncInvocationWithExtension(
	endpointName, requestedID, input, outputLocation, filename, pathExtension string,
) *AsyncInvocation

RecordAsyncInvocationWithExtension is RecordAsyncInvocation plus the S3OutputPathExtension, appended to the synthesised output path.

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) SetEndpointLookup added in v1.2.0

func (b *InMemoryBackend) SetEndpointLookup(lookup EndpointLookup)

SetEndpointLookup wires the backend to the emulated SageMaker service's endpoint registry, enabling EndpointName validation on invoke calls. When left unset (the default for a bare NewInMemoryBackend, e.g. in unit tests that never go through Provider.Init), validateEndpoint is a no-op success -- this preserves this service's pre-existing behaviour of accepting any EndpointName, matching a standalone gopherstack instance where the SageMaker control-plane service isn't wired into the same process.

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

TouchSession marks an existing stateful session as invoked, or -- if the session has passed its ExpiresAt -- evicts it and reports the closure via SessionTouchOutcome.ClosedSessionID (see setSessionResponseHeader, which surfaces this as the X-Amzn-SageMaker-Closed-Session-Id response header). A sessionID that does not match any tracked session is a silent no-op, matching this backend's pre-existing behaviour for unrecognised session IDs.

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.

type SessionTouchOutcome added in v1.2.0

type SessionTouchOutcome struct {
	// ClosedSessionID is set to the session's ID when TouchSession found the
	// session expired and evicted it, mirroring the real AWS
	// InvokeEndpointOutput.ClosedSessionId behaviour. It is empty when the
	// session was touched normally or was not found at all.
	ClosedSessionID string
}

SessionTouchOutcome reports what TouchSession did to the named session.

Jump to

Keyboard shortcuts

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