[MM-60685] Fix racy TestSyncLdap (#28324)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f8bdba459
Коммит
7ff22436dc
@@ -54,9 +54,19 @@ func TestContext(t testing.TB) *Context {
|
||||
return EmptyContext(logger)
|
||||
}
|
||||
|
||||
// clone creates a shallow copy of Context, allowing clones to apply per-request changes.
|
||||
// Clone creates a deep copy of [CTX].
|
||||
// It should only be used to pass a [CTX] to a separate goroutine that
|
||||
// has a longer lifespan than the main goroutine handling the request.
|
||||
// It should be used sparsely as coping [CTX] is often unnecessary.
|
||||
func (c *Context) Clone() CTX {
|
||||
return c.clone()
|
||||
}
|
||||
|
||||
// clone creates a deep copy of [Context], allowing clones to apply per-request changes.
|
||||
// It unexported to prevent leaking the [Context] type from the [CTX] interface.
|
||||
func (c *Context) clone() *Context {
|
||||
cCopy := *c
|
||||
cCopy.session = *c.session.DeepCopy()
|
||||
return &cCopy
|
||||
}
|
||||
|
||||
@@ -173,4 +183,5 @@ type CTX interface {
|
||||
WithLogger(mlog.LoggerIFace) CTX
|
||||
WithContext(ctx context.Context) CTX
|
||||
With(func(ctx CTX) CTX) CTX
|
||||
Clone() CTX
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user