neh 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0567a7b6d4b3447f6101fa3862024751fe912d09c32159c2d60e4d4e59d6ecf1
4
- data.tar.gz: 0e25bd53826dd8802f94a0708ea73cb00001c7d1f224acea9d8851f818ec2940
3
+ metadata.gz: e9a34bc3bc69cf530b83888832f87d576e01223ba302feaf5e723884878a0e91
4
+ data.tar.gz: 3986b68fa2ff9e119b5cf5a18863d45a6ac11785c8a476fac2680ddec369e209
5
5
  SHA512:
6
- metadata.gz: 31e4294dd35df3193358e93b632c2c7746590670a21367efeb60fbfd3fa53553500a3906aa725fb87f8b6b12d8559a164834b4c431f05e145b2d99caf4173a16
7
- data.tar.gz: 75779ccf1bdc6e51f25a25348741f130748094abcc71db3199a4ab170f3910dbd9daa423c8f864896be86b5418dceb5b53c138b12e9479db5cff41c4c6d848e2
6
+ metadata.gz: 5377ead7a8e6c3f86e393152496380ec1f94d2c5f432f8946bb1e463119e8a66edad9c24b5ced9513c7c6b659bcbb3ab569e97eeb0a972ae5d0b7bdd820c9d88
7
+ data.tar.gz: 20506ca2fe416565e300e7d067b1e358e39c5b8bb7d65a166ce2fbab2128870b4f9ac1883547b6f1a0e950a3daba8f10e0d9a45b0fac417dfa43f7f2a19b89a4
data/lib/neh/cli/base.rb CHANGED
@@ -22,6 +22,8 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
22
22
  @uuid = SecureRandom.uuid
23
23
  url = "ws://#{server_host}:#{server_port}/cable?uuid=#{@uuid}"
24
24
  @endpoint = Async::HTTP::Endpoint.parse(url)
25
+ @message_pool = {}
26
+ @expected_sequence_number = 1
25
27
  end
26
28
 
27
29
  def execute
@@ -74,12 +76,21 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
74
76
  end
75
77
  end
76
78
 
79
+ def process_message_in_order
80
+ while @message_pool.key?(@expected_sequence_number)
81
+ print @message_pool.delete(@expected_sequence_number)
82
+ @expected_sequence_number += 1
83
+ end
84
+ end
85
+
77
86
  def handle_channel_message(connection, message)
78
87
  type = message[:type]
88
+ sequence_number = message[:sequence_number]
79
89
 
80
90
  case type
81
91
  when 'output'
82
- print message[:message]
92
+ @message_pool[sequence_number] = message[:message]
93
+ process_message_in_order
83
94
  when 'worker_done'
84
95
  close(connection)
85
96
  end
data/lib/neh/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neh
4
- VERSION = "0.0.20"
4
+ VERSION = "0.0.21"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atsushi Ishida
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport