tail-cf-plugin 0.0.14.pre → 0.0.15.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,32 +1,32 @@
1
- require 'celluloid/websocket/client'
2
-
3
1
  module TailCfPlugin
4
2
  class LoggregatorClient
5
- include Celluloid
6
-
7
3
  def initialize(output)
8
4
  @output = output
9
5
  end
10
6
 
11
7
  def listen(loggregator_host, space_id, app_id, user_token)
12
- websocket_address = "ws://#{loggregator_host}/tail/spaces/#{space_id}"
8
+ websocket_address = "wss://#{loggregator_host}/tail/spaces/#{space_id}"
13
9
  websocket_address += "/apps/#{app_id}" if app_id
10
+
14
11
  websocket_address += "?authorization=#{URI.encode(user_token)}"
15
12
 
16
- @client = Celluloid::WebSocket::Client.new(websocket_address, current_actor, headers: {"Origin" => "http://localhost" })
17
- end
13
+ EM.run {
14
+ ws = Faye::WebSocket::Client.new(websocket_address, nil, :headers => {"Origin" => "http://localhost"})
18
15
 
19
- def on_open
20
- output.puts("Connected to server.")
21
- end
16
+ ws.on :message do |event|
17
+ received_message = LogMessage.decode(event.data.pack("C*"))
18
+ output.puts([received_message.app_id, received_message.source_id, received_message.message_type_name, received_message.message].join(" "))
19
+ end
22
20
 
23
- def on_message(data)
24
- received_message = LogMessage.decode(data.pack("C*"))
25
- output.puts([received_message.app_id, received_message.source_id, received_message.message_type_name, received_message.message].join(" "))
26
- end
21
+ ws.on :error do |event|
22
+ output.puts("Server error")
23
+ end
27
24
 
28
- def on_close(code, reason)
29
- output.puts("Server dropped connection...goodbye. #{code} #{reason}")
25
+ ws.on :close do |event|
26
+ output.puts("Server dropped connection...goodbye.")
27
+ EM.stop
28
+ end
29
+ }
30
30
  end
31
31
 
32
32
  private
@@ -1,4 +1,6 @@
1
1
  require 'cf'
2
+ require 'faye/websocket'
3
+ require 'eventmachine'
2
4
 
3
5
  module TailCfPlugin
4
6
  require 'tail-cf-plugin/loggregator_client'
@@ -25,7 +27,6 @@ module TailCfPlugin
25
27
 
26
28
  loggregator_client = LoggregatorClient.new(STDOUT)
27
29
  loggregator_client.listen(loggregator_host, client.current_space.guid, app_guid, client.token.auth_header)
28
- wait_for_ws_connection_close
29
30
  end
30
31
 
31
32
  ::ManifestsPlugin.default_to_app_from_manifest(:tail, false)
@@ -37,9 +38,5 @@ module TailCfPlugin
37
38
  "loggregator.#{target_base}"
38
39
  end
39
40
 
40
- def wait_for_ws_connection_close
41
- sleep
42
- end
43
-
44
41
  end
45
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tail-cf-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14.pre
4
+ version: 0.0.15.pre
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -34,13 +34,13 @@ dependencies:
34
34
  - !ruby/object:Gem::Version
35
35
  version: '5.0'
36
36
  - !ruby/object:Gem::Dependency
37
- name: beefcake
37
+ name: faye-websocket
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 0.3.7
43
+ version: 0.6.1
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -48,15 +48,15 @@ dependencies:
48
48
  requirements:
49
49
  - - ~>
50
50
  - !ruby/object:Gem::Version
51
- version: 0.3.7
51
+ version: 0.6.1
52
52
  - !ruby/object:Gem::Dependency
53
- name: celluloid-websocket-client
53
+ name: beefcake
54
54
  requirement: !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- version: 0.0.1
59
+ version: 0.3.7
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
@@ -64,71 +64,7 @@ dependencies:
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.1
68
- - !ruby/object:Gem::Dependency
69
- name: rake
70
- requirement: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ! '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rspec
86
- requirement: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ! '>='
90
- - !ruby/object:Gem::Version
91
- version: '0'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- - !ruby/object:Gem::Dependency
101
- name: thin
102
- requirement: !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ! '>='
106
- - !ruby/object:Gem::Version
107
- version: '0'
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
- requirements:
113
- - - ! '>='
114
- - !ruby/object:Gem::Version
115
- version: '0'
116
- - !ruby/object:Gem::Dependency
117
- name: faye-websocket
118
- requirement: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ! '>='
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
67
+ version: 0.3.7
132
68
  description: CF command line tool to tail CF Application Logs
133
69
  email:
134
70
  - vcap-dev@googlegroups.com