xconsul 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +28 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/xconsul.rb +33 -0
- data/lib/xconsul/consul/service.rb +12 -0
- data/lib/xconsul/load_balance/base.rb +16 -0
- data/lib/xconsul/load_balance/round_robin.rb +22 -0
- data/lib/xconsul/load_balancer.rb +69 -0
- data/lib/xconsul/version.rb +3 -0
- data/xconsul.gemspec +43 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89aa922e83a7dc27f3170b17ee7e023a9b42eb0f
|
4
|
+
data.tar.gz: 231964930ec3277f1a291df99a49acc49e293812
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a46c32b83cb54f9600fd18b9215c0573f7814c2969412e81631e51f8b3d01553961bca096d523dbb8cc97a57a57833e07b3c0d181c69f1be24aac00cea918be
|
7
|
+
data.tar.gz: 452b39f2ad1ac7a3dbe8a5f50a1031b93f7980b14f94ca038433ef53b25bbb202cfb6e13171a4970845499255863e17b96ee1809ec1d689d1ef9b0fb950d80df
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Style/AsciiComments:
|
2
|
+
Description: 'Use only ascii symbols in comments.'
|
3
|
+
StyleGuide: '#english-comments'
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
CountComments: false # count full line comments?
|
8
|
+
Max: 100
|
9
|
+
|
10
|
+
Metrics/LineLength:
|
11
|
+
Max: 120
|
12
|
+
Metrics/AbcSize:
|
13
|
+
# The ABC size is a calculated magnitude, so this number can be an Integer or
|
14
|
+
# a Float.
|
15
|
+
Max: 30
|
16
|
+
|
17
|
+
Metrics/MethodLength:
|
18
|
+
CountComments: false # count full line comments?
|
19
|
+
Max: 30
|
20
|
+
|
21
|
+
Metrics/CyclomaticComplexity:
|
22
|
+
Max: 7
|
23
|
+
|
24
|
+
Metrics/PerceivedComplexity:
|
25
|
+
Max: 8
|
26
|
+
|
27
|
+
AllCops:
|
28
|
+
TargetRubyVersion: 2.3.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at zhchsf@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Xconsul
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xconsul`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'xconsul', git: 'git@xxxx/xconsul.git', tag: 'v0.x.x'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
配置consul:
|
22
|
+
```ruby
|
23
|
+
# 统一配置consul,非必须(如果配置了acl此处就必须配置了,否则hosts取值会是空)
|
24
|
+
# 注意:consul配置会影响所有在同一项目的此gem配置,所有要求必须使用同一个consul集群
|
25
|
+
consul_config_options = {
|
26
|
+
url: 'consul 地址,可以不传,Diplomat Gem会使用默认localhost:8500',
|
27
|
+
config_options: {ssl: {version: :TLSv1_2}, headers: {"X-Consul-Token" => "xxxx"}
|
28
|
+
}
|
29
|
+
Xconsul.configure_consul_connection(consul_config_options)
|
30
|
+
```
|
31
|
+
|
32
|
+
使用consul动态服务:
|
33
|
+
```ruby
|
34
|
+
# 生成balancer,每个client gem自己维护一个balancer示例,后续都通过此示例调用
|
35
|
+
# cache_expired_seconds 暂时强制了必须5s以上
|
36
|
+
consul_service_options = {service_name: 'xxx', cache_expired_seconds: 60}
|
37
|
+
balance_options = {balance_algorithm: :round_robin} # 目前内部只有一种算法,此参数可以直接不传
|
38
|
+
balancer = Xconsul.gen_balancer(consul_service_options, balance_options)
|
39
|
+
# 获取host,如果没有可选host会raise异常
|
40
|
+
balancer.host
|
41
|
+
```
|
42
|
+
|
43
|
+
不使用consul,手工配置hosts,需要配置:use_fixed_hosts true & fixed_hosts:
|
44
|
+
```ruby
|
45
|
+
# 生成balancer,每个client gem自己维护一个balancer示例,后续都通过此示例调用
|
46
|
+
# cache_expired_seconds 暂时强制了必须5s以上
|
47
|
+
consul_service_options = {
|
48
|
+
service_name: 'xxx', cache_expired_seconds: 60,
|
49
|
+
use_fixed_hosts: true, fixed_hosts: ['10.10.116.249:8881', '10.10.116.249:8882']
|
50
|
+
}
|
51
|
+
balance_options = {balance_algorithm: :round_robin} # 目前内部只有一种算法,此参数可以直接不传
|
52
|
+
balancer = Xconsul.gen_balancer(consul_service_options, balance_options)
|
53
|
+
# 获取host,如果没有可选host会raise异常
|
54
|
+
balancer.host
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xconsul. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
71
|
+
|
72
|
+
## Code of Conduct
|
73
|
+
|
74
|
+
Everyone interacting in the Xconsul project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/xconsul/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "xconsul"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/xconsul.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'diplomat'
|
2
|
+
require "xconsul/version"
|
3
|
+
require "xconsul/load_balancer"
|
4
|
+
|
5
|
+
module Xconsul
|
6
|
+
|
7
|
+
# 通过此方法生成一个balancer,后面获取host时调用 balancer.host('10.10.142.233:8890')
|
8
|
+
# 所有Hash key请传入symbol格式
|
9
|
+
# consul_options [Hash]: 详细见::Xconsul::LoadBalancer内注释
|
10
|
+
# balance_options [Hash]: 暂时不需要传
|
11
|
+
# balance_algorithm 负载均衡算法,暂时无用,只有一种算法,自动使用
|
12
|
+
def self.gen_balancer(consul_options, balance_options = {})
|
13
|
+
::Xconsul::LoadBalancer.new(consul_options, balance_options)
|
14
|
+
end
|
15
|
+
|
16
|
+
# 注意:这个配置是全局行的,配置后其他gem调用consul也会生效,所以要求所有的必须使用同一个consul服务
|
17
|
+
# consul_options [Hash]: 示例
|
18
|
+
# {
|
19
|
+
# url: 'consul 地址,不传Diplomat会使用默认localhost地址',
|
20
|
+
# config_options: {ssl: {version: :TLSv1_2}, headers: {"X-Consul-Token" => "xxxx"}
|
21
|
+
# }
|
22
|
+
# 其他参数有需要时再加
|
23
|
+
def self.configure_consul_connection(consul_options)
|
24
|
+
return if consul_options.length.zero?
|
25
|
+
url = consul_options[:url]
|
26
|
+
config_options = consul_options[:config_options] || {}
|
27
|
+
|
28
|
+
Diplomat.configure do |config|
|
29
|
+
config.url = url if url
|
30
|
+
config.options = config_options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# consul service 调用封装
|
2
|
+
module Xconsul
|
3
|
+
module Consul
|
4
|
+
class Service
|
5
|
+
# 返回示例: ['10.10.142.233:8890', '192.168.0.2:8901']
|
6
|
+
def self.hosts_with_port(service_name)
|
7
|
+
services = Diplomat::Service.get(service_name, :all)
|
8
|
+
services.map { |service| "#{service.Address}:#{service.ServicePort}" }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'round_robin'
|
2
|
+
module Xconsul
|
3
|
+
module LoadBalance
|
4
|
+
class Base
|
5
|
+
# balance_algorithm 请传sym格式
|
6
|
+
def self.generate(balance_algorithm)
|
7
|
+
case balance_algorithm
|
8
|
+
when :round_robin
|
9
|
+
return RoundRobin.new
|
10
|
+
else
|
11
|
+
raise '未支持的load balance算法'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# 轮训调度算法
|
2
|
+
# 最简单策略,调用计数器每调用一次+1,调用数 % hosts数,根据mod值取host
|
3
|
+
# 计算器暂时不做线程安全处理,1 不需要完全这么精确,并发发同一host多个也无所谓,2 减少代码锁
|
4
|
+
module Xconsul
|
5
|
+
module LoadBalance
|
6
|
+
class RoundRobin
|
7
|
+
# attr_accessor :hosts # ['192.168.0.1:8909']
|
8
|
+
attr_accessor :counter # Integer
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@counter = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
# hosts ['192.168.0.1:8909', '192.168.0.2:8901']
|
15
|
+
def select(hosts)
|
16
|
+
idx = @counter % hosts.size
|
17
|
+
@counter += 1
|
18
|
+
hosts[idx]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# 负责load balance算法调用封装
|
2
|
+
require_relative 'load_balance/base'
|
3
|
+
require_relative 'consul/service'
|
4
|
+
|
5
|
+
module Xconsul
|
6
|
+
# balancer = Xconsul::LoadBalancer.new({}); balancer.host
|
7
|
+
class LoadBalancer
|
8
|
+
DEFAULT_CACHE_EXPIRED_SECONDS = 30
|
9
|
+
|
10
|
+
attr_accessor :consul_service_name # consul service 名称
|
11
|
+
attr_accessor :latest_hosts # 最近一次获取的hosts
|
12
|
+
attr_accessor :last_timestamp # 上次获取hosts的时间戳
|
13
|
+
attr_accessor :cache_expired_seconds # hosts缓存有效期,每隔一定时间从consul获取最新list,不传使用默认值
|
14
|
+
attr_accessor :load_balance_processor # load balancer
|
15
|
+
|
16
|
+
# consul_options
|
17
|
+
# service_name(必填): consul服务的名称
|
18
|
+
# cache_expired_seconds(可选):hosts缓存有效期,每隔一定时间从consul获取最新list,不传使用默认值
|
19
|
+
# use_fixed_hosts(可选,默认false): 为true使用固定hosts,主要用于dev环境,或者暂时不使用consul
|
20
|
+
# fixed_hosts(可选): 手工配置的hosts列表,当use_fixed_hosts 为true时必须传入,格式为['10.10.142.233:8890', 'xxx']
|
21
|
+
# balance_options [Hash]:
|
22
|
+
# balance_algorithm 负载均衡算法,暂时无用,只有一种算法,自动使用
|
23
|
+
def initialize(consul_options, balance_options = {})
|
24
|
+
@consul_service_name = consul_options[:service_name]
|
25
|
+
@cache_expired_seconds = consul_options[:cache_expired_seconds].to_i
|
26
|
+
@cache_expired_seconds = DEFAULT_CACHE_EXPIRED_SECONDS if @cache_expired_seconds <= 5
|
27
|
+
|
28
|
+
balance_algorithm = :round_robin
|
29
|
+
@load_balance_processor = generate_load_balance_processor(balance_algorithm)
|
30
|
+
|
31
|
+
if consul_options[:use_fixed_hosts] == true
|
32
|
+
@latest_hosts = consul_options[:fixed_hosts]
|
33
|
+
@last_timestamp = Time.now.to_i + 315360000 # 设置一个未来10年的时间戳,cache不过期
|
34
|
+
else
|
35
|
+
@latest_hosts = []
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# 获取一个host with port,示例:'10.10.142.233:8890'
|
40
|
+
def host
|
41
|
+
hosts = hosts_with_cache
|
42
|
+
raise "consul_service:#{consul_service_name} 无可用hosts" if hosts.length.zero?
|
43
|
+
@load_balance_processor.select(hosts)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def generate_load_balance_processor(balance_algorithm)
|
49
|
+
::Xconsul::LoadBalance::Base.generate(balance_algorithm)
|
50
|
+
end
|
51
|
+
|
52
|
+
# 带cache的hosts
|
53
|
+
# 如果没有过期,并且hosts不为空,则返回上次结果,否则重新查consul
|
54
|
+
def hosts_with_cache
|
55
|
+
if not_expired?
|
56
|
+
return latest_hosts unless latest_hosts.length.zero?
|
57
|
+
end
|
58
|
+
@latest_hosts = Xconsul::Consul::Service.hosts_with_port(consul_service_name)
|
59
|
+
@last_timestamp = Time.now.to_i
|
60
|
+
@latest_hosts
|
61
|
+
end
|
62
|
+
|
63
|
+
# 判断是否在有效期内
|
64
|
+
def not_expired?
|
65
|
+
return false unless last_timestamp
|
66
|
+
(last_timestamp + cache_expired_seconds) >= Time.now.to_i
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/xconsul.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "xconsul/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xconsul"
|
8
|
+
spec.version = Xconsul::VERSION
|
9
|
+
spec.authors = ["zhchsf"]
|
10
|
+
spec.email = ["zhchsf@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{consul 获取hosts + 负载均衡}
|
13
|
+
spec.description = %q{通过consul服务获取指定服务hosts,并且使用简单的负载均衡策略,返回一个host:port}
|
14
|
+
spec.homepage = "https://github.com/zhchsf/xconsul"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_dependency 'diplomat', '~> 2.2.5'
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "> 1.16"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
spec.add_development_dependency 'pry'
|
41
|
+
spec.add_development_dependency 'webmock'
|
42
|
+
spec.add_development_dependency 'timecop'
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xconsul
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- zhchsf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: diplomat
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.2.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.2.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
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
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: timecop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: 通过consul服务获取指定服务hosts,并且使用简单的负载均衡策略,返回一个host:port
|
112
|
+
email:
|
113
|
+
- zhchsf@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
120
|
+
- CODE_OF_CONDUCT.md
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/xconsul.rb
|
128
|
+
- lib/xconsul/consul/service.rb
|
129
|
+
- lib/xconsul/load_balance/base.rb
|
130
|
+
- lib/xconsul/load_balance/round_robin.rb
|
131
|
+
- lib/xconsul/load_balancer.rb
|
132
|
+
- lib/xconsul/version.rb
|
133
|
+
- xconsul.gemspec
|
134
|
+
homepage: https://github.com/zhchsf/xconsul
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata:
|
138
|
+
allowed_push_host: https://rubygems.org
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.6.10
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: consul 获取hosts + 负载均衡
|
159
|
+
test_files: []
|