Skip to content

Conversation

@ckshitij
Copy link
Contributor

@ckshitij ckshitij commented Nov 4, 2025

Pull Request

Description:

  • Addess issue-2226
  • Added Provider and Subscriber interfaces for runtime configuration management.
  • Introduced mock implementations for testing remote configuration behaviour.
  • Enhanced remote logger to support dynamic log level updates via remote configuration.
  • Implemented HTTP-based remote configuration fetching and client registration.
  • Added comprehensive tests for remote configuration and logger functionality.
package config

// File provides interfaces for building a runtime-config
// subscription and update system. It allows components within an
// application to receive configuration updates dynamically from one
// or more config sources.
//
// There are two core abstractions:
//
//   1. Provider – A source of configuration data that can push updates
//      to registered subscribers. Examples include remote config
//      services, file watchers, environment refreshers, or feature
//      flag systems.
//
//   2. Subscriber – Any component that wants to react to configuration
//      changes at runtime. A subscriber implements UpdateConfig and
//      receives new configuration values whenever the provider pushes
//      an update.
//
// Typical usage:
//   - Create a Provider implementation (e.g., remote config fetcher).
//   - Register one or more Subscribers.
//   - Call Start() on the Provider to begin delivering updates.

// Subscriber represents any component that can be updated at runtime.
// Implementers define how the component should react to new configuration
// values received from a Provider.
type Subscriber interface {
	// UpdateConfig is invoked whenever the Provider pushes a new
	// configuration map. Implementations should apply the provided
	// configuration and update internal state accordingly.
	UpdateConfig(config map[string]any)
}

// Provider represents a runtime configuration provider.
// Providers act as sources of truth for configuration updates and are
// responsible for notifying all registered Subscribers whenever a
// configuration change occurs.
type Provider interface {
	// Register adds a Subscriber that should receive configuration updates.
	Register(c Subscriber)

	// Start begins the provider's update loop. Implementations may fetch
	// configuration from external systems, listen to changes, or poll at
	// intervals. Subscribers are notified via UpdateConfig when updates occur.
	Start()
}

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

@ckshitij ckshitij force-pushed the issue/2226 branch 2 times, most recently from 443dc6e to 9b79f98 Compare November 4, 2025 19:25
@ckshitij
Copy link
Contributor Author

ckshitij commented Nov 5, 2025

@coolwednesday and @aryanmehrotra kindly review the PR.

Copy link
Member

@Umang01-hash Umang01-hash left a comment

Choose a reason for hiding this comment

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

  • Consider renaming interfaces for better clarity: RemoteConfigurableConfigSubscriber and RemoteConfiguration ConfigProvider

  • All the newly added tests inside remotelogger_test.go have if conditions in the end like:

	if atomic.LoadInt32(&logger.changeCnt) != 0 {
		t.Errorf("expected no ChangeLevel when invalid key present")
	}
	if !foundErrorLog {
		t.Errorf("expected error log message for invalid JSON response, got logs: %v", logger.messages)
	}
	if client.lastConfig["logLevel"] != "DEBUG" {
		t.Errorf("expected logLevel=DEBUG, got %v", client.lastConfig["logLevel"])
	}

We should generally avoid all these if-else conditions inside test methods. Please refactor your tests too.

  • Same if-else conditions inside test lies in file remote_config_test.go. Please refactor it also.

  • It would be nicer if you can also attach a screenshot of the functionality working after your changes so other developers can easily review.

@Umang01-hash
Copy link
Member

@ckshitij Thank you for contributing to GoFr. I have left some review comments on your PR. Please address them and we will review it again after all comments are resolved.

@Umang01-hash
Copy link
Member

@ckshitij Are you still working on this PR? If yes, let's resolve the review comments quickly so we can further review your PR.

@ckshitij
Copy link
Contributor Author

@ckshitij Are you still working on this PR? If yes, let's resolve the review comments quickly so we can further review your PR.

@Umang01-hash Yes I’m still working on the same, got busy with something , will try to address the comments by this weekend.

@ckshitij ckshitij force-pushed the issue/2226 branch 4 times, most recently from 27300a9 to 601fde3 Compare November 20, 2025 08:19
@Umang01-hash
Copy link
Member

@ckshitij Have you resolved all the review comments. if yes we can re-review the PR then....

@ckshitij
Copy link
Contributor Author

@ckshitij Have you resolved all the review comments. if yes we can re-review the PR then....

@Umang01-hash yes, all the review comments are resolved.

Copy link
Member

@Umang01-hash Umang01-hash left a comment

Choose a reason for hiding this comment

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

@ckshitij a few issues in the current PR:

  1. The names provided in PR description: Added RemoteConfigurable and RemoteConfiguration interfaces for runtime configuration management. don't match the actual interface names. Please correct it.
  2. In the PR description please provide any example of the functionality so it can be easily tested and also we need to update the documentation properly regarding this change.

@ckshitij
Copy link
Contributor Author

ckshitij commented Nov 29, 2025

@ckshitij a few issues in the current PR:

  1. The names provided in PR description: Added RemoteConfigurable and RemoteConfiguration interfaces for runtime configuration management. don't match the actual interface names. Please correct it.
  2. In the PR description please provide any example of the functionality so it can be easily tested and also we need to update the documentation properly regarding this change.

Hi @Umang01-hash,

Thanks for the review!

I have updated the interface names in the PR description, and since the example is already added in the test file, I’ll reference it there for easier testing of the runtime configuration flow test.

Regarding the documentation update, could you please point me to the exact reference or starting point where the documentation for this module should be updated? I want to ensure the changes are added in the right place and follow the existing structure.

@Umang01-hash
Copy link
Member

@ckshitij I think we can update this Page in the doucmentation:

https://gofr.dev/docs/advanced-guide/remote-log-level-change

Right now it only talks about Remote Log Level Change you can refactor it to include the new improvements remote config etc.

@Umang01-hash
Copy link
Member

@ckshitij Did we updated the documentation? Can i re-review the PR ??

@ckshitij
Copy link
Contributor Author

ckshitij commented Dec 6, 2025

@ckshitij Did we updated the documentation? Can i re-review the PR ??

@Umang01-hash I have updated the doc. You can re-review the PR.

- Added RemoteConfigurable and RemoteConfiguration interfaces for runtime configuration management.
- Introduced mock implementations for testing remote configuration behavior.
- Enhanced remote logger to support dynamic log level updates via remote configuration.
- Implemented HTTP-based remote configuration fetching and client registration.
- Added comprehensive tests for remote configuration and logger functionality.
…ation to Subscriber and Provider for clarity
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