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,7 +1,9 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import (
"context"
"fmt"
)
// DeserializeInput provides the input parameters for the DeserializeInput to
@@ -11,10 +13,7 @@ type DeserializeInput struct {
Request interface{}
}
// DeserializeOutput provides the result returned by the next
// DeserializeHandler. The DeserializeMiddleware should deserialize the
// RawResponse into a Result that can be consumed by middleware higher up in
// the stack.
// DeserializeOutput provides the result returned by the next DeserializeHandler.
type DeserializeOutput struct {
RawResponse interface{}
Result interface{}
@@ -29,7 +28,7 @@ type DeserializeHandler interface {
}
// DeserializeMiddleware provides the interface for middleware specific to the
// serialize step. Delegates to the next DeserializeHandler for further
// deserialize step. Delegates to the next DeserializeHandler for further
// processing.
type DeserializeMiddleware interface {
// ID returns a unique ID for the middleware in the DeserializeStep. The step does not
@@ -44,8 +43,8 @@ type DeserializeMiddleware interface {
)
}
// DeserializeMiddlewareFunc returns a DeserializeMiddleware with the unique ID
// provided, and the func to be invoked.
// DeserializeMiddlewareFunc returns a DeserializeMiddleware with the unique ID provided,
// and the func to be invoked.
func DeserializeMiddlewareFunc(id string, fn func(context.Context, DeserializeInput, DeserializeHandler) (DeserializeOutput, Metadata, error)) DeserializeMiddleware {
return deserializeMiddlewareFunc{
id: id,
@@ -78,15 +77,14 @@ var _ DeserializeMiddleware = (deserializeMiddlewareFunc{})
// DeserializeStep provides the ordered grouping of DeserializeMiddleware to be
// invoked on a handler.
type DeserializeStep struct {
ids *orderedIDs
head *decoratedDeserializeHandler
tail *decoratedDeserializeHandler
}
// NewDeserializeStep returns a DeserializeStep ready to have middleware for
// initialization added to it.
// NewDeserializeStep returns an DeserializeStep ready to have middleware for
// deserialize added to it.
func NewDeserializeStep() *DeserializeStep {
return &DeserializeStep{
ids: newOrderedIDs(),
}
return &DeserializeStep{}
}
var _ Middleware = (*DeserializeStep)(nil)
@@ -103,77 +101,161 @@ func (s *DeserializeStep) ID() string {
func (s *DeserializeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h DeserializeHandler = deserializeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedDeserializeHandler{
Next: h,
With: order[i].(DeserializeMiddleware),
}
}
sIn := DeserializeInput{
Request: in,
}
res, metadata, err := h.HandleDeserialize(ctx, sIn)
wh := &deserializeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleDeserialize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleDeserialize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *DeserializeStep) Get(id string) (DeserializeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(DeserializeMiddleware), 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 *DeserializeStep) Add(m DeserializeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedDeserializeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedDeserializeHandler{s.head, m}
} else {
tail := &decoratedDeserializeHandler{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 *DeserializeStep) Insert(m DeserializeMiddleware, 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 = &decoratedDeserializeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedDeserializeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedDeserializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedDeserializeHandler{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 *DeserializeStep) Swap(id string, m DeserializeMiddleware) (DeserializeMiddleware, 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.(DeserializeMiddleware), 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 *DeserializeStep) Remove(id string) (DeserializeMiddleware, 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.(DeserializeMiddleware), 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.(*decoratedDeserializeHandler)
} 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 *DeserializeStep) 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
// *deserializeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedDeserializeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *DeserializeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *DeserializeStep) get(id string) (found, prev *decoratedDeserializeHandler) {
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
// *deserializeWrapHandler
h, _ = h.Next.(*decoratedDeserializeHandler)
}
return
}
type deserializeWrapHandler struct {
@@ -187,9 +269,10 @@ var _ DeserializeHandler = (*deserializeWrapHandler)(nil)
func (w deserializeWrapHandler) HandleDeserialize(ctx context.Context, in DeserializeInput) (
out DeserializeOutput, metadata Metadata, err error,
) {
resp, metadata, err := w.Next.Handle(ctx, in.Request)
res, metadata, err := w.Next.Handle(ctx, in.Request)
return DeserializeOutput{
RawResponse: resp,
RawResponse: res,
Result: nil,
}, metadata, err
}
@@ -206,12 +289,12 @@ func (h decoratedDeserializeHandler) HandleDeserialize(ctx context.Context, in D
return h.With.HandleDeserialize(ctx, in, h.Next)
}
// DeserializeHandlerFunc provides a wrapper around a function to be used as a deserialize middleware handler.
// DeserializeHandlerFunc provides a wrapper around a function to be used as deserializeMiddleware.
type DeserializeHandlerFunc func(context.Context, DeserializeInput) (DeserializeOutput, Metadata, error)
// HandleDeserialize invokes the wrapped function with the given arguments.
func (d DeserializeHandlerFunc) HandleDeserialize(ctx context.Context, in DeserializeInput) (DeserializeOutput, Metadata, error) {
return d(ctx, in)
// HandleDeserialize calls the wrapped function with the provided arguments.
func (f DeserializeHandlerFunc) HandleDeserialize(ctx context.Context, in DeserializeInput) (DeserializeOutput, Metadata, error) {
return f(ctx, in)
}
var _ DeserializeHandler = DeserializeHandlerFunc(nil)