Skip to content

Commit

Permalink
test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Nov 8, 2024
1 parent 025c94e commit 85bf3ba
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions internal/extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,39 +184,20 @@ func (em *ExtensionManager) SendEndInvocationRequest(ctx context.Context, functi
}
}
fmt.Printf("[DEBUG lambda] extension.go context: ")
dumpContext(ctx)
dumpContextValue(ctx)

resp, err := em.httpClient.Do(req)
if err != nil || resp.StatusCode != 200 {
logger.Error(fmt.Errorf("could not send end invocation payload to the extension: %v", err))
}
}

func dumpContext(ctx context.Context) {
val := reflect.ValueOf(ctx)
typ := reflect.TypeOf(ctx)

// If it's a pointer, get the underlying element
if val.Kind() == reflect.Ptr {
val = val.Elem()
typ = typ.Elem()
}

if typ.Kind() == reflect.Struct {
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
fieldType := typ.Field(i)

// Just print the field name and type, since we can't safely access unexported fields
fmt.Printf("Field: %s, Type: %v\n", fieldType.Name, fieldType.Type)

// If this field is itself a context, recurse into it
if field.Type().Implements(reflect.TypeOf((*context.Context)(nil)).Elem()) {
if !field.IsNil() {
fmt.Printf("Nested context in %s:\n", fieldType.Name)
dumpContext(field.Interface().(context.Context))
}
}
func dumpContextValue(ctx context.Context) {
val := reflect.ValueOf(ctx).Elem()
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
if field.Kind() == reflect.Interface && !field.IsNil() {
fmt.Printf("Key type: %T\n", field.Interface())
}
}
}
Expand Down

0 comments on commit 85bf3ba

Please sign in to comment.