synapse-easy 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synapse/easy.rb +3 -1
- data/lib/synapse/easy/extra_section.rb +32 -0
- data/lib/synapse/easy/frontend_section.rb +13 -0
- data/lib/synapse/easy/haproxy.rb +3 -8
- data/lib/synapse/easy/service.rb +11 -7
- data/lib/synapse/easy/stats_section.rb +56 -0
- data/lib/synapse/easy/version.rb +1 -1
- data/synapse-easy.gemspec +1 -1
- metadata +5 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8961a6aaaf5f5a1097995faad093746e0c8296
|
4
|
+
data.tar.gz: 72a1da2617782d24d3a55e2e13a6111a8f9fd7b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52cc731e18617759c1e833c8d7d7c9c12fd129fd9309543af62c2989a6c260a1c7f2bf70a225439628db843a91333914da64d9b6b319c9fca2679e8ac7167a8
|
7
|
+
data.tar.gz: 5b9b03ddf7efa65b1979ef064fcb10cdb7c0ac398776a9bfbe4e37289c2349001567d1d0addadf1af6c72fa4247591c165a2dbf34e2316b240442373025bbe09
|
data/lib/synapse/easy.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "active_support/core_ext/hash/indifferent_access"
|
3
|
+
require "fake/hash"
|
4
|
+
|
5
|
+
module Synapse
|
6
|
+
module Easy
|
7
|
+
class ExtraSection
|
8
|
+
include Fake::Hash
|
9
|
+
attr_accessor :name, :type, :options
|
10
|
+
def initialize params={}
|
11
|
+
@name = params[:name]
|
12
|
+
@type = params[:type]
|
13
|
+
@type ||= "frontend"
|
14
|
+
@options ||= []
|
15
|
+
end
|
16
|
+
def label
|
17
|
+
"#{type} #{name}"
|
18
|
+
end
|
19
|
+
def section_options
|
20
|
+
options
|
21
|
+
end
|
22
|
+
def each *args, &block
|
23
|
+
section_options.each(*args,&block)
|
24
|
+
end
|
25
|
+
def to_synapse
|
26
|
+
{
|
27
|
+
label => section_options
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/synapse/easy/haproxy.rb
CHANGED
@@ -8,17 +8,12 @@ module Synapse
|
|
8
8
|
module Easy
|
9
9
|
class Haproxy
|
10
10
|
include Fake::Hash
|
11
|
-
class << self
|
12
|
-
def instance_id size=3
|
13
|
-
@instance_id ||= SecureRandom.hex(size)
|
14
|
-
end
|
15
|
-
end
|
16
11
|
attr_accessor :reload_command, :do_writes, :do_reloads, :do_socket,
|
17
12
|
:frontends, :socket_file_path, :config_file_path,
|
18
13
|
:pid_file_path, :global_maxconn, :default_maxconn, :nbproc,
|
19
14
|
:default_log, :global_log_server, :global_log_level,
|
20
15
|
:default_retries, :default_log,:default_options,
|
21
|
-
:default_balance, :default_timeouts
|
16
|
+
:default_balance, :default_timeouts, :extra_sections
|
22
17
|
attr_reader :defaults, :global, :workdir
|
23
18
|
def initialize params={}
|
24
19
|
@do_writes ||= true
|
@@ -52,8 +47,8 @@ module Synapse
|
|
52
47
|
"server" => 60,
|
53
48
|
}
|
54
49
|
end
|
55
|
-
def instance_id
|
56
|
-
|
50
|
+
def instance_id size=3
|
51
|
+
@instance_id ||= SecureRandom.hex(size)
|
57
52
|
end
|
58
53
|
def workdir= workdir
|
59
54
|
@workdir = workdir if workdir.is_a? Pathname
|
data/lib/synapse/easy/service.rb
CHANGED
@@ -10,13 +10,15 @@ module Synapse
|
|
10
10
|
attr_accessor :port, :mode, :uri, :inter, :rise, :fall, :method, :path,
|
11
11
|
:hosts, :registry, :customer, :application, :function,
|
12
12
|
:extension, :name, :leader_election, :keep_default_servers,
|
13
|
-
:active
|
13
|
+
:active, :enable_backend, :enable_frontend
|
14
14
|
attr_reader :default_servers
|
15
15
|
def initialize params={}
|
16
16
|
@default_servers ||= []
|
17
17
|
@discovery ||= {}
|
18
18
|
@haproxy ||= {}
|
19
|
+
@port = params[:port]
|
19
20
|
@port ||= Freeport.port
|
21
|
+
@hosts = params[:hosts]
|
20
22
|
@hosts ||= Resolv::Consul.services(:zookeeper).collect{|x|"#{x.address}:#{x.port}"}
|
21
23
|
@mode = params[:mode]
|
22
24
|
@mode ||= :tcp
|
@@ -44,6 +46,8 @@ module Synapse
|
|
44
46
|
@name = params[:name]
|
45
47
|
@name ||= [@customer,@application,@function].join("_")
|
46
48
|
@active ||= false
|
49
|
+
@enable_frontend = params[:enable_frontend]
|
50
|
+
@enable_frontend ||= true if @enable_frontend.nil?
|
47
51
|
end
|
48
52
|
def add_default_server name, port
|
49
53
|
@default_servers << "#{name}:#{port}"
|
@@ -75,11 +79,11 @@ module Synapse
|
|
75
79
|
}.with_indifferent_access
|
76
80
|
end
|
77
81
|
def haproxy
|
78
|
-
{
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
82
|
+
result = {}.with_indifferent_access
|
83
|
+
result[:port] = port if enable_frontend
|
84
|
+
result[:listen] = listen
|
85
|
+
result[:server_options] = server_options
|
86
|
+
result
|
83
87
|
end
|
84
88
|
def server_options
|
85
89
|
"check inter #{inter} rise #{rise} fall #{fall}" if [inter,rise,fall].compact.size == 3
|
@@ -94,7 +98,7 @@ module Synapse
|
|
94
98
|
return application => {
|
95
99
|
default_servers:default_servers,
|
96
100
|
discovery: discovery,
|
97
|
-
haproxy:
|
101
|
+
haproxy: haproxy
|
98
102
|
}
|
99
103
|
end
|
100
104
|
def address
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "synapse/easy/extra_section"
|
2
|
+
require "socket"
|
3
|
+
require "freeport"
|
4
|
+
|
5
|
+
module Synapse
|
6
|
+
module Easy
|
7
|
+
class StatsSection < ExtraSection
|
8
|
+
attr_accessor :address, :port, :uri, :enabled, :refresh, :realm,
|
9
|
+
:hide_version, :username, :password, :scope, :show_node,
|
10
|
+
:node
|
11
|
+
def initialize params={}
|
12
|
+
super
|
13
|
+
@address = params[:address]
|
14
|
+
@address ||= "localhost"
|
15
|
+
@port = params[:port]
|
16
|
+
@port ||= Freeport.port
|
17
|
+
@uri = params[:uri]
|
18
|
+
@uri ||= "/"
|
19
|
+
@enabled = params[:enabled]
|
20
|
+
@enabled ||= true if @enabled.nil?
|
21
|
+
@refresh = params[:refresh]
|
22
|
+
@refresh ||= 5
|
23
|
+
@realm = params[:realm]
|
24
|
+
@realm ||= "HAProxy\\ Stats"
|
25
|
+
@hide_version = params[:hide_version]
|
26
|
+
@hide_version ||= true if @hide_version.nil?
|
27
|
+
@username = params[:username]
|
28
|
+
@password = params[:password]
|
29
|
+
@scope = params[:scope]
|
30
|
+
@show_node = params[:show_node]
|
31
|
+
@show_node ||= false if @show_node.nil?
|
32
|
+
@node = params[:node]
|
33
|
+
@node ||= Socket.gethostname
|
34
|
+
end
|
35
|
+
def section_options
|
36
|
+
@options + [
|
37
|
+
"mode http",
|
38
|
+
( "stats enable" if enabled ),
|
39
|
+
"stats uri #{uri}",
|
40
|
+
"stats refresh #{refresh}",
|
41
|
+
"stats realm #{realm}",
|
42
|
+
( "stats hide-version" if hide_version),
|
43
|
+
( "stats auth #{username}:#{password}" if username and password ),
|
44
|
+
( "stats scope #{scope}" if scope ),
|
45
|
+
( "stats show-node #{node}" if show_node ),
|
46
|
+
].compact
|
47
|
+
end
|
48
|
+
def bind
|
49
|
+
[address,port].compact.join(":")
|
50
|
+
end
|
51
|
+
def label
|
52
|
+
"listen stats #{bind}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/synapse/easy/version.rb
CHANGED
data/synapse-easy.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "synapse-config", "~> 0.1"
|
21
|
+
# spec.add_dependency "synapse-config", "~> 0.1"
|
22
22
|
spec.add_dependency "resolv-consul", "~> 0.1"
|
23
23
|
spec.add_dependency "freeport", "~> 0.1"
|
24
24
|
spec.add_dependency "fake-hash", "~> 0.1"
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse-easy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Kaufmann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: synapse-config
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.1'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.1'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: resolv-consul
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,8 +95,11 @@ files:
|
|
109
95
|
- bin/console
|
110
96
|
- bin/setup
|
111
97
|
- lib/synapse/easy.rb
|
98
|
+
- lib/synapse/easy/extra_section.rb
|
99
|
+
- lib/synapse/easy/frontend_section.rb
|
112
100
|
- lib/synapse/easy/haproxy.rb
|
113
101
|
- lib/synapse/easy/service.rb
|
102
|
+
- lib/synapse/easy/stats_section.rb
|
114
103
|
- lib/synapse/easy/version.rb
|
115
104
|
- synapse-easy.gemspec
|
116
105
|
homepage: http://synapse.stei.gr/easy
|