acquia-cloud 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/acquia/cloud/logs/streamer.rb +30 -10
- data/lib/acquia/cloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4182a6236125a8d1f01f9e91e413ed3f8d2c026a
|
4
|
+
data.tar.gz: 326ab2c189dc55f63ccf49959d1e0752f59396a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 830ea71f88ba33fc22c8eb3b249e0522916c92f2c7fe39c120a5501766bd170c906e0dec973c7fbf2b44e2d001acef6c24b96536347d63f75272b0e453440be1
|
7
|
+
data.tar.gz: 6a2bd7d7e024eb3ea6bddc47846b7c9753897c46bf503ccdf1ff42f681796ccd251eb375efcdf7ce075e74a06c15d4c091b53863dbbda4ba656df725bb9e452f
|
@@ -1,7 +1,8 @@
|
|
1
|
-
require 'socket'
|
2
|
-
require 'websocket'
|
3
1
|
require 'json'
|
2
|
+
require 'socket'
|
3
|
+
require 'time'
|
4
4
|
require 'uri'
|
5
|
+
require 'websocket'
|
5
6
|
|
6
7
|
module Acquia
|
7
8
|
class Cloud
|
@@ -12,6 +13,7 @@ module Acquia
|
|
12
13
|
RECV_LENGTH = 16 * 1024
|
13
14
|
|
14
15
|
attr_reader :remote_server
|
16
|
+
attr_accessor :keepalive_duration
|
15
17
|
|
16
18
|
def initialize(url, message)
|
17
19
|
@url = url
|
@@ -19,6 +21,8 @@ module Acquia
|
|
19
21
|
@logs = []
|
20
22
|
@available = []
|
21
23
|
@enabled_types = []
|
24
|
+
@keepalive_duration = 5000
|
25
|
+
@last_keepalive = @last_data = Time.now
|
22
26
|
end
|
23
27
|
|
24
28
|
def debug
|
@@ -58,11 +62,11 @@ module Acquia
|
|
58
62
|
opts[:type] = opts[:source].type
|
59
63
|
end
|
60
64
|
|
61
|
-
send(
|
65
|
+
send(
|
62
66
|
cmd: 'enable',
|
63
67
|
server: opts[:server],
|
64
68
|
type: opts[:type],
|
65
|
-
|
69
|
+
)
|
66
70
|
end
|
67
71
|
|
68
72
|
def enable_type(type)
|
@@ -78,11 +82,11 @@ module Acquia
|
|
78
82
|
opts[:type] = opts[:source].type
|
79
83
|
end
|
80
84
|
|
81
|
-
send(
|
85
|
+
send(
|
82
86
|
cmd: 'disable',
|
83
87
|
server: opts[:server],
|
84
88
|
type: opts[:type],
|
85
|
-
|
89
|
+
)
|
86
90
|
end
|
87
91
|
|
88
92
|
def disable_type(type)
|
@@ -99,19 +103,35 @@ module Acquia
|
|
99
103
|
end
|
100
104
|
end
|
101
105
|
|
102
|
-
protected
|
106
|
+
# protected
|
103
107
|
|
104
108
|
def send(message)
|
105
109
|
message = message.to_json
|
106
110
|
STDERR.puts "-> #{message}" if @debug
|
107
111
|
frame = ::WebSocket::Frame::Outgoing::Client.new(version: @handshake.version, type: 'text', data: message)
|
108
|
-
@socket.
|
112
|
+
@socket.send frame.to_s, 0
|
109
113
|
end
|
110
114
|
|
111
115
|
def update
|
116
|
+
# Send a keepalive if required
|
117
|
+
if Time.now - @last_keepalive < @keepalive_duration
|
118
|
+
send(cmd: 'keepalive')
|
119
|
+
end
|
120
|
+
|
112
121
|
# Read as much as possible
|
113
|
-
|
114
|
-
|
122
|
+
while true
|
123
|
+
read = @socket.read_nonblock(RECV_LENGTH)
|
124
|
+
@last_data = Time.now
|
125
|
+
@incoming << read
|
126
|
+
end
|
127
|
+
rescue ::IO::WaitReadable => e
|
128
|
+
if Time.now - @last_data > @keepalive_duration * 1.5
|
129
|
+
# There hasn't been a socket level error, but we're worried at this
|
130
|
+
# point. Trigger a proper socket close 'just in case' then flag a
|
131
|
+
# broken pipe to downstream code.
|
132
|
+
close
|
133
|
+
raise Errno::EPIPE
|
134
|
+
end
|
115
135
|
loop do
|
116
136
|
msg = @incoming.next
|
117
137
|
break unless msg
|
data/lib/acquia/cloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acquia-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Equiem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|