Skip to content

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

Merged
merged 31 commits into from
May 23, 2022
Merged

Rc realtime #3730

merged 31 commits into from
May 23, 2022

Conversation

qdpham13
Copy link
Contributor

@qdpham13 qdpham13 commented May 16, 2022

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 16, 2022

Coverage Report 1

Affected Products

  • firebase-config

    Overall coverage changed from 88.93% (bd761a7) to 87.49% (86af789) by -1.44%.

    FilenameBase (bd761a7)Merge (86af789)Diff
    ConfigRealtimeHttpClient.java?0.00%?
    ConfigUpdateListener.java?0.00%?
    ConfigUpdateListenerRegistration.java?0.00%?

Test Logs

Notes

  • Commit (86af789) is created by Prow via merging PR base commit (bd761a7) and head commit (0bd4c2b).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/7Q9sPcBiAn.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 16, 2022

Size Report 1

Affected Products

  • firebase-config

    TypeBase (bd761a7)Merge (86af789)Diff
    aar63.3 kB65.1 kB+1.85 kB (+2.9%)
    apk (release)733 kB733 kB+652 B (+0.1%)

Test Logs

Notes

  • Commit (86af789) is created by Prow via merging PR base commit (bd761a7) and head commit (0bd4c2b).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/zQzR6JmFH8.html

@qdpham13
Copy link
Contributor Author

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.

@qdpham13 qdpham13 requested review from vkryachko and rlazo May 16, 2022 21:14
@qdpham13
Copy link
Contributor Author

/test smoke-tests

Copy link
Member

@vkryachko vkryachko left a 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

Comment on lines 41 to 61
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);
}
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

@qdpham13 qdpham13 changed the base branch from realtime-rc-merge to master May 18, 2022 16:24
@qdpham13 qdpham13 changed the base branch from master to realtime-rc-merge May 18, 2022 16:25
@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-config:
error: Added class com.google.firebase.remoteconfig.FirebaseRemoteConfig.ConfigUpdateListener [AddedInterface]
error: Added class com.google.firebase.remoteconfig.FirebaseRemoteConfig.ConfigUpdateListenerRegistration [AddedClass]

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.

@qdpham13 qdpham13 changed the base branch from realtime-rc-merge to master May 19, 2022 17:32
@qdpham13 qdpham13 changed the base branch from master to realtime-rc-merge May 19, 2022 17:32
@qdpham13 qdpham13 changed the base branch from realtime-rc-merge to master May 19, 2022 17:32
@qdpham13 qdpham13 changed the base branch from master to realtime-rc-merge May 19, 2022 17:35
@qdpham13 qdpham13 changed the base branch from realtime-rc-merge to master May 19, 2022 17:35
@qdpham13 qdpham13 changed the base branch from master to realtime-rc-merge May 19, 2022 17:36
@qdpham13
Copy link
Contributor Author

/test check-coverage-changed


public class ConfigRealtimeHttpClient {

private final Map<Integer, ConfigUpdateListener> listeners;
Copy link
Member

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

Copy link
Contributor Author

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++);
Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

Choose a reason for hiding this comment

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

private?

Copy link
Contributor Author

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.

@vkryachko vkryachko self-requested a review May 19, 2022 18:48
Copy link
Member

@vkryachko vkryachko left a comment

Choose a reason for hiding this comment

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

Unapprove for now

@vkryachko vkryachko dismissed their stale review May 19, 2022 18:49

Unapprove

Make internal ConfigUpdateListenerRegistration non-static to access private listener removal method from outer class.
Add synchonization to listeners set.
@qdpham13 qdpham13 requested a review from vkryachko May 19, 2022 19:41
private final Set<ConfigUpdateListener> listeners;

public ConfigRealtimeHttpClient() {
listeners = Collections.synchronizedSet(new LinkedHashSet<ConfigUpdateListener>());
Copy link
Member

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.

Copy link
Contributor Author

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.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 20, 2022

@qdpham13: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
build-plugins-check 99c166c link /test build-plugins-check

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.

@qdpham13
Copy link
Contributor Author

/test copyright-check

@qdpham13 qdpham13 merged commit 465488e into realtime-rc-merge May 23, 2022
@qdpham13 qdpham13 deleted the rc-realtime-dev branch May 23, 2022 23:19
@qdpham13 qdpham13 restored the rc-realtime-dev branch May 23, 2022 23:19
@firebase firebase locked and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants