Merge branch 'dev-advloadblancer-2'

This commit is contained in:
Shelikhoo
2021-04-13 15:09:32 +01:00
32 changed files with 1583 additions and 45 deletions
+16
View File
@@ -13,6 +13,7 @@ const (
contentSessionKey
muxPreferedSessionKey
sockoptSessionKey
trackedConnectionErrorKey
)
// ContextWithID returns a new context with the given ID.
@@ -116,3 +117,18 @@ func SetForcedOutboundTagToContext(ctx context.Context, tag string) context.Cont
ContentFromContext(ctx).SetAttribute("forcedOutboundTag", tag)
return ctx
}
type TrackedRequestErrorFeedback interface {
SubmitError(err error)
}
func SubmitOutboundErrorToOriginator(ctx context.Context, err error) {
if errorTracker := ctx.Value(trackedConnectionErrorKey); errorTracker != nil {
errorTracker := errorTracker.(TrackedRequestErrorFeedback)
errorTracker.SubmitError(err)
}
}
func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context {
return context.WithValue(ctx, trackedConnectionErrorKey, tracker)
}