Documentation
¶
Index ¶
- Constants
- Variables
- type Application
- type CreateApplicationOptions
- 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) AddApplicationInternal(app *Application)
- func (b *InMemoryBackend) AddJobRunInternal(jr *JobRun)
- func (b *InMemoryBackend) CancelJobRun(applicationID, jobRunID string) (*JobRun, error)
- func (b *InMemoryBackend) CreateApplication(name, appType, releaseLabel, architecture string, tags map[string]string, ...) (*Application, error)
- func (b *InMemoryBackend) DeleteApplication(id string) error
- func (b *InMemoryBackend) GetApplication(id string) (*Application, error)
- func (b *InMemoryBackend) GetDashboardForJobRun(applicationID, jobRunID string) (string, error)
- func (b *InMemoryBackend) GetJobRun(applicationID, jobRunID string) (*JobRun, error)
- func (b *InMemoryBackend) GetResourceDashboard(applicationID, resourceID, resourceType string) (string, error)
- func (b *InMemoryBackend) GetSession(applicationID, sessionID string) (*Session, error)
- func (b *InMemoryBackend) GetSessionEndpoint(applicationID, sessionID string) (string, string, time.Time, error)
- func (b *InMemoryBackend) ListApplications(nextToken string, maxResults int, states ...string) ([]*Application, string)
- func (b *InMemoryBackend) ListJobRunAttempts(applicationID, jobRunID, nextToken string, maxResults int) ([]*JobRunAttemptSummary, string, error)
- func (b *InMemoryBackend) ListJobRuns(applicationID, nextToken string, maxResults int, states ...string) ([]*JobRun, string, error)
- func (b *InMemoryBackend) ListSessions(applicationID, nextToken string, maxResults int, ...) ([]*Session, string, error)
- func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[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) StartApplication(id string) error
- func (b *InMemoryBackend) StartJobRun(applicationID, executionRoleArn, name, mode string, tags map[string]string, ...) (*JobRun, error)
- func (b *InMemoryBackend) StartSession(applicationID, clientToken, executionRoleArn, name string, ...) (*Session, error)
- func (b *InMemoryBackend) StopApplication(id string) error
- func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) TerminateSession(applicationID, sessionID string) (*Session, error)
- func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateApplication(id string, update func(*Application)) (*Application, error)
- type JobRun
- type JobRunAttemptSummary
- type Provider
- type Session
- type StartJobRunOptions
Constants ¶
const ( // SessionStateSubmitted identifies a newly submitted session. SessionStateSubmitted = "SUBMITTED" // SessionStateStarting identifies a session being provisioned. SessionStateStarting = "STARTING" // SessionStateStarted identifies an active session. SessionStateStarted = "STARTED" // SessionStateIdle identifies an idle active session. SessionStateIdle = "IDLE" // SessionStateBusy identifies a busy active session. SessionStateBusy = "BUSY" // SessionStateFailed identifies a failed session. SessionStateFailed = "FAILED" // SessionStateTerminated identifies a terminated session. SessionStateTerminated = "TERMINATED" )
const ApplicationStateCreated = "CREATED"
ApplicationStateCreated is the state when an application has been created.
const ApplicationStateCreating = "CREATING"
ApplicationStateCreating is the state when an application is being created.
const ApplicationStateStarted = "STARTED"
ApplicationStateStarted is the state when an application is running.
const ApplicationStateStarting = "STARTING"
ApplicationStateStarting is the state when an application is starting.
const ApplicationStateStopped = "STOPPED"
ApplicationStateStopped is the state when an application has stopped.
const ApplicationStateStopping = "STOPPING"
ApplicationStateStopping is the state when an application is stopping.
const ApplicationStateTerminated = "TERMINATED"
ApplicationStateTerminated is the state when an application is terminated.
const DefaultJobRunExecutionTimeoutMinutes = 720
DefaultJobRunExecutionTimeoutMinutes is the timeout the real EMR Serverless API reports for a job run when StartJobRun did not specify executionTimeoutMinutes (types.JobRun.ExecutionTimeoutMinutes doc: "If no timeout was specified, then it returns the default timeout of 720 minutes.").
const JobRunStateCancelled = "CANCELLED"
JobRunStateCancelled is the state when a job run has been cancelled.
const JobRunStateCancelling = "CANCELLING"
JobRunStateCancelling is the state when a job run is being cancelled.
const JobRunStateFailed = "FAILED"
JobRunStateFailed is the state when a job run has failed.
const JobRunStatePending = "PENDING"
JobRunStatePending is the state when a job run is pending.
const JobRunStateRunning = "RUNNING"
JobRunStateRunning is the state when a job run is running.
const JobRunStateScheduled = "SCHEDULED"
JobRunStateScheduled is the state when a job run is scheduled.
const JobRunStateSubmitted = "SUBMITTED"
JobRunStateSubmitted is the state when a job run has been submitted.
const JobRunStateSuccess = "SUCCESS"
JobRunStateSuccess is the state when a job run completed successfully.
Variables ¶
var ( // ErrNotFound is returned when a requested resource does not exist. ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) // ErrAlreadyExists is returned when a resource already exists. ErrAlreadyExists = awserr.New("ConflictException", awserr.ErrAlreadyExists) // ErrValidation is returned when input validation fails. ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter) // ErrInvalidState is returned when an operation is not valid for the resource's current state. ErrInvalidState = awserr.New("RequestFailedException", awserr.ErrInvalidParameter) )
var ErrNilAppContext = errors.New("emrserverless provider: nil AppContext")
ErrNilAppContext is returned when Init is called with a nil application context.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
Tags map[string]string `json:"tags,omitempty"`
// ExtraConfig holds application configuration sub-objects that this
// in-memory backend does not interpret (initialCapacity, maximumCapacity,
// autoStartConfiguration, autoStopConfiguration, networkConfiguration,
// imageConfiguration, monitoringConfiguration, workerTypeSpecifications,
// runtimeConfiguration, interactiveConfiguration) but must still store and
// echo back verbatim on GetApplication/ListApplications -- AWS clients
// (Terraform, drift-detection tooling) commonly round-trip these values,
// and CreateApplication/UpdateApplication silently discarding them is a
// disguised no-op. Keyed by AWS wire field name; see applicationToMap.
ExtraConfig map[string]any `json:"extraConfig,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ApplicationID string `json:"applicationId"`
Arn string `json:"arn"`
Name string `json:"name"`
Type string `json:"type"`
ReleaseLabel string `json:"releaseLabel"`
Architecture string `json:"architecture,omitempty"`
State string `json:"state"`
// StateDetails holds additional details about the application's current
// state. Optional on the real API (types.Application.StateDetails is not
// a required response member); this backend leaves it empty except where
// a state transition sets a specific message.
StateDetails string `json:"stateDetails,omitempty"`
}
Application represents an EMR Serverless application.
type CreateApplicationOptions ¶
CreateApplicationOptions carries optional CreateApplication parameters beyond the always-present name/type/releaseLabel/architecture/tags: the client idempotency token (matching AWS's CreateApplicationInput.ClientToken, a required input field on the real API) and the configuration sub-objects this backend stores but does not interpret. Passed as a trailing variadic argument so existing call sites that don't need these are unaffected.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
}
Handler is the Echo HTTP handler for EMR Serverless operations (REST-JSON protocol).
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a new EMR Serverless handler.
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.
func (*Handler) ExtractResource ¶
ExtractResource extracts a resource identifier from the request path.
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 EMR Serverless requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority. Uses 87 to be evaluated before AppConfig (priority 86) which also uses /applications paths.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears all backend state. Used for test isolation.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches EMR Serverless requests. For /applications paths, it additionally checks the Authorization header service name to distinguish from AppConfig (which also uses /applications).
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend stores EMR Serverless state in memory.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new InMemoryBackend.
func (*InMemoryBackend) AddApplicationInternal ¶
func (b *InMemoryBackend) AddApplicationInternal(app *Application)
AddApplicationInternal directly inserts an Application into the backend without going through the HTTP layer. Intended for test seeding only.
func (*InMemoryBackend) AddJobRunInternal ¶
func (b *InMemoryBackend) AddJobRunInternal(jr *JobRun)
AddJobRunInternal directly inserts a JobRun into the backend without going through the HTTP layer. The application must already exist. Intended for test seeding only.
func (*InMemoryBackend) CancelJobRun ¶
func (b *InMemoryBackend) CancelJobRun(applicationID, jobRunID string) (*JobRun, error)
CancelJobRun cancels a job run.
func (*InMemoryBackend) CreateApplication ¶
func (b *InMemoryBackend) CreateApplication( name, appType, releaseLabel, architecture string, tags map[string]string, opts ...CreateApplicationOptions, ) (*Application, error)
CreateApplication creates a new EMR Serverless application. If opts carries a non-empty ClientToken that was already used successfully, the previously created application is returned instead of erroring or creating a duplicate -- matching AWS's client-idempotency-token contract, which real SDKs rely on when retrying a CreateApplication call after a timeout.
func (*InMemoryBackend) DeleteApplication ¶
func (b *InMemoryBackend) DeleteApplication(id string) error
DeleteApplication removes an application. It rejects the request if the application is in STARTED or STARTING state.
func (*InMemoryBackend) GetApplication ¶
func (b *InMemoryBackend) GetApplication(id string) (*Application, error)
GetApplication retrieves an application by ID.
func (*InMemoryBackend) GetDashboardForJobRun ¶
func (b *InMemoryBackend) GetDashboardForJobRun(applicationID, jobRunID string) (string, error)
GetDashboardForJobRun returns a dashboard URL for a job run.
func (*InMemoryBackend) GetJobRun ¶
func (b *InMemoryBackend) GetJobRun(applicationID, jobRunID string) (*JobRun, error)
GetJobRun retrieves a job run by application ID and job run ID.
func (*InMemoryBackend) GetResourceDashboard ¶
func (b *InMemoryBackend) GetResourceDashboard(applicationID, resourceID, resourceType string) (string, error)
GetResourceDashboard returns a dashboard URL for a supported session resource.
func (*InMemoryBackend) GetSession ¶
func (b *InMemoryBackend) GetSession(applicationID, sessionID string) (*Session, error)
GetSession retrieves an interactive session.
func (*InMemoryBackend) GetSessionEndpoint ¶
func (b *InMemoryBackend) GetSessionEndpoint(applicationID, sessionID string) (string, string, time.Time, error)
GetSessionEndpoint produces an active session endpoint and expiring token.
func (*InMemoryBackend) ListApplications ¶
func (b *InMemoryBackend) ListApplications( nextToken string, maxResults int, states ...string, ) ([]*Application, string)
ListApplications returns paginated applications, optionally filtered by state.
func (*InMemoryBackend) ListJobRunAttempts ¶
func (b *InMemoryBackend) ListJobRunAttempts( applicationID, jobRunID, nextToken string, maxResults int, ) ([]*JobRunAttemptSummary, string, error)
ListJobRunAttempts returns paginated attempt summaries for a job run.
func (*InMemoryBackend) ListJobRuns ¶
func (b *InMemoryBackend) ListJobRuns( applicationID, nextToken string, maxResults int, states ...string, ) ([]*JobRun, string, error)
ListJobRuns returns paginated job runs for an application, optionally filtered by state.
func (*InMemoryBackend) ListSessions ¶
func (b *InMemoryBackend) ListSessions( applicationID, nextToken string, maxResults int, createdAfter, createdBefore time.Time, states ...string, ) ([]*Session, string, error)
ListSessions returns sessions ordered newest first with optional state and time filtering.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
ListTagsForResource returns tags for a resource identified by ARN.
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 it to the initial empty state.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot produced by Snapshot.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON.
func (*InMemoryBackend) StartApplication ¶
func (b *InMemoryBackend) StartApplication(id string) error
StartApplication transitions an application to STARTED state.
func (*InMemoryBackend) StartJobRun ¶
func (b *InMemoryBackend) StartJobRun( applicationID, executionRoleArn, name, mode string, tags map[string]string, opts ...StartJobRunOptions, ) (*JobRun, error)
StartJobRun creates and starts a new job run. If opts carries a non-empty ClientToken that was already used successfully for this application, the previously created job run is returned instead of creating a duplicate -- matching AWS's client-idempotency-token contract. JobDriver and ConfigurationOverrides are stored and echoed back verbatim by GetJobRun/ListJobRuns rather than discarded: JobDriver is a required field on the real JobRun response shape, so dropping it there would silently erase the job specification the caller submitted.
func (*InMemoryBackend) StartSession ¶
func (b *InMemoryBackend) StartSession( applicationID, clientToken, executionRoleArn, name string, idleTimeoutMinutes int64, configurationOverrides map[string]any, tags map[string]string, ) (*Session, error)
StartSession creates an interactive session on a running application.
func (*InMemoryBackend) StopApplication ¶
func (b *InMemoryBackend) StopApplication(id string) error
StopApplication transitions an application to STOPPED state.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
TagResource adds or updates tags on a resource identified by ARN.
func (*InMemoryBackend) TerminateSession ¶
func (b *InMemoryBackend) TerminateSession(applicationID, sessionID string) (*Session, error)
TerminateSession moves a session to terminal state.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error
UntagResource removes tags from a resource identified by ARN.
func (*InMemoryBackend) UpdateApplication ¶
func (b *InMemoryBackend) UpdateApplication(id string, update func(*Application)) (*Application, error)
UpdateApplication applies a mutating function to an application.
type JobRun ¶
type JobRun struct {
Tags map[string]string `json:"tags,omitempty"`
// JobDriver is the job driver (sparkSubmit/hive) supplied to StartJobRun.
// GetJobRun/ListJobRuns mark this as a required response field in the
// real API; storing and echoing it verbatim (rather than discarding it)
// avoids silently dropping the job specification the caller submitted.
JobDriver any `json:"jobDriver,omitempty"`
// ConfigurationOverrides is the configurationOverrides supplied to
// StartJobRun, echoed back verbatim.
ConfigurationOverrides any `json:"configurationOverrides,omitempty"`
// ExecutionIamPolicy is the optional IAM policy supplied to StartJobRun
// (StartJobRunInput.ExecutionIamPolicy), echoed back verbatim.
ExecutionIamPolicy any `json:"executionIamPolicy,omitempty"`
// RetryPolicy is the retry policy supplied to StartJobRun
// (StartJobRunInput.RetryPolicy), echoed back verbatim.
RetryPolicy any `json:"retryPolicy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ApplicationID string `json:"applicationId"`
JobRunID string `json:"jobRunId"`
Arn string `json:"arn"`
Name string `json:"name"`
State string `json:"state"`
ExecutionRoleArn string `json:"executionRoleArn"`
Mode string `json:"mode,omitempty"`
ReleaseLabel string `json:"releaseLabel,omitempty"`
StateDetails string `json:"stateDetails,omitempty"`
// CreatedBy is the IAM principal that created the job run -- a required
// field on the real JobRun/JobRunSummary response shape
// (types.JobRun.CreatedBy). This in-memory backend does not model IAM
// principals, so it uses the execution role ARN as a best-effort
// substitute, matching the convention already used by
// ListJobRunAttempts' synthesized attempt.
CreatedBy string `json:"createdBy"`
// ExecutionTimeoutMinutes is the job run timeout in minutes. The real API
// returns the default timeout (720 minutes) when none was supplied to
// StartJobRun; see StartJobRunOptions.ExecutionTimeoutMinutes.
ExecutionTimeoutMinutes int64 `json:"executionTimeoutMinutes"`
}
JobRun represents an EMR Serverless job run.
type JobRunAttemptSummary ¶
type JobRunAttemptSummary struct {
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
JobCreatedAt time.Time `json:"jobCreatedAt"`
ApplicationID string `json:"applicationId"`
Arn string `json:"arn"`
CreatedBy string `json:"createdBy"`
ExecutionRole string `json:"executionRole"`
ID string `json:"id"`
ReleaseLabel string `json:"releaseLabel"`
State string `json:"state"`
StateDetails string `json:"stateDetails"`
Name string `json:"name"`
Type string `json:"type"`
Attempt int32 `json:"attempt"`
}
JobRunAttemptSummary represents a single attempt of a job run.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for EMR Serverless.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the EMR Serverless backend and handler.
type Session ¶
type Session struct {
Tags map[string]string `json:"tags,omitempty"`
ConfigurationOverrides map[string]any `json:"configurationOverrides,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt,omitzero"`
ApplicationID string `json:"applicationId"`
SessionID string `json:"sessionId"`
Arn string `json:"arn"`
Name string `json:"name,omitempty"`
State string `json:"state"`
StateDetails string `json:"stateDetails"`
CreatedBy string `json:"createdBy"`
ExecutionRoleArn string `json:"executionRoleArn"`
ReleaseLabel string `json:"releaseLabel"`
IdleTimeoutMinutes int64 `json:"idleTimeoutMinutes,omitempty"`
}
Session represents an interactive EMR Serverless session.
type StartJobRunOptions ¶
type StartJobRunOptions struct {
JobDriver any
ConfigurationOverrides any
ExecutionIamPolicy any
RetryPolicy any
ClientToken string
ExecutionTimeoutMinutes int64
}
StartJobRunOptions carries optional StartJobRun parameters beyond the always-present applicationID/executionRoleArn/name/mode/tags: the client idempotency token (matching AWS's StartJobRunInput.ClientToken, a required input field on the real API), the job driver, configuration overrides, execution IAM policy, execution timeout, and retry policy. Passed as a trailing variadic argument so existing call sites that don't need these are unaffected.