Skip to content
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

Batch subscribe #716

Merged
merged 12 commits into from
Feb 17, 2023
Merged

Batch subscribe #716

merged 12 commits into from
Feb 17, 2023

Conversation

llbartekll
Copy link
Contributor

Description

  • Add batch subscribe relay method
  • Integrate batch subscribe into resubscription services
  • change socket connection publisher subject to current value subject; in sample wallet sessionEngine was usually initialised after socket was already connected and Sign SDK's resubscribtion was never triggered.

Resolves #708

How Has This Been Tested?

  • manually

Due Dilligence

  • Breaking change
  • Requires a documentation update

@arein arein added the accepted label Feb 14, 2023
@llbartekll llbartekll marked this pull request as draft February 14, 2023 17:53
@llbartekll llbartekll marked this pull request as ready for review February 14, 2023 18:31
@@ -32,6 +32,7 @@ class ResubscriptionService {

func resubscribe(account: Account) async throws {
let topics = chatStorage.getThreads(account: account).map { $0.topic }
guard !topics.isEmpty else { return }
Copy link
Contributor

Choose a reason for hiding this comment

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

may be do this check inside butchSubscribe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we do but it throws an error batchContainsNoItems

.asRPCRequest()
let message = try! request.asJSONEncodedString()
var cancellable: AnyCancellable?
cancellable = batchSubscriptionResponsePublisher
Copy link
Contributor

Choose a reason for hiding this comment

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

we are doing the same logic in different places. Could we refactor it somehow?

@@ -292,6 +317,8 @@ public final class RelayClient {
requestAcknowledgePublisherSubject.send(response.id)
} else if let subscriptionId = try? anyCodable.get(String.self) {
subscriptionResponsePublisherSubject.send((response.id, subscriptionId))
} else if let subscriptionIds = try? anyCodable.get([String].self) {
batchSubscriptionResponsePublisherSubject.send((response.id, subscriptionIds))
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to use different ack publishers? Can we use one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 we can

@llbartekll llbartekll requested a review from flypaper0 February 17, 2023 07:56
@llbartekll llbartekll merged commit fb8b5d1 into develop Feb 17, 2023
@llbartekll llbartekll deleted the batch-subscribe branch February 17, 2023 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants