anycable 0.5.1 → 0.5.2

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: 190929557d66d3cb49e7dee5e8a87f841f8e6a248df55673faab9b09d4027d81
4
- data.tar.gz: 0b703c1626163f1175664aeae26110214fdd3d819633291f390ec2401e985dee
3
+ metadata.gz: '079d557557d69550f4a490d8fcbcd35b922df102af44c076ea14bc92bff5dda3'
4
+ data.tar.gz: 29339983ff86ec5f52959397b566926c00d7116fa8dd56dc4933bac4bd526689
5
5
  SHA512:
6
- metadata.gz: 17f2e03a750e60a1bc3f9022212cc7009c3ecf825bacf37552ceadbf1e195421281d5d9509495c8dfd1805948061c6f29406299e8cc51f9a1b4924549173bf30
7
- data.tar.gz: 10032b73f09581d3bb9d9ebf844765d28fb5de1d80e970ea1ead176c67cf1c35fa93d9cd9f1d8f4f7d251ba92c03a9226b7ade4e6c9c83ed990364b3023153db
6
+ metadata.gz: a4fdb1f8ccbb3c633996c4aae85ce60263ab5c8f68f13909d93ef2ebe390e5124901b2832221b7fdd809fef1e3ae04628e4e5437aa6f262da51248041b5d0030
7
+ data.tar.gz: ba3d770e79aa4775e894d2f568787f62d96f1e699828549e0dba1880a85597e01e565fe0781a51b1da42f7cd359cc7580846c7c01f297ee498e4cbfacfba8329
@@ -2,13 +2,17 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.5.2 (2018-09-06)
6
+
7
+ - [#48](https://github.com/anycable/anycable/pull/48) Add HTTP health server ([@DarthSim][])
8
+
5
9
  ## 0.5.1 (2018-06-13)
6
10
 
7
11
  Minor fixes.
8
12
 
9
13
  ## 0.5.0 (2017-10-21)
10
14
 
11
- - [#2](https://github.com/anycable/anycable/issues/2) Add support for [Redis Sentinel](https://redis.io/topics/sentinel). ([@accessd](https://github.com/accessd))
15
+ - [#2](https://github.com/anycable/anycable/issues/2) Add support for [Redis Sentinel](https://redis.io/topics/sentinel). ([@accessd][])
12
16
 
13
17
  - [#28](https://github.com/anycable/anycable/issues/28) Support arbitrary headers. ([@palkan][])
14
18
 
@@ -91,3 +95,5 @@ Implement `Disconnect` handler, which invokes `Connection#disconnect` (along wit
91
95
 
92
96
  [@palkan]: https://github.com/palkan
93
97
  [@sadovnik]: https://github.com/sadovnik
98
+ [@accessd]: https://github.com/accessd
99
+ [@DarthSim]: https://github.com/DarthSim
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/anycable/anycable/master?grs=github) [![Gem Version](https://badge.fury.io/rb/anycable.svg)](https://rubygems.org/gems/anycable) [![Build Status](https://travis-ci.org/anycable/anycable.svg?branch=master)](https://travis-ci.org/anycable/anycable) [![Circle CI](https://circleci.com/gh/anycable/anycable/tree/master.svg?style=svg)](https://circleci.com/gh/anycable/anycable/tree/master)
2
- [![Dependency Status](https://dependencyci.com/github/anycable/anycable/badge)](https://dependencyci.com/github/anycable/anycable)
3
2
  [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
4
3
 
5
4
  # Anycable
@@ -47,6 +46,8 @@ Read our [Wiki](https://github.com/anycable/anycable/wiki) for more.
47
46
 
48
47
  ## Talks
49
48
 
49
+ - One cable to rule them all, RubyKaigi 2018, [slides](https://speakerdeck.com/palkan/rubykaigi-2018-anycable-one-cable-to-rule-them-all) and [video](https://www.youtube.com/watch?v=jXCPuNICT8s) (EN)
50
+
50
51
  - Wroc_Love.rb 2018 [slides](https://speakerdeck.com/palkan/wroc-love-dot-rb-2018-cables-cables-cables) and [video](https://www.youtube.com/watch?v=AUxFFOehiy0) (EN)
51
52
 
52
53
  - RubyConfMY 2017 [slides](https://speakerdeck.com/palkan/rubyconf-malaysia-2017-anycable) and [video](https://www.youtube.com/watch?v=j5oFx525zNw) (EN)
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake", ">= 10.0"
27
27
  spec.add_development_dependency "rack", "~> 2.0"
28
28
  spec.add_development_dependency "rspec", ">= 3.5"
29
- spec.add_development_dependency "rubocop", "~> 0.57.1"
29
+ spec.add_development_dependency "rubocop", "~> 0.58.0"
30
30
  spec.add_development_dependency "simplecov", ">= 0.3.8"
31
31
  spec.add_development_dependency "pry-byebug"
32
32
  end
@@ -14,7 +14,8 @@ module Anycable
14
14
  log_file: nil,
15
15
  log_level: :info,
16
16
  log_grpc: false,
17
- debug: false # Shortcut to enable GRPC logging and debug level
17
+ debug: false, # Shortcut to enable GRPC logging and debug level
18
+ http_health_port: nil
18
19
 
19
20
  def initialize(*)
20
21
  super
@@ -23,5 +24,9 @@ module Anycable
23
24
  self.log_level = :debug
24
25
  self.log_grpc = true
25
26
  end
27
+
28
+ def http_health_port_provided?
29
+ !http_health_port.nil? && http_health_port != ""
30
+ end
26
31
  end
27
32
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'webrick'
4
+ require 'anycable/server'
5
+
6
+ module Anycable
7
+ # Server for HTTP healthchecks
8
+ module HealthServer
9
+ class << self
10
+ def start(port)
11
+ return if running?
12
+
13
+ @health_server ||= build_server(port)
14
+ Thread.new { @health_server.start }
15
+
16
+ Anycable.logger.info "HTTP health server is listening on #{port}"
17
+ end
18
+
19
+ def stop
20
+ return unless running?
21
+ @health_server.shutdown
22
+ end
23
+
24
+ def running?
25
+ @health_server&.status == :Running
26
+ end
27
+
28
+ private
29
+
30
+ SUCCESS_RESPONSE = [200, "Ready"].freeze
31
+ FAILURE_RESPONSE = [503, "Not Ready"].freeze
32
+
33
+ def build_server(port)
34
+ WEBrick::HTTPServer.new(
35
+ Port: port,
36
+ Logger: Anycable.logger,
37
+ AccessLog: []
38
+ ).tap do |server|
39
+ server.mount_proc '/health' do |_, res|
40
+ res.status, res.body = Anycable::Server.running? ? SUCCESS_RESPONSE : FAILURE_RESPONSE
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'grpc'
4
4
  require 'anycable/rpc_handler'
5
+ require 'anycable/health_server'
5
6
 
6
7
  module Anycable
7
8
  # Wrapper over GRPC server
@@ -11,11 +12,9 @@ module Anycable
11
12
 
12
13
  def start
13
14
  log_grpc! if Anycable.config.log_grpc
14
- @grpc_server ||= build_server
15
15
 
16
- Anycable.logger.info "RPC server is listening on #{Anycable.config.rpc_host}"
17
- Anycable.logger.info "Broadcasting Redis channel: #{Anycable.config.redis_channel}"
18
- grpc_server.run_till_terminated
16
+ start_http_health_server
17
+ start_grpc_server
19
18
  end
20
19
 
21
20
  def stop
@@ -34,12 +33,27 @@ module Anycable
34
33
 
35
34
  private
36
35
 
36
+ def start_grpc_server
37
+ @grpc_server ||= build_server
38
+
39
+ Anycable.logger.info "RPC server is listening on #{Anycable.config.rpc_host}"
40
+ Anycable.logger.info "Broadcasting Redis channel: #{Anycable.config.redis_channel}"
41
+
42
+ grpc_server.run_till_terminated
43
+ end
44
+
37
45
  def build_server
38
46
  GRPC::RpcServer.new.tap do |server|
39
47
  server.add_http2_port(Anycable.config.rpc_host, :this_port_is_insecure)
40
48
  server.handle(Anycable::RPCHandler)
41
49
  end
42
50
  end
51
+
52
+ def start_http_health_server
53
+ return unless Anycable.config.http_health_port_provided?
54
+ Anycable::HealthServer.start(Anycable.config.http_health_port)
55
+ at_exit { Anycable::HealthServer.stop }
56
+ end
43
57
  end
44
58
  end
45
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anycable
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.57.1
123
+ version: 0.58.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.57.1
130
+ version: 0.58.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: simplecov
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,7 @@ files:
201
201
  - lib/anycable.rb
202
202
  - lib/anycable/config.rb
203
203
  - lib/anycable/handler/exceptions_handling.rb
204
+ - lib/anycable/health_server.rb
204
205
  - lib/anycable/pubsub.rb
205
206
  - lib/anycable/rpc/rpc_pb.rb
206
207
  - lib/anycable/rpc/rpc_services_pb.rb