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

Fix excessive memory usage in the high-volume messages use case #196

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix excessive memory usage in the high-volume messages use case
jguz-pubnub committed Dec 10, 2024
commit f1b575c3436260dadeb5cd0fe3c059a796decc41
Original file line number Diff line number Diff line change
@@ -50,6 +50,8 @@ public extension URLSessionConfiguration {
let configuration = URLSessionConfiguration.pubnub
configuration.timeoutIntervalForRequest += Constant.minimumSubscribeRequestTimeout
configuration.httpMaximumConnectionsPerHost = 1
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
configuration.urlCache = nil

return configuration
}
29 changes: 19 additions & 10 deletions Sources/PubNub/Models/PubNubFile.swift
Original file line number Diff line number Diff line change
@@ -305,6 +305,8 @@ public protocol PubNubFileEvent {
var additionalMessage: JSONCodable? { get }
/// Meta information for the event
var metadata: JSONCodable? { get }
/// A user-provided custom message type
var customMessageType: String? { get set }

/// Allows for converting between different `PubNubFileEvent` types
init(from other: PubNubFileEvent) throws
@@ -339,46 +341,51 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
public var channelGroup: String?
public var publisher: String
public var timetoken: Timetoken
public var customMessageType: String?

var concreteFile: PubNubFileBase
public var file: PubNubFile {
return concreteFile
concreteFile
}

var concreteAdditionalMessage: AnyJSON?
public var additionalMessage: JSONCodable? {
get {
return concreteAdditionalMessage
concreteAdditionalMessage
}
set {
concreteAdditionalMessage = newValue?.codableValue
}
}

var concreteMeta: AnyJSON?

public var metadata: JSONCodable? {
get {
return concreteMeta
concreteMeta
}
set {
concreteMeta = newValue?.codableValue
}
}

var concreteFile: PubNubFileBase
var concreteAdditionalMessage: AnyJSON?
var concreteMeta: AnyJSON?


public init(
file: PubNubFile,
channelGroup: String?,
publisher: String,
timetoken: Timetoken,
additionalMessage: JSONCodable?,
metadata: JSONCodable?
metadata: JSONCodable?,
customMessageType: String? = nil
) {
concreteFile = PubNubFileBase(from: file)
self.channelGroup = channelGroup
self.publisher = publisher
self.timetoken = timetoken
self.additionalMessage = additionalMessage
self.metadata = metadata
self.customMessageType = customMessageType
}

public init(from other: PubNubFileEvent) throws {
@@ -388,7 +395,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
publisher: other.publisher,
timetoken: other.timetoken,
additionalMessage: other.additionalMessage,
metadata: other.metadata
metadata: other.metadata,
customMessageType: other.customMessageType
)
}

@@ -414,7 +422,8 @@ public struct PubNubFileEventBase: PubNubFileEvent, Hashable {
publisher: publisher,
timetoken: subscription.publishTimetoken.timetoken,
additionalMessage: filePayload.additionalDetails,
metadata: subscription.metadata
metadata: subscription.metadata,
customMessageType: subscription.customMessageType
)
}