Skip to content

Commit 917ca89

Browse files
add: async parameter
1 parent e54bf5f commit 917ca89

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/ld-eventsource/client.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class Client
5252
# The default HTTP method for requests.
5353
DEFAULT_HTTP_METHOD = "GET"
5454

55+
THREAD_NAME = 'LD/SSEClient'
56+
5557
#
5658
# Creates a new SSE client.
5759
#
@@ -112,7 +114,8 @@ def initialize(uri,
112114
method: DEFAULT_HTTP_METHOD,
113115
payload: nil,
114116
retry_enabled: true,
115-
http_client_options: nil)
117+
http_client_options: nil,
118+
async: true)
116119
@uri = URI(uri)
117120
@stopped = Concurrent::AtomicBoolean.new(false)
118121
@retry_enabled = retry_enabled
@@ -167,7 +170,11 @@ def initialize(uri,
167170

168171
yield self if block_given?
169172

170-
Thread.new { run_stream }.name = 'LD/SSEClient'
173+
if async
174+
Thread.new { run_stream }.name = THREAD_NAME
175+
else
176+
run_stream
177+
end
171178
end
172179

173180
#

0 commit comments

Comments
 (0)