Skip to content

CLIENT-3365 Dynamic config changes #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: stage
Choose a base branch
from

Conversation

mirzakaracic
Copy link
Contributor

@mirzakaracic mirzakaracic commented Apr 4, 2025

Dynamic configuration changes for GO-lang client.

@mirzakaracic mirzakaracic self-assigned this Apr 28, 2025
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch from 02c9cbe to 6099646 Compare May 1, 2025 04:59
@mirzakaracic mirzakaracic changed the title Initial changes for dynamic config CLIENT-3365 Dynamic config changes May 1, 2025
@mirzakaracic mirzakaracic marked this pull request as ready for review May 1, 2025 05:00
@mirzakaracic mirzakaracic requested a review from khaf May 1, 2025 05:00
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch 9 times, most recently from 1fc1ff4 to ceb6683 Compare May 5, 2025 23:04
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch from ceb6683 to 0c43acc Compare May 8, 2025 19:10
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch 3 times, most recently from ffc8838 to b4191a7 Compare May 21, 2025 19:14
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch from aac6597 to f282446 Compare May 21, 2025 19:31
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch 6 times, most recently from 67281a5 to bbaf515 Compare June 6, 2025 05:02
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch 2 times, most recently from e8806c0 to eea4478 Compare June 7, 2025 19:27
@mirzakaracic mirzakaracic force-pushed the CLIENT-3365_dynamic-config-changes branch from eea4478 to c9b5dc2 Compare June 9, 2025 23:41
Copy link
Collaborator

@khaf khaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file ginkgo.report should also be removed from the repo and added to the .gitignore file.

@@ -58,7 +58,15 @@ func NewBatchDeletePolicy() *BatchDeletePolicy {
}
}

func (bdp *BatchDeletePolicy) toWritePolicy(bp *BatchPolicy) *WritePolicy {
func NewBatchDeletePolicyOrDefaultFromCache(dynConfig *DynConfig) *BatchDeletePolicy {
Copy link
Collaborator

@khaf khaf Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better name for it would be NewDynamicBatchDeletePolicy; Same for the rest of them.
The current name is not very Go like.

return wp
}

// copyBatchDeletePolicy creates a new BasePolicy instance and copies the values from the source BatchDeletePolicy.
func copyBatchDeletePolicy(src *BatchDeletePolicy) *BatchDeletePolicy {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a method:

func (bdp *BatchDeletePolicy) copy() *BatchDeletePolicy {
...
}

Same for the rest.

}

// applyConfigToBatchDeletePolicy applies the dynamic configuration and generates a new policy
func applyConfigToBatchDeletePolicy(policy *BatchDeletePolicy, dynConfig *DynConfig) *BatchDeletePolicy {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also should be a method with a more idiomatic name:

func (bdp *BatchDeletePolicy) patchDynamic(dynConfig *DynConfig) *BatchDeletePolicy {
...
}

}
}

func mapDynamicBatchDeletePolicy(policy *BatchDeletePolicy, dynConfig *DynConfig) *BatchDeletePolicy {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

func (bdp *BatchDeletePolicy) mapDynamic(dynConfig *DynConfig) *BatchDeletePolicy {
...
}

cp := NewClientPolicy()

cfg := &dynconfig.Config{
Static: &dynconfig.StaticConfig{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What were the result of discussions regarding removing the static/dynamic sections for future compatibility?

// ----------------------------------------------------------------
// Main watch goroutine for the config provider
// ----------------------------------------------------------------
func (dc *DynConfig) watchConfig(interval time.Duration) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better for this interval to come from the config. Why does it not?

// Enum types
// ----------------------------------------------------------------

// TODO(Khosrow): Deal with the circular dependencies to remove the redefinition of these types.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the maps run just once when the config file is being read, or every time we patch user policies?

)

const (
DSN_REGEX_PATTERN = `^\s*([A-Za-z][A-Za-z0-9+.-]*://)?(.*)$`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to use named patterns so that you won't have to fiddle with the indices.

responseTxnRollPolicy = copyTxnRollPolicy(policy)
responseTxnRollPolicy = mapDynamicTxnRollPolicy(responseTxnRollPolicy, dynConfig)

return responseTxnRollPolicy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using methods, this would become a one liner:

return policy.copy().mapDynamic(dynConfig)

IdleTimeout *int `yaml:"max_socket_idle"`
Timeout *int `yaml:"timeout"`
ErrorRateWindow *int `yaml:"error_rate_window"`
MaxErrorRate *int `yaml:"max_error_rate"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and a few more values are set in the ClientPolicy, but the clientPolicy attribute in the Cluster object is not turned in to an atomic.Pointer. That change needs to be done.

Metrics *Metrics `yaml:"metrics"`
}

type Client struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if all the yaml labels are the same for all clients.

type Client struct {
// static config
ConfigInterval *int `yaml:"config_interval"`
ConnectionQueueSize *int `yaml:"connection_queue_size"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be labeled as max_connections_per_node, same as Java. The labels should be unified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants