neh 0.0.20 → 0.0.22

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: a348fb883a6cb05766862daf8761222a2899ab9f6487296d490cdfb1dafee8ad
4
+ data.tar.gz: '04319db4bc44ab64d7efc0425ccaef06a08baeb960a4613abba4e558f24ee54d'
5
5
  SHA512:
6
- metadata.gz: 31e4294dd35df3193358e93b632c2c7746590670a21367efeb60fbfd3fa53553500a3906aa725fb87f8b6b12d8559a164834b4c431f05e145b2d99caf4173a16
7
- data.tar.gz: 75779ccf1bdc6e51f25a25348741f130748094abcc71db3199a4ab170f3910dbd9daa423c8f864896be86b5418dceb5b53c138b12e9479db5cff41c4c6d848e2
6
+ metadata.gz: 34e7279aa665e9782e2ae78626f36b4f7e94b4163e979a08746cc6fc8ca25af8845256b51739bb4d951a059e82dcbd53c326fe91ce3c51bd8a356d5eb80c729e
7
+ data.tar.gz: 10b7893ee7fca52b57c3a0872a9136d83258f3602e2fe2742bc22d792c482b2b5b8649dee26e841c67b6009b803bb4ebf2ade8e7dc0212c12149f47a98f73b9d
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,11 +76,22 @@ 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'
92
+ @message_pool[sequence_number] = message[:message]
93
+ process_message_in_order
94
+ when 'error'
82
95
  print message[:message]
83
96
  when 'worker_done'
84
97
  close(connection)
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.22"
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.22
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-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport