This commit is contained in:
2026-02-19 10:07:43 +00:00
parent 007438e372
commit 6e637ecf77
1763 changed files with 60820 additions and 279516 deletions

View File

@@ -1,6 +1,10 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import "context"
import (
"context"
"fmt"
)
// FinalizeInput provides the input parameters for the FinalizeMiddleware to
// consume. FinalizeMiddleware may modify the Request value before forwarding
@@ -23,7 +27,7 @@ type FinalizeHandler interface {
}
// FinalizeMiddleware provides the interface for middleware specific to the
// serialize step. Delegates to the next FinalizeHandler for further
// finalize step. Delegates to the next FinalizeHandler for further
// processing.
type FinalizeMiddleware interface {
// ID returns a unique ID for the middleware in the FinalizeStep. The step does not
@@ -38,8 +42,8 @@ type FinalizeMiddleware interface {
)
}
// FinalizeMiddlewareFunc returns a FinalizeMiddleware with the unique ID
// provided, and the func to be invoked.
// FinalizeMiddlewareFunc returns a FinalizeMiddleware with the unique ID provided,
// and the func to be invoked.
func FinalizeMiddlewareFunc(id string, fn func(context.Context, FinalizeInput, FinalizeHandler) (FinalizeOutput, Metadata, error)) FinalizeMiddleware {
return finalizeMiddlewareFunc{
id: id,
@@ -72,20 +76,19 @@ var _ FinalizeMiddleware = (finalizeMiddlewareFunc{})
// FinalizeStep provides the ordered grouping of FinalizeMiddleware to be
// invoked on a handler.
type FinalizeStep struct {
ids *orderedIDs
head *decoratedFinalizeHandler
tail *decoratedFinalizeHandler
}
// NewFinalizeStep returns a FinalizeStep ready to have middleware for
// initialization added to it.
// NewFinalizeStep returns an FinalizeStep ready to have middleware for
// finalize added to it.
func NewFinalizeStep() *FinalizeStep {
return &FinalizeStep{
ids: newOrderedIDs(),
}
return &FinalizeStep{}
}
var _ Middleware = (*FinalizeStep)(nil)
// ID returns the unique id of the step as a middleware.
// ID returns the unique ID of the step as a middleware.
func (s *FinalizeStep) ID() string {
return "Finalize stack step"
}
@@ -97,77 +100,161 @@ func (s *FinalizeStep) ID() string {
func (s *FinalizeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h FinalizeHandler = finalizeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedFinalizeHandler{
Next: h,
With: order[i].(FinalizeMiddleware),
}
}
sIn := FinalizeInput{
Request: in,
}
res, metadata, err := h.HandleFinalize(ctx, sIn)
wh := &finalizeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleFinalize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleFinalize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *FinalizeStep) Get(id string) (FinalizeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(FinalizeMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *FinalizeStep) Add(m FinalizeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedFinalizeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedFinalizeHandler{s.head, m}
} else {
tail := &decoratedFinalizeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *FinalizeStep) Insert(m FinalizeMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedFinalizeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedFinalizeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedFinalizeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedFinalizeHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *FinalizeStep) Swap(id string, m FinalizeMiddleware) (FinalizeMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(FinalizeMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *FinalizeStep) Remove(id string) (FinalizeMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(FinalizeMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedFinalizeHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *FinalizeStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *finalizeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedFinalizeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *FinalizeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *FinalizeStep) get(id string) (found, prev *decoratedFinalizeHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *finalizeWrapHandler
h, _ = h.Next.(*decoratedFinalizeHandler)
}
return
}
type finalizeWrapHandler struct {
@@ -200,10 +287,10 @@ func (h decoratedFinalizeHandler) HandleFinalize(ctx context.Context, in Finaliz
return h.With.HandleFinalize(ctx, in, h.Next)
}
// FinalizeHandlerFunc provides a wrapper around a function to be used as a finalize middleware handler.
// FinalizeHandlerFunc provides a wrapper around a function to be used as finalizeMiddleware.
type FinalizeHandlerFunc func(context.Context, FinalizeInput) (FinalizeOutput, Metadata, error)
// HandleFinalize invokes the wrapped function with the given arguments.
// HandleFinalize calls the wrapped function with the provided arguments.
func (f FinalizeHandlerFunc) HandleFinalize(ctx context.Context, in FinalizeInput) (FinalizeOutput, Metadata, error) {
return f(ctx, in)
}