-
Notifications
You must be signed in to change notification settings - Fork 624
Rc realtime #3730
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
Rc realtime #3730
Conversation
…egistration. Also exposes methods to be used by public RC file.
…egistration. Also exposes methods to be used by public RC file.
Coverage Report 1Affected Products
Test Logs
Notes |
Size Report 1Affected Products
Test Logs
Notes |
For check-changes, it looks like all the tests passed but it said it failed. And for copyright-check, I'm not sure how to add the new file to the copyright so leaving it for now. |
/test smoke-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why the base branch is not master, not having seen the previous changes to this branch makes it hard to review this PR
public static class ConfigUpdateListenerRegistration { | ||
private final ConfigRealtimeHttpClient client; | ||
private final int listenerKey; | ||
|
||
public ConfigUpdateListenerRegistration(ConfigRealtimeHttpClient client, int listenerKey) { | ||
this.client = client; | ||
this.listenerKey = listenerKey; | ||
} | ||
|
||
public void remove() { | ||
client.removeRealtimeConfigUpdateListener(listenerKey); | ||
} | ||
} | ||
|
||
// Event Listener interface to be used by developers. | ||
public interface ConfigUpdateListener { | ||
// Call back for when Realtime fetches. | ||
void onEvent(); | ||
|
||
void onError(Exception error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these types supposed to be used by developers? if so I suggest extracting them as top level classes and putting them under com.google.firebase.remoteconfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to top level RC class. And the base branch is not master b/c we wanted to not have our new SDK changes be public in future releases while we're not completely finished with implementation. We wanted to wait until full implementation to finish before merging into master. Do you think we should just merge into master instread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's fine, I thought the base branch contained your prototype implementation already. if the base branch is not diverged from master, it's ok to keep this all on a feature branch
…egistration. Also exposes methods to be used by public RC file.
The public api surface has changed for the subproject firebase-config: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
/test check-coverage-changed |
|
||
public class ConfigRealtimeHttpClient { | ||
|
||
private final Map<Integer, ConfigUpdateListener> listeners; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need a map? wouldn't a Set<ConfigUpdateListener>
work?
Also, looks like you're not synchronizing access to this map/set, this can lead to race conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to synchronized set
ConfigUpdateListener configUpdateListener) { | ||
listeners.put(listenerCount, configUpdateListener); | ||
beginRealtime(); | ||
return new ConfigUpdateListenerRegistrationInternal(this, listenerCount++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of capturing this
explicitly, you can make ConfigUpdateListenerRegistrationInternal
non static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to non static
return new ConfigUpdateListenerRegistrationInternal(this, listenerCount++); | ||
} | ||
|
||
public void removeRealtimeConfigUpdateListener(int listenerKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left public so registration could access but fixed with above change. Changed to private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unapprove for now
Make internal ConfigUpdateListenerRegistration non-static to access private listener removal method from outer class. Add synchonization to listeners set.
private final Set<ConfigUpdateListener> listeners; | ||
|
||
public ConfigRealtimeHttpClient() { | ||
listeners = Collections.synchronizedSet(new LinkedHashSet<ConfigUpdateListener>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest external synchronization instead of synchronizedSet as it's still not safe to iterate over synchronizedSet without explicit synchronization, which you will need when you implement event delivery.
So I would suggest making all methods that mutate the set synchronized
and add a @GuardedBy("this")
annotation to the listeners field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thanks for the suggestions! I'll make sure to keep this mind for other methods that interact with it.
@qdpham13: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/test copyright-check |
Creates Realtime Http client file. Includes ConfigUpdate Listener & Registration classes. Also includes empty helper methods that will be filled out in future PRs.
As part of bug/230368934