diff --git a/auto_polling_policy.go b/auto_polling_policy.go index 3fbe021..09cadf3 100644 --- a/auto_polling_policy.go +++ b/auto_polling_policy.go @@ -13,8 +13,7 @@ type autoPollingPolicy struct { initialized uint32 stop chan struct{} closed uint32 - configChanged func(config string, parser *ConfigParser) - parser *ConfigParser + configChanged func() } // autoPollConfig describes the configuration for auto polling. @@ -22,7 +21,7 @@ type autoPollConfig struct { // The auto polling interval. autoPollInterval time.Duration // The configuration change listener. - changeListener func(config string, parser *ConfigParser) + changeListener func() } func (config autoPollConfig) getModeIdentifier() string { @@ -41,7 +40,7 @@ func AutoPoll(interval time.Duration) RefreshMode { // AutoPollWithChangeListener creates an auto polling refresh mode with change listener callback. func AutoPollWithChangeListener( interval time.Duration, - changeListener func(config string, parser *ConfigParser)) RefreshMode { + changeListener func()) RefreshMode { return autoPollConfig{autoPollInterval: interval, changeListener: changeListener} } @@ -58,7 +57,6 @@ func newAutoPollingPolicy( initialized: no, stop: make(chan struct{}), configChanged: autoPollConfig.changeListener, - parser: newParser(logger), } policy.startPolling() return policy @@ -109,7 +107,7 @@ func (policy *autoPollingPolicy) poll() { if response.isFetched() && cached != response.body { policy.store.set(response.body) if policy.configChanged != nil { - policy.configChanged(response.body, policy.parser) + policy.configChanged() } } diff --git a/auto_polling_policy_test.go b/auto_polling_policy_test.go index 7b83b62..78706d5 100644 --- a/auto_polling_policy_test.go +++ b/auto_polling_policy_test.go @@ -63,7 +63,7 @@ func TestAutoPollingPolicy_GetConfigurationAsync_WithListener(t *testing.T) { fetcher := newFakeConfigProvider() logger := DefaultLogger() fetcher.SetResponse(fetchResponse{status: Fetched, body: "test"}) - c := make(chan string, 1) + c := make(chan bool, 1) defer close(c) policy := newAutoPollingPolicy( fetcher, @@ -71,13 +71,13 @@ func TestAutoPollingPolicy_GetConfigurationAsync_WithListener(t *testing.T) { logger, AutoPollWithChangeListener( time.Second*2, - func(config string, parser *ConfigParser) { c <- config }, + func() { c <- true }, ).(autoPollConfig), ) defer policy.close() - config := <-c + called := <-c - if config != "test" { + if !called { t.Error("Expecting test as result") } } diff --git a/version.go b/version.go index 13bd2ea..a6241c0 100644 --- a/version.go +++ b/version.go @@ -1,5 +1,5 @@ package configcat const ( - version = "3.0" + version = "3.1" )