Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–12 unchanged (12 lines)
13 "github.com/cockroachdb/cockroach/pkg/util/retry"
14 "github.com/cockroachdb/cockroach/pkg/util/timeutil"
15)
16
17var useFastRetry = envutil.EnvOrDefaultBool(
18 "COCKROACH_CHANGEFEED_TESTING_FAST_RETRY", false)
19
20// getRetry returns retry object for changefeed.
21func getRetry(ctx context.Context, maxBackoff, backoffReset time.Duration) Retry {
22 opts := retry.Options{
23 InitialBackoff: 1 * time.Second,
24 Multiplier: 2,
25 MaxBackoff: maxBackoff,
26 }
27
28 if useFastRetry {
29 opts = retry.Options{
30 InitialBackoff: 5 * time.Millisecond,
31 Multiplier: 2,
32 MaxBackoff: 250 * time.Millisecond,
33 }
34 }
35
36 return Retry{Retry: retry.StartWithCtx(ctx, opts),
37 resetRetryAfter: backoffReset}
38}
39
40func testingUseFastRetry() func() {
…lines 41–75 unchanged (35 lines)

After

…lines 1–13 unchanged (13 lines)
14 "github.com/cockroachdb/cockroach/pkg/util/timeutil"
15)
16
17var useFastRetry = envutil.EnvOrDefaultBool(
18 "COCKROACH_CHANGEFEED_TESTING_FAST_RETRY", false)
19
20// initialRetryBackoffOverride overrides the initial retry backoff for
21// changefeeds, which is useful for testing retry behavior near
22// maximum backoff without requiring many retries.
23var initialRetryBackoffOverride = envutil.EnvOrDefaultDuration(
24 "COCKROACH_CHANGEFEED_TESTING_INITIAL_RETRY_BACKOFF", 0)
25
26// getRetry returns retry object for changefeed.
27func getRetry(ctx context.Context, maxBackoff, backoffReset time.Duration) Retry {
28 opts := retry.Options{
29 InitialBackoff: 1 * time.Second,
30 Multiplier: 2,
31 MaxBackoff: maxBackoff,
32 }
33
34 if initialRetryBackoffOverride > 0 {
35 opts.InitialBackoff = initialRetryBackoffOverride
36 } else if useFastRetry {
37 opts = retry.Options{
38 InitialBackoff: 5 * time.Millisecond,
39 Multiplier: 2,
40 MaxBackoff: 250 * time.Millisecond,
41 }
42 }
43
44 return Retry{Retry: retry.StartWithCtx(ctx, opts),
45 resetRetryAfter: backoffReset}
46}
47
48func testingUseFastRetry() func() {
…lines 49–83 unchanged (35 lines)

Before

source_file
comment "// Copyright 2022 The Cockroach Authors."
comment "//"
comment "// Use of this software is governed by the CockroachDB Softw"...
comment "// included in the /LICENSE file."
package_clause
package "package"
package_identifier "changefeedccl"
import_declaration (+30 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "useFastRetry"
= "="
expression_list
call_expression
selector_expression
identifier "envutil"
. "."
field_identifier "EnvOrDefaultBool"
argument_list
( "("
interpreted_string_literal
" "\""
interpreted_string_literal_content "COCKROACH_CHANGEFEED_TESTING_FAST_RETRY"
" "\""
, ","
false "false"
) ")"
comment "// getRetry returns retry object for changefeed."
function_declaration
func "func"
identifier "getRetry"
parameter_list
( "("
parameter_declaration
identifier "ctx"
qualified_type
package_identifier "context"
. "."
type_identifier "Context"
, ","
parameter_declaration
identifier "maxBackoff"
, ","
identifier "backoffReset"
qualified_type
package_identifier "time"
. "."
type_identifier "Duration"
) ")"
type_identifier "Retry"
block
{ "{"
statement_list
short_var_declaration (+40 nodes collapsed)
if_statement (+53 nodes collapsed)
return_statement (+31 nodes collapsed)
} "}"
function_declaration (+39 nodes collapsed)
comment "// Retry is a thin wrapper around retry.Retry which"
comment "// resets retry state if changefeed been running for suffici"...
comment "// long time."
type_declaration (+28 nodes collapsed)
comment "// Next returns whether the retry loop should continue, and "...
comment "// appropriate length of time before yielding back to the ca"...
comment "// If the last call to Next() happened long time ago, the am"...
comment "// to wait gets reset."
method_declaration (+97 nodes collapsed)
method_declaration (+36 nodes collapsed)

After

source_file
comment "// Copyright 2022 The Cockroach Authors."
comment "//"
comment "// Use of this software is governed by the CockroachDB Softw"...
comment "// included in the /LICENSE file."
package_clause
package "package"
package_identifier "changefeedccl"
import_declaration (+30 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "useFastRetry"
= "="
expression_list
call_expression
selector_expression
identifier "envutil"
. "."
field_identifier "EnvOrDefaultBool"
argument_list
( "("
interpreted_string_literal
" "\""
interpreted_string_literal_content "COCKROACH_CHANGEFEED_TESTING_FAST_RETRY"
" "\""
, ","
false "false"
) ")"
comment "// initialRetryBackoffOverride overrides the initial retry b"...
comment "// changefeeds, which is useful for testing retry behavior n"...
comment "// maximum backoff without requiring many retries."
var_declaration
var "var"
var_spec
identifier "initialRetryBackoffOverride"
= "="
expression_list
call_expression
selector_expression
identifier "envutil"
. "."
field_identifier "EnvOrDefaultDuration"
argument_list
( "("
interpreted_string_literal
" "\""
interpreted_string_literal_content "COCKROACH_CHANGEFEED_TESTING_INITIAL_RETRY_BACKOFF"
" "\""
, ","
int_literal "0"
) ")"
comment "// getRetry returns retry object for changefeed."
function_declaration
func "func"
identifier "getRetry"
parameter_list
( "("
parameter_declaration
identifier "ctx"
qualified_type
package_identifier "context"
. "."
type_identifier "Context"
, ","
parameter_declaration
identifier "maxBackoff"
, ","
identifier "backoffReset"
qualified_type
package_identifier "time"
. "."
type_identifier "Duration"
) ")"
type_identifier "Retry"
block
{ "{"
statement_list
short_var_declaration (+40 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "initialRetryBackoffOverride"
> ">"
int_literal "0"
block
{ "{"
statement_list
assignment_statement
expression_list
selector_expression
identifier "opts"
. "."
field_identifier "InitialBackoff"
= "="
expression_list
identifier "initialRetryBackoffOverride"
} "}"
else "else"
if_statement (+53 nodes collapsed)
return_statement (+31 nodes collapsed)
} "}"
function_declaration (+39 nodes collapsed)
comment "// Retry is a thin wrapper around retry.Retry which"
comment "// resets retry state if changefeed been running for suffici"...
comment "// long time."
type_declaration (+28 nodes collapsed)
comment "// Next returns whether the retry loop should continue, and "...
comment "// appropriate length of time before yielding back to the ca"...
comment "// If the last call to Next() happened long time ago, the am"...
comment "// to wait gets reset."
method_declaration (+97 nodes collapsed)
method_declaration (+36 nodes collapsed)